+ SUIT_ViewWindow* aVW = GetViewWindow();
+ if (aVW) {
+ double aScale[3] = {1.0, 1.0, 1.0};
+ ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
+ }
+ }
+
+ //================================================
+ // Certain presentation view parameters management
+ //================================================
+ class TPrsManageEvent: public SALOME_Event
+ {
+ protected:
+ View3D_i* myView3D;
+ ScalarMap_ptr myPrs;
+ string myError;
+
+ TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ myView3D(theView3D),
+ myPrs(ScalarMap::_duplicate(thePrs)),
+ myError("Unknown error occured")
+ {}
+ VISU_Actor* GetMyActor()
+ {
+ SUIT_ViewWindow* aVW = myView3D->GetViewWindow();
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aVW);
+ if (!aVW) {
+ myError = "Corrupted view window";
+ } else {
+ ScalarMap_i* aPrs = dynamic_cast<ScalarMap_i*>(VISU::GetServant(myPrs).in());
+ if (!aPrs) {
+ myError = "Corrupted presentation";
+ } else {
+ VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
+ if (!anActor) {
+ myError = "No actor found. Display the presentation at first.";
+ } else {
+ myError = "";
+ return anActor;
+ }
+ }
+ }
+ return NULL;
+ }
+ };
+
+ // Get
+ class TGetPrsTypeEvent: public TPrsManageEvent {
+ public:
+ typedef VISU::PresentationType TResult;
+ TResult myResult;
+ TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor())
+ myResult = (VISU::PresentationType)anActor->GetRepresentation();
+ }
+ };
+
+ class TGetShrinkedEvent: public TPrsManageEvent {
+ public:
+ typedef bool TResult;
+ TResult myResult;
+ TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(false) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if (anActor->IsShrunkable())
+ myResult = anActor->IsShrunk();
+ else
+ myResult = false;
+ }
+ }
+ };
+
+ class TGetShadedEvent: public TPrsManageEvent {
+ public:
+ typedef bool TResult;
+ TResult myResult;
+ TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(false) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor())
+ if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor))
+ myResult = aScalarMapActor->IsShading();
+ }
+ };
+
+ class TGetOpacityEvent: public TPrsManageEvent {
+ public:
+ typedef double TResult;
+ TResult myResult;
+ TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ vtkFloatingPointType oldvalue = anActor->GetOpacity();
+ myResult = (double)oldvalue;
+ }
+ }
+ };
+
+ class TGetLineWidthEvent: public TPrsManageEvent {
+ public:
+ typedef double TResult;
+ TResult myResult;
+ TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ vtkFloatingPointType oldvalue = anActor->GetLineWidth();
+ myResult = (double)oldvalue;
+ }
+ }
+ };
+
+ // Set
+ class TSetPrsTypeEvent: public TPrsManageEvent {
+ private:
+ PresentationType myPrsType;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType):
+ TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute() {
+ VISU::VISUType aType = myPrs->GetType();
+ switch (myPrsType) {
+ case VISU::INSIDEFRAME:
+ {
+ if (aType != VISU::TSCALARMAP &&
+ aType != VISU::TDEFORMEDSHAPE &&
+ aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
+ aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
+ myResult = "Insideframe representation is not available for this type of presentations.";
+ return;
+ }
+ }
+ break;
+ case VISU::SURFACEFRAME:
+ {
+ if (aType != VISU::TSCALARMAP &&
+ aType != VISU::TDEFORMEDSHAPE &&
+ aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
+ aType != VISU::TDEFORMEDSHAPEANDSCALARMAP &&
+ aType != VISU::TCUTPLANES &&
+ aType != VISU::TISOSURFACES &&
+ aType != VISU::TPLOT3D) {
+ myResult = "Surfaceframe representation is not available for this type of presentations.";
+ return;
+ }
+ }
+ break;
+ case VISU::SHRINK:
+ myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
+ return;
+ default:
+ break;
+ }
+ if (VISU_Actor* anActor = GetMyActor()) {
+ anActor->SetRepresentation((int)myPrsType);
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = myError;
+ }
+ }
+ };
+
+ class TSetShrinkedEvent: public TPrsManageEvent {
+ private:
+ bool myIsOn;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
+ TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute() {
+ VISU::VISUType aType = myPrs->GetType();
+ if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
+ myResult = "Shrinked representation is not available for this type of presentations.";
+ } else {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if (anActor->IsShrunkable()) {
+ if (myIsOn) anActor->SetShrink();
+ else anActor->UnShrink();
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = "This presentation is not shrunkable.";
+ }
+ } else {
+ myResult = myError;
+ }
+ }
+ }
+ };
+
+ class TSetShadedEvent: public TPrsManageEvent {
+ private:
+ bool myIsOn;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
+ TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if (VISU_ScalarMapAct* aScalarMapActor =
+ dynamic_cast<VISU_ScalarMapAct*>(anActor)) {
+ aScalarMapActor->SetShading(myIsOn);
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = "Corrupted actor";
+ }
+ } else {
+ myResult = myError;
+ }
+ }
+ };
+
+ class TSetOpacityEvent: public TPrsManageEvent {
+ private:
+ double myOpacity;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity):
+ TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute() {
+ VISU::VISUType aType = myPrs->GetType();
+ if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
+ myResult = "Opacity is meaningless for this type of presentations.";
+ return;
+ }
+ if (VISU_Actor* anActor = GetMyActor()) {
+ anActor->SetOpacity((vtkFloatingPointType)myOpacity);
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = myError;
+ }
+ }
+ };
+
+ class TSetLineWidthEvent: public TPrsManageEvent {
+ private:
+ double myLineWidth;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth):
+ TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute() {
+ if (myPrs->GetType() == VISU::TVECTORS) {
+ myResult = "Line Width is meaningless for Vectors presentation.";
+ return;
+ }
+ if (VISU_Actor* anActor = GetMyActor()) {
+ anActor->SetLineWidth((vtkFloatingPointType)myLineWidth);
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = myError;
+ }
+ }
+ };
+
+ class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
+ private:
+ Quadratic2DPresentationType myPrsType;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D,
+ ScalarMap_ptr thePrs,
+ Quadratic2DPresentationType theType):
+ TPrsManageEvent(theView3D, thePrs), myPrsType(theType),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute()
+ {
+ VISU::VISUType aType = myPrs->GetType();
+ if (aType != VISU::TSCALARMAP &&
+ aType != VISU::TDEFORMEDSHAPE &&
+ aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
+ aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
+ myResult = "2D Quadratic element representation is not available for this type of presentations.";
+ return;
+ }
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if(myPrsType == VISU::LINES)
+ anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
+ else if(myPrsType == VISU::ARCS)
+ anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
+
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = myError;
+ }
+ }
+ };
+
+ class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
+ public:
+ typedef VISU::Quadratic2DPresentationType TResult;
+ TResult myResult;
+ TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines)
+ myResult = VISU::LINES;
+ else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs)
+ myResult = VISU::ARCS;
+ }
+ }
+ };
+
+ PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
+ }
+ CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetShrinkedEvent(this,thePrs));
+ }
+ CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetShadedEvent(this,thePrs));
+ }
+ CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetOpacityEvent(this,thePrs));
+ }
+ CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
+ }
+
+ Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs));
+ }
+
+ char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
+ {
+ string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
+ return CORBA::string_dup(aRet.c_str());
+ }
+ char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked)
+ {
+ string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked));
+ return CORBA::string_dup(aRet.c_str());
+ }
+ char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded)
+ {
+ string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded));
+ return CORBA::string_dup(aRet.c_str());
+ }
+ char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity)
+ {
+ string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity));
+ return CORBA::string_dup(aRet.c_str());
+ }
+ char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth)
+ {
+ string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
+ return CORBA::string_dup(aRet.c_str());
+ }
+
+ char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType)
+ {
+ string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType));
+ return CORBA::string_dup(aRet.c_str());