]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Create TextZone in the VTK Viewer.
authornds <nds@opencascade.com>
Wed, 13 Feb 2008 13:35:32 +0000 (13:35 +0000)
committernds <nds@opencascade.com>
Wed, 13 Feb 2008 13:35:32 +0000 (13:35 +0000)
src/SVTK/SVTK.pro
src/SVTK/SVTK_Actor2DWidget.cxx [new file with mode: 0644]
src/SVTK/SVTK_Actor2DWidget.h [new file with mode: 0644]
src/SVTK/SVTK_CaptionActor2DWidget.cxx [new file with mode: 0644]
src/SVTK/SVTK_CaptionActor2DWidget.h [new file with mode: 0644]
src/SVTK/SVTK_MainWindow.cxx
src/SVTK/SVTK_MainWindow.h
src/SVTK/SVTK_TextRegionDlg.cxx [new file with mode: 0644]
src/SVTK/SVTK_TextRegionDlg.h [new file with mode: 0644]
src/SVTK/resources/SVTK_images.ts
src/SVTK/resources/SVTK_msg_en.ts

index b7e5eb2d1ad8b893115b19bc2bea8678f2d66483..86028467b47512367afa9ceb276553bc7294d7ef 100644 (file)
@@ -26,7 +26,10 @@ HEADERS += SVTK_Actor.h
 HEADERS += SALOME_Actor.h
 HEADERS += SVTK_RectPicker.h
 HEADERS += SVTK_DeviceActor.h
+HEADERS += SVTK_Actor2DWidget.h
+HEADERS += SVTK_CaptionActor2DWidget.h
 HEADERS += SVTK_NonIsometricDlg.h
+HEADERS += SVTK_TextRegionDlg.h
 HEADERS += SVTK_UpdateRateDlg.h
 HEADERS += SVTK_CubeAxesDlg.h
 
@@ -57,9 +60,12 @@ SOURCES += SVTK_Actor.cxx
 SOURCES += SALOME_Actor.cxx
 SOURCES += SVTK_RectPicker.cxx
 SOURCES += SVTK_DeviceActor.cxx
+SOURCES += SVTK_Actor2DWidget.cxx
+SOURCES += SVTK_CaptionActor2DWidget.cxx
 SOURCES += SVTK_CubeAxesActor2D.cxx
 SOURCES += SVTK_NonIsometricDlg.cxx
 SOURCES += SVTK_UpdateRateDlg.cxx
+SOURCES += SVTK_TextRegionDlg.cxx
 SOURCES += SVTK_CubeAxesDlg.cxx
 SOURCES += SVTK_DialogBase.cxx
 SOURCES += SVTK_FontWidget.cxx
