Changeset b677ab
- Timestamp:
- Oct 14, 2013, 11:41:38 PM (11 years ago)
- Branches:
- 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
- Children:
- fb9f6d
- Parents:
- f0964c
- git-author:
- Frederik Heber <heber@…> (09/04/13 21:20:34)
- git-committer:
- Frederik Heber <heber@…> (10/14/13 23:41:38)
- Location:
- src/UIElements/Views/Qt4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Plotting/QSeisPageRegistry.hpp
rf0964c rb677ab 58 58 QSeisPageRegistry(); 59 59 ~QSeisPageRegistry(); 60 public: 60 61 void registerInstance(QSeisPlotPage *instance); 61 62 void unregisterInstance(QSeisPlotPage *instance); -
src/UIElements/Views/Qt4/Plotting/QSeisPlot.cpp
rf0964c rb677ab 29 29 //insertLegend(new QwtLegend(), QwtPlot::RightLegend); 30 30 31 plottype* tmp = QSeisXMLParser::getInstance().return_plottype_by_name(type.toStdString()); 32 ASSERT(tmp != NULL, 31 { 32 const std::string name("energy"); 33 const std::string xlabel("Distance"); 34 const std::string ylabel("Energy"); 35 const std::string style(""); 36 const std::vector<int> xunits; 37 const std::vector<int> yunits; 38 const std::vector<std::string> unitnames; 39 const std::map<std::string,std::string> unitmap; 40 m_plottype = new plottype(name,xlabel,ylabel,style,xunits,yunits, unitnames,unitmap); 41 } 42 // plottype* tmp = QSeisXMLParser::getInstance().return_plottype_by_name(type.toStdString()); 43 ASSERT(m_plottype != NULL, 33 44 "QSeisPlot::QSeisPlot() - could not find desired plottype by name "+type.toStdString()+"."); 34 std::cout << "Type is " << type.toStdString() << ", " << tmp<< std::endl;45 std::cout << "Type is " << type.toStdString() << ", " << m_plottype << std::endl; 35 46 36 47 //label axes 37 const std::string xlabel = tmp->get_label(plottype::X);38 const std::string ylabel = tmp->get_label(plottype::Y);39 const std::string xunits = tmp->get_units(plottype::X);40 const std::string yunits = tmp->get_units(plottype::Y);48 const std::string xlabel = m_plottype->get_label(plottype::X); 49 const std::string ylabel = m_plottype->get_label(plottype::Y); 50 const std::string xunits = m_plottype->get_units(plottype::X); 51 const std::string yunits = m_plottype->get_units(plottype::Y); 41 52 setAxisTitle(xBottom, (xlabel+std::string(" [")+xunits+std::string("]")).c_str()); 42 53 setAxisTitle(yLeft, (ylabel+std::string(" [")+yunits+std::string("]")).c_str()); … … 88 99 QSeisPlot::~QSeisPlot() 89 100 { 90 101 delete m_plottype; 91 102 } 92 103 -
src/UIElements/Views/Qt4/Plotting/QSeisPlot.hpp
rf0964c rb677ab 28 28 #include <map> 29 29 #include <string> 30 31 class plottype; 30 32 31 33 /** … … 75 77 QPointF startPan; 76 78 bool panning; 79 plottype *m_plottype; 80 77 81 void mouseMoveEvent(QMouseEvent *event); 78 82 void mousePressEvent(QMouseEvent *event); -
src/UIElements/Views/Qt4/QtFragmentList.cpp
rf0964c rb677ab 60 60 { 61 61 setColumnCount(COLUMNCOUNT); 62 setSelectionMode(QAbstractItemView::MultiSelection);63 64 62 QStringList header; 65 63 for(int i=0; i<COLUMNCOUNT;++i) -
src/UIElements/Views/Qt4/QtHomologyList.cpp
rf0964c rb677ab 40 40 #include <QAbstractItemView> 41 41 #include <QtGui/QTreeWidget> 42 #include <QtGui/QTabWidget> 42 43 #include<Qt/qsplitter.h> 43 44 44 45 #include "CodePatterns/MemDebug.hpp" 45 46 47 #include "CodePatterns/Log.hpp" 48 46 49 #include "Fragmentation/Homology/HomologyContainer.hpp" 50 #include "FunctionApproximation/FunctionModel.hpp" 51 #include "FunctionApproximation/TrainingData.hpp" 52 #include "Potentials/CompoundPotential.hpp" 53 #include "Potentials/EmpiricalPotential.hpp" 54 #include "Potentials/InternalCoordinates/Coordinator.hpp" 47 55 #include "Potentials/PotentialRegistry.hpp" 56 #ifdef HAVE_QWT 57 #include "UIElements/Views/Qt4/Plotting/QSeisData.hpp" 58 #include "UIElements/Views/Qt4/Plotting/QSeisPageRegistry.hpp" 59 #include "UIElements/Views/Qt4/Plotting/QSeisPlotCurve.hpp" 60 #include "UIElements/Views/Qt4/Plotting/QSeisPlotPage.hpp" 61 #include "UIElements/Views/Qt4/Plotting/QSeisCurveRegistry.hpp" 62 #endif 48 63 #include "World.hpp" 49 64 … … 61 76 treewidget = new QTreeWidget (splitter); 62 77 splitter->addWidget(treewidget); 63 widget = new QWidget (splitter); 78 79 #ifdef HAVE_QWT 80 widget = new QSeisPlotPage ("energy", splitter); 81 QSeisPageRegistry::getInstance().registerInstance(widget); 82 #else 83 widget = new QWidget(splitter); 84 #endif 64 85 splitter->addWidget(widget); 65 splitter->setStretchFactor(10, 1); 86 // splitter->setStretchFactor(10, 1); 87 88 treewidget->setSelectionMode( QTreeWidget::SingleSelection ); 66 89 67 90 treewidget->setColumnCount(COLUMNCOUNT); 68 treewidget->setSelectionMode(QAbstractItemView::MultiSelection);69 70 91 QStringList header; 71 92 for(int i=0; i<COLUMNCOUNT;++i) … … 83 104 potentialregistry_enabled = true; 84 105 106 #ifdef HAVE_QWT 107 //connect the PlotCurveRegistry directly to the PlotPage registry 108 connect(QSeisCurveRegistry::getPointer(), SIGNAL(curveAdded(std::string, QString)), QSeisPageRegistry::getPointer(), SLOT(addCurve(std::string, QString))); 109 connect(QSeisCurveRegistry::getPointer(), SIGNAL(curveRemoved(std::string, QString)), QSeisPageRegistry::getPointer(), SLOT(removeCurve(std::string, QString))); 110 connect(QSeisCurveRegistry::getPointer(), SIGNAL(curveChanged(std::string, QString)), QSeisPageRegistry::getPointer(), SLOT(updateCurve(std::string, QString))); 111 #endif 112 85 113 connect(treewidget,SIGNAL(itemSelectionChanged()),this,SLOT(rowSelected())); 86 114 connect(this,SIGNAL(changed()),this,SLOT(update())); … … 100 128 101 129 // force an update from Qt... 102 clearing = true;103 treewidget->clear();104 clearing = false;105 //emit changed();doesn't work!?!130 // clearing = true; 131 // treewidget->clear(); 132 // clearing = false; 133 emit changed(); //doesn't work!?! 106 134 } 107 135 … … 114 142 HomologySelection.clear(); 115 143 treewidget->clear(); 144 #ifdef HAVE_QWT 145 QSeisCurveRegistry::getInstance().resetRegistry(); 146 #endif 116 147 117 148 size_t count = 0; 118 for (HomologyContainer::const_key_iterator iter = homologies.key_begin(); 119 iter != homologies.key_end(); iter = homologies.getNextKey(iter), ++count) { 120 HomologyContainer::range_t occurences = homologies.getHomologousGraphs(*iter); 149 for (HomologyContainer::const_key_iterator homologyiter = homologies.key_begin(); 150 homologyiter != homologies.key_end(); 151 homologyiter = homologies.getNextKey(homologyiter), ++count) { 152 HomologyContainer::range_t occurences = homologies.getHomologousGraphs(*homologyiter); 121 153 const HomologyGraph &graph = occurences.first->first; 122 154 const size_t times = std::distance(occurences.first, occurences.second); 123 155 156 // create item 124 157 QTreeWidgetItem *treeItem = new QTreeWidgetItem(treewidget); 125 158 treeItem->setText(NUMBER, QString::number(count)); … … 141 174 } 142 175 HomologySelection.push_back(treeItem->isSelected()); 176 177 #ifdef HAVE_QWT 178 // create associated curve in plot 179 CompoundPotential *compound = new CompoundPotential(graph); 180 ASSERT( compound != NULL, 181 "QtHomologyList::refill() - compound is NULL."); 182 TrainingData data(compound->getSpecificFilter()); 183 data(homologies.getHomologousGraphs(graph)); 184 if (!data.getTrainingInputs().empty()) { 185 // generate QSeisData 186 const TrainingData::InputVector_t &inputs = data.getTrainingInputs(); 187 const TrainingData::OutputVector_t &outputs = data.getTrainingOutputs(); 188 std::vector<double> xvalues; 189 std::vector<double> yvalues; 190 for (TrainingData::OutputVector_t::const_iterator outputiter = outputs.begin(); 191 outputiter != outputs.end(); ++outputiter) 192 yvalues.push_back((*outputiter)[0]); 193 194 // go through each potential 195 for (CompoundPotential::models_t::const_iterator potiter = compound->begin(); 196 potiter != compound->end(); 197 ++potiter) { 198 const EmpiricalPotential &potential = dynamic_cast<const EmpiricalPotential &>(**potiter); 199 const std::string potentialname = potential.getName(); 200 Coordinator::ptr coordinator = potential.getCoordinator(); 201 // then we need to sample the potential 202 xvalues.clear(); 203 for (TrainingData::InputVector_t::const_iterator inputiter = inputs.begin(); 204 inputiter != inputs.end(); ++inputiter) 205 xvalues.push_back((*coordinator)(*inputiter)); 206 207 // We need to sort the xvalues (and yvalues also) 208 std::vector<double>::const_iterator xiter = xvalues.begin(); 209 std::vector<double>::const_iterator yiter = yvalues.begin(); 210 std::map<double, std::set<double> > sorted_xy; 211 for (;xiter != xvalues.end(); ++xiter, ++yiter) { 212 std::set<double> yset; 213 yset.insert(*yiter); 214 std::pair<std::map<double, std::set<double> >::iterator, bool> inserter = 215 sorted_xy.insert(std::make_pair(*xiter, yset)); 216 if (!inserter.second) 217 inserter.first->second.insert(*yiter); 218 } 219 xvalues.clear(); 220 yvalues.clear(); 221 for (std::map<double, std::set<double> >::const_iterator iter = sorted_xy.begin(); 222 iter != sorted_xy.end(); ++iter) { 223 for (std::set<double>::const_iterator valueiter = iter->second.begin(); 224 valueiter != iter->second.end(); 225 ++valueiter) { 226 xvalues.push_back(iter->first); 227 yvalues.push_back(*valueiter); 228 } 229 } 230 231 QSeisData data(xvalues, yvalues, QString(potentialname.c_str())); 232 // couple to QSeisPlotCurve and register the curve 233 QSeisPlotCurve *curve = new QSeisPlotCurve(QString(potentialname.c_str()), "energy"); 234 curve->updateCurve(&data); 235 if (!QSeisCurveRegistry::getInstance().isPresentByName(curve->getName())) 236 QSeisCurveRegistry::getInstance().registerInstance(curve); 237 else 238 delete curve; 239 // couple to QSeisPlotPage 240 widget->addCurve(potentialname); 241 242 } 243 } 244 #endif 143 245 } 144 246 dirty = false; … … 171 273 bool newSelection = item->isSelected(); 172 274 if (newSelection != HomologySelection[i]){ 173 HomologySelection[i] = newSelection;275 // TODO: Add selected curve to QTabWidget 174 276 } 175 277 } -
src/UIElements/Views/Qt4/QtHomologyList.hpp
rf0964c rb677ab 19 19 20 20 class HomologyGraph; 21 class QSeisPlotPage; 21 22 class QTreeWidget; 22 23 … … 58 59 private: 59 60 QTreeWidget *treewidget; 61 62 #ifdef HAVE_QWT 63 QSeisPlotPage *widget; 64 #else 60 65 QWidget *widget; 66 #endif 61 67 }; 62 68
Note:
See TracChangeset
for help on using the changeset viewer.