From 35a257528333727c5af36ab26d1bd8196da219fe Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 17 May 2005 11:15:41 +0000 Subject: [PATCH] Apply button for Offset dialog --- src/VISUGUI/VisuGUI.cxx | 9 +++- src/VISUGUI/VisuGUI_OffsetDlg.cxx | 72 +++++++++++++++++++++++++++++-- src/VISUGUI/VisuGUI_OffsetDlg.h | 12 +++++- 3 files changed, 87 insertions(+), 6 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 199bedbf..28f7edb4 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -4509,13 +4509,18 @@ void VisuGUI::SetActiveDialogBox(QDialog* aDlg) void VisuGUI::TranslatePrs() { + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs"); CORBA::Object_var anObject = GetSelectedObj(); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); if(VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in())){ - float aOffset[3]; + VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg(aPrsObject); + aDlg->show(); + } + } + /* float aOffset[3]; aPrsObject->GetOffset(aOffset); VisuGUI_OffsetDlg aDlg; aDlg.setOffset(aOffset); @@ -4544,7 +4549,7 @@ void VisuGUI::TranslatePrs() } } } - } + }*/ } diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index 92f1ce01..6914dfe0 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -1,9 +1,15 @@ #include "VisuGUI_OffsetDlg.h" +#include "VisuGUI.h" #include "QAD_SpinBoxDbl.h" #include "QAD_Application.h" #include "QAD_Desktop.h" +#include "QAD_RightFrame.h" + +#include "VTKViewer_ViewFrame.h" +#include "VISU_Actor.h" +#include "vtkRenderer.h" #include #include @@ -15,9 +21,15 @@ #define MAXVAL 1e10 -VisuGUI_OffsetDlg::VisuGUI_OffsetDlg() -: QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +extern CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO=NULL, QAD_Study* theStudy=NULL, + VISU::Storable::TRestoringMap* pMap=NULL); + + +VisuGUI_OffsetDlg::VisuGUI_OffsetDlg(VISU::Prs3d_i* thePrs) +: QDialog( QAD_Application::getDesktop(), 0, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) { + myPrs = thePrs; setName( "VisuGUI_OffsetDlg" ); setCaption( tr( "TIT_OFFSETDLG" ) ); setSizeGripEnabled( TRUE ); @@ -66,14 +78,27 @@ VisuGUI_OffsetDlg::VisuGUI_OffsetDlg() GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons, "buttonApply" ); + buttonOk->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 2 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 3 ); + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 4 ); TopLayout->addWidget( GroupButtons ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( updateOffset() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + float aOffset[3]; + myPrs->GetOffset(aOffset); + myOldOffset[0] = aOffset[0]; + myOldOffset[1] = aOffset[1]; + myOldOffset[2] = aOffset[2]; + setOffset(aOffset); } @@ -106,3 +131,44 @@ bool VisuGUI_OffsetDlg::isToSave() const { return mySaveChk->isChecked(); } + + +void VisuGUI_OffsetDlg::updateOffset() +{ + float aOffset[3]; + getOffset(aOffset); + if (isToSave()) + myPrs->SetOffset(aOffset); + + for(int i = 0, nbFrames = VisuGUI::GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++){ + if(QAD_StudyFrame* aFrame = VisuGUI::GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) { + if(VISU_Actor* anActor = VisuGUI::GetActor(myPrs,aViewFrame)) { + anActor->SetPosition(aOffset); + aViewFrame->getRenderer()->ResetCameraClippingRange(); + aViewFrame->Repaint(); + + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); + if ( !CORBA::is_nil( anObject ) ) + aViewFrame->highlight(anIO, 1); + } + } + } + } +} + + +void VisuGUI_OffsetDlg::accept() +{ + updateOffset(); + QDialog::accept(); +} + +void VisuGUI_OffsetDlg::reject() +{ + setOffset(myOldOffset); + updateOffset(); + QDialog::reject(); +} diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.h b/src/VISUGUI/VisuGUI_OffsetDlg.h index 48703f10..e4b94fc5 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.h +++ b/src/VISUGUI/VisuGUI_OffsetDlg.h @@ -3,6 +3,7 @@ #define DIALOGBOX_OFFSET_H #include "QAD_SpinBoxDbl.h" +#include "VISU_Prs3d_i.hh" // QT Includes #include @@ -14,7 +15,7 @@ class VisuGUI_OffsetDlg: public QDialog { Q_OBJECT public: - VisuGUI_OffsetDlg(); + VisuGUI_OffsetDlg(VISU::Prs3d_i* thePrs); ~VisuGUI_OffsetDlg() {}; void setOffset(const float* theOffset); @@ -24,12 +25,21 @@ class VisuGUI_OffsetDlg: public QDialog public slots: void onReset(); + protected slots: + virtual void accept(); + virtual void reject(); + void updateOffset(); + private: + VISU::Prs3d_i* myPrs; + QAD_SpinBoxDbl* myDxEdt; QAD_SpinBoxDbl* myDyEdt; QAD_SpinBoxDbl* myDzEdt; QCheckBox* mySaveChk; + + float myOldOffset[3]; }; #endif // DIALOGBOX_OFFSET_H -- 2.39.2