From eecea7489cdf656e87f8c7c7a54a21c6e83491ad Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 27 May 2005 09:02:19 +0000 Subject: [PATCH] Bug 8825: Multiple translation --- src/VISUGUI/VisuGUI.cxx | 59 ++++++++++++++----------------- src/VISUGUI/VisuGUI_OffsetDlg.cxx | 51 ++++++++++++++++---------- src/VISUGUI/VisuGUI_OffsetDlg.h | 18 +++++++--- 3 files changed, 73 insertions(+), 55 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 9babe860..8772c164 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2960,6 +2960,8 @@ bool VisuGUI::CustomPopup (QAD_Desktop* parent, QPopupMenu* thePopup, const QStr } else if ( selMode == homoPresentations ) { if (isVTKViewer) { + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) + thePopup->insertItem("Translate...", visuGUI, SLOT(TranslatePrs())); thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) ); thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) ); thePopup->insertSeparator(); @@ -4544,44 +4546,37 @@ void VisuGUI::TranslatePrs() { if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs"); - CORBA::Object_var anObject = GetSelectedObj(); + VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg(); + + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It ( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + if ( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); + if(VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in())){ + aDlg->addPresentation(aPrsObject); + } + } + } + } + } + if (aDlg->getPrsCount() > 0) + aDlg->show(); + else + delete aDlg; + /* 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())){ - VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg(aPrsObject); aDlg->show(); } - } - /* float aOffset[3]; - aPrsObject->GetOffset(aOffset); - VisuGUI_OffsetDlg aDlg; - aDlg.setOffset(aOffset); - if (aDlg.exec() == QDialog::Accepted) { - aDlg.getOffset(aOffset); - if (aDlg.isToSave()) - aPrsObject->SetOffset(aOffset); - // RecreateActor(aPrsObject); - for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++){ - if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ - QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); - if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) - if(VISU_Actor* anActor = GetActor(aPrsObject,aViewFrame)) - anActor->SetPosition(aOffset); - } - } - 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_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index e09c21c8..2ffaf7d0 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -25,11 +25,12 @@ extern CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO=NU VISU::Storable::TRestoringMap* pMap=NULL); -VisuGUI_OffsetDlg::VisuGUI_OffsetDlg(VISU::Prs3d_i* thePrs) +VisuGUI_OffsetDlg::VisuGUI_OffsetDlg() : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) { - myPrs = thePrs; + myPrsList.setAutoDelete(false); + setName( "VisuGUI_OffsetDlg" ); setCaption( tr( "TIT_OFFSETDLG" ) ); setSizeGripEnabled( TRUE ); @@ -95,14 +96,23 @@ VisuGUI_OffsetDlg::VisuGUI_OffsetDlg(VISU::Prs3d_i* thePrs) 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); + } +void VisuGUI_OffsetDlg::addPresentation(VISU::Prs3d_i* thePrs) +{ + myPrsList.append(thePrs); + OffcetStruct aOffs; + thePrs->GetOffset(aOffs.myOffcet); + myOldOffsets.append(aOffs); + if (myPrsList.count() == 1) + setOffset(aOffs.myOffcet); + else if (myPrsList.count() == 2) { + float aOffset[3]; + aOffset[0] = aOffset[1] = aOffset[2] = 0; + setOffset(aOffset); + } +} void VisuGUI_OffsetDlg::setOffset(const float* theOffset) @@ -138,23 +148,21 @@ bool VisuGUI_OffsetDlg::isToSave() const } -void VisuGUI_OffsetDlg::updateOffset() +void VisuGUI_OffsetDlg::updateOffset(VISU::Prs3d_i* thePrs, float* theOffset) { - float aOffset[3]; - getOffset(aOffset); - if (isToSave()) - myPrs->SetOffset(aOffset); + if (myPrsList.count() == 0) return; + if (isToSave()) thePrs->SetOffset(theOffset); 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)) { aViewFrame->onAdjustTrihedron(); - if(VISU_Actor* anActor = VisuGUI::GetActor(myPrs,aViewFrame)) { - anActor->SetPosition(aOffset); + if(VISU_Actor* anActor = VisuGUI::GetActor(thePrs,aViewFrame)) { + anActor->SetPosition(theOffset); aViewFrame->getRenderer()->ResetCameraClippingRange(); aViewFrame->Repaint(); - + Handle(SALOME_InteractiveObject) anIO; CORBA::Object_var anObject = GetSelectedObj(&anIO); if ( !CORBA::is_nil( anObject ) ) @@ -168,13 +176,18 @@ void VisuGUI_OffsetDlg::updateOffset() void VisuGUI_OffsetDlg::accept() { - updateOffset(); + float aOffset[3]; + getOffset(aOffset); + for (int i = 0; i < myPrsList.count(); i++) { + updateOffset(myPrsList.at(i), aOffset); + } QDialog::accept(); } void VisuGUI_OffsetDlg::reject() { - setOffset(myOldOffset); - updateOffset(); + for (int i = 0; i < myPrsList.count(); i++) { + updateOffset(myPrsList.at(i), myOldOffsets[i].myOffcet); + } QDialog::reject(); } diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.h b/src/VISUGUI/VisuGUI_OffsetDlg.h index e4b94fc5..8ab70ca9 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.h +++ b/src/VISUGUI/VisuGUI_OffsetDlg.h @@ -7,16 +7,24 @@ // QT Includes #include +#include class QAD_SpinBoxDbl; class QCheckBox; +struct OffcetStruct { + float myOffcet[3]; +}; + class VisuGUI_OffsetDlg: public QDialog { Q_OBJECT public: - VisuGUI_OffsetDlg(VISU::Prs3d_i* thePrs); + VisuGUI_OffsetDlg(); ~VisuGUI_OffsetDlg() {}; + + void addPresentation(VISU::Prs3d_i* thePrs); + int getPrsCount() const { return myPrsList.count(); } void setOffset(const float* theOffset); void getOffset(float* theOffset) const; @@ -28,10 +36,11 @@ class VisuGUI_OffsetDlg: public QDialog protected slots: virtual void accept(); virtual void reject(); - void updateOffset(); + void updateOffset(VISU::Prs3d_i* thePrs, float* theOffset); private: - VISU::Prs3d_i* myPrs; + // VISU::Prs3d_i* myPrs; + QPtrList myPrsList; QAD_SpinBoxDbl* myDxEdt; QAD_SpinBoxDbl* myDyEdt; @@ -39,7 +48,8 @@ class VisuGUI_OffsetDlg: public QDialog QCheckBox* mySaveChk; - float myOldOffset[3]; + QValueList myOldOffsets; + //float myOldOffset[3]; }; #endif // DIALOGBOX_OFFSET_H -- 2.39.2