Skip to content

Commit 10147b6

Browse files
author
htallone
committed
First
0 parents  commit 10147b6

File tree

101 files changed

+5572
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+5572
-0
lines changed

.qmake.stash

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
QMAKE_CXX.INCDIRS = \
2+
/usr/include/c++/8 \
3+
/usr/include/c++/8/i686-redhat-linux \
4+
/usr/include/c++/8/backward \
5+
/usr/lib/gcc/i686-redhat-linux/8/include \
6+
/usr/local/include \
7+
/usr/include
8+
QMAKE_CXX.LIBDIRS = \
9+
/usr/lib/gcc/i686-redhat-linux/8 \
10+
/usr/lib \
11+
/lib
12+
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
13+
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 8
14+
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 1
15+
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 1
16+
QMAKE_CXX.COMPILER_MACROS = \
17+
QT_COMPILER_STDCXX \
18+
QMAKE_GCC_MAJOR_VERSION \
19+
QMAKE_GCC_MINOR_VERSION \
20+
QMAKE_GCC_PATCH_VERSION

FigureWindow.pro

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
QT += widgets printsupport
2+
3+
TARGET = FigWin
4+
TEMPLATE = app
5+
6+
RESOURCES =
7+
8+
QMAKE_CXXFLAGS += -std=c++11
9+
10+
INCLUDEPATH += FigureWindow
11+
12+
HEADERS += qcustomplot/qcustomplot.h
13+
SOURCES += qcustomplot/qcustomplot.cpp
14+
15+
HEADERS += FigureWindow/figurewindow.h \
16+
FigureWindow/PlottablesEditWidget.h \
17+
FigureWindow/ColorSelectComboBox.h \
18+
FigureWindow/AxisEditWidget.h \
19+
FigureWindow/LegendEditWidget.h \
20+
FigureWindow/TitleEditWidget.h \
21+
FigureWindow/DockTitleBarWidget.h \
22+
FigureWindow/FigureSubplotWindow.h \
23+
FigureWindow/FigureWidget.h \
24+
FigureWindow/ImageSaveWidget.h \
25+
FigureWindow/SimpleEditWidget.h
26+
27+
SOURCES += FigureWindow/figurewindow.cpp \
28+
FigureWindow/PlottablesEditWidget.cpp \
29+
FigureWindow/ColorSelectComboBox.cpp \
30+
FigureWindow/AxisEditWidget.cpp \
31+
FigureWindow/LegendEditWidget.cpp \
32+
FigureWindow/TitleEditWidget.cpp \
33+
FigureWindow/DockTitleBarWidget.cpp \
34+
FigureWindow/FigureSubplotWindow.cpp \
35+
FigureWindow/FigureWidget.cpp \
36+
FigureWindow/ImageSaveWidget.cpp \
37+
FigureWindow/SimpleEditWidget.cpp
38+
39+
40+
SOURCES += demo.cpp
41+
42+
43+
44+

FigureWindow/AxisEditWidget.cpp

