1 // File : VisuGUI_StreamLinesDlg.cxx
2 // Created : 06 / 03 / 2003
3 // Author : Vitaly SMETANNIKOV
6 // Copyright : Open CASCADE
9 #include "VisuGUI_StreamLinesDlg.h"
11 #include <qgroupbox.h>
12 #include <qcolordialog.h>
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
18 VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg()
19 : QDialog( QAD_Application::getDesktop(), "VisuGUI_StreamLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
21 setCaption("Stream lines Preferences");
22 setSizeGripEnabled( TRUE );
24 QGridLayout* TopLayout = new QGridLayout( this );
25 TopLayout->setSpacing( 6 );
26 TopLayout->setMargin( 11 );
28 QLabel* aStepLenLbl = new QLabel( tr( "Step Length" ), this);
29 TopLayout->addWidget(aStepLenLbl, 0, 0);
30 myStepLen = new QAD_SpinBoxDbl( this);
31 myStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
32 TopLayout->addWidget(myStepLen, 0, 1);
34 QLabel* aIntegStepLenLbl = new QLabel( tr( "Integration Step" ), this);
35 TopLayout->addWidget(aIntegStepLenLbl, 1, 0);
36 myIntegStepLen = new QAD_SpinBoxDbl( this);
37 myIntegStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
38 TopLayout->addWidget(myIntegStepLen, 1, 1);
40 QLabel* aPropagationLbl = new QLabel( tr( "Propagation Time" ), this);
41 TopLayout->addWidget(aPropagationLbl, 2, 0);
42 myPropTime = new QAD_SpinBoxDbl( this, 0, 1000, 10);
43 myPropTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
44 TopLayout->addWidget(myPropTime, 2, 1);
46 QLabel* aDirLbl = new QLabel( tr( "Direction" ), this);
47 TopLayout->addWidget(aDirLbl, 3, 0);
48 myDirCombo = new QComboBox(this);
49 myDirCombo->insertItem("Forward");
50 myDirCombo->insertItem("Backward");
51 myDirCombo->insertItem("Both");
52 TopLayout->addWidget(myDirCombo, 3, 1);
54 myUseScalar = new QCheckBox( tr( "Magnitude coloring" ), this, "UseMagn" );
55 // TopLayout->addMultiCellWidget(myUseScalar, 4, 4, 0, 1);
56 connect( myUseScalar, SIGNAL( clicked() ), this, SLOT( enableSetColor() ) );
57 TopLayout->addWidget(myUseScalar, 4, 0);
59 SelColor = new QPushButton( tr( "Use Color" ), this, "SelColor" );
60 connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) );
61 TopLayout->addWidget( SelColor, 4, 1);
63 QGroupBox* aGroupButtons = new QGroupBox( this, "GroupButtons" );
64 aGroupButtons->setColumnLayout(0, Qt::Vertical );
65 aGroupButtons->layout()->setSpacing( 0 );
66 aGroupButtons->layout()->setMargin( 0 );
68 QGridLayout* aGroupButtonsLayout = new QGridLayout( aGroupButtons->layout() );
69 aGroupButtonsLayout->setAlignment( Qt::AlignTop );
70 aGroupButtonsLayout->setSpacing( 6 );
71 aGroupButtonsLayout->setMargin( 11 );
73 QPushButton* aOkBtn = new QPushButton( tr( "&OK" ), aGroupButtons, "buttonOk" );
74 aOkBtn->setAutoDefault( TRUE );
75 aOkBtn->setDefault( TRUE );
76 aGroupButtonsLayout->addWidget( aOkBtn, 0, 0 );
77 aGroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
79 QPushButton* aCancelBtn = new QPushButton( tr( "&Cancel" ) , aGroupButtons, "buttonCancel" );
80 aCancelBtn->setAutoDefault( TRUE );
81 aGroupButtonsLayout->addWidget( aCancelBtn, 0, 2 );
82 connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
83 connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
84 TopLayout->addMultiCellWidget( aGroupButtons, 5, 5, 0, 1 );
90 void VisuGUI_StreamLinesDlg::initFromPrsObject(VISU::StreamLines_i* thePrs) {
91 myStepLen->setValue(thePrs->GetStepLength());
92 myIntegStepLen->setValue(thePrs->GetIntegrationStep());
93 myPropTime->setValue(thePrs->GetPropagationTime());
94 switch (thePrs->GetDirection()) {
95 case VISU::StreamLines::FORWARD:
96 myDirCombo->setCurrentItem(0);
98 case VISU::StreamLines::BACKWARD:
99 myDirCombo->setCurrentItem(1);
101 case VISU::StreamLines::BOTH:
102 myDirCombo->setCurrentItem(2);
104 myUseScalar->setChecked(thePrs->isColored());
106 setColor(QColor(thePrs->GetColor()[0]*255,
107 thePrs->GetColor()[1]*255,
108 thePrs->GetColor()[2]*255));
114 void VisuGUI_StreamLinesDlg::storeToPrsObject(VISU::StreamLines_i* thePrs) {
115 thePrs->SetStepLength(myStepLen->value());
116 thePrs->SetIntegrationStep(myIntegStepLen->value());
117 thePrs->SetPropagationTime(myPropTime->value());
118 switch (myDirCombo->currentItem()) {
120 thePrs->SetDirection(VISU::StreamLines::FORWARD);
123 thePrs->SetDirection(VISU::StreamLines::BACKWARD);
126 thePrs->SetDirection(VISU::StreamLines::BOTH);
128 thePrs->setColored(myUseScalar->isChecked());
131 aColor[0] = myColor.red()/255.;
132 aColor[1] = myColor.green()/255.;
133 aColor[2] = myColor.blue()/255.;
135 thePrs->SetColor(aColor);
141 void VisuGUI_StreamLinesDlg::setColor( QColor color )
144 SelColor->setPaletteBackgroundColor(myColor);
149 Called when "Select Color" buttonx clicked
151 void VisuGUI_StreamLinesDlg::setVColor()
153 QColor cnew = QColorDialog::getColor( myColor, this );
154 if ( cnew.isValid() )
160 Enbled/disables magnitude coloring
162 void VisuGUI_StreamLinesDlg::enableMagnColor( bool enable )
164 myUseScalar->setEnabled( enable );
169 Called when "Magnitude Coloring" check box clicked
171 void VisuGUI_StreamLinesDlg::enableSetColor()
173 SelColor->setEnabled(!myUseScalar->isChecked() );