source: src/UIElements/Views/Qt4/Plotting/QSeisData.cpp@ 3b1798

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 3b1798 was 35302b, checked in by Frederik Heber <heber@…>, 11 years ago

Added many files from project Seismolo.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * QSeisData.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 "QSeisData.hpp"
14
15#include "UIElements/Views/Qt4/Plotting/QSeisPlotCurve.hpp"
16#include "UIElements/Views/Qt4/Plotting/QSeisCurveRegistry.hpp"
17
18// have this after(!) all Qt includes
19#include "CodePatterns/MemDebug.hpp"
20
21/** Constructor for QSeisData.
22 *
23 * We create the QSeisPlotCurve instance here by calling createCurve().
24 *
25 * @param name file name data is associated with
26 * @param columnNo column number in the file this instance represents
27 */
28QSeisData::QSeisData(QString name, quint32 columnNo) :
29 intName(name), columnNumber(columnNo)
30{
31 createCurve();
32}
33
34/** Constructor for QSeisData.
35 *
36 * Note that we do not spawn any QSeisCurve instance here.
37 *
38 * @param xValues predefined set of x values
39 * @param yValues predefined set of y values
40 * @param name file for this data set
41 */
42QSeisData::QSeisData(std::vector<double> xValues, std::vector<double> yValues, QString name) :
43 intName(name), xData(xValues), yData(yValues)
44{
45
46}
47
48/** Destructor for QSeisData.
49 *
50 */
51QSeisData::~QSeisData()
52{
53}
54
55/** Create QSeisCurve instance for this data set if not yet present.
56 *
57 * We check in QSeisCurveRegistry whether a curve associated with \a intName is
58 * already present. If so, we associated with it, overwriting any association
59 * which another QSeisData has (probably from an old file that was deleted but
60 * whose data has been preserved so far). If not, we create a new instance and
61 * register it.
62 *
63 * \note We make this instance child of the curve such that it is destroyed when
64 * then curve is destroyed.
65 *
66 */
67void QSeisData::createCurve()
68{
69 QSeisPlotCurve *new_curve = NULL;
70 // if curve is already present, replace binding to this one
71 if (QSeisCurveRegistry::getInstance().isPresentByName(intName.toStdString())) {
72 new_curve = QSeisCurveRegistry::getInstance().getByName(intName.toStdString());
73 } else {
74// QString type = QSeisXMLParser::getInstance().getTypeOfName(intName);
75// new_curve = new QSeisPlotCurve(intName, type);
76 }
77 connect(this, SIGNAL(dataChanged(QwtData*)), new_curve, SLOT(updateCurve(QwtData*)));
78 connect(this, SIGNAL(dataOutOfDate()), new_curve, SLOT(markAsOutOfDate()));
79 connect(new_curve, SIGNAL(dataRequested()), this, SIGNAL(dataRequested()));
80 setParent(new_curve);
81
82 // if replacing present curve, notify
83 if (QSeisCurveRegistry::getInstance().isPresentByName(intName.toStdString())) {
84 emit dataChanged(this);
85 } else {
86 QSeisCurveRegistry::getInstance().registerInstance(new_curve);
87 }
88}
89
90/** Slot for updating of the data contents.
91 *
92 * We get here all data because then QSeisParser (who gives the signal) can
93 * bind to all QSeisData instances' slots at once.
94 *
95 * @param newData new data to store
96 */
97void QSeisData::updateData(const std::vector<std::vector<double> > &newData)
98{
99 xData.clear();
100 yData.clear();
101 if (newData.size() > columnNumber)
102 {
103 xData = newData[0];
104 yData = newData[columnNumber];
105 }
106 emit dataChanged((QwtData *)this);
107}
108
109/** Copy function.
110 *
111 * This is defined in QwtData, hence we need to implement it.
112 *
113 * @return copy of this instance
114 */
115QSeisData* QSeisData::copy() const
116{
117 return new QSeisData(xData, yData, intName);
118}
119
120/** Getter for size of the data set, i.e. number of tupels.
121 *
122 * @return number of data tupels.
123 */
124size_t QSeisData::size() const
125{
126 return xData.size();
127}
128
129/** Getter for specific x value
130 *
131 * @param i index of value
132 * @return \a xData[i] or 0. if not present
133 */
134double QSeisData::x(size_t i) const
135{
136 if (i < xData.size())
137 return xData.at(i);
138 else
139 return 0.0f;
140}
141
142/** Getter for specific y value
143 *
144 * @param i index of value
145 * @return \a yData[i] or 0. if not present
146 */
147double QSeisData::y(size_t i) const
148{
149 if (i < yData.size())
150 return yData.at(i);
151 else
152 return 0.0f;
153}
Note: See TracBrowser for help on using the repository browser.