Changeset f79d65 for src/UIElements/TextUI/Query
- Timestamp:
- Jun 19, 2017, 8:24:16 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChemicalSpaceEvaluator, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
- Children:
- 1ba51c
- Parents:
- 2eded3e
- git-author:
- Frederik Heber <heber@…> (03/30/17 21:59:00)
- git-committer:
- Frederik Heber <frederik.heber@…> (06/19/17 08:24:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/TextUI/Query/VectorsTextQuery.cpp
r2eded3e rf79d65 41 41 #include "CodePatterns/Log.hpp" 42 42 #include "CodePatterns/Verbose.hpp" 43 #include "Geometry/GeometryRegistry.hpp" 43 44 #include "LinearAlgebra/Vector.hpp" 44 45 #include "LinearAlgebra/RealSpaceMatrix.hpp" … … 54 55 55 56 bool TextDialog::VectorsTextQuery::handle() { 57 std::stringstream output; 56 58 std::cout << getDescription() << std::endl; 57 59 char coords[3] = {'x', 'y', 'z'}; 58 60 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 59 for (int i=0;i<3;i++) 60 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); 61 std::cout << "Enter three comma-separated coordinates, vector name, ? for list or empty for end." << std::endl; 62 while (true) { 63 for (int i=0;i<3;i++) 64 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); 61 65 62 std::string line;63 getline(std::cin,line);66 std::string line; 67 getline(std::cin,line); 64 68 65 // dissect by "," 66 double coord = 0.; 67 std::string::iterator olditerspace = line.begin(); 68 std::string::iterator olditercomma = line.begin(); 69 int counter = 0; 70 Vector temp_element; 71 for(std::string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) { 72 if (*vectoriter == ',') 73 counter++; 74 if ((*vectoriter == ' ') && (counter == 2)) { 75 counter = 0; 76 for(std::string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) { 77 if (*componentiter == ',') { 78 std::istringstream stream(std::string(componentiter, olditercomma)); 79 stream >> coord; 80 temp_element[counter++] = coord; 81 olditercomma = componentiter; 82 } 69 if (line == "?") { 70 GeometryRegistry ® = GeometryRegistry::getInstance(); 71 72 GeometryRegistry::const_iterator iter; 73 for (iter = reg.getBeginIter(); iter != reg.getEndIter(); iter ++){ 74 GeometryObject *v = iter->second; 75 std::cout << "\t" << *v << std::endl; 83 76 } 84 if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also 85 std::istringstream stream(std::string(olditercomma, vectoriter)); 86 stream >> coord; 87 temp_element[counter++] = coord; 88 } 89 temp.push_back(temp_element); 90 olditerspace = vectoriter; 77 } else if (line.empty()) { 78 break; 79 } else { 80 // simply append with white-space delimiter 81 temp.push_back(line); 91 82 } 92 83 }
Note:
See TracChangeset
for help on using the changeset viewer.