source: src/UIElements/Views/Qt4/Plotting/QSeisPlotPage.cpp@ 50246c

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 50246c was 50246c, checked in by Frederik Heber <heber@…>, 9 years ago

FIX: made disconnect() check for NULL pointers.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * QSeisPlotPage.cpp
3 *
4 * Created on: Jan 30, 2011
5 * Author: landvogt
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include <QtGui/QHBoxLayout>
14#include <QtGui/QListView>
15#include <QtGui/QListWidgetItem>
16
17#include "UIElements/Views/Qt4/Plotting/QSeisPlotPage.hpp"
18#include "UIElements/Views/Qt4/Plotting/QSeisPlot.hpp"
19#include "UIElements/Views/Qt4/Plotting/QListWidgetCurveItem.hpp"
20#include "UIElements/Views/Qt4/Plotting/QSeisPlotCurve.hpp"
21#include "UIElements/Views/Qt4/Plotting/QSeisCurveRegistry.hpp"
22
23// have this after(!) all Qt includes
24#include "CodePatterns/MemDebug.hpp"
25
26QSeisPlotPage::QSeisPlotPage(QString type, QWidget *parent) :
27 QWidget(parent),
28 plotType(type),
29 curveList(NULL),
30 plot (NULL),
31 layoutInitialized(false)
32{
33 //create GUI elements
34 layout = new QHBoxLayout(this);
35 setLayout(layout);
36
37}
38
39QSeisPlotPage::~QSeisPlotPage()
40{
41 if (layoutInitialized)
42 deinitializeLayout();
43}
44
45void QSeisPlotPage::initializeLayout()
46{
47 curveList = new QListWidget(this);
48 curveList->setMaximumWidth(250);
49 connect(curveList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChanged(QListWidgetItem*)));
50 plot = new QSeisPlot(this,plotType);
51 plot->setMinimumHeight(10);
52 layout->addWidget(curveList);
53 layout->addWidget(plot);
54 layoutInitialized = true;
55}
56
57void QSeisPlotPage::deinitializeLayout()
58{
59 if (curveList != NULL) {
60 disconnect(curveList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(listItemChanged(QListWidgetItem*)));
61 layout->removeWidget(curveList);
62 }
63 layout->removeWidget(plot);
64 delete curveList;
65 delete plot;
66 layoutInitialized = false;
67}
68
69std::string QSeisPlotPage::getName()
70{
71 return plotType.toStdString();
72}
73
74void QSeisPlotPage::resetPlot()
75{
76 plot->resetPlot();
77}
78
79void QSeisPlotPage::addCurve(std::string name)
80{
81 if (!layoutInitialized)
82 initializeLayout();
83
84 QSeisPlotCurve *curve = QSeisCurveRegistry::getInstance().getByName(name);
85 QListWidgetCurveItem *item = new QListWidgetCurveItem();
86 item->curveName = curve->getName();
87 item->setText(curve->getDisplayName());
88
89 if (curve->plot() != NULL)
90 item->setCheckState(Qt::Checked);
91 else
92 item->setCheckState(Qt::Unchecked);
93
94 curveList->addItem((QListWidgetItem *)item);
95}
96
97void QSeisPlotPage::updateCurve(std::string name)
98{
99 QSeisPlotCurve *curve = QSeisCurveRegistry::getInstance().getByName(name);
100 if (curve->plot() != NULL)
101 curve->plot()->replot();
102}
103
104void QSeisPlotPage::removeCurve(std::string name)
105{
106// QSeisPlotCurve *curve = QSeisCurveRegistry::getInstance().getByName(name);
107
108 for (int i = 0; i < curveList->count(); i++)
109 {
110 QListWidgetCurveItem *item = (QListWidgetCurveItem *)curveList->item(i);
111 if (item->curveName == name)
112 {
113 curveList->takeItem(i);
114 delete item;
115 return;
116 }
117 }
118
119 if (curveList->count() == 0)
120 deinitializeLayout();
121}
122
123void QSeisPlotPage::listItemChanged(QListWidgetItem *item)
124{
125 QListWidgetCurveItem *curveItem = (QListWidgetCurveItem *)item;
126 QSeisPlotCurve *curve = QSeisCurveRegistry::getInstance().getByName(curveItem->curveName);
127
128 if (curveItem->checkState() == Qt::Unchecked)
129 {
130 if (curve->plot() != NULL)
131 {
132 curve->detach();
133 //be carefull - changing the text color triggers this slot!
134 curveItem->setTextColor(QColor(Qt::black));
135 }
136 }
137 else if (curveItem->checkState() == Qt::Checked)
138 {
139 if (curve->plot() == NULL)
140 {
141 curve->attach(plot);
142 //be carefull - changing the text color triggers this slot!
143 curveItem->setTextColor(curve->pen().color());
144 }
145 }
146
147 plot->replot();
148 plot->resetZoomer();
149}
Note: See TracBrowser for help on using the repository browser.