Implementation of the "0021239: EDF 1829 OCC: Bring to front selected objects" issue.

This commit is contained in:
rnv 2012-03-13 08:41:21 +00:00
parent 8afd587dc9
commit 2981cca5dd
19 changed files with 333 additions and 28 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -0,0 +1,10 @@
/*!
\page bring_to_front_page Bring To Front
\n This option is relevant for better viewing of the complex 3D models.
This item allow to bring to front of viewer selected geometrical object.
\image html bring_example.png
*/

View File

@ -21,6 +21,10 @@ object.</li>
viewer and from the Object Browser.</li> viewer and from the Object Browser.</li>
<li>\subpage display_mode_page "Display Mode" - allows to select between <li>\subpage display_mode_page "Display Mode" - allows to select between
Wireframe and Shading presentation.</li> Wireframe and Shading presentation.</li>
<li>\subpage bring_to_front_page "Bring To Front" - allows to bring to
front of the viewer selected geometrical object.</li>
<li><b>Clear Top Level State</b> - allows to remove from foregroung of the viewer
geometrical objects which were added there via <b>Bring To Front</b> command.</li>
<li>\subpage color_page "Color" - allows to change the filling color in <li>\subpage color_page "Color" - allows to change the filling color in
the standard <b>Select Color</b> menu.</li> the standard <b>Select Color</b> menu.</li>
<li>\subpage transparency_page "Transparency" - allows to change the <li>\subpage transparency_page "Transparency" - allows to change the

View File

@ -49,6 +49,7 @@
<parameter name="line_color" value="255, 0, 0" /> <parameter name="line_color" value="255, 0, 0" />
<parameter name="point_color" value="255, 255, 0" /> <parameter name="point_color" value="255, 255, 0" />
<parameter name="isos_color" value="200, 200, 200" /> <parameter name="isos_color" value="200, 200, 200" />
<parameter name="toplevel_color" value="170, 85, 0" />
<parameter name="type_of_marker" value="1" /> <parameter name="type_of_marker" value="1" />
<parameter name="deflection_coeff" value="0.001" /> <parameter name="deflection_coeff" value="0.001" />
<parameter name="auto_create_base_objects" value="false" /> <parameter name="auto_create_base_objects" value="false" />

View File

@ -149,6 +149,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
v = isAutoColor( idx ); v = isAutoColor( idx );
else if ( p == "isVectorsMode" ) else if ( p == "isVectorsMode" )
v = isVectorsMode( idx ); v = isVectorsMode( idx );
else if ( p == "topLevel" )
v = topLevel( idx );
else if ( p == "hasHiddenChildren" ) else if ( p == "hasHiddenChildren" )
v = hasHiddenChildren( idx ); v = hasHiddenChildren( idx );
else if ( p == "hasShownChildren" ) else if ( p == "hasShownChildren" )
@ -512,3 +514,40 @@ QString GEOMGUI_Selection::selectionMode() const
} }
return ""; return "";
} }
bool GEOMGUI_Selection::topLevel( const int index ) const {
bool res = false;
#ifdef USE_VISUAL_PROP_MAP
bool found = false;
QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP );
if ( v.canConvert<bool>() ) {
res = v.toBool();
found = true;
}
if ( !found ) {
#endif
SALOME_View* view = GEOM_Displayer::GetActiveView();
QString viewType = activeViewType();
if ( view && viewType == OCCViewer_Viewer::Type() ) {
SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
AIS_ListOfInteractive lst;
occPrs->GetObjects( lst );
if ( lst.Extent() ) {
Handle(AIS_InteractiveObject) io = lst.First();
if ( !io.IsNull() ) {
Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
if ( !aSh.IsNull() )
res = (bool)aSh->isTopLevel();
}
}
}
}
}
}
return res;
}

View File

