Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VVTK / VVTK_SegmentationCursorDlg.cxx
index 63487fed62b3c685aa0d4815e480d6734b45e1b3..4f4d4e39d5ab4f7fdd1ea335cc4f44c6a41f2408 100644 (file)
@@ -22,6 +22,7 @@
 #include "VISU_GaussPointsPL.hxx"
 #include "VISU_OpenGLPointSpriteMapper.hxx"
 
+#include "LightApp_Application.h"
 #include "SUIT_MessageBox.h"
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Session.h"
@@ -96,7 +97,7 @@ namespace VISU
     static TTextureMap aTextureMap;
     
     TTextureValue aTextureValue;
-    TTextureKey aTextureKey(theMainTexture,theAlphaTexture);
+    TTextureKey aTextureKey(theMainTexture.latin1(),theAlphaTexture.latin1());
     TTextureMap::const_iterator anIter = aTextureMap.find(aTextureKey);
     if(anIter != aTextureMap.end()){
       aTextureValue = anIter->second;
@@ -141,8 +142,6 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c
                                      myEventCallbackCommand.GetPointer(), 
                                      myPriority);
 
-  SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
-
   setCaption( tr( "SEGMENTATION_CURSOR_DLG_TITLE" ) );
   setSizeGripEnabled(TRUE);
 
@@ -183,9 +182,9 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c
 
   QLabel* ZOriginLabel = new QLabel( tr( "ORIGIN_Z" ), myOriginGroup );
   myZOriginSpinBox = new QtxDblSpinBox( -1000.0, 1000.0, 0.1, myOriginGroup );
-  myZOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  //myZOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   myZOriginSpinBox->setMinimumWidth( 100 );
-  myZOriginSpinBox->setValue( 0.0 );
+  myZOriginSpinBox->setValue( 1.0 );
 
   OriginGroupLayout->addWidget(   XOriginLabel,   0, 0 );
   OriginGroupLayout->addWidget( myXOriginSpinBox, 0, 1 );
@@ -381,11 +380,19 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c
   buttonClose->setAutoDefault( TRUE );
   GroupButtonsLayout->addWidget( buttonClose, 0, 2 );
 
+  QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
+  buttonHelp->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
+
   TopLayout->addWidget( myTabBox );
   TopLayout->addWidget( GroupButtons );
 
   connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) );
   connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) );
+  connect( buttonHelp,  SIGNAL( clicked() ), this, SLOT( onClickHelp() ) );
+
+  connect(parent, SIGNAL(Show( QShowEvent * )), this, SLOT(onParentShow()));
+  connect(parent, SIGNAL(Hide( QHideEvent * )), this, SLOT(onParentHide()));
 }
 
 VVTK_SegmentationCursorDlg::~VVTK_SegmentationCursorDlg()
@@ -463,13 +470,13 @@ void VVTK_SegmentationCursorDlg::UpdateSegmentation()
     myRadiusGroup->hide();
 
     VISU_PlanesWidget *pPlanesWidget=myWidgetCtrl->GetPlanesWidget();
-    float origin[3];
+    vtkFloatingPointType origin[3];
     pPlanesWidget->GetOrigin( origin );
     myXOriginSpinBox->setValue( origin[0] );
     myYOriginSpinBox->setValue( origin[1] );
     myZOriginSpinBox->setValue( origin[2] );
 
-    float normal[3];
+    vtkFloatingPointType normal[3];
     pPlanesWidget->GetNormal( normal );
     myDXDirectionSpinBox->setValue( normal[0] );
     myDYDirectionSpinBox->setValue( normal[1] );
@@ -484,7 +491,7 @@ void VVTK_SegmentationCursorDlg::UpdateSegmentation()
     myRadiusGroup->show();
     
     VISU_SphereWidget *pSphereWidget=myWidgetCtrl->GetSphereWidget();
-    float origin[3], aRadius;
+    vtkFloatingPointType origin[3], aRadius;
     pSphereWidget->GetCenter(origin);
     myXOriginSpinBox->setValue( origin[0] );
     myYOriginSpinBox->setValue( origin[1] );