diff --git a/src/SVTK/SVTK_Actor2DWidget.cxx b/src/SVTK/SVTK_Actor2DWidget.cxx
new file mode 100644 (file)
index 0000000..9617c77
--- /dev/null
@@ -0,0 +1,479 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#include "SVTK_Actor2DWidget.h"
+
+#include <vtkActor2D.h>
+#include <vtkCallbackCommand.h>
+#include <vtkObjectFactory.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCoordinate.h>
+
+#include <vtkCaptionActor2D.h>
+#include <vtkTextProperty.h>
+#include <vtkCoordinate.h>
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_Actor2DWidget);
+vtkCxxSetObjectMacro(SVTK_Actor2DWidget, Actor2D, vtkActor2D);
+
+SVTK_Actor2DWidget::SVTK_Actor2DWidget()
+{
+  this->Actor2D = NULL;
+  this->EventCallbackCommand->SetCallback(SVTK_Actor2DWidget::ProcessEvents);
+  this->State = SVTK_Actor2DWidget::Outside;
+  this->LeftButtonDown = 0;
+  this->RightButtonDown = 0;
+  this->Priority = 0.55;
+}
+
+SVTK_Actor2DWidget::~SVTK_Actor2DWidget()
+{
+  this->SetActor2D(0);
+}
+
+void SVTK_Actor2DWidget::SetEnabled(int enabling)
+{
+  if ( ! this->Interactor )
+    {
+    vtkErrorMacro(<<"The interactor must be set prior to enabling/disabling widget");
+    return;
+    }
+  
+  if ( enabling ) 
+    {
+    vtkDebugMacro(<<"Enabling line widget");
+    if ( this->Enabled ) //already enabled, just return
+      {
+      return;
+      }
+    
+    if ( ! this->CurrentRenderer )
+      {
+      this->SetCurrentRenderer(this->Interactor->FindPokedRenderer(
+        this->Interactor->GetLastEventPosition()[0],
+        this->Interactor->GetLastEventPosition()[1]));
+      if (this->CurrentRenderer == NULL)
+        {
+        return;
+        }
+      }
+
+    this->Enabled = 1;
+    
+    // listen for the following events
+    vtkRenderWindowInteractor *i = this->Interactor;
+    i->AddObserver(vtkCommand::MouseMoveEvent, 
+                   this->EventCallbackCommand, this->Priority);
+    i->AddObserver(vtkCommand::LeftButtonPressEvent, 
+                   this->EventCallbackCommand, this->Priority);
+    i->AddObserver(vtkCommand::LeftButtonReleaseEvent, 
+                   this->EventCallbackCommand, this->Priority);
+    i->AddObserver(vtkCommand::RightButtonPressEvent, 
+                   this->EventCallbackCommand, this->Priority);
+    i->AddObserver(vtkCommand::RightButtonReleaseEvent, 
+                   this->EventCallbackCommand, this->Priority);
+
+    // Add the scalar bar
+    this->CurrentRenderer->AddViewProp(this->Actor2D);
+    this->InvokeEvent(vtkCommand::EnableEvent,NULL);
+    }
+  else //disabling------------------------------------------
+    {
+    vtkDebugMacro(<<"Disabling line widget");
+    if ( ! this->Enabled ) //already disabled, just return
+      {
+      return;
+      }
+    this->Enabled = 0;
+
+    // don't listen for events any more
+    this->Interactor->RemoveObserver(this->EventCallbackCommand);
+
+    // turn off the line
+    this->CurrentRenderer->RemoveActor(this->Actor2D);
+    this->InvokeEvent(vtkCommand::DisableEvent,NULL);
+    this->SetCurrentRenderer(NULL);
+    }
+  
+  this->Interactor->Render();
+}
+
+void SVTK_Actor2DWidget::ProcessEvents(vtkObject* vtkNotUsed(object), 
+                                       unsigned long event,
+                                       void* clientdata, 
+                                       void* vtkNotUsed(calldata))
+{
+  SVTK_Actor2DWidget* self = reinterpret_cast<SVTK_Actor2DWidget *>( clientdata );
+  
+  //okay, let's do the right thing
+  switch(event)
+    {
+    case vtkCommand::LeftButtonPressEvent:
+      self->OnLeftButtonDown();
+      break;
+    case vtkCommand::LeftButtonReleaseEvent:
+      self->OnLeftButtonUp();
+      break;
+    case vtkCommand::RightButtonPressEvent:
+      self->OnRightButtonDown();
+      break;
+    case vtkCommand::RightButtonReleaseEvent:
+      self->OnRightButtonUp();
+      break;
+    case vtkCommand::MouseMoveEvent:
+      self->OnMouseMove();
+      break;
+    }
+}
+
+
+int SVTK_Actor2DWidget::ComputeStateBasedOnPosition(int X, int Y, 
+                                                    int *pos1, int *pos2)
+{
+  int Result;
+  
+  // what are we modifying? The position, or size?
+  // if size what piece?
+  // if we are within 7 pixels of an edge...
+  int e1 = 0;
+  int e2 = 0;
+  int e3 = 0;
+  int e4 = 0;
+  if (X - pos1[0] < 7)
+    {
+    e1 = 1;
+    }
+  if (pos2[0] - X < 7)
+    {
+    e3 = 1;
+    }
+  if (Y - pos1[1] < 7)
+    {
+    e2 = 1;
+    }
+  if (pos2[1] - Y < 7)
+    {
+    e4 = 1;
+    }
+
+  // assume we are moving
+  Result = SVTK_Actor2DWidget::Moving;
+  // unless we are on a corner or edges
+  if (e2)
+    {
+    Result = SVTK_Actor2DWidget::AdjustingE2;
+    }
+  if (e4)
+    {
+    Result = SVTK_Actor2DWidget::AdjustingE4;
+    }
+  if (e1)
+    {
+    Result = SVTK_Actor2DWidget::AdjustingE1;
+    if (e2)
+      {
+      Result = SVTK_Actor2DWidget::AdjustingP1;
+      }
+    if (e4)
+      {
+      Result = SVTK_Actor2DWidget::AdjustingP4;
+      }
+    }
+  if (e3)
+    {
+    Result = SVTK_Actor2DWidget::AdjustingE3;
+    if (e2)
+      {
+      Result = SVTK_Actor2DWidget::AdjustingP2;
+      }
+    if (e4)
+      {
+      Result = SVTK_Actor2DWidget::AdjustingP3;
+      }
+    }
+
+  return Result;
+}
+
+void SVTK_Actor2DWidget::SetCursor(int cState)
+{
+  switch (cState)
+    {
+    case SVTK_Actor2DWidget::AdjustingP1:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZESW);
+      break;
+    case SVTK_Actor2DWidget::AdjustingP3:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZENE);
+      break;
+    case SVTK_Actor2DWidget::AdjustingP2:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZESE);
+      break;
+    case SVTK_Actor2DWidget::AdjustingP4:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZENW);
+      break;
+    case SVTK_Actor2DWidget::AdjustingE1:
+    case SVTK_Actor2DWidget::AdjustingE3:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZEWE);
+      break;
+    case SVTK_Actor2DWidget::AdjustingE2:
+    case SVTK_Actor2DWidget::AdjustingE4:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZENS);
+      break;
+    case SVTK_Actor2DWidget::Moving:
+      this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_SIZEALL);
+      break;        
+    }
+}
+
+
+void SVTK_Actor2DWidget::OnLeftButtonDown()
+{
+  if(!this->Actor2D)
+    return;
+
+  // We're only here is we are enabled
+  int X = this->Interactor->GetEventPosition()[0];
+  int Y = this->Interactor->GetEventPosition()[1];
+
+  // are we over the widget?
+  //this->Interactor->FindPokedRenderer(X,Y);
+  int *pos1 = this->Actor2D->GetPositionCoordinate()
+    ->GetComputedDisplayValue(this->CurrentRenderer);
+  int *pos2 = this->Actor2D->GetPosition2Coordinate()
+    ->GetComputedDisplayValue(this->CurrentRenderer);
+
+  // are we not over the scalar bar, ignore
+  if (X < pos1[0] || X > pos2[0] || Y < pos1[1] || Y > pos2[1])
+    {
+    return;
+    }
+  
+  if(this->Interactor->GetRepeatCount() > 1){
+    this->InvokeEvent(SVTK_Actor2DWidget::EditEvent, NULL);
+    return;
+  }
+
+  // start a drag, store the normalized view coords
+  double X2 = X;
+  double Y2 = Y;
+  // convert to normalized viewport coordinates
+  this->CurrentRenderer->DisplayToNormalizedDisplay(X2,Y2);
+  this->CurrentRenderer->NormalizedDisplayToViewport(X2,Y2);
+  this->CurrentRenderer->ViewportToNormalizedViewport(X2,Y2);
+  this->StartPosition[0] = X2;
+  this->StartPosition[1] = Y2;
+
+  this->State = this->ComputeStateBasedOnPosition(X, Y, pos1, pos2);
+  this->SetCursor(this->State);
+  
+  this->EventCallbackCommand->SetAbortFlag(1);
+  this->StartInteraction();
+  this->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);
+  this->LeftButtonDown = 1;
+}
+
+void SVTK_Actor2DWidget::OnMouseMove()
+{
+  if(!this->Actor2D)
+    return;
+
+  // compute some info we need for all cases
+  int X = this->Interactor->GetEventPosition()[0];
+  int Y = this->Interactor->GetEventPosition()[1];
+
+  
+  // compute the display bounds of the scalar bar if we are inside or outside
+  int *pos1, *pos2;
+  if (this->State == SVTK_Actor2DWidget::Outside ||
+      this->State == SVTK_Actor2DWidget::Inside)
+    {
+    pos1 = this->Actor2D->GetPositionCoordinate()
+      ->GetComputedDisplayValue(this->CurrentRenderer);
+    pos2 = this->Actor2D->GetPosition2Coordinate()
+      ->GetComputedDisplayValue(this->CurrentRenderer);
+  
+    if (this->State == SVTK_Actor2DWidget::Outside)
+      {
+      // if we are not over the scalar bar, ignore
+      if (X < pos1[0] || X > pos2[0] ||
+          Y < pos1[1] || Y > pos2[1])
+        {
+        return;
+        }
+      // otherwise change our state to inside
+      this->State = SVTK_Actor2DWidget::Inside;
+      }
+  
+    // if inside, set the cursor to the correct shape
+    if (this->State == SVTK_Actor2DWidget::Inside)
+      {
+      // if we have left then change cursor back to default
+      if (X < pos1[0] || X > pos2[0] ||
+          Y < pos1[1] || Y > pos2[1])
+        {
+        this->State = SVTK_Actor2DWidget::Outside;
+        this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_DEFAULT);
+        return;
+        }
+      // adjust the cursor based on our position
+      this->SetCursor(this->ComputeStateBasedOnPosition(X,Y,pos1,pos2));
+      return;
+      }
+    }
+  
+  double XF = X;
+  double YF = Y;
+  // convert to normalized viewport coordinates
+  this->CurrentRenderer->DisplayToNormalizedDisplay(XF,YF);
+  this->CurrentRenderer->NormalizedDisplayToViewport(XF,YF);
+  this->CurrentRenderer->ViewportToNormalizedViewport(XF,YF);
+  
+  // there are four parameters that can be adjusted
+  double *fpos1 = this->Actor2D->GetPositionCoordinate()->GetValue();
+  double *fpos2 = this->Actor2D->GetPosition2Coordinate()->GetValue();
+  double par1[2];
+  double par2[2];
+  par1[0] = fpos1[0];
+  par1[1] = fpos1[1];
+  par2[0] = fpos1[0] + fpos2[0];  
+  par2[1] = fpos1[1] + fpos2[1];  
+    
+  // based on the state, adjust the ScalarBar parameters
+  switch (this->State)
+    {
+    case SVTK_Actor2DWidget::AdjustingP1:
+      par1[0] = par1[0] + XF - this->StartPosition[0];
+      par1[1] = par1[1] + YF - this->StartPosition[1];
+      break;
+    case SVTK_Actor2DWidget::AdjustingP2:
+      par2[0] = par2[0] + XF - this->StartPosition[0];
+      par1[1] = par1[1] + YF - this->StartPosition[1];
+      break;
+    case SVTK_Actor2DWidget::AdjustingP3:
+      par2[0] = par2[0] + XF - this->StartPosition[0];
+      par2[1] = par2[1] + YF - this->StartPosition[1];
+      break;
+    case SVTK_Actor2DWidget::AdjustingP4:
+      par1[0] = par1[0] + XF - this->StartPosition[0];
+      par2[1] = par2[1] + YF - this->StartPosition[1];
+      break;
+    case SVTK_Actor2DWidget::AdjustingE1:
+      par1[0] = par1[0] + XF - this->StartPosition[0];
+      break;
+    case SVTK_Actor2DWidget::AdjustingE2:
+      par1[1] = par1[1] + YF - this->StartPosition[1];
+      break;
+    case SVTK_Actor2DWidget::AdjustingE3:
+      par2[0] = par2[0] + XF - this->StartPosition[0];
+      break;
+    case SVTK_Actor2DWidget::AdjustingE4:
+      par2[1] = par2[1] + YF - this->StartPosition[1];
+      break;
+    case SVTK_Actor2DWidget::Moving:
+      // first apply the move
+      par1[0] = par1[0] + XF - this->StartPosition[0];
+      par1[1] = par1[1] + YF - this->StartPosition[1];
+      par2[0] = par2[0] + XF - this->StartPosition[0];
+      par2[1] = par2[1] + YF - this->StartPosition[1];
+      break;
+    }
+  
+  // push the change out to the scalar bar
+  // make sure the scalar bar doesn't shrink to nothing
+  if (par2[0] > par1[0] && par2[1] > par1[1])
+    {
+    this->Actor2D->GetPositionCoordinate()->SetValue(par1[0],par1[1]);
+    this->Actor2D->GetPosition2Coordinate()->
+      SetValue(par2[0] - par1[0], par2[1] - par1[1]);
+    this->StartPosition[0] = XF;
+    this->StartPosition[1] = YF;      
+    }
+  
+  // start a drag
+  this->EventCallbackCommand->SetAbortFlag(1);
+  this->InvokeEvent(vtkCommand::InteractionEvent,NULL);
+  this->Interactor->Render();
+}
+
+void SVTK_Actor2DWidget::OnLeftButtonUp()
+{
+  if (this->State == SVTK_Actor2DWidget::Outside || this->LeftButtonDown == 0)
+    {
+    return;
+    }
+
+  // stop adjusting
+  this->State = SVTK_Actor2DWidget::Outside;
+  this->EventCallbackCommand->SetAbortFlag(1);
+  this->Interactor->GetRenderWindow()->SetCurrentCursor(VTK_CURSOR_DEFAULT);
+  this->EndInteraction();
+  this->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
+  this->LeftButtonDown = 0;
+}
+
+void SVTK_Actor2DWidget::OnRightButtonDown()
+{
+
+  // are we not over the scalar bar, ignore
+  if (this->State == SVTK_Actor2DWidget::Outside)
+    {
+    return;
+    }
+
+  if (this->HasObserver(vtkCommand::RightButtonPressEvent) ) 
+    {
+    this->EventCallbackCommand->SetAbortFlag(1);
+    this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
+    }
+  RightButtonDown = 1;
+}
+
+void SVTK_Actor2DWidget::OnRightButtonUp()
+{
+  if (RightButtonDown == 0) {
+    return;
+  }
+
+  if (this->HasObserver(vtkCommand::RightButtonReleaseEvent)) 
+    {
+    this->EventCallbackCommand->SetAbortFlag(1);
+    this->InvokeEvent(vtkCommand::RightButtonReleaseEvent,NULL);
+    }
+  this->RightButtonDown = 0;
+}
+
+void SVTK_Actor2DWidget::PrintSelf(ostream& os, vtkIndent indent)
+{
+  this->Superclass::PrintSelf(os,indent);
+  
+  os << indent << "Actor2D: " << this->Actor2D << "\n";
+}
diff --git a/src/SVTK/SVTK_Actor2DWidget.h b/src/SVTK/SVTK_Actor2DWidget.h
new file mode 100644 (file)
index 0000000..0b3f8c2
--- /dev/null
@@ -0,0 +1,127 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#ifndef __SVTK_ACTOR2D_WIDGET__
+#define __SVTK_ACTOR2D_WIDGET__
+
+#include "SVTK.h"
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include <vtkInteractorObserver.h>
+#include <vtkCommand.h>
+
+class vtkActor2D;
+class vtkRenderer;
+
+
+//----------------------------------------------------------------------------
+class SVTK_EXPORT SVTK_Actor2DWidget : public vtkInteractorObserver
+{
+public:
+  static SVTK_Actor2DWidget *New();
+  vtkTypeMacro(SVTK_Actor2DWidget, vtkInteractorObserver);
+  void PrintSelf(ostream& os, vtkIndent indent);
+
+  void SetActor2D(vtkActor2D *theActor2D);
+  vtkGetObjectMacro(Actor2D, vtkActor2D);
+  
+  // Description:
+  // Methods for turning the interactor observer on and off.
+  virtual void SetEnabled(int);
+
+  //! connect to this event to process editing
+  enum Event
+  {
+    EditEvent = vtkCommand::UserEvent + 1000
+  };
+
+protected:
+  SVTK_Actor2DWidget();
+  ~SVTK_Actor2DWidget();
+
+  // the actor that is used
+  vtkActor2D *Actor2D;
+
+  //! handles the events
+  static void ProcessEvents(vtkObject* object, 
+                            unsigned long event,
+                            void* clientdata, 
+                            void* calldata);
+
+  //! ProcessEvents() dispatches to these methods.
+  void OnLeftButtonDown();
+  void OnLeftButtonUp();
+  void OnRightButtonDown();
+  void OnRightButtonUp();
+  void OnMouseMove();
+
+  //! used to compute relative movements
+  double StartPosition[2];
+  
+  //! manage the state of the widget
+  int State;
+
+  //! use this to track whether left/right button was pressed to gate action on button up event.
+  int LeftButtonDown;
+  int RightButtonDown;
+  enum WidgetState
+  {
+    Moving=0,
+    AdjustingP1,
+    AdjustingP2,
+    AdjustingP3,
+    AdjustingP4,
+    AdjustingE1,
+    AdjustingE2,
+    AdjustingE3,
+    AdjustingE4,
+    Inside,
+    Outside
+  };
+
+  // use to determine what state the mouse is over, edge1 p1, etc.
+  // returns a state from the WidgetState enum above
+  int ComputeStateBasedOnPosition(int X, int Y, int *pos1, int *pos2);
+
+  // set the cursor to the correct shape based on State argument
+  void SetCursor(int State);
+
+private:
+  SVTK_Actor2DWidget(const SVTK_Actor2DWidget&);  //Not implemented
+  void operator=(const SVTK_Actor2DWidget&);  //Not implemented
+};
+
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif // __SVTK_ACTOR2D_WIDGET__
diff --git a/src/SVTK/SVTK_CaptionActor2DWidget.cxx b/src/SVTK/SVTK_CaptionActor2DWidget.cxx
new file mode 100644 (file)
index 0000000..91b2fcd
--- /dev/null
@@ -0,0 +1,93 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#include "SVTK_CaptionActor2DWidget.h"
+
+#include <vtkObjectFactory.h>
+
+#include <vtkCaptionActor2D.h>
+#include <vtkTextProperty.h>
+#include <vtkCoordinate.h>
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_CaptionActor2DWidget);
+
+SVTK_CaptionActor2DWidget::SVTK_CaptionActor2DWidget()
+{
+  this->CaptionActor2D = NULL;
+}
+
+SVTK_CaptionActor2DWidget::~SVTK_CaptionActor2DWidget()
+{
+  this->SetCaptionActor2D(0);
+}
+
+void 
+SVTK_CaptionActor2DWidget
+::SetCaptionActor2D(vtkCaptionActor2D *theCaptionActor2D)
+{
+  this->SetActor2D(theCaptionActor2D);
+  CaptionActor2D = theCaptionActor2D;
+}
+
+//----------------------------------------------------------------------------
+namespace SVTK
+{
+  SVTK_CaptionActor2DWidget*
+  PublishCaptionActor2D(vtkRenderWindowInteractor* theInteractor)
+  {
+    vtkCaptionActor2D* aCaptionActor2D = vtkCaptionActor2D::New();
+    aCaptionActor2D->SetPickable(true); 
+    aCaptionActor2D->SetBorder(true);
+    aCaptionActor2D->SetLeader(false);
+    aCaptionActor2D->SetCaption("");
+
+    vtkCoordinate* aCoordinate = aCaptionActor2D->GetPositionCoordinate();
+    aCoordinate->SetCoordinateSystemToNormalizedViewport();
+    aCoordinate->SetReferenceCoordinate(NULL);
+    aCoordinate->SetCoordinateSystemToNormalizedViewport();
+    aCoordinate->SetValue(0.05, 0.05);
+    aCaptionActor2D->SetWidth(0.25);
+    aCaptionActor2D->SetHeight(0.15);
+
+    vtkTextProperty *aTextProperty = vtkTextProperty::New();
+    aCaptionActor2D->SetCaptionTextProperty(aTextProperty);
+    aTextProperty->SetJustificationToCentered();
+    aTextProperty->SetVerticalJustificationToCentered();
+    aTextProperty->SetFontSize(10);
+    aTextProperty->Delete();
+
+    SVTK_CaptionActor2DWidget* aWidget = SVTK_CaptionActor2DWidget::New();
+    aWidget->SetCaptionActor2D(aCaptionActor2D);
+    aWidget->SetInteractor(theInteractor);
+    aWidget->SetEnabled(1);
+
+    return aWidget;
+  }
+}
diff --git a/src/SVTK/SVTK_CaptionActor2DWidget.h b/src/SVTK/SVTK_CaptionActor2DWidget.h
new file mode 100644 (file)
index 0000000..6b3427b
--- /dev/null
@@ -0,0 +1,79 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#ifndef __SVTK_CAPTION_ACTOR2D_WIDGET__
+#define __SVTK_CAPTION_ACTOR2D_WIDGET__
+
+#include "SVTK.h"
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "SVTK_Actor2DWidget.h"
+
+class vtkCaptionActor2D;
+
+
+//----------------------------------------------------------------------------
+class SVTK_EXPORT SVTK_CaptionActor2DWidget : public SVTK_Actor2DWidget
+{
+public:
+  static SVTK_CaptionActor2DWidget *New();
+  vtkTypeMacro(SVTK_CaptionActor2DWidget, SVTK_Actor2DWidget);
+
+  void SetCaptionActor2D(vtkCaptionActor2D *theCaptionActor2D);
+  vtkGetObjectMacro(CaptionActor2D, vtkCaptionActor2D);
+  
+protected:
+  SVTK_CaptionActor2DWidget();
+  ~SVTK_CaptionActor2DWidget();
+
+  // the actor that is used
+  vtkCaptionActor2D *CaptionActor2D;
+
+private:
+  SVTK_CaptionActor2DWidget(const SVTK_CaptionActor2DWidget&);  //Not implemented
+  void operator=(const SVTK_CaptionActor2DWidget&);  //Not implemented
+};
+
+
+//----------------------------------------------------------------------------
+namespace SVTK
+{
+  SVTK_CaptionActor2DWidget*
+  PublishCaptionActor2D(vtkRenderWindowInteractor* theInteractor);
+}
+
+
+//----------------------------------------------------------------------------
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif // __SVTK_CAPTION_ACTOR2D_WIDGET__
index 2d50a0606347c84c58e6f1668bc9e0b1b8215045..276760378128ae292f73614de40cddef19cf8ffe 100644 (file)
@@ -34,9 +34,6 @@
 #include <QPrintDialog>
 #include <QApplication>
 
