From 1cffeefb0eb5585be042525ae62a27ed1e5fca1d Mon Sep 17 00:00:00 2001 From: rnv Date: Tue, 20 May 2008 10:27:45 +0000 Subject: [PATCH] Improvement NPAL18030 EDF 610 VISU (to be able to translate a gauss point presentation). --- src/OBJECT/VISU_GaussPtsAct.cxx | 108 +++++++++++++++++++++++++++--- src/OBJECT/VISU_GaussPtsAct.h | 25 ++++++- src/VISUGUI/VisuGUI.cxx | 26 +------ src/VISUGUI/VisuGUI_OffsetDlg.cxx | 59 ++++++++++++++-- src/VISUGUI/VisuGUI_OffsetDlg.h | 7 ++ 5 files changed, 186 insertions(+), 39 deletions(-) diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index c9514f44..b75073e3 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #include #include @@ -154,7 +156,10 @@ VISU_GaussPtsAct myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents); + vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); + myDeviceActor->SetProperty(GetProperty()); + myDeviceActor->SetUserMatrix(aMatrix); myDeviceActor->SetVisibility(true); myDeviceActor->SetPickable(false); @@ -174,6 +179,7 @@ VISU_GaussPtsAct myScalarBarCtrl->Delete(); myMapper->Delete(); + aMatrix->Delete(); } VISU_GaussPtsAct @@ -330,6 +336,7 @@ int VISU_GaussPtsAct ::RenderOpaqueGeometry(vtkViewport *viewport) { + GetMatrix(myDeviceActor->GetUserMatrix()); return 1; } @@ -337,6 +344,7 @@ int VISU_GaussPtsAct ::RenderTranslucentGeometry(vtkViewport *viewport) { + GetMatrix(myDeviceActor->GetUserMatrix()); return 1; } @@ -733,7 +741,23 @@ VISU_GaussPtsAct if(myIsPreselected){ anIsChanged = (myLastPreHighlightObjID != anObjId); if(anIsChanged){ - vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + //Take into account translation + vtkFloatingPointType aLocalNodeCoord[3]; + this->Transform->Push(); + this->Transform->PostMultiply(); + this->Transform->Identity(); + + this->Transform->Translate(this->Position[0], + this->Position[1], + this->Position[2]); + double aPosition[3]; + this->Transform->GetPosition(aPosition); + + aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; + aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1]; + aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2]; + vtkDataSet* aDataSet = GetInput(); vtkPointData* aPointData = aDataSet->GetPointData(); if(vtkDataArray *aScalarArray = aPointData->GetScalars()){ @@ -752,10 +776,12 @@ VISU_GaussPtsAct GetRadius(anObjId,aVtkId,aScalarArray), GetMagnification(anObjId), GetClamp(anObjId), - aNodeCoord, + aLocalNodeCoord, aColor); } + } + this->Transform->Pop(); myLastPreHighlightObjID = anObjId; } myCursorPyramid->SetVisibility(true); @@ -903,6 +929,13 @@ VISU_GaussPtsAct return false; } + + +void VISU_GaussPtsAct::SetPosition(double _arg[3]){ + Superclass::SetPosition(_arg); + Highlight(isHighlighted()); +} + //================================================================== // function : Highlight // purpose : @@ -971,11 +1004,28 @@ VISU_GaussPtsAct int anObjId = aMapIndex(1); vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + if ( !aNodeCoord ) + return; + //Take into account translation + vtkFloatingPointType aLocalNodeCoord[3]; + this->Transform->Push(); + this->Transform->PostMultiply(); + this->Transform->Identity(); + this->Transform->Translate(this->Position[0], + this->Position[1], + this->Position[2]); + double aPosition[3]; + this->Transform->GetPosition(aPosition); + aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; + aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1]; + aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2]; + this->Transform->Pop(); + vtkFloatingPointType aFocalPnt[3]; aCamera->GetFocalPoint(aFocalPnt); - if ( !aNodeCoord || CheckIsSameVector( aNodeCoord, aFocalPnt, 3 ) ) + if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) ) return; // FlyTo @@ -985,11 +1035,11 @@ VISU_GaussPtsAct anInteractor->SetDolly(0.0); anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber()); - anInteractor->FlyTo(aRenderer, aNodeCoord); + anInteractor->FlyTo(aRenderer, aLocalNodeCoord); aRenderer->ResetCameraClippingRange(); anInteractor->SetDolly(aDollyWas); anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); - anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord); + anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aLocalNodeCoord); // std::ostringstream aStr; // int anObjId = aMapIndex(1); @@ -997,8 +1047,7 @@ VISU_GaussPtsAct // vtkIdType aVtkId = GetNodeVTKID(anObjId); if(aVtkId >= 0){ - vtkFloatingPointType *aNodeCoord = GetNodeCoord(anObjId); - vtkFloatingPointType aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.}; + vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.}; // vtkDataSet* aDataSet = GetInput(); vtkPointData* aDataSetAttributes = aDataSet->GetPointData(); @@ -1017,7 +1066,7 @@ VISU_GaussPtsAct GetRadius(anObjId,aVtkId,aScalarArray), GetMagnification(anObjId), GetClamp(anObjId), - aNodeCoord, + aLocalNodeCoord, myHighlightActor->GetProperty()->GetColor()); myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight); // @@ -1218,13 +1267,18 @@ VISU_GaussPtsAct1 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents); + vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); + myInsideDeviceActor->SetVisibility(false); myInsideDeviceActor->SetPickable(false); + myInsideDeviceActor->SetUserMatrix(aMatrix); myInsideDeviceActor->Delete(); myOutsideDeviceActor->SetVisibility(false); myOutsideDeviceActor->SetPickable(false); + myOutsideDeviceActor->SetUserMatrix(aMatrix); myOutsideDeviceActor->Delete(); + aMatrix->Delete(); } VISU_GaussPtsAct1 @@ -1281,6 +1335,28 @@ VISU_GaussPtsAct1 } +int +VISU_GaussPtsAct1 +::RenderOpaqueGeometry(vtkViewport *viewport) +{ + + Superclass::RenderOpaqueGeometry(viewport); + GetMatrix(myInsideDeviceActor->GetUserMatrix()); + GetMatrix(myOutsideDeviceActor->GetUserMatrix()); + return 1; +} + +int +VISU_GaussPtsAct1 +::RenderTranslucentGeometry(vtkViewport *viewport) +{ + Superclass::RenderTranslucentGeometry(viewport); + GetMatrix(myInsideDeviceActor->GetUserMatrix()); + GetMatrix(myOutsideDeviceActor->GetUserMatrix()); + + return 1; +} + //---------------------------------------------------------------------------- void VISU_GaussPtsAct1 @@ -1369,7 +1445,6 @@ VISU_GaussPtsAct1 return aPipeLine->GetMagnification(); } - //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPtsAct1 @@ -1386,11 +1461,20 @@ VISU_GaussPtsAct1 //---------------------------------------------------------------- + +void +VISU_GaussPtsAct1::SetPosition(double _arg[3]){ + if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<selectedObjects(aListIO); - - SalomeApp_Study* aStudy = GetAppStudy(this); - SALOME_ListIteratorOfListIO anIter(aListIO); - for (; anIter.More(); anIter.Next()) { - Handle(SALOME_InteractiveObject) anIO = anIter.Value(); - if (anIO->hasEntry()) { - QString anEntry(anIO->getEntry()); - VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry); - if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)) - aDlg->addPresentation(aPrsObject); - else if (VISU::PointMap3d_i* aPrs = dynamic_cast(anObjectInfo.myBase)) { - aDlg->addPointMapPresentation(aPrs); - } - } - } - if (aDlg->getPrsCount() > 0) - aDlg->show(); - else - delete aDlg; + aDlg->exec(); } void @@ -2690,7 +2668,7 @@ VisuGUI mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true ); mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true ); - aRule = "selcount>0 and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}"; + aRule = "selcount>0 and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}"; mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true ); aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}"; diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index 4ae427de..d6af7e49 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -27,7 +27,9 @@ #include "VISU_Actor.h" #include "LightApp_Application.h" +#include "SALOME_ListIteratorOfListIO.hxx" #include "SalomeApp_Application.h" +#include "LightApp_SelectionMgr.h" #include "SVTK_ViewWindow.h" #include "SVTK_ViewModel.h" #include "SUIT_Desktop.h" @@ -55,7 +57,8 @@ VisuGUI_OffsetDlg::VisuGUI_OffsetDlg (VisuGUI* theModule) : QDialog(VISU::GetDesktop(theModule), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), -myModule(theModule) + myModule(theModule), + mySelectionMgr(VISU::GetSelectionMgr(theModule)) { myPrsList.setAutoDelete(false); myPointMapList.setAutoDelete(false); @@ -132,6 +135,49 @@ myModule(theModule) connect(buttonApply, SIGNAL(clicked()), this, SLOT(onApply())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); + + onSelectionChanged(); + show(); +} + + +void VisuGUI_OffsetDlg::show(){ + if(getPrsCount() > 0 ) + QDialog::show(); +} + +void VisuGUI_OffsetDlg::onSelectionChanged(){ + if(!mySelectionMgr) + return; + + //Clear old selection + clearPresentations(); + + SALOME_ListIO aListIO; + mySelectionMgr->selectedObjects(aListIO); + + SalomeApp_Study* aStudy = VISU::GetAppStudy(myModule); + SALOME_ListIteratorOfListIO anIter(aListIO); + for (; anIter.More(); anIter.Next()) { + Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + if (anIO->hasEntry()) { + QString anEntry(anIO->getEntry()); + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry); + if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)) + addPresentation(aPrsObject); + else if (VISU::PointMap3d_i* aPrs = dynamic_cast(anObjectInfo.myBase)) { + addPointMapPresentation(aPrs); + } + } + } +} + +void VisuGUI_OffsetDlg::clearPresentations(){ + myPrsList.clear(); + myPointMapList.clear(); + myOldOffsets.clear(); + myOldPointMapOffsets.clear(); } void VisuGUI_OffsetDlg::addPresentation (VISU::Prs3d_i* thePrs) @@ -199,8 +245,11 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp if (myPrsList.count() == 0) return; - if (isToSave()) + if (isToSave()) { thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]); + thePrs->UpdateActors(); + return; + } ViewManagerList aViewManagerList; SalomeApp_Application* anApp = myModule->getApp(); @@ -212,11 +261,10 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) { - vw->onAdjustTrihedron(); if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) { - anActor->SetPosition(theOffset); - vw->highlight(thePrs->GetIO(), 1); + anActor->SetPosition(theOffset); + vw->onAdjustTrihedron(); vw->getRenderer()->ResetCameraClippingRange(); vw->Repaint(); } @@ -286,6 +334,7 @@ void VisuGUI_OffsetDlg::onApply() { vtkFloatingPointType anOffset[3]; getOffset(anOffset); + for (int i = 0; i < myPrsList.count(); i++) { updateOffset(myPrsList.at(i), anOffset); } diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.h b/src/VISUGUI/VisuGUI_OffsetDlg.h index 901365ca..1c02b80b 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.h +++ b/src/VISUGUI/VisuGUI_OffsetDlg.h @@ -32,6 +32,7 @@ class QCheckBox; class QtxDblSpinBox; class VisuGUI; +class LightApp_SelectionMgr; struct OffsetStruct { @@ -59,9 +60,12 @@ class VisuGUI_OffsetDlg: public QDialog VisuGUI_OffsetDlg (VisuGUI* theModule); ~VisuGUI_OffsetDlg() {}; + virtual void show (); + void addPresentation (VISU::Prs3d_i* thePrs); void addPointMapPresentation (VISU::PointMap3d_i* thePrs); int getPrsCount() const { return myPrsList.count() + myPointMapList.count(); } + void clearPresentations(); void setOffset (const vtkFloatingPointType* theOffset); void getOffset (vtkFloatingPointType* theOffset) const; @@ -78,12 +82,15 @@ class VisuGUI_OffsetDlg: public QDialog virtual void reject(); void onApply(); void onHelp(); + void onSelectionChanged(); + private: void updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointType* theOffset); void updatePointMapOffset (VISU::PointMap3d_i* thePrs, vtkFloatingPointType* theOffset); VisuGUI * myModule; + LightApp_SelectionMgr* mySelectionMgr; QtxDblSpinBox * myDxEdt; QtxDblSpinBox * myDyEdt; -- 2.39.2