From: vsr Date: Mon, 9 Nov 2009 11:42:50 +0000 (+0000) Subject: 0020012: EDF 831 GEOM : API for points representation in 3D viewer X-Git-Tag: V5_1_3rc2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f341d9035fd7fd29c04def52acd439ce9d36886c;p=modules%2Fgeom.git 0020012: EDF 831 GEOM : API for points representation in 3D viewer --- diff --git a/resources/marker_1.png b/resources/marker_1.png index f0d21091d..8bbaa854e 100755 Binary files a/resources/marker_1.png and b/resources/marker_1.png differ diff --git a/resources/marker_2.png b/resources/marker_2.png index 8bbaa854e..f0d21091d 100755 Binary files a/resources/marker_2.png and b/resources/marker_2.png differ diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index f17dfceeb..a3e9d133b 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -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 ); diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index d6b4dabf0..bb8d0aaab 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -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; diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 435419768..e8c6128fc 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -89,6 +89,7 @@ #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include +#include 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, diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 748ecd84f..94257fbd4 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -665,6 +665,22 @@ ICON_VERTEX_MARKER_9 marker_9.png + + ICON_VERTEX_MARKER_10 + marker_10.png + + + ICON_VERTEX_MARKER_11 + marker_11.png + + + ICON_VERTEX_MARKER_12 + marker_12.png + + + ICON_VERTEX_MARKER_13 + marker_13.png + ICO_ARC arc.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index ed1f7a99e..0764dd852 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -2551,6 +2551,10 @@ Please, select face, shell or solid and try again MEN_WORK_PLANE Working Plane + + MEN_POP_POINT_MARKER + Point Marker + NAME_LBL Name: @@ -3051,6 +3055,10 @@ Please, select face, shell or solid and try again STB_WORK_PLANE Create a working plane + + STB_POP_POINT_MARKER + Set Point Marker + SUPPRESS_RESULT Suppress Result @@ -3511,6 +3519,10 @@ Please, select face, shell or solid and try again TOP_WORK_PLANE Create a working plane + + TOP_POP_POINT_MARKER + Point Marker + WRN_NOT_IMPLEMENTED Sorry, this functionality is not yet implemented @@ -4265,4 +4277,51 @@ Would you like to continue? Delete objects + + GEOMToolsGUI_MarkerDlg + + SET_MARKER_TLT + Set Point Marker + + + STANDARD_MARKER + Standard + + + CUSTOM_MARKER + Custom + + + TYPE + Type: + + + SCALE + Scale: + + + CUSTOM + Texture: + + + BROWSE + Browse... + + + OK_BTN + &OK + + + CANCEL_BTN + &Cancel + + + HELP_BTN + &Help + + + LOAD_TEXTURE_TLT + Load Texture + + diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 5e88b7c2c..85c121983 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -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 anTypeOfMarkerIndexesList; - QList 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 aMarkerTypeIndicesList; + QList 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 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 ) diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 67a793b7e..2cbd9d1dd 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -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