#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 <qlayout.h>
#include <qhbox.h>
#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 );
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);
}
{
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<VTKViewer_ViewFrame*>(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();
+}