@ -69,6 +69,7 @@ private:
bool hasHiddenChildren( const int ) const; bool hasHiddenChildren( const int ) const;
bool hasShownChildren( const int ) const; bool hasShownChildren( const int ) const;
bool compoundOfVertices( const int ) const; bool compoundOfVertices( const int ) const;
bool topLevel( const int ) const;
bool isComponent( const int ) const; bool isComponent( const int ) const;
GEOM::GEOM_Object_ptr getObject( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const;

View File

@ -666,15 +666,18 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() ); AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt()); AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
//Color property if(aPropMap.contains(TOP_LEVEL_PROP)) {
if(aPropMap.contains(COLOR_PROP)) { AISShape->setTopLevel( aPropMap.value(TOP_LEVEL_PROP).value<Standard_Boolean>() );
}
if(aPropMap.contains(COLOR_PROP)) {
Quantity_Color quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>()); Quantity_Color quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
AISShape->SetShadingColor( quant_col ); AISShape->SetShadingColor( quant_col );
} else } else
useObjColor = true; useObjColor = true;
}else { }else {
MESSAGE("myDisplayMode = "<< myDisplayMode) MESSAGE("myDisplayMode = "<< myDisplayMode)
AISShape->SetDisplayMode( myDisplayMode ); AISShape->SetDisplayMode( myDisplayMode );
AISShape->SetShadingColor( myShadingColor ); AISShape->SetShadingColor( myShadingColor );
} }
@ -899,7 +902,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
anAspect->SetTypeOfMarker( myTypeOfMarker ); anAspect->SetTypeOfMarker( myTypeOfMarker );
AISShape->Attributes()->SetPointAspect( anAspect ); AISShape->Attributes()->SetPointAspect( anAspect );
} }
} else if(!hasColor) { } else if( !hasColor ) {
//In case if color wasn't defined in the property map of the object //In case if color wasn't defined in the property map of the object
//and GEOM_Object color also wasn't defined get default color from Resource Mgr. //and GEOM_Object color also wasn't defined get default color from Resource Mgr.
QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ); QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
@ -2025,6 +2028,10 @@ PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
//11. Width of iso-lines //11. Width of iso-lines
aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1)); aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
if(viewer_type == SOCC_Viewer::Type()) {
aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False);
}
return aDefaultMap; return aDefaultMap;
} }

View File

@ -2363,6 +2363,30 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_DISPLAY_ONLY</source> <source>MEN_DISPLAY_ONLY</source>
<translation>Show Only</translation> <translation>Show Only</translation>
</message> </message>
<message>
<source>MEN_BRING_TO_FRONT</source>
<translation>Bring To Front</translation>
</message>
<message>
<source>TOP_BRING_TO_FRONT</source>
<translation>Bring To Front</translation>
</message>
<message>
<source>STB_BRING_TO_FRONT</source>
<translation>Bring To Front</translation>
</message>
<message>
<source>MEN_CLS_BRING_TO_FRONT</source>
<translation>Clear Top Level State</translation>
</message>
<message>
<source>TOP_CLS_BRING_TO_FRONT</source>
<translation>Clear Top Level State</translation>
</message>
<message>
<source>STB_CLS_BRING_TO_FRONT</source>
<translation>Clear Top Level State</translation>
</message>
<message> <message>
<source>MEN_EDGE</source> <source>MEN_EDGE</source>
<translation>Edge</translation> <translation>Edge</translation>
@ -2935,6 +2959,10 @@ Please, select face, shell or solid and try again</translation>
<source>PREF_ISOS_COLOR</source> <source>PREF_ISOS_COLOR</source>
<translation>Color of isolines</translation> <translation>Color of isolines</translation>
</message> </message>
<message>
<source>PREF_TOPLEVEL_COLOR</source>
<translation>Top level color</translation>
</message>
<message> <message>
<source>PREF_LINE_COLOR</source> <source>PREF_LINE_COLOR</source>
<translation>Color of edges, vectors, wires</translation> <translation>Color of edges, vectors, wires</translation>

View File

