2 // File : SALOMEGUI_SetupCurveDlg.cxx
3 // Created : Wed Jun 27 16:38:42 2001
4 // Author : Vadim SANDLER
7 // Copyright : Open CASCADE
10 #include "SALOMEGUI_SetupCurveDlg.h"
11 #include "QAD_Tools.h"
14 #include <qpushbutton.h>
15 #include <qcombobox.h>
17 #include <qtoolbutton.h>
18 #include <qgroupbox.h>
19 #include <qcolordialog.h>
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
30 SALOMEGUI_SetupCurveDlg::SALOMEGUI_SetupCurveDlg( QWidget* parent )
31 : QDialog( parent, "SALOMEGUI_SetupCurveDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
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 );
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 );
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
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
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
80 QLabel* aColorLab = new QLabel( tr( "CURVE_COLOR_LAB" ), TopGroup );
81 myColorBtn = new QToolButton( TopGroup );
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 );
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 );
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 );
105 GroupButtonsLayout->addWidget( myOkBtn );
106 GroupButtonsLayout->addStretch();
107 GroupButtonsLayout->addWidget( myCancelBtn );
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 ) );
114 topLayout->addWidget( TopGroup, 0, 0 );
115 topLayout->addWidget( GroupButtons, 1, 0 );
117 QAD_Tools::centerWidget( this, parent );
122 SALOMEGUI_SetupCurveDlg::~SALOMEGUI_SetupCurveDlg()
126 Sets line style and width
128 void SALOMEGUI_SetupCurveDlg::setLine( const int line, const int width )
130 myLineCombo->setCurrentItem( line );
131 myLineSpin->setValue( width );
136 int SALOMEGUI_SetupCurveDlg::getLine() const
138 return myLineCombo->currentItem();
143 int SALOMEGUI_SetupCurveDlg::getLineWidth() const
145 return myLineSpin->value();
150 void SALOMEGUI_SetupCurveDlg::setMarker( const int marker )
152 myMarkerCombo->setCurrentItem( marker );
157 int SALOMEGUI_SetupCurveDlg::getMarker() const
159 return myMarkerCombo->currentItem();
164 void SALOMEGUI_SetupCurveDlg::setColor( const QColor& color )
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 );
172 pal.setInactive( ci );
173 myColorBtn->setPalette( pal );
178 QColor SALOMEGUI_SetupCurveDlg::getColor() const
180 return myColorBtn->palette().active().button();
183 <Color> button slot, invokes color selection dialog box
185 void SALOMEGUI_SetupCurveDlg::onColorChanged()
187 QColor color = QColorDialog::getColor( getColor() );
188 if ( color.isValid() ) {