-#include <vtkGenericRenderWindowInteractor.h>
-#include <vtkRenderer.h>
-
 #include <QtxAction.h>
 #include <QtxMultiAction.h>
 #include <QtxToolBar.h>
@@ -50,6 +47,9 @@
 #include "SVTK_UpdateRateDlg.h"
 #include "SVTK_CubeAxesDlg.h"
 #include "SVTK_SetRotationPointDlg.h"
+
+#include "SVTK_TextRegionDlg.h"
+
 #include "SVTK_MainWindow.h"
 #include "SVTK_Event.h"
 #include "SVTK_Renderer.h"
@@ -57,6 +57,9 @@
 #include "SVTK_InteractorStyle.h"
 #include "SVTK_Selector.h"
 
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkRenderer.h>
+
 /*!
   Constructor
 */
@@ -94,10 +97,12 @@ SVTK_MainWindow
   myInteractor->setFocus();
   setFocusProxy(myInteractor);
 
-  myUpdateRateDlg = new SVTK_UpdateRateDlg(myActionsMap[UpdateRate],this,"SVTK_UpdateRateDlg");
-  myNonIsometricDlg = new SVTK_NonIsometricDlg(myActionsMap[NonIsometric],this,"SVTK_NonIsometricDlg");
-  myCubeAxesDlg = new SVTK_CubeAxesDlg(myActionsMap[GraduatedAxes],this,"SVTK_CubeAxesDlg");
-  mySetRotationPointDlg = new SVTK_SetRotationPointDlg(myActionsMap[ChangeRotationPointId],this,"SVTK_SetRotationPointDlg");
+  myUpdateRateDlg = new SVTK_UpdateRateDlg(myActionsMap[UpdateRate], this, "SVTK_UpdateRateDlg");
+  myNonIsometricDlg = new SVTK_NonIsometricDlg(myActionsMap[NonIsometric], this," SVTK_NonIsometricDlg");
+  myCubeAxesDlg = new SVTK_CubeAxesDlg(myActionsMap[GraduatedAxes], this, "SVTK_CubeAxesDlg");
+  mySetRotationPointDlg = new SVTK_SetRotationPointDlg(myActionsMap[ChangeRotationPointId], this, "SVTK_SetRotationPointDlg");
+  myTextRegionDlg = new SVTK_TextRegionDlg(myActionsMap[TextRegion], this, "SVTK_TextRegionDlg");
+
 }
 
 /*!
@@ -576,6 +581,14 @@ SVTK_MainWindow
   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
   myActionsMap[ UpdateRate ] = anAction;
 
+  // onTextRegion: Create Text Region
+  anAction = new QtxAction(tr("MNU_SVTK_TEXT_REGION"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_TEXT_REGION" ) ),
+                          tr( "MNU_SVTK_TEXT_REGION" ), 0, this);
+  anAction->setStatusTip(tr("DSC_SVTK_TEXT_REGION"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onTextRegion()));
+  myActionsMap[ TextRegion ] = anAction;
+
   // print view
   anAction = new QtxAction(tr("MNU_PRINT_VIEW"), 
                           theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_PRINT_VIEW" ) ),
@@ -628,6 +641,7 @@ SVTK_MainWindow
   myToolBar->addAction( myActionsMap[UpdateRate] );
   myToolBar->addAction( myActionsMap[NonIsometric] );
   myToolBar->addAction( myActionsMap[GraduatedAxes] );
+  myToolBar->addAction( myActionsMap[TextRegion] );
   myToolBar->addAction( myActionsMap[PrintId] );
 }
 
@@ -857,6 +871,13 @@ SVTK_MainWindow
   Repaint();
 }
 
+void
+SVTK_MainWindow
+::onTextRegion()
+{
+  myTextRegionDlg->PublishNew(GetInteractor());
+}
+
 void
 SVTK_MainWindow
 ::onUpdateRate(bool theIsActivate)
index 57d9de91522d657213d4a434acb9a77e3a715188..95503a88ed5248f3f1b4aeb488d0f81615629050 100644 (file)
@@ -48,6 +48,7 @@ class SVTK_UpdateRateDlg;
 class SVTK_CubeAxesActor2D;
 class SVTK_CubeAxesDlg;
 class SVTK_SetRotationPointDlg;
+class SVTK_TextRegionDlg;
 
 class VTKViewer_Trihedron;
 class VTKViewer_Actor;
@@ -231,6 +232,8 @@ public:
   void onNonIsometric(bool theIsActivate);
   void onGraduatedAxes(bool theIsActivate);
 
+  void onTextRegion();
+
   void onAdjustTrihedron();
   void onAdjustCubeAxes();
 
@@ -252,7 +255,8 @@ public:
   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, 
         ChangeRotationPointId, RotationId,
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, 
-        ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, PrintId };
+        ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
+         TextRegion, PrintId };
   typedef QMap<int, QtxAction*> TActionsMap;
 
   SUIT_ViewWindow* myViewWindow;
@@ -261,6 +265,7 @@ public:
   SVTK_UpdateRateDlg* myUpdateRateDlg;
   SVTK_CubeAxesDlg* myCubeAxesDlg;
   SVTK_SetRotationPointDlg* mySetRotationPointDlg;
+  SVTK_TextRegionDlg* myTextRegionDlg;
 
   vtkSmartPointer<vtkObject> myEventDispatcher;
   TActionsMap myActionsMap;  
diff --git a/src/SVTK/SVTK_TextRegionDlg.cxx b/src/SVTK/SVTK_TextRegionDlg.cxx
new file mode 100644 (file)
index 0000000..45766d8
--- /dev/null
@@ -0,0 +1,321 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#include "SVTK_TextRegionDlg.h"
+
+#include "SVTK_CaptionActor2DWidget.h"
+#include "SVTK_RenderWindowInteractor.h"
+
+#include "SVTK_MainWindow.h"
+#include "SVTK_FontWidget.h"
+
+#include "QtxAction.h"
+
+#include <QGroupBox>
+#include <QTextEdit>
+#include <QPushButton>
+#include <QComboBox>
+#include <QCheckBox>
+#include <QLayout>
+#include <QLineEdit>
+
+#include <vtkCaptionActor2D.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkTextProperty.h>
+
+
+/*!
+  Constructor
+*/
+SVTK_TextRegionDlg
+::SVTK_TextRegionDlg(QtxAction* theAction,
+                    SVTK_MainWindow* theParent,
+                    const char* theName):
+  SVTK_DialogBase(theAction,
+                 theParent, 
+                 theName),
+  myMainWindow( theParent ),
+  myPriority(0.0),
+  myEventCallbackCommand(vtkCallbackCommand::New())
+{
+  myEventCallbackCommand->Delete();
+  myEventCallbackCommand->SetClientData(this);
+  myEventCallbackCommand->SetCallback(SVTK_TextRegionDlg::ProcessEvents);
+
+  setWindowTitle(tr("DLG_TITLE"));
+  QVBoxLayout* aFormLayout = new QVBoxLayout( this );
+  aFormLayout->setSpacing( 5 );
+  aFormLayout->setMargin( 5 );
+  {
+    QGroupBox* aGroupBox = new QGroupBox( this );
+    aGroupBox->setTitle( tr( "TEXT_PROPERTIES" ) );
+
+    QVBoxLayout* aGrLayout = new QVBoxLayout( aGroupBox );
+    aGrLayout->setSpacing( 6 );
+    aGrLayout->setMargin( 11 );
+    {
+      aGrLayout->setAlignment( Qt::AlignTop );
+  
+      {
+       SVTK_FontWidget* aWidget = new SVTK_FontWidget(aGroupBox);
+       aGrLayout->addWidget( aWidget );
+       connect(aWidget, SIGNAL(Modified()), SLOT(onAutoApply()));
+       myFontWidget = aWidget;
+      }
+
+      {
+       QTextEdit* aTextEdit = new QTextEdit( aGroupBox );
+       aTextEdit->setLineWrapMode( QTextEdit::WidgetWidth );
+       aGrLayout->addWidget( aTextEdit );
+       connect(aTextEdit, SIGNAL(textChanged()), SLOT(onAutoApply()));
+       myTextEdit = aTextEdit;
+      }
+    }
+
+    aFormLayout->addWidget( aGroupBox );
+  }
+  {
+    QGroupBox* aGroupBox = new QGroupBox( this );
+    QVBoxLayout* aGrLayout = new QVBoxLayout( aGroupBox );
+    aGrLayout->setSpacing( 6 );
+    aGrLayout->setMargin( 11 );
+
+    {
+      aGrLayout->setAlignment( Qt::AlignTop );
+      {
+       QCheckBox* aCheckBox = new QCheckBox( aGroupBox );
+       aCheckBox->setText( tr( "AUTO_APPLY" ) );
+       aCheckBox->setChecked( TRUE );
+       aGrLayout->addWidget( aCheckBox );
+       myAutoApplyCheckBox = aCheckBox;
+      }
+    }
+
+    aFormLayout->addWidget( aGroupBox );
+  }
+  {
+    QGroupBox* aGroupBox = new QGroupBox( this );
+    QVBoxLayout* aGrLayout = new QVBoxLayout( aGroupBox );
+    aGrLayout->setSpacing( 6 );
+    aGrLayout->setMargin( 11 );
+
+    {
+      aGrLayout->setAlignment( Qt::AlignTop );
+
+      {
+       QPushButton* aPushButton = new QPushButton( aGroupBox );
+       aPushButton->setText( tr( "OK" ) );
+       aGrLayout->addWidget( aPushButton );
+       connect(aPushButton, SIGNAL(clicked()), SLOT(onOk()));
+      }
+      {
+       QPushButton* aPushButton = new QPushButton( aGroupBox );
+       aPushButton->setText( tr( "APPLY" ) );
+       aGrLayout->addWidget( aPushButton );
+       connect(aPushButton, SIGNAL(clicked()), SLOT(onApply()));
+      }
+      {
+       QSpacerItem* aSpacer = new QSpacerItem( 157, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+       aGrLayout->addItem( aSpacer );
+      }
+      {
+       QPushButton* aPushButton = new QPushButton( aGroupBox );
+       aPushButton->setText( tr( "CLOSE" ) );
+       aGrLayout->addWidget( aPushButton );
+       connect(aPushButton, SIGNAL(clicked()), SLOT(onClose()));
+      }
+    }
+
+    aFormLayout->addWidget( aGroupBox );
+  }
+}
+
+/*!
+  Destroys the object and frees any allocated resources
+ */
+SVTK_TextRegionDlg
+::~SVTK_TextRegionDlg()
+{
+  // no need to delete child widgets, Qt does it all for us
+}
+
+/*!
+  Processes events
+*/
+void 
+SVTK_TextRegionDlg
+::ProcessEvents(vtkObject* theObject, 
+               unsigned long theEvent,
+               void* theClientData, 
+               void* vtkNotUsed(theCallData))
+{
+  SVTK_TextRegionDlg* self = reinterpret_cast<SVTK_TextRegionDlg*>(theClientData);
+
+  if(theEvent == SVTK_Actor2DWidget::EditEvent){
+    SVTK_CaptionActor2DWidget* aWidget = dynamic_cast<SVTK_CaptionActor2DWidget*>(theObject);
+    self->Update( aWidget );
+  }
+}
+
+/*!
+  Update
+*/
+void 
+SVTK_TextRegionDlg
+::Update(SVTK_CaptionActor2DWidget* theWidget)
+{
+  if(!theWidget)
+    return;
+
+  vtkCaptionActor2D* aCaptionActor2D = theWidget->GetCaptionActor2D();
+  if(!aCaptionActor2D)
+    return;
+
+  myWidget = NULL; // To avoid call of onApply function
+
+  //myFontWidget->SetData(aCaptionActor2D->GetCaptionTextProperty());
+  QColor aTitleColor(255, 255, 255);
+  int aTitleFontFamily = VTK_ARIAL;
+  bool isTitleBold = false;
+  bool isTitleItalic = false;
+  bool isTitleShadow = false;
+
+  vtkTextProperty* aTitleProp = aCaptionActor2D->GetCaptionTextProperty();
+  if (aTitleProp !=0)
+  {
+    vtkFloatingPointType c[ 3 ];
+    aTitleProp->GetColor(c);
+    aTitleColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255));
+    aTitleFontFamily = aTitleProp->GetFontFamily();
+    isTitleBold = aTitleProp->GetBold() ? true : false;
+    isTitleItalic = aTitleProp->GetItalic() ? true : false;
+    isTitleShadow = aTitleProp->GetShadow() ? true : false;
+  }
+  myFontWidget->SetData(aTitleColor, aTitleFontFamily, isTitleBold,
+                        isTitleItalic, isTitleShadow);
+
+  myTextEdit->setText(aCaptionActor2D->GetCaption());
+
+  myWidget = theWidget;
+  
+  show();
+}
+
+/*!
+  PublishNew
+*/
+void 
+SVTK_TextRegionDlg
+::PublishNew(SVTK_RenderWindowInteractor* theInteractor)
+{
+  SVTK_CaptionActor2DWidget* aWidget = SVTK::PublishCaptionActor2D(theInteractor->GetDevice());
+
+  aWidget->AddObserver( SVTK_Actor2DWidget::EditEvent, 
+                       myEventCallbackCommand.GetPointer(), 
+                       myPriority );
+
+  Update(aWidget);
+}
+
+/*!
+  Verify validity of entry data
+*/
+bool 
+SVTK_TextRegionDlg
+::onApply()
+{
+  if(!myWidget)
+    return false;
+
+  vtkCaptionActor2D* aCaptionActor2D = myWidget->GetCaptionActor2D();
+  if(!aCaptionActor2D)
+    return false;
+
+  QColor aTitleColor(255, 255, 255);
+  int aTitleFontFamily = VTK_ARIAL;
+  bool isTitleBold = false;
+  bool isTitleItalic = false;
+  bool isTitleShadow = false;
+
+  //myFontWidget->GetData(aCaptionActor2D->GetCaptionTextProperty());
+  vtkTextProperty* aCaptionProp = aCaptionActor2D->GetCaptionTextProperty();
+  myFontWidget->GetData( aTitleColor, aTitleFontFamily, isTitleBold,
+                         isTitleItalic, isTitleShadow );
+  if ( aCaptionProp ) {
+    aCaptionProp->SetColor(aTitleColor.red() / 255.,
+                          aTitleColor.green() / 255.,
+                          aTitleColor.blue() / 255.);
+    aCaptionProp->SetFontFamily(aTitleFontFamily);
+    aCaptionProp->SetBold(isTitleBold ? 1 : 0);
+    aCaptionProp->SetItalic(isTitleItalic ? 1 : 0);
+    aCaptionProp->SetShadow(isTitleShadow ? 1 : 0);
+
+    aCaptionActor2D->SetCaptionTextProperty(aCaptionProp);
+  }
+
+  aCaptionActor2D->SetCaption(myTextEdit->toPlainText().toLatin1());
+
+  myMainWindow->Repaint();
+
+  return true;
+}
+
+/*!
+  Verify validity of entry data
+*/
+bool 
+SVTK_TextRegionDlg
+::onAutoApply()
+{
+  if(!myAutoApplyCheckBox->isChecked())
+    return false;
+
+  return onApply();
+}
+
+/*!
+  SLOT called when "Ok" button pressed.
+*/
+void 
+SVTK_TextRegionDlg
+::onOk()
+{
+  done(onApply());
+}
+
+/*!
+  SLOT: called when "Close" button pressed. Close dialog
+*/
+void 
+SVTK_TextRegionDlg
+::onClose()
+{
+  reject();
+}
diff --git a/src/SVTK/SVTK_TextRegionDlg.h b/src/SVTK/SVTK_TextRegionDlg.h
new file mode 100644 (file)
index 0000000..dae423a
--- /dev/null
@@ -0,0 +1,98 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#ifndef SVTK_TEXT_REGION_DLG_H
+#define SVTK_TEXT_REGION_DLG_H
+
+#include "SVTK_DialogBase.h"
+
+#include <vtkSmartPointer.h>
+
+class SVTK_MainWindow;
+class SVTK_RenderWindowInteractor;
+
+class SVTK_FontWidget;
+class SVTK_CaptionActor2DWidget;
+
+class QTextEdit;
+class QCheckBox;
+
+class vtkCallbackCommand;
+class vtkObject;
+
+
+//----------------------------------------------------------------------------
+class SVTK_TextRegionDlg : public SVTK_DialogBase
+{
+  Q_OBJECT;
+
+public:
+  SVTK_TextRegionDlg(QtxAction* theAction,
+                    SVTK_MainWindow* theParent,
+                    const char* theName);
+
+  ~SVTK_TextRegionDlg();
+
+  void PublishNew(SVTK_RenderWindowInteractor* theInteractor);
+
+private slots:
+  void onOk();
+  bool onApply();
+  bool onAutoApply();
+  void onClose();
+
+ private:
+  //----------------------------------------------------------------------------
+  SVTK_MainWindow *myMainWindow;
+
+  // Priority at which events are processed
+  vtkFloatingPointType myPriority;
+
+  // Used to process events
+  vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+  // Description:
+  // Main process event method
+  static
+  void
+  ProcessEvents(vtkObject* object, 
+               unsigned long event,
+               void* clientdata, 
+               void* calldata);
+  
+  void Update(SVTK_CaptionActor2DWidget* theWidget);
+
+  SVTK_CaptionActor2DWidget* myWidget;
+  SVTK_FontWidget* myFontWidget;
+  QCheckBox* myAutoApplyCheckBox;
+  QTextEdit* myTextEdit;
+
+};
+
+
+#endif // SVTK_TEXT_REGION_DLG_H
index 6e4a9d1d752d96628659d038fc8a42aee6a5f14e..6330af3497bd00d6cc40bbcd2a4d330716b90be2 100644 (file)
         <source>ICON_UPDATE_RATE</source>
         <translation>view_update_rate.png</translation>
     </message>
