]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0020012: EDF 831 GEOM : API for points representation in 3D viewer
authorvsr <vsr@opencascade.com>
Mon, 9 Nov 2009 11:42:50 +0000 (11:42 +0000)
committervsr <vsr@opencascade.com>
Mon, 9 Nov 2009 11:42:50 +0000 (11:42 +0000)
resources/marker_1.png
resources/marker_2.png
src/GEOMGUI/GEOMGUI_Selection.cxx
src/GEOMGUI/GEOMGUI_Selection.h
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h

index f0d21091d88a83773e7979511c1ff6200b48b3d4..8bbaa854e234d7a1d13ac8dc60d02098178db461 100755 (executable)
Binary files a/resources/marker_1.png and b/resources/marker_1.png differ
index 8bbaa854e234d7a1d13ac8dc60d02098178db461..f0d21091d88a83773e7979511c1ff6200b48b3d4 100755 (executable)
Binary files a/resources/marker_2.png and b/resources/marker_2.png differ
index f17dfceebfb2d796320d6fb3a63eaf9b02c22f9e..a3e9d133b849598d95f10c653bb678c06271221c 100644 (file)
@@ -83,6 +83,8 @@ QVariant GEOMGUI_Selection::parameter( const int ind, const QString& p ) const
 //  else
   if( p == "type" )
     return QVariant( typeName( ind ) );
+  if( p == "typeid" )
+    return QVariant( typeId( ind ) );
   else if ( p == "displaymode" )
     return QVariant( displayMode( ind ) );
   else if ( p == "isAutoColor" )
@@ -112,6 +114,15 @@ QString GEOMGUI_Selection::typeName( const int index ) const
   return "Unknown";
 }
 
