]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx
Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_SetupCurveDlg.cxx
1 using namespace std;
2 //  File      : SALOMEGUI_SetupCurveDlg.cxx
3 //  Created   : Wed Jun 27 16:38:42 2001
4 //  Author    : Vadim SANDLER
5 //  Project   : SALOME
6 //  Module    : SALOMEGUI
7 //  Copyright : Open CASCADE
8 //  $Header$
9
10 #include "SALOMEGUI_SetupCurveDlg.h"
11 #include "QAD_Tools.h"
12 #include <qlayout.h>
13 #include <qlabel.h>
14 #include <qpushbutton.h>
15 #include <qcombobox.h>
16 #include <qspinbox.h>
17 #include <qtoolbutton.h>
18 #include <qgroupbox.h>
19 #include <qcolordialog.h>
20
21 #define MARGIN_SIZE      11
22 #define SPACING_SIZE     6
23 #define MIN_COMBO_WIDTH  100
24 #define MIN_SPIN_WIDTH   50
25 #define MAX_LINE_WIDTH   100
26
27 /*!
28   Constructor
29 */
30 SALOMEGUI_SetupCurveDlg::SALOMEGUI_SetupCurveDlg( QWidget* parent )
31      : QDialog( parent, "SALOMEGUI_SetupCurveDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
32 {
33   setCaption( tr("TLT_SETUP_CURVE") );
34   setSizeGripEnabled( TRUE );
35   QGridLayout* topLayout = new QGridLayout( this ); 
36   topLayout->setSpacing( SPACING_SIZE );
37   topLayout->setMargin( MARGIN_SIZE );
38
39   QGroupBox* TopGroup = new QGroupBox( this );
40   TopGroup->setColumnLayout( 0, Qt::Vertical );
41   TopGroup->layout()->setSpacing( 0 ); TopGroup->layout()->setMargin( 0 );
42   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
43   TopGroupLayout->setAlignment( Qt::AlignTop );
44   TopGroupLayout->setSpacing( SPACING_SIZE ); TopGroupLayout->setMargin( MARGIN_SIZE );
45
46   QLabel* aLineTypeLab = new QLabel( tr( "CURVE_LINE_TYPE_LAB" ), TopGroup );
47   myLineCombo = new QComboBox( false, TopGroup );
48   myLineCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
49   myLineCombo->setMinimumWidth( MIN_COMBO_WIDTH );
50   myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) );
51   myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) );
52   myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) );
53   myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) );
54   myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) );
55   myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
56   myLineCombo->setCurrentItem( 1 ); // SOLID by default
57
58   QLabel* aLineWidthLab = new QLabel( tr( "CURVE_LINE_WIDTH_LAB" ), TopGroup );
59   myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, TopGroup );
60   myLineSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
61   myLineSpin->setMinimumWidth( MIN_SPIN_WIDTH );
62   myLineSpin->setValue( 0 );        // default width is 0
63
64   QLabel* aMarkerLab = new QLabel( tr( "CURVE_MARKER_TYPE_LAB" ), TopGroup );
65   myMarkerCombo = new QComboBox( false, TopGroup );
66   myMarkerCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
67   myMarkerCombo->setMinimumWidth( MIN_COMBO_WIDTH );
68   myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) );
69   myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) );
70   myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) );
71   myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) );
72   myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) );
73   myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) );
74   myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) );
75   myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) );
76   myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) );
77   myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) );
78   myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default
79
80   QLabel* aColorLab = new QLabel( tr( "CURVE_COLOR_LAB" ), TopGroup );
81   myColorBtn = new QToolButton( TopGroup );
82
83   TopGroupLayout->addWidget( aLineTypeLab, 0, 0 );
84   TopGroupLayout->addMultiCellWidget( myLineCombo, 0, 0, 1, 2 );
85   TopGroupLayout->addWidget( aLineWidthLab, 1, 0 );
86   TopGroupLayout->addMultiCellWidget( myLineSpin, 1, 1, 1, 2 );
87   TopGroupLayout->addWidget( aMarkerLab, 2, 0 );
88   TopGroupLayout->addMultiCellWidget( myMarkerCombo, 2, 2, 1, 2 );
89   TopGroupLayout->addWidget( aColorLab, 3, 0 );
90   TopGroupLayout->addWidget( myColorBtn, 3, 1 );
91   TopGroupLayout->setColStretch( 2, 5 );
92
93   QGroupBox* GroupButtons = new QGroupBox( this );
94   GroupButtons->setColumnLayout( 0, Qt::Vertical );
95   GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 );
96   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
97   GroupButtonsLayout->setAlignment( Qt::AlignTop );
98   GroupButtonsLayout->setSpacing( SPACING_SIZE ); GroupButtonsLayout->setMargin( MARGIN_SIZE );
99
100   myOkBtn = new QPushButton( tr( "BUT_OK" ), GroupButtons );
101   myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
102   myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ) , GroupButtons );
103   myCancelBtn->setAutoDefault( true );
104
105   GroupButtonsLayout->addWidget( myOkBtn );
106   GroupButtonsLayout->addStretch();
107   GroupButtonsLayout->addWidget( myCancelBtn );
108
109   connect( myColorBtn,  SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
110   connect( myOkBtn,     SIGNAL( clicked() ), this, SLOT( accept() ) );
111   connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
112   setColor( QColor( 0, 0, 0 ) );
113
114   topLayout->addWidget( TopGroup,     0, 0 );
115   topLayout->addWidget( GroupButtons, 1, 0 );
116
117   QAD_Tools::centerWidget( this, parent );
118 }
119 /*!
120   Destructor
121 */
122 SALOMEGUI_SetupCurveDlg::~SALOMEGUI_SetupCurveDlg()
123 {
124 }
125 /*!
126   Sets line style and width
127 */
128 void SALOMEGUI_SetupCurveDlg::setLine( const int line, const int width )
129 {
130   myLineCombo->setCurrentItem( line );
131   myLineSpin->setValue( width );
132 }
133 /*!
134   Gets line style
135 */
136 int SALOMEGUI_SetupCurveDlg::getLine() const
137 {
138   return myLineCombo->currentItem();
139 }
140 /*!
141   Gets line width
142 */
143 int SALOMEGUI_SetupCurveDlg::getLineWidth() const
144 {
145   return myLineSpin->value();
146 }
147 /*!
148   Sets marker style
149 */
150 void SALOMEGUI_SetupCurveDlg::setMarker( const int marker )
151 {
152   myMarkerCombo->setCurrentItem( marker );
153 }
154 /*!
155   Gets marker style
156 */
157 int SALOMEGUI_SetupCurveDlg::getMarker() const 
158 {
159   return myMarkerCombo->currentItem();
160 }
161 /*!
162   Sets color
163 */
164 void SALOMEGUI_SetupCurveDlg::setColor( const QColor& color )
165 {
166   QPalette pal = myColorBtn->palette();
167   QColorGroup ca = pal.active();
168   ca.setColor( QColorGroup::Button, color );
169   QColorGroup ci = pal.inactive();
170   ci.setColor( QColorGroup::Button, color );
171   pal.setActive( ca );
172   pal.setInactive( ci );
173   myColorBtn->setPalette( pal );
174 }
175 /*!
176   Gets color
177 */
178 QColor SALOMEGUI_SetupCurveDlg::getColor() const 
179 {
180   return myColorBtn->palette().active().button();
181 }
182 /*!
183   <Color> button slot, invokes color selection dialog box
184 */
185 void SALOMEGUI_SetupCurveDlg::onColorChanged()
186 {
187   QColor color = QColorDialog::getColor( getColor() );
188   if ( color.isValid() ) {
189     setColor( color );
190   }
191 }
192
193
194
195
196