Changeset b677ab


Ignore:
Timestamp:
Oct 14, 2013, 11:41:38 PM (11 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Added QSeisPlotPage to QtHomologyList.

  • spawning QSeisPlotCurves in QtHomologyList::refill() if homologies are present.
  • selected QSeisPlotCurve is plotted.
  • xy values are sorted (required by QSeisData).
Location:
src/UIElements/Views/Qt4
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Plotting/QSeisPageRegistry.hpp

    rf0964c rb677ab  
    5858    QSeisPageRegistry();
    5959    ~QSeisPageRegistry();
     60public:
    6061    void registerInstance(QSeisPlotPage *instance);
    6162    void unregisterInstance(QSeisPlotPage *instance);
  • src/UIElements/Views/Qt4/Plotting/QSeisPlot.cpp

    rf0964c rb677ab  
    2929    //insertLegend(new QwtLegend(), QwtPlot::RightLegend);
    3030
    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,
    3344        "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;
    3546
    3647    //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);
    4152    setAxisTitle(xBottom, (xlabel+std::string(" [")+xunits+std::string("]")).c_str());
    4253    setAxisTitle(yLeft, (ylabel+std::string(" [")+yunits+std::string("]")).c_str());
     
    8899QSeisPlot::~QSeisPlot()
    89100{
    90 
     101  delete m_plottype;
    91102}
    92103
  • src/UIElements/Views/Qt4/Plotting/QSeisPlot.hpp

    rf0964c rb677ab  
    2828#include <map>
    2929#include <string>
     30
     31class plottype;
    3032
    3133/**
     
    7577    QPointF startPan;
    7678    bool panning;
     79    plottype *m_plottype;
     80
    7781    void mouseMoveEvent(QMouseEvent *event);
    7882    void mousePressEvent(QMouseEvent *event);
  • src/UIElements/Views/Qt4/QtFragmentList.cpp

    rf0964c rb677ab  
    6060{
    6161  setColumnCount(COLUMNCOUNT);
    62   setSelectionMode(QAbstractItemView::MultiSelection);
    63 
    6462  QStringList header;
    6563        for(int i=0; i<COLUMNCOUNT;++i)
  • src/UIElements/Views/Qt4/QtHomologyList.cpp

    rf0964c rb677ab  
    4040#include <QAbstractItemView>
    4141#include <QtGui/QTreeWidget>
     42#include <QtGui/QTabWidget>
    4243#include<Qt/qsplitter.h>
    4344
    4445#include "CodePatterns/MemDebug.hpp"
    4546
     47#include "CodePatterns/Log.hpp"
     48
    4649#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"
    4755#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
    4863#include "World.hpp"
    4964
     
    6176  treewidget = new QTreeWidget (splitter);
    6277  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
    6485  splitter->addWidget(widget);
    65   splitter->setStretchFactor(10, 1);
     86//  splitter->setStretchFactor(10, 1);
     87
     88  treewidget->setSelectionMode( QTreeWidget::SingleSelection );
    6689
    6790  treewidget->setColumnCount(COLUMNCOUNT);
    68   treewidget->setSelectionMode(QAbstractItemView::MultiSelection);
    69 
    7091  QStringList header;
    7192        for(int i=0; i<COLUMNCOUNT;++i)
     
    83104        potentialregistry_enabled = true;
    84105
     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
    85113  connect(treewidget,SIGNAL(itemSelectionChanged()),this,SLOT(rowSelected()));
    86114  connect(this,SIGNAL(changed()),this,SLOT(update()));
     
    100128
    101129  // 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!?!
    106134}
    107135
     
    114142  HomologySelection.clear();
    115143  treewidget->clear();
     144#ifdef HAVE_QWT
     145  QSeisCurveRegistry::getInstance().resetRegistry();
     146#endif
    116147
    117148  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);
    121153    const HomologyGraph &graph = occurences.first->first;
    122154    const size_t times = std::distance(occurences.first, occurences.second);
    123155
     156    // create item
    124157    QTreeWidgetItem *treeItem = new QTreeWidgetItem(treewidget);
    125158    treeItem->setText(NUMBER, QString::number(count));
     
    141174    }
    142175    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
    143245  }
    144246  dirty = false;
     
    171273    bool newSelection = item->isSelected();
    172274    if (newSelection != HomologySelection[i]){
    173       HomologySelection[i] = newSelection;
     275      // TODO: Add selected curve to QTabWidget
    174276    }
    175277  }
  • src/UIElements/Views/Qt4/QtHomologyList.hpp

    rf0964c rb677ab  
    1919
    2020class HomologyGraph;
     21class QSeisPlotPage;
    2122class QTreeWidget;
    2223
     
    5859private:
    5960  QTreeWidget *treewidget;
     61
     62#ifdef HAVE_QWT
     63  QSeisPlotPage *widget;
     64#else
    6065  QWidget *widget;
     66#endif
    6167};
    6268
Note: See TracChangeset for help on using the changeset viewer.