+int GEOMGUI_Selection::typeId( const int index ) const
+{
+  int aType = -1;
+  GEOM::GEOM_Object_var anObj = getObject( index );
+  if ( !CORBA::is_nil( anObj ) )
+    aType = anObj->GetType();
+  return aType;
+}
+
 bool GEOMGUI_Selection::isVisible( const int index ) const
 {
   GEOM::GEOM_Object_var obj = getObject( index );
index d6b4dabf0cecce501220fa341067c953fa2d9c7e..bb8d0aaab7fef938d2fb16fe8e78c38fd6ae7267 100644 (file)
@@ -48,6 +48,7 @@ private:
   bool                  isVisible( const int ) const;
   bool                  isAutoColor( const int ) const;
   QString               typeName( const int ) const;  
+  int                   typeId( const int ) const;  
   QString               displayMode( const int ) const;
   QString               selectionMode() const;
   bool                  isVectorsMode( const int ) const;
index 435419768671e3ba5bde36390feb90ad1698cb92..e8c6128fc1c7d20d74fdcc80f9b3125855e54763 100644 (file)
@@ -89,6 +89,7 @@
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 
 #include <GEOMImpl_Types.hxx>
+#include <Graphic3d_HArray1OfBytes.hxx>
 
 using namespace std;
 
@@ -257,13 +258,10 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
   myShadingColor = SalomeApp_Tools::color( col );
 
   myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
-  myTypeOfMarker = (Aspect_TypeOfMarker)resMgr->integerValue("Geometry", "type_of_marker", Aspect_TOM_PLUS);
-  myScaleOfMarker = resMgr->doubleValue("Geometry", "marker_scale", 1.);
-  if(myScaleOfMarker < 1.0)
-    myScaleOfMarker = 1.0;
-  if(myScaleOfMarker > 7.)
-    myScaleOfMarker = 7.;
-
+  int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
+  myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
+  myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
+  myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
 
   myColor = -1;
   // This color is used for shape displaying. If it is equal -1 then
@@ -752,7 +750,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
                      Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
                      if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
                      Standard_Integer aWidth, aHeight;
-                     Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTextureAspect( getStudy(), aTextureId, aWidth, aHeight );
+                     Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTexture( getStudy(), aTextureId, aWidth, aHeight );
                      if ( !aTexture.IsNull() ) {
                        static int TextureId = 0;
                        Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect(aQuanColor,
index 748ecd84ffd94e4cb3e86d8ccf41409a14d08635..94257fbd4c9034fbc647a3e8c6dd97e2d544ada8 100644 (file)
             <source>ICON_VERTEX_MARKER_9</source>
             <translation>marker_9.png</translation>
         </message>
+       <message>
+            <source>ICON_VERTEX_MARKER_10</source>
+            <translation>marker_10.png</translation>
+        </message>
+       <message>
+            <source>ICON_VERTEX_MARKER_11</source>
+            <translation>marker_11.png</translation>
+        </message>
+       <message>
+            <source>ICON_VERTEX_MARKER_12</source>
+            <translation>marker_12.png</translation>
+        </message>
+       <message>
+            <source>ICON_VERTEX_MARKER_13</source>
+            <translation>marker_13.png</translation>
+        </message>
         <message>
             <source>ICO_ARC</source>
             <translation>arc.png</translation>
index ed1f7a99e881eed3b574cd94c355bb92104508b7..0764dd852a775ba25b9cbb79dc50f7f1ed508d2c 100644 (file)
@@ -2551,6 +2551,10 @@ Please, select face, shell or solid and try again</translation>
             <source>MEN_WORK_PLANE</source>
             <translation>Working Plane</translation>
         </message>
+        <message>
+            <source>MEN_POP_POINT_MARKER</source>
+            <translation>Point Marker</translation>
+        </message>
         <message>
             <source>NAME_LBL</source>
             <translation>Name: </translation>
@@ -3051,6 +3055,10 @@ Please, select face, shell or solid and try again</translation>
             <source>STB_WORK_PLANE</source>
             <translation>Create a working plane</translation>
         </message>
+        <message>
+            <source>STB_POP_POINT_MARKER</source>
+            <translation>Set Point Marker</translation>
+        </message>
         <message>
             <source>SUPPRESS_RESULT</source>
             <translation>Suppress Result</translation>
@@ -3511,6 +3519,10 @@ Please, select face, shell or solid and try again</translation>
             <source>TOP_WORK_PLANE</source>
             <translation>Create a working plane</translation>
         </message>
+        <message>
+            <source>TOP_POP_POINT_MARKER</source>
+            <translation>Point Marker</translation>
+        </message>
         <message>
             <source>WRN_NOT_IMPLEMENTED</source>
             <translation>Sorry, this functionality is not yet implemented</translation>
@@ -4265,4 +4277,51 @@ Would you like to continue?</translation>
             <translation>Delete objects</translation>
         </message>
     </context>
+    <context>
+        <name>GEOMToolsGUI_MarkerDlg</name>
+        <message>
+            <source>SET_MARKER_TLT</source>
+            <translation>Set Point Marker</translation>
+        </message>
+        <message>
+            <source>STANDARD_MARKER</source>
+            <translation>Standard</translation>
+        </message>
+        <message>
+            <source>CUSTOM_MARKER</source>
+            <translation>Custom</translation>
+        </message>
+        <message>
+            <source>TYPE</source>
+            <translation>Type:</translation>
+        </message>
+        <message>
+            <source>SCALE</source>
+            <translation>Scale:</translation>
+        </message>
+        <message>
+            <source>CUSTOM</source>
+            <translation>Texture:</translation>
+        </message>
+        <message>
+            <source>BROWSE</source>
+            <translation>Browse...</translation>
+        </message>
+        <message>
+            <source>OK_BTN</source>
+            <translation>&amp;OK</translation>
+        </message>
+        <message>
+            <source>CANCEL_BTN</source>
+            <translation>&amp;Cancel</translation>
+        </message>
+        <message>
+            <source>HELP_BTN</source>
+            <translation>&amp;Help</translation>
+        </message>
+        <message>
+            <source>LOAD_TEXTURE_TLT</source>
+            <translation>Load Texture</translation>
+        </message>
+    </context>
 </TS>
index 5e88b7c2cd2b949aca768ae15cbb8e7953478797..85c12198389138e627d325b78cf240a1f0fc1ce0 100644 (file)
@@ -382,6 +382,7 @@ void GeometryGUI::OnGUIEvent( int id )
       id == 8036 ||  // POPUP VIEWER - DISABLE AUTO COLOR
       id == 8037 ||  // POPUP VIEWER - SHOW CHILDREN
       id == 8038 ||  // POPUP VIEWER - HIDE CHILDREN
+      id == 8039 ||  // POPUP VIEWER - POINT MARKER
       id == 804  ||  // POPUP VIEWER - ADD IN STUDY
       id == 901  ||  // OBJECT BROWSER - RENAME
       id == 9024 ) { // OBJECT BROWSER - OPEN
@@ -904,6 +905,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 8001, "POP_CREATE_GROUP" );
   createGeomAction( 8037, "POP_SHOW_CHILDREN" );
   createGeomAction( 8038, "POP_HIDE_CHILDREN" );
+  createGeomAction( 8039, "POP_POINT_MARKER" );
 
   // make wireframe-shading items to be exclusive (only one at a time is selected)
   //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
@@ -1171,6 +1173,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
   mgr->insert( action(  8034 ), -1, -1 ); // isos
   mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
+  mgr->insert( action(  8039 ), -1, -1 ); // point marker
+  mgr->setRule( action( 8039 ), QString( "selcount>0 and $typeid in {%1}" ).arg( GEOM_POINT ), QtxPopupMgr::VisibleRule );
   mgr->insert( separator(), -1, -1 );     // -----------
   mgr->insert( action(  8035 ), -1, -1 ); // auto color
   mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
@@ -1463,7 +1467,7 @@ QString GeometryGUI::engineIOR() const
   return "";
 }
 
-Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTextureAspect( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
+Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
 {
   theWidth = theHeight = 0;
   Handle(Graphic3d_HArray1OfBytes) aTexture;
@@ -1569,7 +1573,7 @@ void GeometryGUI::createPreferences()
                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
 
   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
-                                   LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
+                                   LightApp_Preferences::Selector, "Geometry", "marker_scale" );
 
   // Set property for default display mode
   QStringList aModesList;
@@ -1588,38 +1592,32 @@ void GeometryGUI::createPreferences()
   setPreferenceProperty( step, "max", 10000 );
   setPreferenceProperty( step, "precision", 3 );
 
-  // Set property for type of vertex marker
-  QList<QVariant> anTypeOfMarkerIndexesList;
-  QList<QVariant> anTypeOfMarkerIconsList;
-
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
-  anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
-
-  // Create icons list
+  // Set property vertex marker type
+  QList<QVariant> aMarkerTypeIndicesList;
+  QList<QVariant> aMarkerTypeIconsList;
+
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  for (int i = 1; i<=9; i++) {
-    QString str = "ICON_VERTEX_MARKER_";
-    str.append( QString::number(i) );
-    QPixmap pixmap (resMgr->loadPixmap("GEOM", tr( str.toLatin1().data() )));
-    anTypeOfMarkerIconsList.append(pixmap);
+  for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
+    QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
+    QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
+    aMarkerTypeIndicesList << (i-1);
+    aMarkerTypeIconsList << pixmap;
   }
 
-  setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
-  setPreferenceProperty( typeOfMarker, "icons", anTypeOfMarkerIconsList );
+  setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
+  setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
+
+  // Set property for vertex marker scale
+  QList<QVariant> aMarkerScaleIndicesList;
+  QStringList     aMarkerScaleValuesList;
 
-  // Set property for Vertex Marker scale
-  setPreferenceProperty( markerScale, "min", 1. );
-  setPreferenceProperty( markerScale, "max", 7. );
-  setPreferenceProperty( markerScale, "precision", 0.01 );
-  setPreferenceProperty( markerScale, "step", 0.5 );
+  for ( int i = GEOM::MS_10; i <= GEOM::MS_70; i++ ) {
+    aMarkerScaleIndicesList << i;
+    aMarkerScaleValuesList  << QString::number( (i-(int)GEOM::MS_10)*0.5 + 1.0 );
+  }
 
+  setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
+  setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
 }
 
 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
index 67a793b7ec3a49c5294234339a33b32ebb6ebac9..2cbd9d1dd4da1c1c461239c4cfd807ee982a26c9 100644 (file)
@@ -76,7 +76,7 @@ public:
   virtual void                initialize( CAM_Application* );
   virtual QString             engineIOR() const;
 
-  static Handle(Graphic3d_HArray1OfBytes) getTextureAspect( SalomeApp_Study*, int, int&, int& );
+  static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
 
   static bool                 InitGeomGen();   //BugID IPAL9186: SRN: To be called by Python scripts