1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SALOMEGUI_NonIsometricDlg.cxx
8 // Author : Vasily Rusyaev
12 #include "VisuGUI_NonIsometricDlg.h"
13 #include "VISU_Actor.h"
14 #include "VISU_PipeLine.hxx"
16 #include "QAD_SpinBoxDbl.h"
17 #include "QAD_Application.h"
18 #include "QAD_Desktop.h"
19 #include "QAD_StudyFrame.h"
20 #include "QAD_RightFrame.h"
21 #include "VTKViewer_ViewFrame.h"
22 #include "utilities.h"
24 #include "SALOME_Selection.h"
25 #include "SALOME_ListIteratorOfListIO.hxx"
26 #include "SALOME_ListIO.hxx"
28 #include <qgroupbox.h>
30 #include <qpushbutton.h>
38 VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
39 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
42 QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame();
43 VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(sf->getRightFrame()->getViewFrame());
46 setName( "NonIsometricDlg" );
47 setCaption( tr( "Scaling" ) );
48 setSizeGripEnabled( TRUE );
50 // Create layout for this dialog
51 QGridLayout* layoutDlg = new QGridLayout( this );
52 layoutDlg->setSpacing(6);
53 layoutDlg->setMargin(11);
55 // Create croup box with grid layout
56 QGroupBox* GroupBox = new QGroupBox( this, "GroupBox" );
57 QGridLayout* glGroupBox = new QGridLayout( GroupBox );
58 glGroupBox->setMargin(11);
59 glGroupBox->setSpacing(6);
62 QLabel* TextLabelX = new QLabel( "X: ", GroupBox, "TextLabelX" );
63 m_sbXcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 );
64 //m_sbXcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
65 m_sbXcoeff->setMinimumWidth( 80 );
66 m_sbXcoeff->setValue( 1.0 );
69 QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" );
70 m_sbYcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 );
71 //m_sbYcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
72 m_sbYcoeff->setMinimumWidth( 80 );
73 m_sbYcoeff->setValue( 1.0 );
76 QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" );
77 m_sbZcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 );
78 //m_sbZcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
79 m_sbZcoeff->setMinimumWidth( 80 );
80 m_sbZcoeff->setValue( 1.0 );
82 // Get initial values from the current VTK viewer
84 double aScaleFactor[3];
85 aViewFrame->GetScale(aScaleFactor);
86 m_sbXcoeff -> setValue(aScaleFactor[0]);
87 m_sbYcoeff -> setValue(aScaleFactor[1]);
88 m_sbZcoeff -> setValue(aScaleFactor[2]);
91 // Create <Reset> button
92 m_bReset = new QPushButton( tr( "&Reset" ), GroupBox, "m_bReset" );
94 // Layout widgets in the group box
95 glGroupBox->addWidget( TextLabelX, 0, 0 );
96 glGroupBox->addWidget( m_sbXcoeff, 0, 1 );
97 glGroupBox->addWidget( TextLabelY, 0, 2 );
98 glGroupBox->addWidget( m_sbYcoeff, 0, 3 );
99 glGroupBox->addWidget( TextLabelZ, 0, 4 );
100 glGroupBox->addWidget( m_sbZcoeff, 0, 5 );
101 glGroupBox->addWidget( m_bReset, 0, 6 );
103 // OK, CANCEL, Apply button
104 QGroupBox* aWgt = new QGroupBox( this );
105 QHBoxLayout* aHBoxLayout = new QHBoxLayout( aWgt );
106 aHBoxLayout->setMargin(11);
107 aHBoxLayout->setSpacing(6);
108 // Create <OK> button
109 QPushButton* m_bOk = new QPushButton( tr( "O&K" ), aWgt, "m_bOk" );
110 m_bOk->setDefault( TRUE );
111 m_bOk->setAutoDefault( TRUE );
112 // Create <Apply> button
113 QPushButton* m_bApply = new QPushButton( tr( "&Apply" ), aWgt, "m_bApply" );
114 m_bApply->setAutoDefault( TRUE );
115 // Create <Cancel> button
116 QPushButton* m_bCancel = new QPushButton( tr( "&Cancel" ), aWgt, "m_bCancel" );
117 m_bCancel->setAutoDefault( TRUE );
120 aHBoxLayout->addWidget( m_bOk );
121 aHBoxLayout->addWidget( m_bApply );
122 aHBoxLayout->addStretch();
123 aHBoxLayout->addWidget( m_bCancel );
125 // Layout top level widgets
126 layoutDlg->addWidget(GroupBox,0,0);
127 layoutDlg->addWidget(aWgt,1,0);
129 // signals and slots connections
130 connect( m_bCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
131 connect( m_bOk, SIGNAL( clicked() ), this, SLOT( onClickOk( ) ) );
132 connect( m_bApply, SIGNAL( clicked() ), this, SLOT( onClickApply( ) ) );
133 connect( m_bReset, SIGNAL( clicked() ), this, SLOT( onClickReset( ) ) );
135 this->resize( 100, this->sizeHint().height() );
139 * Destroys the object and frees any allocated resources
141 VisuGUI_NonIsometricDlg::~VisuGUI_NonIsometricDlg()
143 // no need to delete child widgets, Qt does it all for us
146 void VisuGUI_NonIsometricDlg::onClickOk()
154 void VisuGUI_NonIsometricDlg::onClickApply(){
155 QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame();
156 SALOME_Selection* Sel = SALOME_Selection::Selection( sf->getStudy()->getSelection() );
159 if( VTKViewer_ViewFrame* vf = dynamic_cast<VTKViewer_ViewFrame*>(sf->getRightFrame()->getViewFrame())){
160 double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
161 vf->SetScale(aScale);
164 SALOME_ListIteratorOfListIO Itinit( Sel->StoredIObjects() );
165 for (; Itinit.More(); Itinit.Next()) {
166 sf->getStudy()->highlight(Itinit.Value(), true);
170 void VisuGUI_NonIsometricDlg::onClickReset()
172 m_bReset->setFocus();
173 m_sbXcoeff->setValue( 1.0 );
174 m_sbYcoeff->setValue( 1.0 );
175 m_sbZcoeff->setValue( 1.0 );