Salome HOME
Porting to OCCT6.5.1
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_MarkerDlg.cxx
index af3a7ba79767aea4c8b6b609ccfa3c8e40015514..bf70a697f3156da53065a1bb5207544f1e748dda 100644 (file)
@@ -1,7 +1,4 @@
-// Copyright (C) 2007-2009  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // 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   : GEOMToolsGUI_MarkerDlg.cxx
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
 
 #include "GEOMToolsGUI_MarkerDlg.h"
 
 #include <GeometryGUI.h>
 #include <GEOM_Displayer.h>
 
+#include <Basics_OCCTVersion.hxx>
+
 #include <QtxComboBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
 #include <LightApp_SelectionMgr.h>
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
@@ -160,7 +161,7 @@ GEOMToolsGUI_MarkerDlg::GEOMToolsGUI_MarkerDlg( QWidget* parent )
 
 GEOMToolsGUI_MarkerDlg::~GEOMToolsGUI_MarkerDlg()
 {
-  myOperation->Destroy();
+  myOperation->UnRegister();
 }
 
 void GEOMToolsGUI_MarkerDlg::setStandardMarker( GEOM::marker_type type, GEOM::marker_size size )
@@ -207,24 +208,38 @@ void GEOMToolsGUI_MarkerDlg::accept()
 {
   if ( getStudy() ) {
     LightApp_SelectionMgr* selMgr = qobject_cast<SalomeApp_Application*>( getStudy()->application() )->selectionMgr();
-    if ( selMgr ) {
-      SALOME_ListIO selected;
-      selMgr->selectedObjects( selected );
-      if ( !selected.IsEmpty() ) {
-        _PTR(Study) study = getStudy()->studyDS();
-        for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) {
-          _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) );
-          GEOM::GEOM_Object_var anObject =
-            GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) );
-          if ( !anObject->_is_nil() ) {
-            if ( myWGStack->currentIndex() == 0 )
-              anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() );
-            else if ( getCustomMarkerID() > 0 )
-              anObject->SetMarkerTexture( getCustomMarkerID() );
+    
+    SUIT_ViewWindow* window =  getStudy()->application()->desktop()->activeWindow();
+    if (window && window->getViewManager()) {
+      int mgrId = window->getViewManager()->getGlobalId();
+      if ( selMgr ) {
+        SALOME_ListIO selected;
+        selMgr->selectedObjects( selected );
+        if ( !selected.IsEmpty() ) {
+          _PTR(Study) study = getStudy()->studyDS();
+          for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) {
+            _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) );
+            GEOM::GEOM_Object_var anObject =
+              GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) );
+            if ( !anObject->_is_nil() ) {
+              if ( myWGStack->currentIndex() == 0 ) {
+                anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() );
+                QString aMarker = "%1%2%3";
+                aMarker = aMarker.arg(getMarkerType());
+                aMarker = aMarker.arg(DIGIT_SEPARATOR);
+                aMarker = aMarker.arg(getStandardMarkerScale());
+                getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, aMarker);
+              }
+              else if ( getCustomMarkerID() > 0 ) {
+                anObject->SetMarkerTexture( getCustomMarkerID() );
+                getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, QString::number(getCustomMarkerID()));
+              }
+            }
           }
+          GEOM_Displayer displayer( getStudy() );
+          displayer.Redisplay( selected, true );
+          selMgr->setSelectedObjects( selected );
         }
-        GEOM_Displayer displayer( getStudy() );
-        displayer.Redisplay( selected, true );
       }
     }
   }
@@ -322,7 +337,13 @@ void GEOMToolsGUI_MarkerDlg::addTexture( int id, bool select ) const
 {
   if ( id > 0 && myCustomTypeCombo->index( id ) == -1 ) {
     int tWidth, tHeight;
-    Handle(Graphic3d_HArray1OfBytes) texture = GeometryGUI::getTexture( getStudy(), id, tWidth, tHeight );
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+    Handle(TColStd_HArray1OfByte) texture = GeometryGUI::getTexture(getStudy(), id, tWidth, tHeight);
+#else
+    Handle(Graphic3d_HArray1OfBytes) texture = GeometryGUI::getTexture(getStudy(), id, tWidth, tHeight);
+#endif
+
     if ( !texture.IsNull() && texture->Length() == tWidth*tHeight/8 ) {
       QImage image( tWidth, tHeight, QImage::Format_Mono );
       image.setColor( 0, qRgba( 0, 0, 0, 0   ) );