From: ouv Date: Thu, 15 Dec 2005 09:32:23 +0000 (+0000) Subject: Fixed bug GVIEW10826 : magnification do not work with segmentation X-Git-Tag: TG-D5-38-2003_D2005-20-12~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9a58b870240c2f77065427a62ac57f50fc8b073c;p=modules%2Fvisu.git Fixed bug GVIEW10826 : magnification do not work with segmentation --- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 629f8fb6..d88d64cc 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -31,6 +31,7 @@ #include "VISU_GaussPtsSettings.h" #include "VISU_GaussPtsDeviceActor.h" #include "VISU_WidgetCtrl.hxx" +#include "VISU_SphereWidget.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_ScalarBarCtrl.hxx" #include "VISU_ScalarBarActor.hxx" @@ -333,11 +334,27 @@ VISU_GaussPtsAct bool VISU_GaussPtsAct -::ChangeMagnification() +::GetChangeMagnification() { return myChangeMagnification; } +void +VISU_GaussPtsAct +::ChangeMagnification( bool up ) +{ + myEventCallbackCommand->SetAbortFlag(1); + + float aMagnification = myInsideCursorSettings->GetMagnification(); + float anIncrement = myInsideCursorSettings->GetIncrement(); + float coefficient = up ? anIncrement : 1 / anIncrement; + + myInsideCursorSettings->SetMagnification( aMagnification * coefficient ); + myInsideCursorSettings->InvokeEvent(VISU::UpdateFromSettingsEvent,NULL); + + Update(); +} + //---------------------------------------------------------------------------- namespace { @@ -469,8 +486,28 @@ VISU_GaussPtsAct switch(myInteractor->GetKeyCode()) { case 'M' : case 'm' : + { + if( myWidgetCtrl->GetEnabled() ) + { + this->ChangeMagnification( myInteractor->GetShiftKey() ); + return; + } + myChangeMagnification = myInteractor->GetShiftKey(); break; + } + case 'D' : + case 'd' : + { + if( myWidgetCtrl->GetEnabled() && myWidgetCtrl->IsSphereActive() ) + { + VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget(); + aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() ); + myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL); + myWidgetCtrl->GetInteractor()->Render(); + } + return; + } default: return; } @@ -1170,6 +1207,8 @@ VISU_GaussPtsAct1 aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() ); aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() ); aPipeline->SetSize( myOutsideCursorSettings->GetSize() ); + aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() ); + aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() ); if( myOutsideCursorSettings->GetUniform() ) { diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index ae8264e9..d80787c8 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -175,7 +175,12 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor //! Return the information about pipeline magnification changing. /*! True indicates that magnification is increased, false - decreased. */ bool - ChangeMagnification(); + GetChangeMagnification(); + + //! Change the pipeline magnification. + virtual + void + ChangeMagnification( bool ); //---------------------------------------------------------------------------- //! Internal highlight. diff --git a/src/OBJECT/VISU_GaussPtsSettings.cxx b/src/OBJECT/VISU_GaussPtsSettings.cxx index 0266f2ad..296f39a3 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.cxx +++ b/src/OBJECT/VISU_GaussPtsSettings.cxx @@ -32,12 +32,13 @@ #include //---------------------------------------------------------------- +vtkStandardNewMacro( VISU_GaussPtsSettings ); vtkStandardNewMacro( VISU_InsideCursorSettings ); vtkStandardNewMacro( VISU_OutsideCursorSettings ); vtkStandardNewMacro( VISU_PickingSettings ); //---------------------------------------------------------------- -VISU_InsideCursorSettings::VISU_InsideCursorSettings() +VISU_GaussPtsSettings::VISU_GaussPtsSettings() { this->Initial = true; @@ -46,27 +47,31 @@ VISU_InsideCursorSettings::VISU_InsideCursorSettings() this->Texture = NULL; this->AlphaThreshold = -1; this->Resolution = -1; - this->MinSize = -1; - this->MaxSize = -1; this->Magnification = -1; this->Increment = -1; } -VISU_InsideCursorSettings::~VISU_InsideCursorSettings() +VISU_GaussPtsSettings::~VISU_GaussPtsSettings() { this->SetTexture( NULL ); } //---------------------------------------------------------------- -VISU_OutsideCursorSettings::VISU_OutsideCursorSettings() +VISU_InsideCursorSettings::VISU_InsideCursorSettings() : + VISU_GaussPtsSettings() { - this->Initial = true; + this->MinSize = -1; + this->MaxSize = -1; +} - this->PrimitiveType = -1; - this->Clamp = -1; - this->Texture = NULL; - this->AlphaThreshold = -1; - this->Resolution = -1; +VISU_InsideCursorSettings::~VISU_InsideCursorSettings() +{ +} + +//---------------------------------------------------------------- +VISU_OutsideCursorSettings::VISU_OutsideCursorSettings() : + VISU_GaussPtsSettings() +{ this->Size = -1; this->Uniform = false; this->Color[0] = -1; @@ -76,7 +81,6 @@ VISU_OutsideCursorSettings::VISU_OutsideCursorSettings() VISU_OutsideCursorSettings::~VISU_OutsideCursorSettings() { - this->SetTexture( NULL ); } //---------------------------------------------------------------- diff --git a/src/OBJECT/VISU_GaussPtsSettings.h b/src/OBJECT/VISU_GaussPtsSettings.h index 1946b58b..e9c7cd2e 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.h +++ b/src/OBJECT/VISU_GaussPtsSettings.h @@ -38,23 +38,24 @@ class vtkImageData; //============================================================================ namespace VISU { - const vtkIdType UpdateInsideSettingsEvent = vtkCommand::UserEvent + 100; - const vtkIdType UpdateOutsideSettingsEvent = vtkCommand::UserEvent + 200; - const vtkIdType UpdatePickingSettingsEvent = vtkCommand::UserEvent + 300; + const vtkIdType UpdateFromSettingsEvent = vtkCommand::UserEvent + 100; + const vtkIdType UpdateInsideSettingsEvent = vtkCommand::UserEvent + 101; + const vtkIdType UpdateOutsideSettingsEvent = vtkCommand::UserEvent + 102; + const vtkIdType UpdatePickingSettingsEvent = vtkCommand::UserEvent + 103; } -//============================================================================ -class VISU_InsideCursorSettings : public vtkObject +//! Base class of Gauss Points settings. +class VISU_GaussPtsSettings : public vtkObject { public: - vtkTypeMacro( VISU_InsideCursorSettings, vtkObject ); + vtkTypeMacro( VISU_GaussPtsSettings, vtkObject ); - VISU_InsideCursorSettings(); - virtual ~VISU_InsideCursorSettings(); + VISU_GaussPtsSettings(); + virtual ~VISU_GaussPtsSettings(); static - VISU_InsideCursorSettings* + VISU_GaussPtsSettings* New(); vtkSetMacro( Initial, bool ); @@ -75,20 +76,13 @@ class VISU_InsideCursorSettings : public vtkObject vtkSetMacro( Resolution, int ); vtkGetMacro( Resolution, int ); - vtkSetMacro( MinSize, float ); - vtkGetMacro( MinSize, float ); - - vtkSetMacro( MaxSize, float ); - vtkGetMacro( MaxSize, float ); - vtkSetMacro( Magnification, float ); vtkGetMacro( Magnification, float ); vtkSetMacro( Increment, float ); vtkGetMacro( Increment, float ); - -private: + protected: bool Initial; int PrimitiveType; @@ -96,49 +90,59 @@ private: vtkImageData* Texture; float AlphaThreshold; int Resolution; - float MinSize; - float MaxSize; float Magnification; float Increment; }; -//============================================================================ -//! Class of Outside Cursor Gauss Points settings. +//! Class of Inside Cursor Gauss Points settings. /*! * Contains information about the point sprite parameters: * Clamp, Texture, Alpha threshold, Const size and Color. * Used by Gauss Points Actor. */ -class VISU_OutsideCursorSettings : public vtkObject +class VISU_InsideCursorSettings : public VISU_GaussPtsSettings { public: - vtkTypeMacro( VISU_OutsideCursorSettings, vtkObject ); + vtkTypeMacro( VISU_InsideCursorSettings, vtkObject ); - VISU_OutsideCursorSettings(); - virtual ~VISU_OutsideCursorSettings(); + VISU_InsideCursorSettings(); + virtual ~VISU_InsideCursorSettings(); static - VISU_OutsideCursorSettings* + VISU_InsideCursorSettings* New(); - vtkSetMacro( Initial, bool ); - vtkGetMacro( Initial, bool ); + vtkSetMacro( MinSize, float ); + vtkGetMacro( MinSize, float ); - vtkSetMacro( PrimitiveType, int ); - vtkGetMacro( PrimitiveType, int ); + vtkSetMacro( MaxSize, float ); + vtkGetMacro( MaxSize, float ); - vtkSetMacro( Clamp, float ); - vtkGetMacro( Clamp, float ); + protected: + float MinSize; + float MaxSize; +}; - vtkSetMacro( Texture, vtkImageData* ); - vtkGetMacro( Texture, vtkImageData* ); - vtkSetMacro( AlphaThreshold, float ); - vtkGetMacro( AlphaThreshold, float ); +//============================================================================ +//! Class of Outside Cursor Gauss Points settings. +/*! + * Contains information about the point sprite parameters: + * Clamp, Texture, Alpha threshold, Const size and Color. + * Used by Gauss Points Actor. + */ +class VISU_OutsideCursorSettings : public VISU_GaussPtsSettings +{ + public: + vtkTypeMacro( VISU_OutsideCursorSettings, vtkObject ); - vtkSetMacro( Resolution, int ); - vtkGetMacro( Resolution, int ); + VISU_OutsideCursorSettings(); + virtual ~VISU_OutsideCursorSettings(); + + static + VISU_OutsideCursorSettings* + New(); vtkSetMacro( Size, float ); vtkGetMacro( Size, float ); @@ -149,14 +153,7 @@ class VISU_OutsideCursorSettings : public vtkObject vtkSetVector3Macro( Color, float ); vtkGetVector3Macro( Color, float ); -private: - bool Initial; - - int PrimitiveType; - float Clamp; - vtkImageData* Texture; - float AlphaThreshold; - int Resolution; + protected: float Size; bool Uniform; float Color[3]; diff --git a/src/PIPELINE/VISU_SphereWidget.cxx b/src/PIPELINE/VISU_SphereWidget.cxx index bd24d602..e28e985f 100755 --- a/src/PIPELINE/VISU_SphereWidget.cxx +++ b/src/PIPELINE/VISU_SphereWidget.cxx @@ -67,6 +67,7 @@ VISU_SphereWidget::VISU_SphereWidget() myImplicitSum=vtkImplicitSum::New(); myImplicitSum->AddFunction(mySphere,-1.0); + myRatio = 2.0; } //==================================================================== // function: ~ @@ -592,6 +593,15 @@ void VISU_SphereWidget::PlaceWidget(float bds[6]) myRmin = EPS*InitialLength; } + +//==================================================================== +// function:ChangeRadius +// purpose: +//==================================================================== +void VISU_SphereWidget::ChangeRadius(bool up) +{ + SetRadius( GetRadius() * ( up ? myRatio : 1 / myRatio ) ); +} //==================================================================== // function:GetPolyData // purpose: diff --git a/src/PIPELINE/VISU_SphereWidget.hxx b/src/PIPELINE/VISU_SphereWidget.hxx index e83b0c71..040a4180 100755 --- a/src/PIPELINE/VISU_SphereWidget.hxx +++ b/src/PIPELINE/VISU_SphereWidget.hxx @@ -58,6 +58,12 @@ public: float* GetCenter(); void GetCenter(float xyz[3]); + // Description: + // Set the ratio of the radius changing. + void SetRatio(float r) { myRatio = r; } + float GetRatio() { return myRatio; } + + void ChangeRadius(bool up); void GetPolyData(vtkPolyData *pd); @@ -119,6 +125,7 @@ protected: float myRmin; vtkSphere *mySphere; vtkImplicitSum* myImplicitSum; + float myRatio; private: VISU_SphereWidget(const VISU_SphereWidget&); //Not implemented void operator=(const VISU_SphereWidget&); //Not implemented diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index 4d8e95a2..59fdedf4 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -655,6 +655,15 @@ msgstr "Inside Cursor Gauss Points Presentation" msgid "VVTK_SegmentationCursorDlg::OUTSIDE_GAUSS_POINTS" msgstr "Outside Cursor Gauss Points Presentation" +msgid "VVTK_SegmentationCursorDlg::MAGNIFICATION_TITLE" +msgstr "Magnification" + +msgid "VVTK_SegmentationCursorDlg::MAGNIFICATION" +msgstr "Magnification (%) : " + +msgid "VVTK_SegmentationCursorDlg::INCREMENT" +msgstr "+/- Ratio : " + msgid "VVTK_PickingDlg::PICKING_DLG_TITLE" msgstr "Picking"