mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-14 09:38:34 +05:00
0023552: Unable to use the contextual menu of Object Browser window
- Another attempt to solve problem with materials sub-menu on desktops like Unity, KDE Plasma etc.
This commit is contained in:
parent
37d3fe3ec7
commit
6b9325db8c
@ -206,6 +206,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
|
|||||||
v = hasHiddenAnnotations(idx);
|
v = hasHiddenAnnotations(idx);
|
||||||
else if ( p == "hasVisibleAnnotations" )
|
else if ( p == "hasVisibleAnnotations" )
|
||||||
v = hasVisibleAnnotations(idx);
|
v = hasVisibleAnnotations(idx);
|
||||||
|
else if ( p == "matMenu" )
|
||||||
|
v = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials", false );
|
||||||
else
|
else
|
||||||
v = LightApp_Selection::parameter( idx, p );
|
v = LightApp_Selection::parameter( idx, p );
|
||||||
|
|
||||||
@ -392,7 +394,7 @@ QString GEOMGUI_Selection::displayMode( const int index ) const
|
|||||||
|
|
||||||
bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const
|
bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const
|
||||||
{
|
{
|
||||||
return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
|
return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", false );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GEOMGUI_Selection::isVectorsMode( const int index ) const
|
bool GEOMGUI_Selection::isVectorsMode( const int index ) const
|
||||||
|
@ -535,8 +535,9 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
|||||||
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
|
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
|
||||||
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
|
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
|
||||||
case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
|
case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
|
||||||
case GEOMOp::OpPredefMaterial: // POPUP MENU - <SOME MATERIAL>
|
case GEOMOp::OpMaterialMenu: // POPUP MENU - MATERIAL PROPERTIES (sub-menu)
|
||||||
case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
|
case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - <SOME MATERIAL>
|
||||||
|
case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - CUSTOM...
|
||||||
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::OpBringToFront: // POPUP MENU - BRING TO FRONT
|
||||||
@ -1151,6 +1152,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
|
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
|
||||||
createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
|
createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
|
||||||
createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
|
createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
|
||||||
|
createGeomAction( GEOMOp::OpMaterialMenu, "POP_MATERIAL_PROPERTIES");
|
||||||
|
action(GEOMOp::OpMaterialMenu)->setMenu( new QMenu() );
|
||||||
createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
|
createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
|
||||||
createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
|
createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
|
||||||
#ifndef DISABLE_GRAPHICSVIEW
|
#ifndef DISABLE_GRAPHICSVIEW
|
||||||
@ -1612,7 +1615,9 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
|
|
||||||
// material properties
|
// material properties
|
||||||
mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
|
mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
|
||||||
mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and matMenu=false", QtxPopupMgr::VisibleRule );
|
||||||
|
mgr->insert( action( GEOMOp::OpMaterialMenu ), -1, -1 );
|
||||||
|
mgr->setRule( action( GEOMOp::OpMaterialMenu ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and matMenu=true", QtxPopupMgr::VisibleRule );
|
||||||
|
|
||||||
// texture
|
// texture
|
||||||
mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
|
mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
|
||||||
@ -2248,26 +2253,12 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString&
|
|||||||
SALOME_ListIO lst;
|
SALOME_ListIO lst;
|
||||||
getApp()->selectionMgr()->selectedObjects( lst );
|
getApp()->selectionMgr()->selectedObjects( lst );
|
||||||
|
|
||||||
//Add submenu for predefined materials
|
// Update submenu for predefined materials
|
||||||
// RNV: '#23552: Unable to use the contextual menu of Object Browser window' issue:
|
|
||||||
// Temporary solution: do not show 'Materials' submenu forcibly
|
|
||||||
//bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
|
|
||||||
bool isPredefMat = false;
|
|
||||||
|
|
||||||
if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
|
if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
|
||||||
QtxPopupMgr* mgr = popupMgr();
|
QMenu* matMenu = action( GEOMOp::OpMaterialMenu )->menu();
|
||||||
//get parent for submenu
|
matMenu->clear();
|
||||||
QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) );
|
QSignalMapper* signalMapper = new QSignalMapper( menu );
|
||||||
//Clear old menu
|
|
||||||
QMenu* oldMenu = act->menu() ;
|
|
||||||
if( oldMenu ) {
|
|
||||||
delete oldMenu;
|
|
||||||
}
|
|
||||||
if( isPredefMat ){
|
|
||||||
QMenu* matMenu = new QMenu();
|
|
||||||
QSignalMapper* signalMapper = new QSignalMapper( matMenu );
|
|
||||||
|
|
||||||
//Get current material model for the object
|
|
||||||
QVariant v;
|
QVariant v;
|
||||||
LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
|
LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
|
||||||
if ( anApp && anApp->activeViewManager() ) {
|
if ( anApp && anApp->activeViewManager() ) {
|
||||||
@ -2278,29 +2269,28 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString&
|
|||||||
}
|
}
|
||||||
QString curModel = "";
|
QString curModel = "";
|
||||||
if ( v.canConvert<QString>() ) curModel = v.toString();
|
if ( v.canConvert<QString>() ) curModel = v.toString();
|
||||||
|
|
||||||
// get list of all predefined materials
|
// get list of all predefined materials
|
||||||
QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
|
QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach ( QString material, materials )
|
foreach ( QString material, materials )
|
||||||
{
|
{
|
||||||
QAction* menAct = matMenu->addAction( material );
|
QAction* a = matMenu->addAction( material );
|
||||||
connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
|
connect( a, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
|
||||||
signalMapper->setMapping( menAct, material );
|
signalMapper->setMapping( a, material );
|
||||||
menAct->setCheckable( true );
|
a->setCheckable( true );
|
||||||
// Set checked if this material is current
|
|
||||||
Material_Model aModel;
|
Material_Model aModel;
|
||||||
aModel.fromResources( material );
|
aModel.fromResources( material );
|
||||||
if ( !found && aModel.toProperties() == curModel ) {
|
if ( !found && aModel.toProperties() == curModel ) {
|
||||||
menAct->setChecked( true );
|
a->setChecked( true );
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) );
|
matMenu->addSeparator();
|
||||||
matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) );
|
matMenu->addAction( action( GEOMOp::OpPredefMaterCustom ) );
|
||||||
connect( signalMapper, SIGNAL( mapped( const QString & ) ),
|
connect( signalMapper, SIGNAL( mapped( const QString & ) ),
|
||||||
this, SLOT( OnSetMaterial( const QString & ) ) );
|
this, SLOT( OnSetMaterial( const QString & ) ) );
|
||||||
act->setMenu( matMenu );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//Set name
|
//Set name
|
||||||
if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
|
if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
|
||||||
@ -2373,9 +2363,8 @@ void GeometryGUI::createPreferences()
|
|||||||
int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
|
int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
|
||||||
LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
|
LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
|
||||||
|
|
||||||
// RNV: Temporary hide this preference, because of the '#23552: Unable to use the contextual menu of Object Browser window' issue
|
addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
|
||||||
//addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
|
LightApp_Preferences::Bool, "Geometry", "predef_materials" );
|
||||||
// LightApp_Preferences::Bool, "Geometry", "predef_materials" );
|
|
||||||
|
|
||||||
int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
|
int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
|
||||||
LightApp_Preferences::Selector,
|
LightApp_Preferences::Selector,
|
||||||
|
@ -51,8 +51,9 @@ namespace GEOMOp {
|
|||||||
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
||||||
OpSetTexture = 1211, // POPUP MENU - SETTEXTURE
|
OpSetTexture = 1211, // POPUP MENU - SETTEXTURE
|
||||||
OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES
|
OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES
|
||||||
OpPredefMaterial = 1213, // POPUP MENU - MATERIAL PROPERTIES - <SOME MATERIAL>
|
OpMaterialMenu = 1213, // POPUP MENU - MATERIAL PROPERTIES (sub-menu)
|
||||||
OpPredefMaterCustom = 1214, // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
|
OpPredefMaterial = 1214, // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - <SOME MATERIAL>
|
||||||
|
OpPredefMaterCustom = 1215, // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - CUSTOM...
|
||||||
OpDiscloseChildren = 1250, // POPUP MENU - DISCLOSE CHILD ITEMS
|
OpDiscloseChildren = 1250, // POPUP MENU - DISCLOSE CHILD ITEMS
|
||||||
OpConcealChildren = 1251, // POPUP MENU - CONCEAL CHILD ITEMS
|
OpConcealChildren = 1251, // POPUP MENU - CONCEAL CHILD ITEMS
|
||||||
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
||||||
|
Loading…
Reference in New Issue
Block a user