source: src/UIElements/TextUI/TextDialog.cpp@ 7cd6e7

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 7cd6e7 was 7cd6e7, checked in by Frederik Heber <heber@…>, 14 years ago

Add all possible versions of queries where the user is asked for multiples of the same.

  • Note that these are correctly implemented in TextUI and CommandLineUI, but not yet in QT4.
  • Property mode set to 100644
File size: 18.2 KB
Line 
1/*
2 * TextDialog.cpp
3 *
4 * Created on: Jan 5, 2010
5 * Author: crueger
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include <iostream>
11
12#include <Descriptors/AtomDescriptor.hpp>
13#include <Descriptors/AtomIdDescriptor.hpp>
14#include <Descriptors/MoleculeDescriptor.hpp>
15#include <Descriptors/MoleculeIdDescriptor.hpp>
16#include "TextUI/TextDialog.hpp"
17
18#include "World.hpp"
19#include "periodentafel.hpp"
20#include "log.hpp"
21#include "verbose.hpp"
22
23#include "atom.hpp"
24#include "element.hpp"
25#include "molecule.hpp"
26#include "vector.hpp"
27#include "Matrix.hpp"
28#include "Box.hpp"
29
30using namespace std;
31
32using boost::lexical_cast;
33using boost::bad_lexical_cast;
34
35
36TextDialog::TextDialog()
37{
38}
39
40TextDialog::~TextDialog()
41{
42}
43
44
45void TextDialog::queryEmpty(const char* title, string description){
46 registerQuery(new EmptyTextQuery(title,description));
47}
48
49void TextDialog::queryBoolean(const char* title, string description){
50 registerQuery(new BooleanTextQuery(title,description));
51}
52
53void TextDialog::queryInt(const char* title, string description){
54 registerQuery(new IntTextQuery(title,description));
55}
56
57void TextDialog::queryInts(const char* title, string description){
58 registerQuery(new IntsTextQuery(title,description));
59}
60
61void TextDialog::queryDouble(const char* title, string description){
62 registerQuery(new DoubleTextQuery(title,description));
63}
64
65void TextDialog::queryDoubles(const char* title, string description){
66 registerQuery(new DoublesTextQuery(title,description));
67}
68
69void TextDialog::queryString(const char* title, string description){
70 registerQuery(new StringTextQuery(title,description));
71}
72
73void TextDialog::queryStrings(const char* title, string description){
74 registerQuery(new StringsTextQuery(title,description));
75}
76
77void TextDialog::queryAtom(const char* title, string description) {
78 registerQuery(new AtomTextQuery(title,description));
79}
80
81void TextDialog::queryAtoms(const char* title, string description) {
82 registerQuery(new AtomsTextQuery(title,description));
83}
84
85void TextDialog::queryMolecule(const char* title, string description) {
86 registerQuery(new MoleculeTextQuery(title,description));
87}
88
89void TextDialog::queryMolecules(const char* title, string description) {
90 registerQuery(new MoleculesTextQuery(title,description));
91}
92
93void TextDialog::queryVector(const char* title, bool check, string description) {
94 registerQuery(new VectorTextQuery(title,check,description));
95}
96
97void TextDialog::queryVectors(const char* title, bool check, string description) {
98 registerQuery(new VectorsTextQuery(title,check,description));
99}
100
101void TextDialog::queryBox(const char* title, string description) {
102 registerQuery(new BoxTextQuery(title,description));
103}
104
105void TextDialog::queryElement(const char* title, string description){
106 registerQuery(new ElementTextQuery(title,description));
107}
108
109void TextDialog::queryElements(const char* title, string description){
110 registerQuery(new ElementsTextQuery(title,description));
111}
112
113/************************** Query Infrastructure ************************/
114
115TextDialog::EmptyTextQuery::EmptyTextQuery(string title, std::string _description) :
116 Dialog::EmptyQuery(title,_description)
117{}
118
119TextDialog::EmptyTextQuery::~EmptyTextQuery() {}
120
121bool TextDialog::EmptyTextQuery::handle() {
122 cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
123 return true;
124}
125
126TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) :
127 Dialog::IntQuery(title,_description)
128{}
129
130TextDialog::IntTextQuery::~IntTextQuery() {}
131
132bool TextDialog::IntTextQuery::handle() {
133 bool badInput = false;
134 do{
135 badInput = false;
136 Log() << Verbose(0) << getTitle();
137 cin >> tmp;
138 if(cin.fail()){
139 badInput=true;
140 cin.clear();
141 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
142 Log() << Verbose(0) << "Input was not a number!" << endl;
143 }
144 } while(badInput);
145 // clear the input buffer of anything still in the line
146 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
147 return true;
148}
149
150TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) :
151 Dialog::IntsQuery(title,_description)
152{}
153
154TextDialog::IntsTextQuery::~IntsTextQuery() {}
155
156bool TextDialog::IntsTextQuery::handle() {
157 Log() << Verbose(0) << getTitle();
158 std::string line;
159 getline(cin,line);
160 // dissect by " "
161 string::iterator olditer = line.begin();
162 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
163 if (*iter == ' ') {
164 std::istringstream stream(string(iter, olditer));
165 stream >> temp;
166 tmp.push_back(temp);
167 olditer = iter;
168 }
169 }
170 if (olditer != line.begin()) { // insert last part also
171 std::istringstream stream(string(olditer, line.end()));
172 stream >> temp;
173 tmp.push_back(temp);
174 }
175
176 return true;
177}
178
179TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) :
180 Dialog::BooleanQuery(title,_description)
181{}
182
183TextDialog::BooleanTextQuery::~BooleanTextQuery() {}
184
185bool TextDialog::BooleanTextQuery::handle() {
186 bool badInput = false;
187 char input = ' ';
188 do{
189 badInput = false;
190 Log() << Verbose(0) << getTitle();
191 cin >> input;
192 if ((input == 'y' ) || (input == 'Y')) {
193 tmp = true;
194 } else if ((input == 'n' ) || (input == 'N')) {
195 tmp = false;
196 } else {
197 badInput=true;
198 cin.clear();
199 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
200 Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
201 }
202 } while(badInput);
203 // clear the input buffer of anything still in the line
204 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
205 return true;
206}
207
208TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) :
209 Dialog::StringQuery(title,_description)
210{}
211
212TextDialog::StringTextQuery::~StringTextQuery() {}
213
214bool TextDialog::StringTextQuery::handle() {
215 Log() << Verbose(0) << getTitle();
216 getline(cin,tmp);
217 return true;
218}
219
220TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) :
221 Dialog::StringsQuery(title,_description)
222{}
223
224TextDialog::StringsTextQuery::~StringsTextQuery() {}
225
226bool TextDialog::StringsTextQuery::handle() {
227 Log() << Verbose(0) << getTitle();
228 getline(cin,temp);
229 // dissect by " "
230 string::iterator olditer = temp.begin();
231 for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
232 if (*iter == ' ') {
233 tmp.push_back(string(iter, olditer));
234 olditer = iter;
235 }
236 }
237 if (olditer != temp.begin()) // insert last part also
238 tmp.push_back(string(olditer, temp.end()));
239
240 return true;
241}
242
243TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) :
244 Dialog::DoubleQuery(title,_description)
245{}
246
247TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
248
249bool TextDialog::DoubleTextQuery::handle() {
250 bool badInput = false;
251 do{
252 badInput = false;
253 Log() << Verbose(0) << getTitle();
254 cin >> tmp;
255 if(cin.fail()){
256 badInput = true;
257 cin.clear();
258 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
259 Log() << Verbose(0) << "Input was not a number!" << endl;
260 }
261 }while(badInput);
262 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
263 return true;
264}
265
266
267TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) :
268 Dialog::DoublesQuery(title,_description)
269{}
270
271TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
272
273bool TextDialog::DoublesTextQuery::handle() {
274 Log() << Verbose(0) << getTitle();
275 std::string line;
276 getline(cin,line);
277 // dissect by " "
278 string::iterator olditer = line.begin();
279 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
280 if (*iter == ' ') {
281 std::istringstream stream(string(iter, olditer));
282 stream >> temp;
283 tmp.push_back(temp);
284 olditer = iter;
285 }
286 }
287 if (olditer != line.begin()) { // insert last part also
288 std::istringstream stream(string(olditer, line.end()));
289 stream >> temp;
290 tmp.push_back(temp);
291 }
292
293 return true;
294}
295
296TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) :
297 Dialog::AtomQuery(title,_description)
298{}
299
300TextDialog::AtomTextQuery::~AtomTextQuery() {}
301
302bool TextDialog::AtomTextQuery::handle() {
303 int idxOfAtom=-1;
304 bool badInput = false;
305 do{
306 badInput = false;
307 Log() << Verbose(0) << getTitle();
308 cin >> idxOfAtom;
309 if(cin.fail()){
310 badInput = true;
311 cin.clear();
312 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
313 Log() << Verbose(0) << "Input was not a number!" << endl;
314 continue;
315 }
316
317 tmp = World::getInstance().getAtom(AtomById(idxOfAtom));
318 if(!tmp && idxOfAtom!=-1){
319 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
320 badInput = true;
321 }
322
323 } while(badInput);
324 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
325 return (idxOfAtom!=-1);
326}
327
328
329TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) :
330 Dialog::AtomsQuery(title,_description)
331{}
332
333TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
334
335bool TextDialog::AtomsTextQuery::handle() {
336 int idxOfAtom=-1;
337 Log() << Verbose(0) << getTitle();
338 std::string line;
339 getline(cin,line);
340 // dissect by " "
341 string::iterator olditer = line.begin();
342 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
343 if (*iter == ' ') {
344 std::istringstream stream(string(iter, olditer));
345 stream >> idxOfAtom;
346 temp = World::getInstance().getAtom(AtomById(idxOfAtom));
347 if(!temp && idxOfAtom!=-1){
348 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
349 break;
350 }
351 tmp.push_back(temp);
352 olditer = iter;
353 }
354 }
355 if (olditer != line.begin()) { // insert last part also
356 std::istringstream stream(string(olditer, line.end()));
357 stream >> idxOfAtom;
358 temp = World::getInstance().getAtom(AtomById(idxOfAtom));
359 if(!temp && idxOfAtom!=-1) {
360 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
361 tmp.push_back(temp);
362 }
363 }
364
365 return (idxOfAtom!=-1);
366}
367
368TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) :
369 Dialog::MoleculeQuery(title,_description)
370{}
371
372TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
373
374bool TextDialog::MoleculeTextQuery::handle() {
375 int idxOfMol=0;
376 bool badInput = false;
377 do{
378 badInput = false;
379 Log() << Verbose(0) << getTitle();
380 cin >> idxOfMol;
381 if(cin.fail()){
382 badInput = true;
383 cin.clear();
384 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
385 Log() << Verbose(0) << "Input was not a number!" << endl;
386 continue;
387 }
388
389 tmp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
390 if(!tmp && idxOfMol!=-1){
391 Log() << Verbose(0) << "Invalid Molecule Index" << endl;
392 badInput = true;
393 }
394
395 } while(badInput);
396 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
397 return (idxOfMol!=-1);
398}
399
400
401TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) :
402 Dialog::MoleculesQuery(title,_description)
403{}
404
405TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
406
407bool TextDialog::MoleculesTextQuery::handle() {
408 int idxOfMol=-1;
409 Log() << Verbose(0) << getTitle();
410 std::string line;
411 getline(cin,line);
412 // dissect by " "
413 string::iterator olditer = line.begin();
414 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
415 if (*iter == ' ') {
416 std::istringstream stream(string(iter, olditer));
417 stream >> idxOfMol;
418 temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
419 if(!temp && idxOfMol!=-1){
420 Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
421 break;
422 }
423 tmp.push_back(temp);
424 olditer = iter;
425 }
426 }
427 if (olditer != line.begin()) { // insert last part also
428 std::istringstream stream(string(olditer, line.end()));
429 stream >> idxOfMol;
430 temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
431 if(!temp && idxOfMol!=-1){
432 Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
433 tmp.push_back(temp);
434 }
435 }
436
437 return (idxOfMol!=-1);
438}
439
440TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) :
441 Dialog::VectorQuery(title,_check,_description)
442{}
443
444TextDialog::VectorTextQuery::~VectorTextQuery()
445{}
446
447bool TextDialog::VectorTextQuery::handle() {
448 std::cout << getTitle();
449 const Matrix &M = World::getInstance().getDomain().getM();
450 char coords[3] = {'x', 'y', 'z'};
451 for (int i=0;i<3;i++)
452 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
453
454 std::string line;
455 getline(cin,line);
456
457 // dissect by ","
458 double coord = 0.;
459 int counter = 0;
460 string::iterator olditer = line.begin();
461 for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
462 if (*iter == ',') {
463 std::istringstream stream(string(iter, olditer));
464 stream >> coord;
465 tmp[counter++] = coord;
466 olditer = iter;
467 }
468 }
469 if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
470 std::istringstream stream(string(olditer, line.end()));
471 stream >> coord;
472 tmp[counter++] = coord;
473 }
474
475 // check vector
476 return World::getInstance().getDomain().isInside(tmp);
477}
478
479TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) :
480 Dialog::VectorsQuery(title,_check,_description)
481{}
482
483TextDialog::VectorsTextQuery::~VectorsTextQuery()
484{}
485
486bool TextDialog::VectorsTextQuery::handle() {
487 std::cout << getTitle();
488 char coords[3] = {'x', 'y', 'z'};
489 const Matrix &M = World::getInstance().getDomain().getM();
490 for (int i=0;i<3;i++)
491 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
492
493 std::string line;
494 getline(cin,line);
495
496 // dissect by ","
497 double coord = 0.;
498 string::iterator olditerspace = line.begin();
499 string::iterator olditercomma = line.begin();
500 int counter = 0;
501 for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
502 if (*vectoriter == ',')
503 counter++;
504 if ((*vectoriter == ' ') && (counter == 2)) {
505 counter = 0;
506 for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) {
507 if (*componentiter == ',') {
508 std::istringstream stream(string(componentiter, olditercomma));
509 stream >> coord;
510 temp[counter++] = coord;
511 olditercomma = componentiter;
512 }
513 }
514 if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also
515 std::istringstream stream(string(olditercomma, vectoriter));
516 stream >> coord;
517 temp[counter++] = coord;
518 }
519 if (World::getInstance().getDomain().isInside(temp))
520 tmp.push_back(temp);
521 olditerspace = vectoriter;
522 }
523 }
524}
525
526TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) :
527 Dialog::BoxQuery(title,_description)
528{}
529
530TextDialog::BoxTextQuery::~BoxTextQuery()
531{}
532
533bool TextDialog::BoxTextQuery::handle() {
534 Log() << Verbose(0) << getTitle();
535
536 std::string coords[6] = {"xx","xy","xz", "yy", "yz", "zz"};
537 for (int i=0;i<6;i++) {
538 Log() << Verbose(0) << coords[i] << ": ";
539 cin >> tmp[i];
540 }
541 return true;
542}
543
544TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) :
545 Dialog::ElementQuery(title,_description)
546{}
547
548TextDialog::ElementTextQuery::~ElementTextQuery()
549{}
550
551bool TextDialog::ElementTextQuery::handle() {
552 bool badInput=false;
553 bool aborted = false;
554 element * temp = NULL;
555 do{
556 badInput = false;
557 Log() << Verbose(0) << getTitle();
558
559 // try to read as Atomic number
560 int Z;
561 cin >> Z;
562 if(!cin.fail()){
563 if(Z==-1){
564 aborted = true;
565 }
566 else{
567 temp = World::getInstance().getPeriode()->FindElement(Z);
568 if(!temp){
569 Log() << Verbose(0) << "No element with this atomic number!" << endl;
570 badInput = true;
571 }
572 }
573 continue;
574 }
575 else{
576 cin.clear();
577 }
578
579 // Try to read as shorthand
580 // the last buffer content was not removed, so we read the
581 // same thing again, this time as a string
582 string shorthand;
583 cin >> shorthand;
584 if(!cin.fail()){
585 if(shorthand.empty()){
586 aborted = true;
587 }
588 else{
589 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
590 if(!temp){
591 Log() << Verbose(0) << "No element with this shorthand!" << endl;
592 badInput = true;
593 }
594 }
595 }
596 else{
597 Log() << Verbose(0) << "Could not read input. Try Again." << endl;
598 cin.clear();
599 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
600 badInput = true;
601 }
602
603 }while(badInput);
604 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
605 return !aborted;
606}
607
608TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) :
609 Dialog::ElementsQuery(title,_description)
610{}
611
612TextDialog::ElementsTextQuery::~ElementsTextQuery()
613{}
614
615bool TextDialog::ElementsTextQuery::handle() {
616 std::string shorthand;
617 int Z=-1;
618 Log() << Verbose(0) << getTitle();
619 std::string line;
620 getline(cin,line);
621 // dissect by " "
622 string::iterator olditer = line.begin();
623 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
624 if (*iter == ' ') {
625 std::istringstream stream(string(iter, olditer));
626 stream >> shorthand;
627 try {
628 Z = lexical_cast<int>(shorthand);
629 temp = World::getInstance().getPeriode()->FindElement(Z);
630 } catch (bad_lexical_cast) {
631 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
632 };
633 if(!temp && Z!=-1){
634 Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
635 break;
636 }
637 tmp.push_back(temp);
638 olditer = iter;
639 }
640 }
641 if (olditer != line.begin()) { // insert last part also
642 std::istringstream stream(string(olditer, line.end()));
643 stream >> shorthand;
644 try {
645 Z = lexical_cast<int>(shorthand);
646 temp = World::getInstance().getPeriode()->FindElement(Z);
647 } catch (bad_lexical_cast) {
648 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
649 };
650 if(!temp && Z!=-1) {
651 Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
652 tmp.push_back(temp);
653 }
654 }
655
656 return (Z!=-1);
657}
Note: See TracBrowser for help on using the repository browser.