mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 01:58:36 +05:00
Implementation of the "16219: EDF PAL 469: "RemoveFromStudy" Function" issue.
This commit is contained in:
parent
d927c2370b
commit
ae3549a5e4
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 15 KiB |
BIN
doc/salome/gui/GEOM/images/publish_dlg.png
Executable file
BIN
doc/salome/gui/GEOM/images/publish_dlg.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
@ -74,9 +74,17 @@ under certain conditions:
|
||||
<ul>
|
||||
<li>\subpage work_with_groups_page "Create Group" - allows creating groups of geometrical objects.</li>
|
||||
<li><b>Hide Children</b> / <b>Show Children</b> - hides / shows child
|
||||
sub-objects in the Object Browser, if the selected geometr object has
|
||||
sub-objects in the Object Browser, if the selected geometric object has
|
||||
child objects. When some child objects are hidden, the name of the
|
||||
parent object is hilghlighted with bold font.</li>
|
||||
|
||||
<li><b>Unpublish</b> - unpublish the selected geometric object from the Object Browser
|
||||
and erase it from all viewers. To publish unpublished geometric objects select in the
|
||||
context menu of the <b>Geometry</b> root object <b>Publish...</b> item.
|
||||
The following dialog box will appear</li>
|
||||
</ul>
|
||||
|
||||
\image html publish_dlg.png <br>
|
||||
|
||||
Switch the checkbox near the appropriate object and click <b>Publish</b> or <b>Publish And Close</b> button.
|
||||
*/
|
||||
|
@ -48,9 +48,11 @@
|
||||
#include <SUIT_ViewManager.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
|
||||
|
||||
#include <SalomeApp_Study.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <LightApp_SelectionMgr.h>
|
||||
#include <LightApp_DataObject.h>
|
||||
#include <SalomeApp_TypeFilter.h>
|
||||
#include <SalomeApp_Tools.h>
|
||||
|
||||
@ -1816,3 +1818,56 @@ SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bo
|
||||
}
|
||||
return aSColor;
|
||||
}
|
||||
|
||||
|
||||
void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
|
||||
const bool eraseOnlyChildren) {
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if ( !app )
|
||||
return;
|
||||
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if ( !appStudy )
|
||||
return;
|
||||
|
||||
LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
|
||||
|
||||
if( !parent)
|
||||
return;
|
||||
|
||||
// Erase from all views
|
||||
QList<SALOME_View*> views;
|
||||
SALOME_View* view;
|
||||
ViewManagerList vmans = app->viewManagers();
|
||||
SUIT_ViewManager* vman;
|
||||
foreach ( vman, vmans ) {
|
||||
SUIT_ViewModel* vmod = vman->getViewModel();
|
||||
view = dynamic_cast<SALOME_View*> ( vmod );
|
||||
if ( view )
|
||||
views.append( view );
|
||||
}
|
||||
|
||||
if( views.count() == 0 )
|
||||
return;
|
||||
|
||||
//Erase childrens w/o update views
|
||||
DataObjectList listObj = parent->children( true );
|
||||
SUIT_DataObject* obj;
|
||||
foreach( obj, listObj ) {
|
||||
LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
|
||||
if(l_obj)
|
||||
foreach ( view, views ) {
|
||||
Handle(SALOME_InteractiveObject) anIO =
|
||||
new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
|
||||
Erase(anIO, false, false, view);
|
||||
}
|
||||
}
|
||||
|
||||
//Erase parent with view update or repaint views
|
||||
foreach ( view, views ) {
|
||||
if(!eraseOnlyChildren)
|
||||
Erase(theIO, false, true, view);
|
||||
else
|
||||
view->Repaint();
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,9 @@ public:
|
||||
const bool forced = false,
|
||||
const bool updateViewer = true );
|
||||
|
||||
void EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
|
||||
const bool eraseOnlyChildren = false);
|
||||
|
||||
/* Display/Erase list of objects methods */
|
||||
|
||||
void Display ( const SALOME_ListIO& theIOList,
|
||||
|
@ -2473,6 +2473,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>MEN_POP_HIDE_CHILDREN</source>
|
||||
<translation>Hide Children</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_UNPUBLISH_OBJ</source>
|
||||
<translation>Unpublish</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_PUBLISH_OBJ</source>
|
||||
<translation>Publish...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_ISOS</source>
|
||||
<translation>Isos</translation>
|
||||
@ -3109,6 +3117,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_POP_SHOW_CHILDREN</source>
|
||||
<translation>Show child objects</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_UNPUBLISH_OBJ</source>
|
||||
<translation>Unpublish object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_PUBLISH_OBJ</source>
|
||||
<translation>Publish object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_HIDE_CHILDREN</source>
|
||||
<translation>Hide child objects</translation>
|
||||
@ -3637,6 +3653,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>TOP_POP_SHOW_CHILDREN</source>
|
||||
<translation>Show Children</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_UNPUBLISH_OBJ</source>
|
||||
<translation>Unpublish object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_PUBLISH_OBJ</source>
|
||||
<translation>Publish object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_HIDE_CHILDREN</source>
|
||||
<translation>Hide Children</translation>
|
||||
@ -4820,4 +4844,35 @@ Would you like to continue?</translation>
|
||||
<translation>New L2</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GEOMToolsGUI_PublishDlg</name>
|
||||
<message>
|
||||
<source>GEOM_PUBLISH_OBJECTS_TLT</source>
|
||||
<translation>Publish Objects</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>OBJECT_NAME</source>
|
||||
<translation>Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>OBJECT_ENTRY</source>
|
||||
<translation>Entry</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>UNSELECT_ALL</source>
|
||||
<translation>U&nselect All</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SELECT_ALL</source>
|
||||
<translation>Select &All</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PUBLISH_BTN</source>
|
||||
<translation>&Publish</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PUBLISH_CLOSE_BTN</source>
|
||||
<translation>P&ublish And Close</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -358,6 +358,8 @@ void GeometryGUI::OnGUIEvent( int id )
|
||||
<< GEOMOp::OpShowOnly
|
||||
<< GEOMOp::OpShowChildren
|
||||
<< GEOMOp::OpHideChildren
|
||||
<< GEOMOp::OpUnpublishObject
|
||||
<< GEOMOp::OpPublishObject
|
||||
<< GEOMOp::OpPointMarker;
|
||||
if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
|
||||
return;
|
||||
@ -398,6 +400,8 @@ void GeometryGUI::OnGUIEvent( int id )
|
||||
case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
|
||||
case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
|
||||
case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
|
||||
case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
|
||||
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
|
||||
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
|
||||
case GEOMOp::OpRename: // POPUP MENU - RENAME
|
||||
libName = "GEOMToolsGUI";
|
||||
@ -785,6 +789,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
|
||||
createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
|
||||
createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
|
||||
createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
|
||||
createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
|
||||
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
|
||||
|
||||
createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
|
||||
@ -975,6 +981,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( GEOMOp::OpShowAll, viewId, -1 );
|
||||
createMenu( GEOMOp::OpHideAll, viewId, -1 );
|
||||
createMenu( separator(), viewId, -1 );
|
||||
createMenu( GEOMOp::OpPublishObject, viewId, -1 );
|
||||
createMenu( separator(), viewId, -1 );
|
||||
|
||||
/*
|
||||
PAL9111:
|
||||
@ -1091,6 +1099,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
"(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
|
||||
|
||||
QtxPopupMgr* mgr = popupMgr();
|
||||
|
||||
mgr->insert( action( GEOMOp::OpRename ), -1, -1 ); // rename
|
||||
mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
|
||||
@ -1099,6 +1108,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
|
||||
mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
|
||||
|
||||
mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
|
||||
mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
|
||||
@ -1180,6 +1190,15 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( separator(), -1, -1 );
|
||||
|
||||
mgr->insert( separator(), -1, -1 ); // -----------
|
||||
mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
|
||||
mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
|
||||
|
||||
|
||||
mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
|
||||
mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
|
||||
|
||||
|
||||
mgr->hide( mgr->actionId( action( myEraseAll ) ) );
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,9 @@ namespace GEOMOp {
|
||||
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
|
||||
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
|
||||
OpRename = 1252, // POPUP MENU - RENAME
|
||||
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
||||
OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
|
||||
|
||||
// DisplayGUI ----------------//--------------------------------
|
||||
OpDisplayMode = 2000, // MENU VIEW - DISPLAY MODE - WIREFRAME/SHADING
|
||||
OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
|
||||
|
@ -362,6 +362,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
||||
case GEOMOp::OpPointMarker: // POPUP - POINT MARKER
|
||||
OnPointMarker();
|
||||
break;
|
||||
case GEOMOp::OpUnpublishObject:// POPUP - UNPUBLISH
|
||||
OnUnpublishObject();
|
||||
break;
|
||||
case GEOMOp::OpPublishObject:// GEOM ROOT OBJECT - POPUP - PUBLISH
|
||||
OnPublishObject();
|
||||
break;
|
||||
default:
|
||||
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
||||
break;
|
||||
|
@ -73,6 +73,8 @@ private:
|
||||
void OnDeflection();
|
||||
void OnSelectOnly(int mode);
|
||||
void OnShowHideChildren( bool );
|
||||
void OnUnpublishObject();
|
||||
void OnPublishObject() ;
|
||||
void OnPointMarker();
|
||||
|
||||
// Shortcut commands
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "GEOMToolsGUI_NbIsosDlg.h"
|
||||
#include "GEOMToolsGUI_DeflectionDlg.h"
|
||||
#include "GEOMToolsGUI_MarkerDlg.h"
|
||||
#include "GEOMToolsGUI_PublishDlg.h"
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_Displayer.h>
|
||||
@ -795,7 +796,12 @@ void GEOMToolsGUI::OnShowHideChildren( bool show )
|
||||
SALOME_ListIO selected;
|
||||
SalomeApp_Application* app =
|
||||
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if ( app ) {
|
||||
|
||||
SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
|
||||
|
||||
GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
|
||||
|
||||
if ( app && disp ) {
|
||||
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if ( aSelMgr && appStudy ) {
|
||||
@ -820,6 +826,8 @@ void GEOMToolsGUI::OnShowHideChildren( bool show )
|
||||
if ( obj ) {
|
||||
_PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
|
||||
aExp->SetExpandable( show );
|
||||
if(!show)
|
||||
disp->EraseWithChildren(IObject,true);
|
||||
} // if ( obj )
|
||||
} // iterator
|
||||
}
|
||||
@ -834,3 +842,78 @@ void GEOMToolsGUI::OnPointMarker()
|
||||
GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
||||
void GEOMToolsGUI::OnUnpublishObject() {
|
||||
SALOME_ListIO selected;
|
||||
SalomeApp_Application* app =
|
||||
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
|
||||
SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
|
||||
|
||||
GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
|
||||
|
||||
if ( app && disp ) {
|
||||
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if ( aSelMgr && appStudy ) {
|
||||
aSelMgr->selectedObjects( selected );
|
||||
if ( !selected.IsEmpty() ) {
|
||||
_PTR(Study) aStudy = appStudy->studyDS();
|
||||
_PTR(StudyBuilder) B = aStudy->NewBuilder();
|
||||
|
||||
bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
|
||||
if ( aLocked ) {
|
||||
SUIT_MessageBox::warning( app->desktop(),
|
||||
QObject::tr( "WRN_WARNING" ),
|
||||
QObject::tr( "WRN_STUDY_LOCKED" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||
|
||||
_PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
|
||||
_PTR(GenericAttribute) anAttr;
|
||||
if ( obj ) {
|
||||
_PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
|
||||
aDrw->SetDrawable( false );
|
||||
disp->EraseWithChildren(IObject);
|
||||
} // if ( obj )
|
||||
} // iterator
|
||||
aSelMgr->clearSelected();
|
||||
}
|
||||
}
|
||||
app->updateObjectBrowser( false );
|
||||
app->updateActions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GEOMToolsGUI::OnPublishObject() {
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if(!app)
|
||||
return;
|
||||
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if(!appStudy)
|
||||
return;
|
||||
|
||||
_PTR(Study) aStudy = appStudy->studyDS();
|
||||
|
||||
if(!aStudy)
|
||||
return;
|
||||
|
||||
//Check lock of the study
|
||||
bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
|
||||
if ( aLocked ) {
|
||||
SUIT_MessageBox::warning( app->desktop(),
|
||||
QObject::tr( "WRN_WARNING" ),
|
||||
QObject::tr( "WRN_STUDY_LOCKED" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
GEOMToolsGUI_PublishDlg * publishDlg =
|
||||
new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
|
||||
publishDlg->exec();
|
||||
}
|
||||
|
389
src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx
Normal file
389
src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx
Normal file
@ -0,0 +1,389 @@
|
||||
// Copyright (C) 2007-2010 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
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : GEOMToolsGUI_PublishDlg.cxx
|
||||
// Author : Roman NIKOLAEV, Open CASCADE S.A.S.
|
||||
//
|
||||
|
||||
#include "GEOMToolsGUI_PublishDlg.h"
|
||||
|
||||
//SALOME GUI includes
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_DataObject.h>
|
||||
|
||||
#include <CAM_DataModel.h>
|
||||
|
||||
#include <SalomeApp_DataObject.h>
|
||||
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <SalomeApp_Module.h>
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
|
||||
//QT includes
|
||||
#include <QGridLayout>
|
||||
#include <QTreeWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#define DEFAULT_MARGIN 11
|
||||
#define DEFAULT_SPACING 6
|
||||
|
||||
GEOMToolsGUI_PublishDlg::GEOMToolsGUI_PublishDlg(QWidget* parent):
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
|
||||
{
|
||||
setObjectName( "GEOMToolsGUI_PublishDlg" );
|
||||
setModal( true );
|
||||
setWindowTitle( tr( "GEOM_PUBLISH_OBJECTS_TLT" ) );
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
//List of the objects
|
||||
myTreeWidget = new QTreeWidget(this);
|
||||
//myTreeWidget->setRootIsDecorated(false);
|
||||
//myTreeWidget->setUniformRowHeights(true);
|
||||
myTreeWidget->setAllColumnsShowFocus(true);
|
||||
myTreeWidget->setColumnCount(2);
|
||||
|
||||
QStringList columnNames;
|
||||
columnNames.append(tr("OBJECT_NAME"));
|
||||
columnNames.append(tr("OBJECT_ENTRY"));
|
||||
QTreeWidgetItem * headerItem = new QTreeWidgetItem(columnNames);
|
||||
myTreeWidget->setHeaderItem ( headerItem );
|
||||
|
||||
//Select All button
|
||||
QPushButton* selectAllButton = new QPushButton( tr("SELECT_ALL"),this );
|
||||
|
||||
//Unselect Select All button
|
||||
QPushButton* unselectAllButton = new QPushButton( tr("UNSELECT_ALL"),this );
|
||||
|
||||
//Publish button
|
||||
QPushButton* publishButton = new QPushButton( tr("GEOM_PUBLISH_BTN"),this );
|
||||
|
||||
//Publish and Close button
|
||||
QPushButton* publishCloseButton = new QPushButton( tr("GEOM_PUBLISH_CLOSE_BTN"), this );
|
||||
|
||||
//Close button
|
||||
QPushButton* closeButton = new QPushButton( tr("GEOM_BUT_CLOSE"), this );
|
||||
|
||||
QGridLayout* gridLayout = new QGridLayout(this);
|
||||
gridLayout->setMargin(DEFAULT_MARGIN);
|
||||
gridLayout->setSpacing(DEFAULT_SPACING);
|
||||
|
||||
gridLayout->addWidget(myTreeWidget, 0, 0, 3, 3);
|
||||
gridLayout->addWidget(selectAllButton, 0, 3, 1, 1);
|
||||
gridLayout->addWidget(unselectAllButton, 1, 3, 1, 1);
|
||||
gridLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 2, 3, 1, 1);
|
||||
gridLayout->addWidget(publishCloseButton, 3, 0, 1, 1);
|
||||
gridLayout->addWidget(publishButton, 3, 1, 1, 1);
|
||||
gridLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 3, 2, 1, 1);
|
||||
gridLayout->addWidget(closeButton, 3, 3, 1, 1);
|
||||
|
||||
//Connect signals and slots
|
||||
connect( selectAllButton, SIGNAL(clicked()), this, SLOT(clickOnSelectAll()) );
|
||||
connect( unselectAllButton, SIGNAL(clicked()), this, SLOT(clickOnUnSelectAll()) );
|
||||
|
||||
connect(publishCloseButton, SIGNAL(clicked()), this, SLOT(clickOnOk()));
|
||||
connect(publishButton, SIGNAL(clicked()), this, SLOT(clickOnApply()));
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
|
||||
initData();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ~GEOMToolsGUI_PublishDlg()
|
||||
// purpose : Destroys the object and frees any allocated resources
|
||||
//=================================================================================
|
||||
GEOMToolsGUI_PublishDlg::~GEOMToolsGUI_PublishDlg()
|
||||
{
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : initData()
|
||||
// purpose : Fill dialog after opening
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::initData() {
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if(!app)
|
||||
return;
|
||||
|
||||
SalomeApp_Module* module = dynamic_cast<SalomeApp_Module*>(app->activeModule());
|
||||
|
||||
if(!module)
|
||||
return;
|
||||
|
||||
CAM_DataModel* dataModel = module->dataModel();
|
||||
if(!dataModel)
|
||||
return;
|
||||
|
||||
myGeomRoot = dynamic_cast<SalomeApp_DataObject*>(dataModel->root());
|
||||
|
||||
if(!myGeomRoot)
|
||||
return;
|
||||
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if(!appStudy )
|
||||
return;
|
||||
|
||||
_PTR(Study) aStudy = appStudy->studyDS();
|
||||
if(!aStudy)
|
||||
return;
|
||||
|
||||
buildTree(aStudy, myGeomRoot);
|
||||
|
||||
|
||||
myTreeWidget->resizeColumnToContents(0);
|
||||
myTreeWidget->resizeColumnToContents(1);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : buildTree()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QTreeWidgetItem* GEOMToolsGUI_PublishDlg::createItem(QTreeWidgetItem* theParent, Pair theAttributes, bool isCheckable) {
|
||||
QStringList aList;
|
||||
aList<<theAttributes.second<<theAttributes.first;
|
||||
QTreeWidgetItem* anItem = new QTreeWidgetItem(aList);
|
||||
|
||||
if(isCheckable)
|
||||
anItem->setCheckState(0, Qt::Unchecked);
|
||||
else {
|
||||
anItem->setFlags(anItem->flags() & ~Qt::ItemIsUserCheckable);
|
||||
}
|
||||
|
||||
if(theParent)
|
||||
theParent->addChild(anItem);
|
||||
else
|
||||
myTreeWidget->addTopLevelItem(anItem);
|
||||
|
||||
myEntryToItem.insert(theAttributes.first, anItem);
|
||||
|
||||
anItem->setExpanded(true);
|
||||
return anItem;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : buildTree()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QTreeWidgetItem* GEOMToolsGUI_PublishDlg::findParentItem(_PTR(Study) theStudy, SalomeApp_DataObject* theObject, BufferedList& theList ) {
|
||||
|
||||
QTreeWidgetItem* aResult = NULL;
|
||||
SalomeApp_DataObject* aParrent = dynamic_cast<SalomeApp_DataObject*>(theObject->parent());
|
||||
if(aParrent) {
|
||||
QString targetEntry = aParrent->entry();
|
||||
if( !(aResult = myEntryToItem.value(targetEntry)) ) {
|
||||
if( aParrent != myGeomRoot ) {
|
||||
QString aName;
|
||||
_PTR(SObject) aSO ( theStudy->FindObjectID(qPrintable(aParrent->entry())));
|
||||
_PTR(GenericAttribute) anAttr;
|
||||
if ( aSO->FindAttribute(anAttr, "AttributeName") ) {
|
||||
_PTR(AttributeName) anAttrName (anAttr);
|
||||
aName = anAttrName->Value().c_str();
|
||||
}
|
||||
theList.push_front(qMakePair(targetEntry, aName));
|
||||
aResult = findParentItem(theStudy,aParrent,theList);
|
||||
} else {
|
||||
//Publish List
|
||||
for(int i = 0; i < theList.size(); i++ ) {
|
||||
aResult = createItem(aResult, theList[i], false);
|
||||
}
|
||||
theList.clear();
|
||||
}
|
||||
} else {
|
||||
//Publish List
|
||||
for(int i = 0; i < theList.size(); i++ ) {
|
||||
aResult = createItem(aResult, theList[i], false);
|
||||
}
|
||||
theList.clear();
|
||||
}
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : buildTree()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem) {
|
||||
if(!theItem || theItem->isReference())
|
||||
return;
|
||||
|
||||
if(theItem != myGeomRoot) {
|
||||
|
||||
//If object hasn't "AttributeDrawable" => it visible
|
||||
bool isDrawable = true;
|
||||
_PTR(SObject) SO ( theStudy->FindObjectID(qPrintable(theItem->entry())));
|
||||
_PTR(GenericAttribute) anAttr;
|
||||
if ( SO && SO->FindAttribute(anAttr, "AttributeDrawable") ) {
|
||||
_PTR(AttributeDrawable) aDrw (anAttr);
|
||||
isDrawable = aDrw->IsDrawable();
|
||||
}
|
||||
|
||||
if(!isDrawable) {
|
||||
QString aName;
|
||||
if ( SO->FindAttribute(anAttr, "AttributeName") ) {
|
||||
_PTR(AttributeName) aAttrName (anAttr);
|
||||
aName = aAttrName->Value().c_str();
|
||||
}
|
||||
BufferedList aList;
|
||||
QTreeWidgetItem* parentItem = findParentItem(theStudy, theItem, aList);
|
||||
createItem(parentItem,qMakePair(theItem->entry(),aName),true);
|
||||
}
|
||||
}
|
||||
|
||||
DataObjectList listObj = theItem->children( false );
|
||||
DataObjectList::iterator itr = listObj.begin();
|
||||
while( itr != listObj.end()) {
|
||||
buildTree(theStudy, dynamic_cast<SalomeApp_DataObject*>(*itr));
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : clickOnApply()
|
||||
// purpose : Called then "Publish" button clicked
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::clickOnApply() {
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if(!app)
|
||||
return;
|
||||
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||
if(!appStudy )
|
||||
return;
|
||||
|
||||
_PTR(Study) aStudy = appStudy->studyDS();
|
||||
if(!aStudy)
|
||||
return;
|
||||
|
||||
|
||||
QList<QTreeWidgetItem*> toProcess;
|
||||
getDrawableList(myTreeWidget->invisibleRootItem(), toProcess);
|
||||
|
||||
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
|
||||
for( int i = 0; i < toProcess.count(); i++) {
|
||||
QTreeWidgetItem* item = toProcess[i];
|
||||
if(item) {
|
||||
QString entry = myEntryToItem.key(item);
|
||||
_PTR(SObject) SO ( aStudy->FindObjectID(qPrintable(entry)) );
|
||||
if(!SO) continue;
|
||||
_PTR(AttributeDrawable) aDrw = aBuilder->FindOrCreateAttribute( SO, "AttributeDrawable" );
|
||||
aDrw->SetDrawable( true );
|
||||
//Remove or change item
|
||||
if( item != myTreeWidget->invisibleRootItem() ){
|
||||
if( item->data(0,Qt::UserRole).toBool() ) {
|
||||
delete item;
|
||||
} else {
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsUserCheckable);
|
||||
item->setData(0,Qt::CheckStateRole,QVariant());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
toProcess.clear();
|
||||
getTails(myTreeWidget->invisibleRootItem(), toProcess);
|
||||
for( int i = 0; i < toProcess.count(); i++) {
|
||||
if( toProcess[i] != myTreeWidget->invisibleRootItem() )
|
||||
delete toProcess[i];
|
||||
}
|
||||
|
||||
app->updateObjectBrowser( false );
|
||||
app->updateActions();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : clickOnOk()
|
||||
// purpose : Called then "Publish And Close" button clicked
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::clickOnOk() {
|
||||
clickOnApply();
|
||||
accept();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : clickOnSelectAll()
|
||||
// purpose : Called then "Select All" button clicked
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::clickOnSelectAll() {
|
||||
processAll(myTreeWidget->invisibleRootItem(),Qt::Checked);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : clickOnUnSelectAll()
|
||||
// purpose : Called then "Unselect All" button clicked
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::clickOnUnSelectAll() {
|
||||
processAll(myTreeWidget->invisibleRootItem(),Qt::Unchecked);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : processAll()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::processAll(QTreeWidgetItem* theItem, Qt::CheckState state) {
|
||||
|
||||
|
||||
if((theItem->flags() & Qt::ItemIsUserCheckable))
|
||||
theItem->setCheckState(0,state);
|
||||
|
||||
int i = 0;
|
||||
while(i < theItem->childCount()) {
|
||||
processAll(theItem->child(i), state);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : processAll()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMToolsGUI_PublishDlg::getDrawableList(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList) {
|
||||
|
||||
theItem->setData(0, Qt::UserRole, true);
|
||||
|
||||
if((theItem->flags() & Qt::ItemIsUserCheckable) ) {
|
||||
theItem->setData(0, Qt::UserRole,theItem->checkState(0) == Qt::Checked);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while(i < theItem->childCount()) {
|
||||
getDrawableList(theItem->child(i), theList);
|
||||
theItem->setData( 0, Qt::UserRole, (theItem->data(0,Qt::UserRole).toBool() && theItem->child(i)->data(0,Qt::UserRole).toBool()) );
|
||||
i++;
|
||||
}
|
||||
|
||||
if( (theItem->flags() & Qt::ItemIsUserCheckable) && (theItem->checkState(0) == Qt::Checked))
|
||||
theList.push_back(theItem);
|
||||
}
|
||||
|
||||
|
||||
void GEOMToolsGUI_PublishDlg::getTails(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList) {
|
||||
int i = 0;
|
||||
while(i < theItem->childCount()) {
|
||||
getTails(theItem->child(i),theList);
|
||||
i++;
|
||||
}
|
||||
|
||||
if(theItem->data(0,Qt::UserRole).toBool())
|
||||
theList.push_back(theItem);
|
||||
}
|
83
src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.h
Normal file
83
src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.h
Normal file
@ -0,0 +1,83 @@
|
||||
// Copyright (C) 2007-2010 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
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : GEOMToolsGUI_PublishDlg.h
|
||||
// Author : Roman NIKOLAEV, Open CASCADE S.A.S.
|
||||
//
|
||||
|
||||
#ifndef GEOMTOOLSGUI_PUBLISHDLG_H
|
||||
#define GEOMTOOLSGUI_PUBLISHDLG_H
|
||||
|
||||
#include "GEOM_ToolsGUI.hxx"
|
||||
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QDialog>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
|
||||
|
||||
|
||||
#include <SALOMEDSClient.hxx>
|
||||
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
class SalomeApp_DataObject;
|
||||
|
||||
typedef QPair<QString, QString> Pair;
|
||||
typedef QList<Pair > BufferedList;
|
||||
typedef QMap<QString, QTreeWidgetItem*> Entry2ItemMap;
|
||||
|
||||
class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_PublishDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GEOMToolsGUI_PublishDlg( QWidget* );
|
||||
~GEOMToolsGUI_PublishDlg();
|
||||
|
||||
protected:
|
||||
void initData();
|
||||
void buildTree(_PTR(Study) theStudy, SalomeApp_DataObject* theItem);
|
||||
QTreeWidgetItem* findParentItem(_PTR(Study) theStudy, SalomeApp_DataObject* theItem, BufferedList& theList);
|
||||
QTreeWidgetItem* createItem(QTreeWidgetItem* theItem, Pair theAttributes, bool isCheckable);
|
||||
void getDrawableList(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList);
|
||||
void getTails(QTreeWidgetItem* theItem, QList<QTreeWidgetItem*>& theList);
|
||||
|
||||
protected slots:
|
||||
void clickOnOk();
|
||||
void clickOnApply();
|
||||
void clickOnSelectAll();
|
||||
void clickOnUnSelectAll();
|
||||
|
||||
private:
|
||||
QTreeWidget* myTreeWidget;
|
||||
SalomeApp_DataObject* myGeomRoot;
|
||||
Entry2ItemMap myEntryToItem;
|
||||
void processAll(QTreeWidgetItem* theItem, Qt::CheckState state);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //GEOMTOOLSGUI_PUBLISHDLG_H
|
@ -34,7 +34,8 @@ salomeinclude_HEADERS = \
|
||||
GEOMToolsGUI_DeflectionDlg.h \
|
||||
GEOMToolsGUI_TransparencyDlg.h \
|
||||
GEOMToolsGUI_DeleteDlg.h \
|
||||
GEOMToolsGUI_MarkerDlg.h
|
||||
GEOMToolsGUI_MarkerDlg.h \
|
||||
GEOMToolsGUI_PublishDlg.h
|
||||
|
||||
dist_libGEOMToolsGUI_la_SOURCES = \
|
||||
GEOMToolsGUI.cxx \
|
||||
@ -43,14 +44,16 @@ dist_libGEOMToolsGUI_la_SOURCES = \
|
||||
GEOMToolsGUI_NbIsosDlg.cxx \
|
||||
GEOMToolsGUI_DeflectionDlg.cxx \
|
||||
GEOMToolsGUI_DeleteDlg.cxx \
|
||||
GEOMToolsGUI_MarkerDlg.cxx
|
||||
GEOMToolsGUI_MarkerDlg.cxx \
|
||||
GEOMToolsGUI_PublishDlg.cxx
|
||||
|
||||
MOC_FILES = \
|
||||
GEOMToolsGUI_TransparencyDlg_moc.cxx \
|
||||
GEOMToolsGUI_NbIsosDlg_moc.cxx \
|
||||
GEOMToolsGUI_DeflectionDlg_moc.cxx \
|
||||
GEOMToolsGUI_DeleteDlg_moc.cxx \
|
||||
GEOMToolsGUI_MarkerDlg_moc.cxx
|
||||
GEOMToolsGUI_MarkerDlg_moc.cxx \
|
||||
GEOMToolsGUI_PublishDlg_moc.cxx
|
||||
|
||||
nodist_libGEOMToolsGUI_la_SOURCES = \
|
||||
$(MOC_FILES)
|
||||
|
Loading…
Reference in New Issue
Block a user