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"
14 #include "VisuGUI_Tools.h"
16 #include "VISU_Actor.h"
17 #include "VISU_PipeLine.hxx"
19 #include "SalomeApp_Application.h"
20 #include "LightApp_SelectionMgr.h"
22 #include "SVTK_ViewWindow.h"
23 #include "SVTK_RenderWindowInteractor.h"
25 #include "SUIT_Desktop.h"
26 #include "SUIT_Session.h"
27 #include "SUIT_ViewWindow.h"
29 #include "SALOME_ListIteratorOfListIO.hxx"
30 #include "SALOME_ListIO.hxx"
32 #include "QtxDblSpinBox.h"
34 #include "utilities.h"
36 #include <qgroupbox.h>
38 #include <qpushbutton.h>
46 VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg (QWidget* parent, const char* name, bool modal, WFlags fl)
47 : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
50 setName("NonIsometricDlg");
51 setCaption(tr("DLG_TITLE"));
52 setSizeGripEnabled(TRUE);
54 SVTK_ViewWindow* aViewWnd = VISU::GetViewWindow();
56 // Create layout for this dialog
57 QGridLayout* layoutDlg = new QGridLayout (this);
58 layoutDlg->setSpacing(6);
59 layoutDlg->setMargin(11);
61 // Create croup box with grid layout
62 QGroupBox* GroupBox = new QGroupBox(this, "GroupBox");
63 QGridLayout* glGroupBox = new QGridLayout(GroupBox);
64 glGroupBox->setMargin(11);
65 glGroupBox->setSpacing(6);
68 QLabel* TextLabelX = new QLabel (tr("LBL_X"), GroupBox, "TextLabelX");
69 m_sbXcoeff = new QtxDblSpinBox(-DBL_MAX, DBL_MAX, 0.1, GroupBox);
70 m_sbXcoeff->setMinimumWidth(80);
71 m_sbXcoeff->setValue(1.0);
74 QLabel* TextLabelY = new QLabel (tr("LBL_Y"), GroupBox, "TextLabelY");
75 m_sbYcoeff = new QtxDblSpinBox(-DBL_MAX, DBL_MAX, 0.1, GroupBox);
76 m_sbYcoeff->setMinimumWidth(80);
77 m_sbYcoeff->setValue(1.0);
80 QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), GroupBox, "TextLabelZ");
81 m_sbZcoeff = new QtxDblSpinBox(-DBL_MAX, DBL_MAX, 0.1, GroupBox);
82 m_sbZcoeff->setMinimumWidth(80);
83 m_sbZcoeff->setValue(1.0);
85 // Get initial values from the current VTK viewer
87 double aScaleFactor[3];
88 aViewWnd->GetScale(aScaleFactor);
89 m_sbXcoeff -> setValue(aScaleFactor[0]);
90 m_sbYcoeff -> setValue(aScaleFactor[1]);
91 m_sbZcoeff -> setValue(aScaleFactor[2]);
94 // Create <Reset> button
95 m_bReset = new QPushButton(tr("&Reset"), GroupBox, "m_bReset");
97 // Layout widgets in the group box
98 glGroupBox->addWidget(TextLabelX, 0, 0);
99 glGroupBox->addWidget(m_sbXcoeff, 0, 1);
100 glGroupBox->addWidget(TextLabelY, 0, 2);
101 glGroupBox->addWidget(m_sbYcoeff, 0, 3);
102 glGroupBox->addWidget(TextLabelZ, 0, 4);
103 glGroupBox->addWidget(m_sbZcoeff, 0, 5);
104 glGroupBox->addWidget(m_bReset, 0, 6);
106 // OK, CANCEL, Apply button
107 QGroupBox* aWgt = new QGroupBox(this);
108 QHBoxLayout* aHBoxLayout = new QHBoxLayout(aWgt);
109 aHBoxLayout->setMargin(11);
110 aHBoxLayout->setSpacing(6);
111 // Create <OK> button
112 QPushButton* m_bOk = new QPushButton(tr("O&K"), aWgt, "m_bOk");
113 m_bOk->setDefault(TRUE);
114 m_bOk->setAutoDefault(TRUE);
115 // Create <Apply> button
116 QPushButton* m_bApply = new QPushButton(tr("&Apply"), aWgt, "m_bApply");
117 m_bApply->setAutoDefault(TRUE);
118 // Create <Cancel> button
119 QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aWgt, "m_bCancel");
120 m_bCancel->setAutoDefault(TRUE);
123 aHBoxLayout->addWidget(m_bOk);
124 aHBoxLayout->addWidget(m_bApply);
125 aHBoxLayout->addStretch();
126 aHBoxLayout->addWidget(m_bCancel);
128 // Layout top level widgets
129 layoutDlg->addWidget(GroupBox,0,0);
130 layoutDlg->addWidget(aWgt,1,0);
132 // signals and slots connections
133 connect(m_bCancel, SIGNAL(clicked()), this, SLOT(reject()));
134 connect(m_bOk, SIGNAL(clicked()), this, SLOT(onClickOk()));
135 connect(m_bApply, SIGNAL(clicked()), this, SLOT(onClickApply()));
136 connect(m_bReset, SIGNAL(clicked()), this, SLOT(onClickReset()));
138 this->resize(100, this->sizeHint().height());
142 * Destroys the object and frees any allocated resources
144 VisuGUI_NonIsometricDlg::~VisuGUI_NonIsometricDlg()
146 // no need to delete child widgets, Qt does it all for us
149 void VisuGUI_NonIsometricDlg::onClickOk()
157 void VisuGUI_NonIsometricDlg::onClickApply()
159 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
160 (SUIT_Session::session()->activeApplication());
161 LightApp_SelectionMgr* mgr = anApp->selectionMgr();
163 SVTK_ViewWindow* vf = VISU::GetViewWindow();
167 double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
168 vf->SetScale(aScale);
170 SALOME_ListIO selected;
171 mgr->selectedObjects(selected);
172 SALOME_ListIteratorOfListIO Itinit(selected);
175 for (; Itinit.More(); Itinit.Next()) {
176 vf->highlight(Itinit.Value(), true);
180 void VisuGUI_NonIsometricDlg::onClickReset()
182 m_bReset->setFocus();
183 m_sbXcoeff->setValue(1.0);
184 m_sbYcoeff->setValue(1.0);
185 m_sbZcoeff->setValue(1.0);