+277
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
/*
2+
* AxisEditWidget.cpp
3+
*
4+
* Created on: Jun 12, 2016
5+
* Author: htallone
6+
*/
7+
8+
#include "AxisEditWidget.h"
9+
10+
AxisEditWidget::AxisEditWidget(QWidget* parent) : QWidget(parent){
11+
// TODO Auto-generated constructor stub
12+
13+
}
14+
15+
AxisEditWidget::AxisEditWidget(QWidget* parent, QCustomPlot *qcustomplotp, int axisIndexp)
16+
: QWidget(parent)
17+
{
18+
qcustomplot = qcustomplotp;
19+
axisIndex = axisIndexp;
20+
21+
22+
axisLabelNameLineEdit = new QLineEdit;
23+
axisRangeLowerLineEdit = new QLineEdit;
24+
axisRangeUpperLineEdit = new QLineEdit;
25+
axisRangeLowerLineEdit->setValidator(new QDoubleValidator());
26+
axisRangeUpperLineEdit->setValidator(new QDoubleValidator());
27+
28+
axisLabelNameLineEdit->setMaximumWidth(200);
29+
axisRangeLowerLineEdit->setMaximumWidth(80);
30+
axisRangeLowerLineEdit->setAlignment(Qt::AlignCenter);
31+
axisRangeUpperLineEdit->setMaximumWidth(80);
32+
axisRangeUpperLineEdit->setAlignment(Qt::AlignCenter);
33+
connect(axisLabelNameLineEdit, SIGNAL(editingFinished()), this, SLOT(slotAxisLabelNameEditingFinished()));
34+
connect(axisRangeLowerLineEdit, SIGNAL(editingFinished()), this, SLOT(slotAxisRangeEditingFinished()));
35+
connect(axisRangeUpperLineEdit, SIGNAL(editingFinished()), this, SLOT(slotAxisRangeEditingFinished()));
36+
37+
fontSelectDialog = new QFontDialog(this);
38+
39+
QLabel * axisNameLabel = new QLabel("Label Name:");
40+
QLabel * axisRangeLabel = new QLabel("Axis Range:");
41+
QLabel * axisLabelFontLabel = new QLabel("Label Font:");
42+
QLabel * axisTicksFontLabel = new QLabel("Ticks Font:");
43+
44+
QHBoxLayout *axisRangeLayoutH = new QHBoxLayout;
45+
axisRangeLayoutH->setMargin(0);
46+
QLabel * rangeSpaceTakeLabel = new QLabel(" ~ ");
47+
rangeSpaceTakeLabel->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
48+
axisRangeLayoutH->addWidget(axisRangeLowerLineEdit);
49+
axisRangeLayoutH->addWidget(rangeSpaceTakeLabel);
50+
axisRangeLayoutH->addWidget(axisRangeUpperLineEdit);
51+
axisRangeLayoutH->addStretch(1);
52+
53+
QHBoxLayout *axisLabelFontLayoutH = new QHBoxLayout;
54+
QPushButton * axisLabelFontSelectButton = new QPushButton(QIcon("./icon/font-select.png"),"Select Font");
55+
//axisLabelFontSelectButton->setFlat(true);
56+
connect(axisLabelFontSelectButton, SIGNAL(clicked()), this, SLOT(slotAxisLabelFontSelected()));
57+
axisLabelFontSelectButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
58+
axisLabelFontLayoutH->addWidget(axisLabelFontSelectButton);
59+
axisLabelFontLayoutH->addStretch(1);
60+
61+
QHBoxLayout *axisTicksLabelFontLayoutH = new QHBoxLayout;
62+
QPushButton * axisTicksLabelFontSelectButton = new QPushButton(QIcon("./icon/font-select.png"),"Select Font");
63+
connect(axisTicksLabelFontSelectButton, SIGNAL(clicked()), this, SLOT(slotAxisTicksLabelFontSelected()));
64+
axisTicksLabelFontSelectButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
65+
axisTicksLabelFontLayoutH->addWidget(axisTicksLabelFontSelectButton);
66+
axisTicksLabelFontLayoutH->addStretch(1);
67+
68+
69+
QGridLayout *axisEditLayoutG = new QGridLayout;
70+
axisEditLayoutG->addWidget(axisNameLabel, 0, 0);
71+
axisEditLayoutG->addWidget(axisLabelNameLineEdit, 0, 1);
72+
axisEditLayoutG->addWidget(axisRangeLabel, 1, 0);
73+
axisEditLayoutG->addLayout(axisRangeLayoutH, 1, 1);
74+
axisEditLayoutG->addWidget(axisLabelFontLabel, 2, 0);
75+
axisEditLayoutG->addLayout(axisLabelFontLayoutH, 2, 1);
76+
axisEditLayoutG->addWidget(axisTicksFontLabel, 3, 0);
77+
axisEditLayoutG->addLayout(axisTicksLabelFontLayoutH, 3, 1);
78+
79+
QHBoxLayout *axisEditStretchLayoutH = new QHBoxLayout;
80+
axisEditStretchLayoutH->addLayout(axisEditLayoutG);
81+
axisEditStretchLayoutH->addStretch(1);
82+
QVBoxLayout *axisEditStretchLayoutV = new QVBoxLayout;
83+
axisEditStretchLayoutV->addLayout(axisEditStretchLayoutH);
84+
axisEditStretchLayoutV->addStretch(1);
85+
86+
this->setLayout(axisEditStretchLayoutV);
87+
88+
89+
if(axisIndex == 0)
90+
{
91+
setAxisLabelName(qcustomplot->xAxis->label());
92+
axisRangeLowerLineEdit->setText(QString::number(qcustomplot->xAxis->range().lower));
93+
axisRangeUpperLineEdit->setText(QString::number(qcustomplot->xAxis->range().upper));
94+
connect(qcustomplot->xAxis, SIGNAL(rangeChanged(const QCPRange &)), this, SLOT(setAxisRange(const QCPRange &)));
95+
}
96+
97+
if(axisIndex == 1)
98+
{
99+
setAxisLabelName(qcustomplot->yAxis->label());
100+
axisRangeLowerLineEdit->setText(QString::number(qcustomplot->yAxis->range().lower));
101+
axisRangeUpperLineEdit->setText(QString::number(qcustomplot->yAxis->range().upper));
102+
connect(qcustomplot->yAxis, SIGNAL(rangeChanged(const QCPRange &)), this, SLOT(setAxisRange(const QCPRange &)));
103+
}
104+
105+
}
106+
107+
AxisEditWidget::~AxisEditWidget() {
108+
// TODO Auto-generated destructor stub
109+
}
110+
111+
void AxisEditWidget::changeAxisIndex(int indexp)
112+
{
113+
axisIndex = indexp;
114+
115+
if(axisIndex == 0)
116+
{
117+
setAxisLabelName(qcustomplot->xAxis->label());
118+
axisRangeLowerLineEdit->setText(QString::number(qcustomplot->xAxis->range().lower));
119+
axisRangeUpperLineEdit->setText(QString::number(qcustomplot->xAxis->range().upper));
120+
disconnect(qcustomplot->yAxis,0,this,0);
121+
connect(qcustomplot->xAxis, SIGNAL(rangeChanged(const QCPRange &)), this, SLOT(setAxisRange(const QCPRange &)));
122+
}
123+
124+
if(axisIndex == 1)
125+
{
126+
setAxisLabelName(qcustomplot->yAxis->label());
127+
axisRangeLowerLineEdit->setText(QString::number(qcustomplot->yAxis->range().lower));
128+
axisRangeUpperLineEdit->setText(QString::number(qcustomplot->yAxis->range().upper));
129+
disconnect(qcustomplot->xAxis,0,this,0);
130+
connect(qcustomplot->yAxis, SIGNAL(rangeChanged(const QCPRange &)), this, SLOT(setAxisRange(const QCPRange &)));
131+
}
132+
}
133+
134+
135+
void AxisEditWidget::setAxisLabelName(const QString & name)
136+
{
137+
if(axisLabelNameLineEdit->text() != name)
138+
axisLabelNameLineEdit->setText(name);
139+
}
140+
void AxisEditWidget::setAxisRange(double lower, double upper)
141+
{
142+
if(axisRangeLowerLineEdit->text().toDouble() != lower)
143+
axisRangeLowerLineEdit->setText(QString::number(lower));
144+
145+
if(axisRangeUpperLineEdit->text().toDouble() != upper)
146+
axisRangeUpperLineEdit->setText(QString::number(upper));
147+
}
148+
149+
void AxisEditWidget::setAxisRange(const QCPRange & newRange)
150+
{
151+
setAxisRange(newRange.lower,newRange.upper);
152+
}
153+
154+
void AxisEditWidget::slotAxisLabelNameEditingFinished()
155+
{
156+
if((axisLabelNameLineEdit->text() == "") || (axisLabelNameLineEdit->text() == "NoName"))
157+
{
158+
if((axisIndex == 0 ) && (qcustomplot->xAxis->label() != ""))
159+
qcustomplot->xAxis->setLabel("");
160+
else if((axisIndex == 1 ) && (qcustomplot->yAxis->label() != ""))
161+
qcustomplot->yAxis->setLabel("");
162+
163+
qcustomplot->replot();
164+
165+
}
166+
else
167+
{
168+
if((axisIndex == 0) && (axisLabelNameLineEdit->text() != qcustomplot->xAxis->label()))
169+
qcustomplot->xAxis->setLabel(axisLabelNameLineEdit->text());
170+
else if((axisIndex == 1) && (axisLabelNameLineEdit->text() != qcustomplot->yAxis->label()))
171+
qcustomplot->yAxis->setLabel(axisLabelNameLineEdit->text());
172+
173+
qcustomplot->replot();
174+
175+
}
176+
}
177+
void AxisEditWidget::slotAxisRangeEditingFinished()
178+
{
179+
if(((sender() == axisRangeLowerLineEdit) && (axisRangeUpperLineEdit != focusWidget()))
180+
|| ((sender() == axisRangeUpperLineEdit) && (axisRangeLowerLineEdit != focusWidget())))
181+
{
182+
double lower = axisRangeLowerLineEdit->text().toDouble();
183+
double upper = axisRangeUpperLineEdit->text().toDouble();
184+
185+
if(lower<upper){
186+
if(axisIndex == 0)
187+
{
188+
double lowerOld = qcustomplot->xAxis->range().lower;
189+
double upperOld = qcustomplot->xAxis->range().upper;
190+
if((lower!=lowerOld) || (upper!=upperOld))
191+
qcustomplot->xAxis->setRange(lower,upper);
192+
}
193+
194+
else if(axisIndex == 1)
195+
{
196+
double lowerOld = qcustomplot->yAxis->range().lower;
197+
double upperOld = qcustomplot->yAxis->range().upper;
198+
if((lower!=lowerOld) || (upper!=upperOld))
199+
qcustomplot->yAxis->setRange(lower,upper);
200+
}
201+
202+
qcustomplot->replot();
203+
}
204+
205+
else
206+
{
207+
QMessageBox::information(this,tr("Range input invalid"),tr("Range input invalid(lower>upper)! Please re-input."));
208+
axisRangeLowerLineEdit->setFocus();
209+
}
210+
211+
212+
}
213+
214+
}
215+
void AxisEditWidget::slotAxisLabelFontSelected()
216+
{
217+
QFont fontSelected;
218+
if(axisIndex == 0){
219+
fontSelectDialog->setCurrentFont(qcustomplot->xAxis->labelFont());
220+
if(fontSelectDialog->exec())
221+
{
222+
fontSelected = fontSelectDialog->selectedFont();
223+
if(fontSelected != qcustomplot->xAxis->labelFont())
224+
{
225+
qcustomplot->xAxis->setLabelFont(fontSelected);
226+
qcustomplot->replot();
227+
}
228+
}
229+
}
230+
else if(axisIndex == 1)
231+
{
232+
fontSelectDialog->setCurrentFont(qcustomplot->yAxis->labelFont());
233+
if(fontSelectDialog->exec())
234+
{
235+
fontSelected = fontSelectDialog->selectedFont();
236+
if(fontSelected != qcustomplot->yAxis->labelFont())
237+
{
238+
qcustomplot->yAxis->setLabelFont(fontSelected);
239+
qcustomplot->replot();
240+
}
241+
}
242+
}
243+
244+
this->setFocus();
245+
}
246+
void AxisEditWidget::slotAxisTicksLabelFontSelected()
247+
{
248+
QFont fontSelected;
249+
if(axisIndex == 0){
250+
fontSelectDialog->setCurrentFont(qcustomplot->xAxis->tickLabelFont());
251+
if(fontSelectDialog->exec())
252+
{
253+
fontSelected = fontSelectDialog->selectedFont();
254+
if(fontSelected != qcustomplot->xAxis->tickLabelFont())
255+
{
256+
qcustomplot->xAxis->setTickLabelFont(fontSelected);
257+
qcustomplot->replot();
258+
}
259+
}
260+
}
261+
else if(axisIndex == 1)
262+
{
263+
fontSelectDialog->setCurrentFont(qcustomplot->yAxis->tickLabelFont());
264+
if(fontSelectDialog->exec())
265+
{
266+
fontSelected = fontSelectDialog->selectedFont();
267+
if(fontSelected != qcustomplot->yAxis->tickLabelFont())
268+
{
269+
qcustomplot->yAxis->setTickLabelFont(fontSelected);
270+
qcustomplot->replot();
271+
}
272+
}
273+
}
274+
275+
this->setFocus();
276+
}
277+