+    <message>
+        <source>ICON_TEXT_REGION</source>
+        <translation>view_text.png</translation>
+    </message>
     <message>
         <source>ICON_PRINT_VIEW</source>
         <translation>view_print.png</translation>
index 49b65d9336c383fdbf92083107d87eeedcfed28d..e48e72b8f65565778dc3471278fe2efaa6e1c2a8 100644 (file)
         <source>MNU_SVTK_UPDATE_RATE</source>
         <translation>Update rate</translation>
     </message>
+    <message>
+        <source>MNU_SVTK_TEXT_REGION</source>
+        <translation>Text Zone</translation>
+    </message>
+    <message>
+        <source>DSC_SVTK_TEXT_REGION</source>
+        <translation>Text Zone</translation>
+    </message>
     <message>
         <source>MNU_PRINT_VIEW</source>
         <translation>Print view</translation>
         <translation>Set Rotation Point</translation>
     </message>
 </context>
+<context>
+    <name>SVTK_TextRegionDlg</name>
+    <message>
+        <source>DLG_TITLE</source>
+        <translation>Text Zone</translation>
+    </message>
+    <message>
+        <source>TEXT_PROPERTIES</source>
+        <translation>Properties</translation>
+    </message>
+    <message>
+        <source>AUTO_APPLY</source>
+        <translation>Auto Apply</translation>
+    </message>
+    <message>
+        <source>OK</source>
+        <translation>OK</translation>
+    </message>
+    <message>
+        <source>APPLY</source>
+        <translation>Apply</translation>
+    </message>
+    <message>
+        <source>CLOSE</source>
+        <translation>Close</translation>
+    </message>
+</context>
 <context>
     <name>SVTK_UpdateRateDlg</name>
     <message>