77#include < TkUtil/MemoryError.h>
88
99#include < qwt_plot_layout.h>
10+ #include < qwt_text.h>
1011
1112#include < QButtonGroup>
1213#include < QColorDialog>
@@ -26,15 +27,10 @@ static const TkUtil::Charset charset ("àéèùô");
2627USE_ENCODING_AUTODETECTION
2728
2829
29- QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
30- QWidget* parent, QwtChartPanel* chartPanel)
30+ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (QWidget* parent, QwtChartPanel* chartPanel)
3131 : QwtChartPanel::QwtChartEditionPanel (parent, chartPanel),
32- _chartPanel (chartPanel),
33- _backgroundColor (Qt::white),
34- _titleTextField (0 ), _titleFontPanel (0 ),
35- _cartesianButton (0 ), _polarButton (0 ),
36- _marginsTextField (0 ),
37- _aspectRatioCheckbox (0 ), _aspectRatioTextField (0 )
32+ _chartPanel (chartPanel), _backgroundColor (Qt::white), _titleTextField (0 ), _titleFontPanel (0 ),
33+ _cartesianButton (0 ), _polarButton (0 ), _marginsTextField (0 ), _aspectRatioCheckbox (0 ), _aspectRatioTextField (0 )
3834{
3935 if (0 != _chartPanel)
4036 _backgroundColor = _chartPanel->getBackgroundColor ( );
@@ -51,19 +47,15 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
5147 vLayout->addLayout (hLayout);
5248 QLabel* label = new QLabel (" Titre :" , group);
5349 hLayout->addWidget (label);
54- QString title =
55- 0 == _chartPanel ? " " : _chartPanel->getPlot ( ).title ( ).text ( );
50+ QString title = 0 == _chartPanel ? " " : _chartPanel->getPlot ( ).title ( ).text ( );
5651 _titleTextField = new QtTextField (title, group);
5752 hLayout->addWidget (_titleTextField);
5853 QPushButton* button = new QPushButton (" Modifier ..." , group);
5954 hLayout->addWidget (button);
6055 connect (button, SIGNAL (clicked ( )), this , SLOT (editTitleCallback ( )));
61- QFont font = 0 == _chartPanel ?
62- QApplication::font ( ) : _chartPanel->getPlot ( ).title ( ).font ( );
63- QColor color = 0 == _chartPanel ?
64- Qt::black : _chartPanel->getPlot ( ).title ( ).color ( );
65- _titleFontPanel =
66- new QtFontPanel (this , font, color, QtFontPanel::HORIZONTAL_PANEL);
56+ QFont font = 0 == _chartPanel ? QApplication::font ( ) : _chartPanel->getPlot ( ).title ( ).font ( );
57+ QColor color = 0 == _chartPanel ? Qt::black : _chartPanel->getPlot ( ).title ( ).color ( );
58+ _titleFontPanel = new QtFontPanel (this , font, color, QtFontPanel::HORIZONTAL_PANEL);
6759 vLayout->addWidget (_titleFontPanel);
6860 vLayout->addStretch (2 );
6961
@@ -74,21 +66,18 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
7466 hLayout = new QHBoxLayout ( );
7567 group->setLayout (hLayout);
7668 mainLayout->addWidget (group);
77- _cartesianButton =
78- new QRadioButton (QSTR (" Cartésienne" ), group);
69+ _cartesianButton = new QRadioButton (QSTR (" Cartésienne" ), group);
7970 hLayout->addWidget (_cartesianButton);
8071 if (QwtChartPanel::CARTESIAN == chartPanel->getDisplayMode ( ))
8172 _cartesianButton->setChecked (true );
82- _cartesianButton->setEnabled (
83- chartPanel->isDisplayModeAllowed (QwtChartPanel::CARTESIAN));
73+ _cartesianButton->setEnabled (chartPanel->isDisplayModeAllowed (QwtChartPanel::CARTESIAN));
8474 buttonGroup->addButton (_cartesianButton);
8575 _polarButton = new QRadioButton (" Polaire" , group);
8676 buttonGroup->addButton (_polarButton);
8777 hLayout->addWidget (_polarButton);
8878 if (QwtChartPanel::POLAR == chartPanel->getDisplayMode ( ))
8979 _polarButton->setChecked (true );
90- _polarButton->setEnabled (
91- chartPanel->isDisplayModeAllowed (QwtChartPanel::POLAR));
80+ _polarButton->setEnabled (chartPanel->isDisplayModeAllowed (QwtChartPanel::POLAR));
9281 hLayout->addStretch (200 );
9382
9483 // Fond :
@@ -100,8 +89,7 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
10089 hLayout->addWidget (label);
10190 button = new QPushButton (" Couleur ..." , group);
10291 hLayout->addWidget (button);
103- connect (button, SIGNAL (clicked ( )), this ,
104- SLOT (backgroundColorCallback ( )));
92+ connect (button, SIGNAL (clicked ( )), this , SLOT (backgroundColorCallback ( )));
10593 hLayout->addStretch (2 );
10694
10795 // Marges :
@@ -113,7 +101,11 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
113101 hLayout->addWidget (label);
114102 int margin = 0 ;
115103 if (0 != _chartPanel)
104+ #ifdef QT_5
116105 _chartPanel->getPlot ( ).getContentsMargins (&margin, &margin, &margin, &margin);
106+ #else // QT_5
107+ margin = _chartPanel->getPlot ( ).contentsMargins ( ).left ( );
108+ #endif // QT_5
117109 _marginsTextField = new QtIntTextField (margin, group);
118110 _marginsTextField->setRange (0 , 100 );
119111 _marginsTextField->setVisibleColumns (3 );
@@ -124,16 +116,13 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
124116 hLayout = new QHBoxLayout ( );
125117 group->setLayout (hLayout);
126118 mainLayout->addWidget (group);
127- _aspectRatioCheckbox =
128- new QCheckBox (" Utiliser le rapport d'aspect" , group);
119+ _aspectRatioCheckbox = new QCheckBox (" Utiliser le rapport d'aspect" , group);
129120 if (0 != _chartPanel)
130121 _aspectRatioCheckbox->setChecked (_chartPanel->useAspectRatio ( ));
131122 hLayout->addWidget (_aspectRatioCheckbox);
132123 label = new QLabel (" Rapport d'aspect :" , group);
133124 hLayout->addWidget (label);
134- _aspectRatioTextField =
135- new QtDoubleTextField (0 == _chartPanel ?
136- 1 . : _chartPanel->getAspectRatio ( ), group);
125+ _aspectRatioTextField = new QtDoubleTextField (0 == _chartPanel ? 1 . : _chartPanel->getAspectRatio ( ), group);
137126 _aspectRatioTextField->setRange (1E-6 , 1E6 );
138127 hLayout->addWidget (_aspectRatioTextField);
139128 hLayout->addStretch (2 );
@@ -143,20 +132,16 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
143132} // QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel
144133
145134
146- QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (
147- const QwtChartGeneralOptionsPanel& view)
135+ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (const QwtChartGeneralOptionsPanel& view)
148136 : QwtChartPanel::QwtChartEditionPanel (0 , 0 ), _chartPanel (0 ),
149137 _backgroundColor (Qt::white), _titleTextField (0 ), _titleFontPanel (0 ),
150- _cartesianButton (0 ), _polarButton (0 ),
151- _marginsTextField (0 ),
152- _aspectRatioCheckbox (0 ), _aspectRatioTextField (0 )
138+ _cartesianButton (0 ), _polarButton (0 ), _marginsTextField (0 ), _aspectRatioCheckbox (0 ), _aspectRatioTextField (0 )
153139{
154140 assert (0 && " QwtChartGeneralOptionsPanel copy constructor is not allowed." );
155141} // QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (const QwtChartGeneralOptionsPanel& view)
156142
157143
158- QwtChartGeneralOptionsPanel& QwtChartGeneralOptionsPanel::operator = (
159- const QwtChartGeneralOptionsPanel& view)
144+ QwtChartGeneralOptionsPanel& QwtChartGeneralOptionsPanel::operator = (const QwtChartGeneralOptionsPanel& view)
160145{
161146 assert (0 && " QwtChartGeneralOptionsPanel::operator = is not allowed." );
162147 return *this ;
@@ -190,8 +175,7 @@ void QwtChartGeneralOptionsPanel::setTitle (const QwtText& title)
190175} // QwtChartGeneralOptionsPanel::setTitle
191176
192177
193- QwtChartPanel::DISPLAY_MODE
194- QwtChartGeneralOptionsPanel::getDisplayMode ( ) const
178+ QwtChartPanel::DISPLAY_MODE QwtChartGeneralOptionsPanel::getDisplayMode ( ) const
195179{
196180 assert (0 != _cartesianButton);
197181 assert (0 != _polarButton);
@@ -205,18 +189,15 @@ QwtChartPanel::DISPLAY_MODE
205189} // QwtChartGeneralOptionsPanel::getDisplayMode
206190
207191
208- void QwtChartGeneralOptionsPanel::setDisplayMode (
209- QwtChartPanel::DISPLAY_MODE mode)
192+ void QwtChartGeneralOptionsPanel::setDisplayMode (QwtChartPanel::DISPLAY_MODE mode)
210193{
211194 assert (0 != _cartesianButton);
212195 assert (0 != _polarButton);
213196
214197 switch (mode)
215198 {
216- case QwtChartPanel::CARTESIAN :
217- _cartesianButton->setChecked (true ); break ;
218- case QwtChartPanel::POLAR :
219- _polarButton->setChecked (true ); break ;
199+ case QwtChartPanel::CARTESIAN : _cartesianButton->setChecked (true ); break ;
200+ case QwtChartPanel::POLAR : _polarButton->setChecked (true ); break ;
220201 default :
221202 {
222203 INTERNAL_ERROR (exc, " Mode de représentation (cartésienne/polaire) indéfini." , " QwtChartGeneralOptionsPanel::setDisplayMode" )
@@ -244,8 +225,7 @@ unsigned int QwtChartGeneralOptionsPanel::getMargins ( ) const
244225 if (0 > _marginsTextField->getValue ( ))
245226 {
246227 UTF8String msg (charset);
247- msg << " La valeur " << (unsigned long )_marginsTextField->getValue ( )
248- << " est négative alors qu'elle devrait être positive ou nulle." ;
228+ msg << " La valeur " << (unsigned long )_marginsTextField->getValue ( ) << " est négative alors qu'elle devrait être positive ou nulle." ;
249229 INTERNAL_ERROR (exc, msg, " QwtChartGeneralOptionsPanel::getMargins" )
250230 throw exc;
251231 } // if (0 > _marginsTextField->getValue ( ))
@@ -335,14 +315,11 @@ void QwtChartGeneralOptionsPanel::editTitleCallback ( )
335315
336316 try
337317 {
338- UTF8String title (
339- QtUnicodeHelper::qstringToUTF8String (_titleTextField->text ( )));
318+ UTF8String title (QtUnicodeHelper::qstringToUTF8String (_titleTextField->text ( )));
340319 QFont font = _titleFontPanel->getFont ( );
341320 QColor textColor = _titleFontPanel->getColor ( );
342321 QColor background = getBackgroundColor ( );
343- QtScientificTextDialog dialog (
344- this , " Titre du graphique" , title, true , font,
345- textColor, background);
322+ QtScientificTextDialog dialog (this , " Titre du graphique" , title, true , font, textColor, background);
346323 if (QDialog::Accepted != dialog.exec ( ))
347324 return ;
348325
0 commit comments