@ -426,6 +426,8 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
case GEOMOp::OpClsBringToFront: //
libName = "GEOMToolsGUI"; libName = "GEOMToolsGUI";
break; break;
case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
@ -844,6 +846,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true ); createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true ); createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" ); createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
createGeomAction( GEOMOp::OpHide, "ERASE" ); createGeomAction( GEOMOp::OpHide, "ERASE" );
createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true ); createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
@ -1216,6 +1220,17 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
#if OCC_VERSION_LARGE > 0x06050200
//QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true";
mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule );
mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );
#endif
mgr->insert( separator(), -1, -1 ); // -----------
dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
@ -1308,7 +1323,6 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule); mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule ); mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
@ -1693,6 +1707,12 @@ void GeometryGUI::createPreferences()
addPreference( tr( "PREF_ISOS_COLOR" ), genGroup, addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
LightApp_Preferences::Color, "Geometry", "isos_color" ); LightApp_Preferences::Color, "Geometry", "isos_color" );
addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
LightApp_Preferences::Color, "Geometry", "toplevel_color" );
addPreference( "", genGroup, LightApp_Preferences::Space );
int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
@ -1964,6 +1984,13 @@ void GeometryGUI::storeVisualParameters (int savePoint)
param = occParam + TRANSPARENCY_PROP; param = occParam + TRANSPARENCY_PROP;
ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
} }
if(aProps.contains(TOP_LEVEL_PROP)) {
param = occParam + TOP_LEVEL_PROP;
Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value<Standard_Boolean>();
if (val == Standard_True)
ip->setParameter(entry, param, "1");
}
} }
if(aProps.contains(ISOS_PROP)) { if(aProps.contains(ISOS_PROP)) {
@ -2092,8 +2119,11 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
} else if(paramNameStr == OPACITY_PROP) { } else if(paramNameStr == OPACITY_PROP) {
aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble()); aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
} else if(paramNameStr == TRANSPARENCY_PROP) { } else if(paramNameStr == TRANSPARENCY_PROP) {
aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble()); aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val.toDouble() );
} else if(paramNameStr == TOP_LEVEL_PROP) {
aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False );
} else if(paramNameStr == DISPLAY_MODE_PROP) { } else if(paramNameStr == DISPLAY_MODE_PROP) {
aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt()); aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
@ -2179,6 +2209,15 @@ void GeometryGUI::onViewAboutToShow()
} }
} }
/*!
\brief Return action by id
\param id identifier of the action
\return action
*/
QAction* GeometryGUI::getAction(const int id) {
return action(id);
}
/*! /*!
\brief Check if this object is can't be renamed in place \brief Check if this object is can't be renamed in place

View File

@ -56,6 +56,7 @@
class QDialog; class QDialog;
class QMenu; class QMenu;
class QAction;
class GEOMGUI_OCCSelector; class GEOMGUI_OCCSelector;
class LightApp_VTKSelector; class LightApp_VTKSelector;
class LightApp_Selection; class LightApp_Selection;
@ -131,6 +132,8 @@ public:
virtual void storeVisualParameters (int savePoint); virtual void storeVisualParameters (int savePoint);
virtual void restoreVisualParameters(int savePoint); virtual void restoreVisualParameters(int savePoint);
QAction* getAction(const int id);
public slots: public slots:
virtual bool deactivateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* );
virtual bool activateModule( SUIT_Study* ); virtual bool activateModule( SUIT_Study* );

View File

@ -70,6 +70,8 @@ namespace GEOMOp {
OpShadingWithEdges = 2202, // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES OpShadingWithEdges = 2202, // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
OpVectors = 2203, // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION OpVectors = 2203, // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE
OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT
OpClsBringToFront = 2206,
// BasicGUI ------------------//-------------------------------- // BasicGUI ------------------//--------------------------------
OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT
OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE

View File

@ -373,6 +373,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
case GEOMOp::OpIsosWidth: case GEOMOp::OpIsosWidth:
OnIsosWidth(); OnIsosWidth();
break; break;
case GEOMOp::OpBringToFront:
OnBringToFront();
break;
case GEOMOp::OpClsBringToFront:
OnClsBringToFront();
break;
default: default:
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
break; break;

View File

@ -78,6 +78,8 @@ private:
void OnMaterialProperties(); void OnMaterialProperties();
void OnEdgeWidth(); void OnEdgeWidth();
void OnIsosWidth(); void OnIsosWidth();
void OnBringToFront();
void OnClsBringToFront();
// Shortcut commands // Shortcut commands
void OnChangeTransparency( bool ); void OnChangeTransparency( bool );

View File

@ -23,6 +23,8 @@
// File : GEOMToolsGUI_1.cxx // File : GEOMToolsGUI_1.cxx
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
#define protected public
#include <PyConsole_Console.h> #include <PyConsole_Console.h>
#include "GEOMToolsGUI.h" #include "GEOMToolsGUI.h"
@ -81,6 +83,9 @@
#include <Prs3d_PointAspect.hxx> #include <Prs3d_PointAspect.hxx>
#include <Graphic3d_AspectMarker3d.hxx> #include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Graphic3d_AspectLine3d.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
#include <TColStd_HArray1OfByte.hxx> #include <TColStd_HArray1OfByte.hxx>
@ -89,6 +94,7 @@
#endif #endif
// QT Includes // QT Includes
#include <QAction>
#include <QColorDialog> #include <QColorDialog>
#include <QInputDialog> #include <QInputDialog>
#include <QFileDialog> #include <QFileDialog>
@ -103,7 +109,6 @@
// VTK includes // VTK includes
#include <vtkRenderer.h> #include <vtkRenderer.h>
void GEOMToolsGUI::OnCheckGeometry() void GEOMToolsGUI::OnCheckGeometry()
{ {
SalomeApp_Application* app = SalomeApp_Application* app =
@ -296,13 +301,17 @@ void GEOMToolsGUI::OnColor()
} }
} // if ( isVTK ) } // if ( isVTK )
else if ( isOCC ) { else if ( isOCC ) {
Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() ); Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
if ( !io.IsNull() ) { if ( !io.IsNull() ) {
Quantity_Color aColor; Quantity_Color aColor;
io->Color( aColor ); io->Color( aColor );
QColor initcolor ((int)( aColor.Red() * 255.0 ), QColor ic = QColor((int )( aColor.Red() * 255.0 ),
(int)( aColor.Green() * 255.0 ), (int)( aColor.Green() * 255.0 ),
(int)( aColor.Blue() * 255.0 )); (int)( aColor.Blue() * 255.0 ));
QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic);
QColor initcolor = v.value<QColor>();
QColor c = QColorDialog::getColor( initcolor, app->desktop() ); QColor c = QColorDialog::getColor( initcolor, app->desktop() );
if ( c.isValid() ) { if ( c.isValid() ) {
SUIT_OverrideCursor(); SUIT_OverrideCursor();
@ -406,8 +415,8 @@ void GEOMToolsGUI::OnTexture()
io = GEOMBase::GetAIS( It.Value(), true ); io = GEOMBase::GetAIS( It.Value(), true );
if ( !io.IsNull() ) { if ( !io.IsNull() ) {
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str())); Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
io->Redisplay( Standard_True ); io->Redisplay( Standard_True );
} // if ( !io.IsNull() ) } // if ( !io.IsNull() )
} // for } // for
ic->UpdateCurrentViewer(); ic->UpdateCurrentViewer();
@ -1187,3 +1196,112 @@ void GEOMToolsGUI::OnIsosWidth() {
GeometryGUI::Modified(); GeometryGUI::Modified();
} // end vtkviewer } // end vtkviewer
} }
void GEOMToolsGUI::OnBringToFront() {
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app )
return;
SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
if(!mod)
return;
GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
if(!disp)
return;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr )
return;
SALOME_ListIO selected;
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() )
return;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
if(!appStudy)
return;
SUIT_ViewWindow* window = app->desktop()->activeWindow();
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
if ( !vm )
return;
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
QAction* a = getGeometryGUI()->action( GEOMOp::OpBringToFront );
bool checked = a->isChecked();
if ( isOCC ) {
GEOMBase* gb = new GEOMBase();
Handle(GEOM_AISShape) aisShape;
Handle(AIS_InteractiveContext) ic = vm->getAISContext();
SALOME_ListIO anIOlst;
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
if ( !aisShape.IsNull() ) {
aisShape->setTopLevel(checked);
int aMgrId = window->getViewManager()->getGlobalId();
appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
anIOlst.Append(aisShape->getIO());
}
} // for...
disp->Redisplay(anIOlst);
GeometryGUI::Modified();
} // if ( isOCC )
}
void GEOMToolsGUI::OnClsBringToFront() {
SalomeApp_Application* app =
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if(!app)
return;
SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
if(!mod)
return;
GEOM_Displayer* disp = dynamic_cast<GEOM_Displayer*>(mod->displayer());
if(!disp)
return;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
if(!appStudy)
return;
SUIT_ViewWindow* window = app->desktop()->activeWindow();
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
if(isOCC){ // if is OCCViewer
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
SALOME_ListIO anIOlst;
AIS_ListOfInteractive aList;
ic->DisplayedObjects( aList );
for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(it.Value());
if(CurObject.IsNull())
continue;
CurObject->setTopLevel(Standard_False);
int aMgrId = window->getViewManager()->getGlobalId();
appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
anIOlst.Append(CurObject->getIO());
}
disp->Redisplay(anIOlst);
GeometryGUI::Modified();
}
}

View File

@ -72,6 +72,11 @@
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <SalomeApp_Tools.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj, static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
const Handle(AIS_InteractiveContext)& theIC, const Handle(AIS_InteractiveContext)& theIC,
@ -139,6 +144,8 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
myUIsoNumber = -1; myUIsoNumber = -1;
myVIsoNumber = -1; myVIsoNumber = -1;
myTopLevel = Standard_False;
} }
void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){ void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
@ -175,16 +182,29 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
{ {
if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
// StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode; Handle(AIS_InteractiveContext) anIC = GetContext();
// StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
switch (aMode) { switch (aMode) {
case 0://StdSelect_DM_Wireframe: case 0://StdSelect_DM_Wireframe:
{ {
restoreIsoNumbers(); restoreIsoNumbers();
// Restore wireframe edges colors // Restore wireframe edges colors
restoreBoundaryColors(); restoreBoundaryColors();
if(isTopLevel()) {
SetColor(topLevelColor());
Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect();
anAspect->SetColor( topLevelColor() );
Attributes()->SetWireAspect( anAspect );
}
StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
break; break;
} }
case 1://StdSelect_DM_Shading: case 1://StdSelect_DM_Shading:
@ -200,7 +220,10 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
} }
case 3: //StdSelect_DM_HLR: case 3: //StdSelect_DM_HLR:
{ {
AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode); if(!isTopLevel())
AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
else
shadingMode(aPresentationManager, aPrs, AIS_Shaded);
break; break;
} }
} }
@ -373,7 +396,7 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
// P->SetPrimitivesAspect(a4bis); // P->SetPrimitivesAspect(a4bis);
// G->SetGroupPrimitivesAspect(a4bis); // G->SetGroupPrimitivesAspect(a4bis);
//a4bis->SetInteriorColor(myShadingColor); //a4bis->SetInteriorColor(myShadingColor);
myDrawer->ShadingAspect()->SetColor(myShadingColor); myDrawer->ShadingAspect()->SetColor(isTopLevel() ? topLevelColor() : myShadingColor);
// PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
//StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
@ -433,3 +456,19 @@ void GEOM_AISShape::restoreBoundaryColors()
anAspect->SetColor( myUnFreeBoundaryColor ); anAspect->SetColor( myUnFreeBoundaryColor );
myDrawer->SetUnFreeBoundaryAspect( anAspect ); myDrawer->SetUnFreeBoundaryAspect( anAspect );
} }
Standard_Boolean GEOM_AISShape::isTopLevel() {
return myTopLevel;
}
void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
myTopLevel = f;
}
Quantity_Color GEOM_AISShape::topLevelColor() {
SUIT_Session* session = SUIT_Session::session();
SUIT_ResourceMgr* resMgr = session->resourceMgr();
QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
return SalomeApp_Tools::color(c);
}

View File

@ -99,6 +99,8 @@ public:
void setIO(const Handle(SALOME_InteractiveObject)& name) ; void setIO(const Handle(SALOME_InteractiveObject)& name) ;
void setName(const Standard_CString aName) ; void setName(const Standard_CString aName) ;
Standard_CString getName() ; Standard_CString getName() ;
Standard_Boolean isTopLevel();
void setTopLevel(Standard_Boolean);
Handle_SALOME_InteractiveObject getIO() ; Handle_SALOME_InteractiveObject getIO() ;
void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight );
~GEOM_AISShape(); ~GEOM_AISShape();
@ -126,6 +128,8 @@ public:
void storeBoundaryColors(); void storeBoundaryColors();
static Quantity_Color topLevelColor();
protected: protected:
void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPrs, const Handle(Prs3d_Presentation)& aPrs,
@ -146,6 +150,7 @@ protected:
private: private:
TCollection_AsciiString myName; TCollection_AsciiString myName;
bool myDisplayVectors; bool myDisplayVectors;
Standard_Boolean myTopLevel;
}; };

View File

@ -1012,7 +1012,7 @@ void GEOM_Actor::SetIsosWidth(const int width) {
} }
int GEOM_Actor::GetIsosWidth() const { int GEOM_Actor::GetIsosWidth() const {
return myWireframeFaceActor->GetProperty()->GetLineWidth(); return (int)myWireframeFaceActor->GetProperty()->GetLineWidth();
} }
void GEOM_Actor::SetWidth(const int width) { void GEOM_Actor::SetWidth(const int width) {
@ -1025,7 +1025,7 @@ void GEOM_Actor::SetWidth(const int width) {
} }
int GEOM_Actor::GetWidth() const { int GEOM_Actor::GetWidth() const {
return myIsolatedEdgeActor->GetProperty()->GetLineWidth(); return (int)myIsolatedEdgeActor->GetProperty()->GetLineWidth();
} }
void GEOM_Actor::RestoreIsoNumbers() void GEOM_Actor::RestoreIsoNumbers()

View File

@ -47,5 +47,6 @@
#define BACK_MATERIAL_PROP "BackMaterial" //Object back material property #define BACK_MATERIAL_PROP "BackMaterial" //Object back material property
#define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge #define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge
#define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines #define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines
#define TOP_LEVEL_PROP "TopLevelFlag" //Top level flag
#endif //GEOM_CONSTANTS_H #endif //GEOM_CONSTANTS_H