source: src/UIElements/Views/Qt4/Plotting/QSeisPlot.cpp@ 0ac3e3

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 0ac3e3 was 0ac3e3, checked in by Frederik Heber <heber@…>, 10 years ago

FIX: QSeisPlotPage takes up all remaining space in QtHomologyList.

  • Property mode set to 100644
File size: 6.0 KB
Line 
1/*
2 * QSeisPlot.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 "UIElements/Views/Qt4/Plotting/QSeisPlot.hpp"
14#include "UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.hpp"
15#include "UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.hpp"
16
17#include <iostream>
18#include <qwt_plot_marker.h>
19
20// have this after(!) all Qt includes
21#include "CodePatterns/MemDebug.hpp"
22
23QSeisPlot::QSeisPlot(QWidget *parent,QString type) : QwtPlot(parent)
24{
25 //no title as there are already the different tabs
26 setTitle("");
27 //display legend on the right hand side
28 //no legend displayed - list names are colored instead
29 //insertLegend(new QwtLegend(), QwtPlot::RightLegend);
30
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,
44 "QSeisPlot::QSeisPlot() - could not find desired plottype by name "+type.toStdString()+".");
45// std::cout << "Type is " << type.toStdString() << ", " << m_plottype << std::endl;
46
47 //label axes
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);
52 setAxisTitle(xBottom, (xlabel+std::string(" [")+xunits+std::string("]")).c_str());
53 setAxisTitle(yLeft, (ylabel+std::string(" [")+yunits+std::string("]")).c_str());
54
55 //add zero line
56 QwtPlotMarker *zeroLine = new QwtPlotMarker();
57 zeroLine->setLineStyle(QwtPlotMarker::HLine);
58 zeroLine->setYValue(0.0);
59 zeroLine->attach(this);
60
61 zoomer = new ScrollZoomer(canvas());
62
63#ifdef QWTPANNER
64 panner = new QwtPlotPanner(canvas());
65 panner->setMouseButton(Qt::MidButton);
66#else
67 panning = false;
68 startPan = QPointF(0.0f, 0.0f);
69#endif
70
71 //init colors
72 availableColors.append(QColor(Qt::darkYellow));
73 availableColors.append(QColor(Qt::darkMagenta));
74 availableColors.append(QColor(Qt::darkCyan));
75 availableColors.append(QColor(Qt::darkGreen));
76 availableColors.append(QColor(Qt::darkRed));
77 availableColors.append(QColor(Qt::yellow));
78 availableColors.append(QColor(Qt::magenta));
79 availableColors.append(QColor(Qt::cyan));
80 availableColors.append(QColor(Qt::green));
81 availableColors.append(QColor(Qt::red));
82 availableColors.append(QColor(Qt::blue));
83 availableColors.append(QColor(Qt::black));
84
85 color_map.insert(std::make_pair("black",QColor(Qt::black)));
86 color_map.insert(std::make_pair("red",QColor(Qt::red)));
87 color_map.insert(std::make_pair("blue",QColor(Qt::blue)));
88 color_map.insert(std::make_pair("green",QColor(Qt::green)));
89 color_map.insert(std::make_pair("cyan",QColor(Qt::cyan)));
90 color_map.insert(std::make_pair("yellow",QColor(Qt::yellow)));
91 color_map.insert(std::make_pair("magenta",QColor(Qt::magenta)));
92 color_map.insert(std::make_pair("darkYellow",QColor(Qt::darkYellow)));
93 color_map.insert(std::make_pair("darkMagenta",QColor(Qt::darkMagenta)));
94 color_map.insert(std::make_pair("darkCyan",QColor(Qt::darkCyan)));
95 color_map.insert(std::make_pair("darkGreen",QColor(Qt::darkGreen)));
96 color_map.insert(std::make_pair("darkRed",QColor(Qt::darkRed)));
97}
98
99QSeisPlot::~QSeisPlot()
100{
101 delete m_plottype;
102}
103
104void QSeisPlot::loadSettingsFromXML(QString fileName)
105{
106 //load settings from XML file sometime in the future
107 qDebug("loadSettingsFromXML %s", fileName.toAscii().constData());
108}
109
110void QSeisPlot::resetZoomer()
111{
112 if (axisAutoScale(xBottom) && axisAutoScale(yLeft))
113 zoomer->setZoomBase(0);
114}
115
116#ifndef QWTPANNER
117void QSeisPlot::mouseMoveEvent(QMouseEvent *event)
118{
119 if ((event->buttons() == Qt::MidButton) && (panning))
120 {
121 double xPos = invTransform(xBottom, event->pos().x() - canvas()->pos().x());
122 double yPos = invTransform(yLeft, event->pos().y() - canvas()->pos().y());
123 zoomer->moveBy(xPos-startPan.x(), yPos-startPan.y());
124 startPan = QPointF(xPos, yPos);
125 }
126}
127
128void QSeisPlot::mousePressEvent(QMouseEvent *event)
129{
130 //start panning only above the plot canvas
131 if ((event->button() == Qt::MidButton)
132 && (event->pos().x() >= canvas()->pos().x())
133 && (event->pos().x() <= (canvas()->pos().x() + canvas()->width()))
134 && (event->pos().y() >= canvas()->pos().y())
135 && (event->pos().y() <= (canvas()->pos().y() + canvas()->height())))
136 {
137 panning = true;
138 startPan = QPointF(invTransform(xBottom, event->pos().x() - canvas()->pos().x()),
139 invTransform(yLeft, event->pos().y() - canvas()->pos().y()));
140 }
141}
142
143void QSeisPlot::mouseReleaseEvent(QMouseEvent *event)
144{
145 if (event->button() == Qt::MidButton)
146 {
147 panning = false;
148 startPan = QPointF(0.0f, 0.0f);
149 }
150}
151#endif
152
153QColor QSeisPlot::getCurveColor(std::string curve_color)
154{
155 if(color_map.count(curve_color)!=0) {
156 if(availableColors.count(color_map[curve_color])!=0) {
157 return color_map[curve_color];
158 }
159 }
160 QColor retColor = QColor(Qt::black);
161 if (!availableColors.isEmpty())
162 {
163 retColor = availableColors.last();
164 availableColors.removeLast();
165 }
166
167 return retColor;
168}
169
170void QSeisPlot::freeCurveColor(QColor color)
171{
172 if (color != QColor(Qt::black) && (!availableColors.contains(color)))
173 {
174 availableColors.append(color);
175 }
176}
177
178void QSeisPlot::resetPlot()
179{
180 setAxisAutoScale(QwtPlot::xBottom);
181 setAxisAutoScale(QwtPlot::yLeft);
182 replot();
183 zoomer->setZoomBase(0);
184}
Note: See TracBrowser for help on using the repository browser.