graphdialogconnector.cpp
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #include "graphdialogconnector.h"
15 #include <qpixmap.h>
16 #include <QPushButton>
17 #include <qpainter.h>
18 #include <qtooltip.h>
19 #include <qtabwidget.h>
20 #include <qimage.h>
21 #include <qlayout.h>
22 #include <QCheckBox>
23 #include "ui_graphdialog.h"
24 
25 XQGraphDialogConnector::XQGraphDialogConnector
26 (const shared_ptr<XGraph> &graph, DlgGraphSetup* item) :
27  XQConnector(graph, item),
28  m_pItem(item) {
29 
30  graph->iterate_commit([=](Transaction &tr){
31  m_selPlot = XNode::createOrphan<XItemNode<XPlotList, XPlot> >("", true, ref(tr), graph->plots(), true);
32  m_selAxis = XNode::createOrphan<XItemNode<XAxisList, XAxis> >("", true, ref(tr), graph->axes(), true);
33  });
34  m_pItem->m_dblIntensity->setRange(0.0, 2.0);
35  m_pItem->m_dblIntensity->setSingleStep(0.1);
36  m_pItem->m_dblPersistence->setRange(0.0, 1.0);
37  m_pItem->m_dblPersistence->setSingleStep(0.1);
38 
39  m_conBackGround = xqcon_create<XColorConnector>
40  (graph->backGround(), m_pItem->m_clrBackGroundColor);
41  m_conDrawLegends = xqcon_create<XQToggleButtonConnector>
42  (graph->drawLegends(), m_pItem->m_ckbDrawLegends);
43  m_conPersistence = xqcon_create<XQDoubleSpinBoxConnector>
44  (graph->persistence(), m_pItem->m_dblPersistence, m_pItem->m_slPersistence);
45  m_conPlots = xqcon_create<XQListWidgetConnector>(m_selPlot, m_pItem->lbPlots, Snapshot( *graph));
46  m_conAxes = xqcon_create<XQListWidgetConnector>(m_selAxis, m_pItem->lbAxes, Snapshot( *graph));
47 
48  m_selAxis->iterate_commit([=](Transaction &tr){
49  m_lsnAxisChanged = tr[ *m_selAxis].onValueChanged().connectWeakly
50  (shared_from_this(), &XQGraphDialogConnector::onSelAxisChanged, XListener::FLAG_MAIN_THREAD_CALL);
51  });
52  m_selPlot->iterate_commit([=](Transaction &tr){
53  m_lsnPlotChanged = tr[ *m_selPlot].onValueChanged().connectWeakly
54  (shared_from_this(), &XQGraphDialogConnector::onSelPlotChanged, XListener::FLAG_MAIN_THREAD_CALL);
55  });
56 
57  m_pItem->showNormal();
58 }
59 XQGraphDialogConnector::~XQGraphDialogConnector() {
60  if(isItemAlive()) m_pItem->close();
61 }
62 
63 void
64 XQGraphDialogConnector::onSelAxisChanged(const Snapshot &shot, XValueNodeBase *) {
65  m_conAutoScale.reset();
66  m_conLogScale.reset();
67  m_conDisplayTicLabels.reset();
68  m_conDisplayMajorTics.reset();
69  m_conDisplayMinorTics.reset();
70  m_conAxisMin.reset();
71  m_conAxisMax.reset();
72  m_conTicLabelFormat.reset();
73  shared_ptr<XAxis> axis = shot[ *m_selAxis];
74  if( !axis) {
75  return;
76  }
77  m_conAutoScale = xqcon_create<XQToggleButtonConnector>(
78  axis->autoScale(), m_pItem->ckbAutoScale);
79  m_conLogScale = xqcon_create<XQToggleButtonConnector>(
80  axis->logScale(), m_pItem->ckbLogScale);
81  m_conDisplayTicLabels = xqcon_create<XQToggleButtonConnector>
82  (axis->displayTicLabels(), m_pItem->ckbDisplayTicLabels);
83  m_conDisplayMajorTics = xqcon_create<XQToggleButtonConnector>
84  (axis->displayMajorTics(), m_pItem->ckbDisplayMajorTics);
85  m_conDisplayMinorTics = xqcon_create<XQToggleButtonConnector>
86  (axis->displayMinorTics(), m_pItem->ckbDisplayMinorTics);
87  m_conAxisMin = xqcon_create<XQLineEditConnector>(axis->minValue(), m_pItem->edAxisMin);
88  m_conAxisMax = xqcon_create<XQLineEditConnector>(axis->maxValue(), m_pItem->edAxisMax);
89  m_conTicLabelFormat = xqcon_create<XQLineEditConnector>
90  (axis->ticLabelFormat(), m_pItem->edTicLabelFormat);
91 }
92 void
93 XQGraphDialogConnector::onSelPlotChanged(const Snapshot &shot, XValueNodeBase *) {
94  m_conDrawPoints.reset();
95  m_conDrawLines.reset();
96  m_conDrawBars.reset();
97  m_conDisplayMajorGrids.reset();
98  m_conDisplayMinorGrids.reset();
99  m_conMajorGridColor.reset();
100  m_conMinorGridColor.reset();
101  m_conPointColor.reset();
102  m_conLineColor.reset();
103  m_conBarColor.reset();
104  m_conMaxCount.reset();
105  m_conClearPoints.reset();
106  m_conIntensity.reset();
107  m_conColorPlot.reset();
108  m_conColorPlotColorLow.reset();
109  m_conColorPlotColorHigh.reset();
110 
111  shared_ptr<XPlot> plot = shot[ *m_selPlot];
112  if( !plot) {
113  return;
114  }
115  m_conDrawPoints = xqcon_create<XQToggleButtonConnector>
116  (plot->drawPoints(), m_pItem->ckbDrawPoints);
117  m_conDrawLines = xqcon_create<XQToggleButtonConnector>
118  (plot->drawLines(), m_pItem->ckbDrawLines);
119  m_conDrawBars = xqcon_create<XQToggleButtonConnector>
120  (plot->drawBars(), m_pItem->ckbDrawBars);
121  m_conDisplayMajorGrids = xqcon_create<XQToggleButtonConnector>
122  (plot->displayMajorGrid(), m_pItem->ckbDisplayMajorGrids);
123  m_conDisplayMinorGrids = xqcon_create<XQToggleButtonConnector>
124  (plot->displayMinorGrid(), m_pItem->ckbDisplayMinorGrids);
125  m_conMajorGridColor = xqcon_create<XColorConnector>
126  (plot->majorGridColor(), m_pItem->clrMajorGridColor);
127  m_conMinorGridColor = xqcon_create<XColorConnector>
128  (plot->minorGridColor(), m_pItem->clrMinorGridColor);
129  m_conPointColor = xqcon_create<XColorConnector>
130  (plot->pointColor(), m_pItem->clrPointColor);
131  m_conLineColor = xqcon_create<XColorConnector>
132  (plot->lineColor(), m_pItem->clrLineColor);
133  m_conBarColor = xqcon_create<XColorConnector>
134  (plot->barColor(), m_pItem->clrBarColor);
135  m_conMaxCount = xqcon_create<XQLineEditConnector>
136  (plot->maxCount(), m_pItem->edMaxCount);
137  m_conClearPoints = xqcon_create<XQButtonConnector>
138  (plot->clearPoints(), m_pItem->btnClearPoints);
139  m_conIntensity = xqcon_create<XQDoubleSpinBoxConnector>
140  (plot->intensity(), m_pItem->m_dblIntensity, m_pItem->m_slIntensity);
141  m_conColorPlot = xqcon_create<XQToggleButtonConnector>
142  (plot->colorPlot(), m_pItem->ckbColorPlot);
143  m_conColorPlotColorLow = xqcon_create<XColorConnector>
144  (plot->colorPlotColorLow(), m_pItem->clrColorPlotLow);
145  m_conColorPlotColorHigh = xqcon_create<XColorConnector>
146  (plot->colorPlotColorHigh(), m_pItem->clrColorPlotHigh);
147 }
148 
149 

Generated for KAME4 by  doxygen 1.8.3