@@ -498,15 +505,15 @@ void VVTK_SegmentationCursorDlg::UpdateSegmentation()
 void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints()
 {
   int aPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite;
-  float aClamp = 200.0;
+  vtkFloatingPointType aClamp = 200.0;
   QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp";
   QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp";
-  float anAlphaThreshold = 0.1;
+  vtkFloatingPointType anAlphaThreshold = 0.1;
   int aResolution = 8;
   int aMinSize = 3;
   int aMaxSize = 33;
   int aMagnification = 100;
-  float anIncrement = 2.0;
+  vtkFloatingPointType anIncrement = 2.0;
 
   if( !myInsideCursorSettings->GetInitial() )
   {
@@ -565,11 +572,11 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints()
 
 void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints()
 {
-  float aClamp = 256.0;
+  vtkFloatingPointType aClamp = 256.0;
   int aPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite;
   QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp";
   QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp";
-  float anAlphaThreshold = 0.1;
+  vtkFloatingPointType anAlphaThreshold = 0.1;
   int aResolution = 8;
   int aSize = 25;
   bool aUniform = false;
@@ -587,7 +594,7 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints()
     myOutsideSizeBox->setOutsideSize( myOutsideCursorSettings->GetSize() );
     myOutsideSizeBox->setUniform( myOutsideCursorSettings->GetUniform() );
 
-    float* aColor = myOutsideCursorSettings->GetColor();
+    vtkFloatingPointType* aColor = myOutsideCursorSettings->GetColor();
     myOutsideSizeBox->setColor( QColor( ( int )( aColor[0] * 255.0 ),
                                        ( int )( aColor[1] * 255.0 ),
                                        ( int )( aColor[2] * 255.0 ) ) );
@@ -696,13 +703,13 @@ void VVTK_SegmentationCursorDlg::ApplySegmentationCursor()
   if( myIsPlaneSegmentation )
   {
     VISU_PlanesWidget *pPlanesWidget=myWidgetCtrl->GetPlanesWidget();
-    float origin[3];
+    vtkFloatingPointType origin[3];
     origin[0] = myXOriginSpinBox->value();
     origin[1] = myYOriginSpinBox->value();
     origin[2] = myZOriginSpinBox->value();
     pPlanesWidget->SetOrigin( origin );
 
-    float normal[3];
+    vtkFloatingPointType normal[3];
     normal[0] = myDXDirectionSpinBox->value();
     normal[1] = myDYDirectionSpinBox->value();
     normal[2] = myDZDirectionSpinBox->value();
@@ -722,7 +729,7 @@ void VVTK_SegmentationCursorDlg::ApplySegmentationCursor()
   else
   {
     VISU_SphereWidget *pSphereWidget=myWidgetCtrl->GetSphereWidget();
-    float origin[3], aRadius;
+    vtkFloatingPointType origin[3], aRadius;
     origin[0] = myXOriginSpinBox->value();
     origin[1] = myYOriginSpinBox->value();
     origin[2] = myZOriginSpinBox->value();
@@ -781,7 +788,7 @@ void VVTK_SegmentationCursorDlg::ApplyOutsideGaussPoints()
   myOutsideCursorSettings->SetUniform( myOutsideSizeBox->getUniform() );
 
   QColor aButtonColor = myOutsideSizeBox->getColor();
-  float aColor[3];
+  vtkFloatingPointType aColor[3];
   aColor[0] = aButtonColor.red() / 255.0;
   aColor[1] = aButtonColor.green() / 255.0;
   aColor[2] = aButtonColor.blue() / 255.0;
@@ -803,6 +810,20 @@ void VVTK_SegmentationCursorDlg::onClickClose()
   reject();
 }
 
+void VVTK_SegmentationCursorDlg::onClickHelp()
+{
+  QString aHelpFileName = "segmentation.htm";
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
+  else {
+    SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                          arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
+                          QObject::tr("BUT_OK"));
+  }
+}
+
 void VVTK_SegmentationCursorDlg::done( int r )
 {
   myPlaneAction->setOn( false );
@@ -813,6 +834,19 @@ void VVTK_SegmentationCursorDlg::done( int r )
   QDialog::done( r );
 }
 
+void VVTK_SegmentationCursorDlg::onParentShow()
+{
+  if(myPlaneAction->isOn() || mySphereAction->isOn())
+    show();
+  else
+    hide();
+}
+
+void VVTK_SegmentationCursorDlg::onParentHide()
+{
+  hide();
+}
+
 bool VVTK_SegmentationCursorDlg::CheckNumberOfFaces()
 {
   if( !myInteractor )