From 195c9262c3252880868574239a84e9367a993b88 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 28 Apr 2005 13:32:56 +0000 Subject: [PATCH] Presentation translation management is added --- src/VISUGUI/Makefile.in | 6 +- src/VISUGUI/VISU_msg_en.po | 5 ++ src/VISUGUI/VisuGUI.cxx | 34 +++++++++++ src/VISUGUI/VisuGUI.h | 2 + src/VISUGUI/VisuGUI_OffsetDlg.cxx | 97 +++++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_OffsetDlg.h | 31 ++++++++++ src/VISU_I/VISU_Prs3d_i.cc | 28 ++++++++- src/VISU_I/VISU_Prs3d_i.hh | 6 ++ 8 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_OffsetDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_OffsetDlg.h diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 2ed8d01e..d34d7d86 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -59,7 +59,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_FileDlg.cxx \ VisuGUI_Plot3DDlg.cxx \ VisuGUI_ClippingDlg.cxx \ - VisuGUI_EditContainerDlg.cxx + VisuGUI_EditContainerDlg.cxx \ + VisuGUI_OffsetDlg.cxx LIB_MOC = \ VisuGUI.h \ @@ -78,7 +79,8 @@ LIB_MOC = \ VisuGUI_Plot3DDlg.h \ VisuGUI_ClippingDlg.h \ VisuGUI_EditContainerDlg.h \ - VisuGUI_Selection.h + VisuGUI_Selection.h \ + VisuGUI_OffsetDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 52ba7bdf..7a592520 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -349,3 +349,8 @@ msgstr "Title" msgid "LBL_LABELS" msgstr "Labels" +msgid "TIT_OFFSETDLG" +msgstr "Translate Presentation" + +msgid "BTN_RESET" +msgstr "Reset" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 8cdbb8d3..6f0eff12 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -67,6 +67,8 @@ #include "VisuGUI_Selection.h" #include "VisuGUI_NonIsometricDlg.h" +#include "VisuGUI_OffsetDlg.h" + #include "SALOMEGUI_ImportOperation.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" #include "utilities.h" @@ -3105,6 +3107,7 @@ bool VisuGUI::CustomPopup (QAD_Desktop* parent, QPopupMenu* thePopup, const QStr } + thePopup->insertItem("Translate...", visuGUI, SLOT(TranslatePrs())); thePopup->insertItem("Clipping planes", visuGUI, SLOT(ClippingPlanes())); if (isVTKViewer) { @@ -4413,3 +4416,34 @@ void VisuGUI::SetActiveDialogBox(QDialog* aDlg) this->myActiveDialogBox = (QDialog*)aDlg ; return ; } + +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]; + aPrsObject->GetOffset(aOffset); + VisuGUI_OffsetDlg aDlg; + aDlg.setOffset(aOffset); + if (aDlg.exec() == QDialog::Accepted) { + aDlg.getOffset(aOffset); + aPrsObject->SetOffset(aOffset); + RecreateActor(aPrsObject); + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { + if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->Repaint(); + } + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); + if ( !CORBA::is_nil( anObject ) ) + vf->highlight(anIO, 1); + } + } + } + } +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 9ac7d83d..381fd4bf 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -282,6 +282,8 @@ public slots: void SelectionInfo(); + void TranslatePrs(); + private : QDialog* myActiveDialogBox; int myState ; diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx new file mode 100644 index 00000000..1da6938e --- /dev/null +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -0,0 +1,97 @@ + +#include "VisuGUI_OffsetDlg.h" + +#include "QAD_SpinBoxDbl.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +#include +#include +#include +#include + + +#define MAXVAL 1e10 + + +VisuGUI_OffsetDlg::VisuGUI_OffsetDlg() +: QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setName( "VisuGUI_OffsetDlg" ); + setCaption( tr( "TIT_OFFSETDLG" ) ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* TopLayout = new QVBoxLayout(this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + QHBox* aOffsetsPane = new QHBox(this); + aOffsetsPane->setSpacing(6); + + new QLabel("dX:", aOffsetsPane); + myDxEdt = new QAD_SpinBoxDbl( aOffsetsPane, "myDxEdt" ); + myDxEdt->setRange(-MAXVAL, MAXVAL); + + new QLabel("dY:", aOffsetsPane); + myDyEdt = new QAD_SpinBoxDbl( aOffsetsPane, "myDyEdt" ); + myDyEdt->setRange(-MAXVAL, MAXVAL); + + new QLabel("dZ:", aOffsetsPane); + myDzEdt = new QAD_SpinBoxDbl( aOffsetsPane, "myDzEdt" ); + myDzEdt->setRange(-MAXVAL, MAXVAL); + + QPushButton* aResetBtn = new QPushButton(tr("BTN_RESET"), aOffsetsPane); + connect(aResetBtn, SIGNAL( clicked() ), this, SLOT( onReset() ) ); + + TopLayout->addWidget(aOffsetsPane); + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + + + +void VisuGUI_OffsetDlg::setOffset(const float* theOffset) +{ + myDxEdt->setValue(theOffset[0]); + myDyEdt->setValue(theOffset[1]); + myDzEdt->setValue(theOffset[2]); +} + + +void VisuGUI_OffsetDlg::getOffset(float* theOffset) const +{ + theOffset[0] = myDxEdt->value(); + theOffset[1] = myDyEdt->value(); + theOffset[2] = myDzEdt->value(); +} + + +void VisuGUI_OffsetDlg::onReset() +{ + myDxEdt->setValue(0); + myDyEdt->setValue(0); + myDzEdt->setValue(0); +} diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.h b/src/VISUGUI/VisuGUI_OffsetDlg.h new file mode 100644 index 00000000..ee056867 --- /dev/null +++ b/src/VISUGUI/VisuGUI_OffsetDlg.h @@ -0,0 +1,31 @@ + +#ifndef DIALOGBOX_OFFSET_H +#define DIALOGBOX_OFFSET_H + +#include "QAD_SpinBoxDbl.h" + +// QT Includes +#include + +class QAD_SpinBoxDbl; + +class VisuGUI_OffsetDlg: public QDialog +{ + Q_OBJECT + public: + VisuGUI_OffsetDlg(); + ~VisuGUI_OffsetDlg() {}; + + void setOffset(const float* theOffset); + void getOffset(float* theOffset) const; + + public slots: + void onReset(); + + private: + QAD_SpinBoxDbl* myDxEdt; + QAD_SpinBoxDbl* myDyEdt; + QAD_SpinBoxDbl* myDzEdt; +}; + +#endif // DIALOGBOX_OFFSET_H diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index c34170a3..97028bcf 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -45,6 +45,7 @@ VISU::Prs3d_i::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) : PrsObject_i(theResult->GetStudyDocument()), myResult(theResult) { + myOffset[0] = myOffset[1] = myOffset[2] = 0; myResult->Register(); mySObject = SALOMEDS::SObject::_duplicate(theSObject); myAddToStudy = true; @@ -55,8 +56,10 @@ VISU::Prs3d_i::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) : void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin) { - if(Prs3d_i* aOrigin = const_cast(theOrigin)) + if(Prs3d_i* aOrigin = const_cast(theOrigin)) { myPipeLine->SameAs(aOrigin->GetPL()); + aOrigin->GetOffset(myOffset); + } } VISU::Prs3d_i::~Prs3d_i() { @@ -78,6 +81,7 @@ void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_Intera } theActor->SetPipeLine(GetPipeLine()); theActor->SetPrs3d(this); + theActor->SetPosition(myOffset); }catch(std::bad_alloc& ex){ throw std::runtime_error("CreateActor >> No enough memory"); throw ex; @@ -91,6 +95,7 @@ void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_Intera void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) { if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<GetMapper()->ShallowCopy(myPipeLine->GetMapper()); + theActor->SetPosition(myOffset); theActor->Modified(); } @@ -162,3 +167,24 @@ VISU::Result_i* VISU::GetResult(SALOMEDS::SObject_ptr theSObject){ return dynamic_cast(VISU::GetServant(aResult.in()).in()); return NULL; } + +void VISU::Prs3d_i::SetOffset(const float* theOffsets) +{ + myOffset[0] = theOffsets[0]; + myOffset[1] = theOffsets[1]; + myOffset[2] = theOffsets[2]; +} + +void VISU::Prs3d_i::SetOffset(float theDx, float theDy, float theDz) +{ + myOffset[0] = theDx; + myOffset[1] = theDy; + myOffset[2] = theDz; +} + +void VISU::Prs3d_i::GetOffset(float* theOffsets) +{ + theOffsets[0] = myOffset[0]; + theOffsets[1] = myOffset[1]; + theOffsets[2] = myOffset[2]; +} diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 32c53c8e..136a6e4e 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -60,6 +60,7 @@ namespace VISU{ protected: bool myAddToStudy; + float myOffset[3]; Result_i *myResult; VISU_PipeLine *myPipeLine; SALOMEDS::SObject_var mySObject; @@ -76,6 +77,11 @@ namespace VISU{ void GetBounds(float aBounds[6]); + void SetOffset(const float* theOffsets); + void SetOffset(float theDx, float theDy, float theDz); + + void GetOffset(float* theOffsets); + virtual const char* GetComment() const = 0; virtual QString GenerateName() = 0; -- 2.39.2