FigureWindow/AxisEditWidget.h

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* AxisEditWidget.h
3+
*
4+
* Created on: Jun 12, 2016
5+
* Author: htallone
6+
*/
7+
8+
#ifndef SRC_AXISEDITWIDGET_H_
9+
#define SRC_AXISEDITWIDGET_H_
10+
11+
#include <QtWidgets>
12+
#include "qcustomplot/qcustomplot.h"
13+
14+
class AxisEditWidget : public QWidget {
15+
16+
Q_OBJECT
17+
18+
public:
19+
AxisEditWidget(QWidget* parent = 0);
20+
AxisEditWidget(QWidget* parent, QCustomPlot *qcustomplotp, int axisIndex);
21+
22+
virtual ~AxisEditWidget();
23+
signals:
24+
25+
public slots:
26+
void changeAxisIndex(int indexp);
27+
28+
void setAxisLabelName(const QString & name);
29+
void setAxisRange(double lower, double upper);
30+
void setAxisRange(const QCPRange & newRange);
31+
32+
void slotAxisLabelNameEditingFinished();
33+
void slotAxisRangeEditingFinished();
34+
void slotAxisLabelFontSelected();
35+
void slotAxisTicksLabelFontSelected();
36+
37+
38+
private slots:
39+
40+
private:
41+
42+
QCustomPlot *qcustomplot;
43+
int axisIndex;
44+
45+
QLineEdit * axisLabelNameLineEdit;
46+
QLineEdit * axisRangeLowerLineEdit;
47+
QLineEdit * axisRangeUpperLineEdit;
48+
49+
QFontDialog * fontSelectDialog;
50+
51+
52+
};
53+
54+
#endif /* SRC_AXISEDITWIDGET_H_ */

0 commit comments

Comments
 (0)