diff --git a/doc/salome/gui/GEOM/images/ob_popup_menu.png b/doc/salome/gui/GEOM/images/ob_popup_menu.png
index 1adb3bebb..51ae305d7 100644
Binary files a/doc/salome/gui/GEOM/images/ob_popup_menu.png and b/doc/salome/gui/GEOM/images/ob_popup_menu.png differ
diff --git a/doc/salome/gui/GEOM/images/publish_dlg.png b/doc/salome/gui/GEOM/images/publish_dlg.png
new file mode 100755
index 000000000..465681351
Binary files /dev/null and b/doc/salome/gui/GEOM/images/publish_dlg.png differ
diff --git a/doc/salome/gui/GEOM/input/viewing_geom_obj.doc b/doc/salome/gui/GEOM/input/viewing_geom_obj.doc
index 39a4f9035..ba06d2397 100644
--- a/doc/salome/gui/GEOM/input/viewing_geom_obj.doc
+++ b/doc/salome/gui/GEOM/input/viewing_geom_obj.doc
@@ -74,9 +74,17 @@ under certain conditions:
\subpage work_with_groups_page "Create Group" - allows creating groups of geometrical objects.
Hide Children / Show Children - 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.
+
+
Unpublish - 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 Geometry root object Publish... item.
+The following dialog box will appear
+\image html publish_dlg.png
+
+Switch the checkbox near the appropriate object and click Publish or Publish And Close button.
*/
diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx
index aff2f8320..1f3a7e09a 100644
--- a/src/GEOMGUI/GEOM_Displayer.cxx
+++ b/src/GEOMGUI/GEOM_Displayer.cxx
@@ -48,9 +48,11 @@
#include
#include
+
#include
#include
#include
+#include
#include
#include
@@ -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( app->activeStudy() );
+ if ( !appStudy )
+ return;
+
+ LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
+
+ if( !parent)
+ return;
+
+ // Erase from all views
+ QList views;
+ SALOME_View* view;
+ ViewManagerList vmans = app->viewManagers();
+ SUIT_ViewManager* vman;
+ foreach ( vman, vmans ) {
+ SUIT_ViewModel* vmod = vman->getViewModel();
+ view = dynamic_cast ( 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(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();
+ }
+}
diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h
index 7b5977046..56676d375 100644
--- a/src/GEOMGUI/GEOM_Displayer.h
+++ b/src/GEOMGUI/GEOM_Displayer.h
@@ -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,
diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts
index 51e009ed2..b4725cbe5 100644
--- a/src/GEOMGUI/GEOM_msg_en.ts
+++ b/src/GEOMGUI/GEOM_msg_en.ts
@@ -2473,6 +2473,14 @@ Please, select face, shell or solid and try again
Hide Children
+
+
+ Unpublish
+
+
+
+ Publish...
+ Isos
@@ -3109,6 +3117,14 @@ Please, select face, shell or solid and try again
Show child objects
+
+
+ Unpublish object
+
+
+
+ Publish object
+ Hide child objects
@@ -3637,6 +3653,14 @@ Please, select face, shell or solid and try again
Show Children
+
+
+ Unpublish object
+
+
+
+ Publish object
+ Hide Children
@@ -4820,4 +4844,35 @@ Would you like to continue?
New L2
+
+ GEOMToolsGUI_PublishDlg
+
+
+ Publish Objects
+
+
+
+ Name
+
+
+
+ Entry
+
+
+
+ U&nselect All
+
+
+
+ Select &All
+
+
+
+ &Publish
+
+
+
+ P&ublish And Close
+
+
diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx
index b7b0bcc28..4ecb54520 100644
--- a/src/GEOMGUI/GeometryGUI.cxx
+++ b/src/GEOMGUI/GeometryGUI.cxx
@@ -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 ) ) );
}
diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h
index ce4f9edbd..4d86e9bdd 100644
--- a/src/GEOMGUI/GeometryGUI_Operations.h
+++ b/src/GEOMGUI/GeometryGUI_Operations.h
@@ -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
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx
index 5f8442776..cbde99ce1 100644
--- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx
+++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx
@@ -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;
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h
index 09cdbd4e8..25516496a 100644
--- a/src/GEOMToolsGUI/GEOMToolsGUI.h
+++ b/src/GEOMToolsGUI/GEOMToolsGUI.h
@@ -73,6 +73,8 @@ private:
void OnDeflection();
void OnSelectOnly(int mode);
void OnShowHideChildren( bool );
+ void OnUnpublishObject();
+ void OnPublishObject() ;
void OnPointMarker();
// Shortcut commands
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
index a37613070..8f434de96 100644
--- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
+++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
@@ -31,6 +31,7 @@
#include "GEOMToolsGUI_NbIsosDlg.h"
#include "GEOMToolsGUI_DeflectionDlg.h"
#include "GEOMToolsGUI_MarkerDlg.h"
+#include "GEOMToolsGUI_PublishDlg.h"
#include
#include
@@ -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(app->activeModule()) : 0;
+
+ GEOM_Displayer* disp = mod ? dynamic_cast(mod->displayer()) : 0;
+
+ if ( app && disp ) {
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
SalomeApp_Study* appStudy = dynamic_cast( 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(app->activeModule()) : 0;
+
+ GEOM_Displayer* disp = mod ? dynamic_cast(mod->displayer()) : 0;
+
+ if ( app && disp ) {
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast( 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( 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();
+}
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx
new file mode 100644
index 000000000..7852c0563
--- /dev/null
+++ b/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx
@@ -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
+#include
+
+#include
+
+#include
+
+#include
+#include
+#include
+
+
+//QT includes
+#include
+#include
+#include
+
+#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(app->activeModule());
+
+ if(!module)
+ return;
+
+ CAM_DataModel* dataModel = module->dataModel();
+ if(!dataModel)
+ return;
+
+ myGeomRoot = dynamic_cast(dataModel->root());
+
+ if(!myGeomRoot)
+ return;
+
+ SalomeApp_Study* appStudy = dynamic_cast( 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<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(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(*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( app->activeStudy() );
+ if(!appStudy )
+ return;
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+ if(!aStudy)
+ return;
+
+
+ QList 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& 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& 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);
+}
diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.h
new file mode 100644
index 000000000..f78cd927f
--- /dev/null
+++ b/src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.h
@@ -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
+#include
+#include
+#include
+
+
+
+
+#include
+
+class QTreeWidget;
+class QTreeWidgetItem;
+
+class SalomeApp_DataObject;
+
+typedef QPair Pair;
+typedef QList BufferedList;
+typedef QMap 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& theList);
+ void getTails(QTreeWidgetItem* theItem, QList& 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
diff --git a/src/GEOMToolsGUI/Makefile.am b/src/GEOMToolsGUI/Makefile.am
index 8f3ffbbd4..fb214b448 100644
--- a/src/GEOMToolsGUI/Makefile.am
+++ b/src/GEOMToolsGUI/Makefile.am
@@ -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)