/// <summary> /// Load crystal parameters from input textboxes and verify they are correct /// </summary> /// <returns>crystal parameters<</returns> public CrystalParameters GetCrystalParametres() { double a = Convert.ToDouble(textBoxA.Text, CultureInfo.InvariantCulture); double b = Convert.ToDouble(textBoxB.Text, CultureInfo.InvariantCulture); double c = Convert.ToDouble(textBoxC.Text, CultureInfo.InvariantCulture); double alpha = Convert.ToDouble(textBoxAlpha.Text, CultureInfo.InvariantCulture); double beta = Convert.ToDouble(textBoxBeta.Text, CultureInfo.InvariantCulture); double gamma = Convert.ToDouble(textBoxGamma.Text, CultureInfo.InvariantCulture); CrystalParameters cp = new CrystalParameters(a, b, c, alpha, beta, gamma); if (!Validator.ValidCrystal(cp)) { return(null); } return(cp); }
/// <summary> /// create plane /// </summary> /// <param name="crystParams">parameters of the crystal</param> /// <param name="inputFile">name of file with input crystal</param> /// <param name="axis">axis and direction of rotation</param> public void CreatePlane(CrystalParameters crystParams, string inputFile, string axis) { PlanarParameters plane = GetPlaneParametres(); if (Equals(plane, null)) { ShowError("Invalid values of plane parametres."); return; } try { Program.CreatePlane(crystParams, plane, inputFile, axis); ActionWasSuccessfull("Plane was created."); } catch { ShowError("Invalid input file with crystal atom's coordinates."); } }
/// <summary> /// Verifies whether input parametres are valid and than creates chosen structure /// </summary> public void VerifyInputParametresAndCreateStructure() { try { //load crystal CrystalParameters crystParams = GetCrystalParametres(); if (Equals(crystParams, null)) { ShowError("Invalid values of crystal cell parametres."); return; } string axis = ChooseAxisOfRotation(); //load files string inputFile = textBoxInputFile.Text; if (inputFile == "") { ShowError("Missing input file with crystal atom's coordinates."); return; } CreatorOfSurface.angstroms = IsComputedInAngstroms(); //load spiral if (comboBoxForm.Text == SPIRAL) { CreateSpiral(crystParams, inputFile, axis); } //load pipe else if (comboBoxForm.Text == PIPE) { CreatePipe(crystParams, inputFile, axis); } else { CreatePlane(crystParams, inputFile, axis); } } catch { ShowError("Missing some input parameters. Check whether everything is filled."); } }
/// <summary> /// create spiral /// </summary> /// <param name="crystParams">parameters of the crystal</param> /// <param name="inputFile">name of file with input crystal</param> /// <param name="axis">axis and direction of rotation</param> public void CreateSpiral(CrystalParameters crystParams, string inputFile, string axis) { SpiralParameters spiralParams = GetSpiralParametres(); if (Equals(spiralParams, null)) { ShowError("Invalid values of spiral parametres."); return; } try { //Program.CreateSpiral(crystParams, spiralParams, inputFile, axis); //TODO:nejak tam nesedi navazovani automu Program.CreateSpiralFromPlane(crystParams, spiralParams, inputFile, axis); ActionWasSuccessfull("Spiral was created."); } catch { ShowError("Mistake while creating spiral. Check your structure parameters or input file."); } }