1 // Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "GEOMToolsGUI_ReduceStudyDlg.h"
22 #include <QVBoxLayout>
23 #include <QHBoxLayout>
25 #include <QGridLayout>
26 #include <QHeaderView>
27 #include <QPushButton>
28 #include <QRadioButton>
32 #include <SUIT_Session.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_DataOwner.h>
35 #include <SalomeApp_Application.h>
36 #include <SalomeApp_Study.h>
37 #include <OCCViewer_ViewManager.h>
38 #include <LightApp_DataOwner.h>
39 #include <GEOMToolsGUI.h>
42 #include <SALOMEconfig.h>
43 #include CORBA_CLIENT_HEADER(GEOM_Gen)
44 #include <GEOMBase_Helper.h>
46 #include <LightApp_SelectionMgr.h>
47 #include <SALOME_ListIteratorOfListIO.hxx>
54 GEOMToolsGUI_ReduceStudyDlg::GEOMToolsGUI_ReduceStudyDlg( QWidget* parent )
55 :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
58 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
59 myVisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_VISIBLE" ) ) );
60 myInvisible = QIcon( resMgr->loadPixmap( "SUIT", tr( "ICON_DATAOBJ_INVISIBLE" ) ) );
62 myApp = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
64 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
65 myStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() );
66 myDisplayer = GEOM_Displayer( study );
68 setWindowTitle( tr( "GEOM_REDUCE_STUDY_TITLE" ) );
69 setAttribute(Qt::WA_DeleteOnClose);
71 QGridLayout* topLayout = new QGridLayout( this );
72 topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
74 /********************** Objects to be kept **********************/
75 QGroupBox* groupKeptObjects = new QGroupBox( tr( "GEOM_REDUCE_STUDY_KEPT_OBJECTS" ) );
76 QGridLayout* layoutKeptObjects = new QGridLayout( groupKeptObjects );
77 createTreeWidget( myTreeKeptObjects = new QTreeWidget() );
78 layoutKeptObjects->addWidget( myTreeKeptObjects );
80 /********************** Objects to be removed **********************/
81 QGroupBox* groupRemoveObjects = new QGroupBox( tr( "GEOM_REDUCE_STUDY_REMOVE_OBJECTS" ) );
82 QGridLayout* layoutRemoveObjects = new QGridLayout( groupRemoveObjects );
83 createTreeWidget( myTreeRemoveObjects = new QTreeWidget() );
84 layoutRemoveObjects->addWidget( myTreeRemoveObjects );
86 /********************** Options **********************/
87 QGroupBox* groupOptions = new QGroupBox( tr( "GEOM_REDUCE_STUDY_OPTIONS" ) );
88 QVBoxLayout* layoutOptions = new QVBoxLayout( groupOptions );
90 // Intermidiate objects
91 QGroupBox* groupIntermediates = createButtonGroup( myGroupIntermediates = new QButtonGroup() );
92 groupIntermediates->setTitle( tr( "GEOM_REDUCE_STUDY_INTERMEDIATES" ) );
95 QGroupBox* groupSubObjects = createButtonGroup( myGroupSubObjects = new QButtonGroup() );
96 groupSubObjects->setTitle( tr( "GEOM_REDUCE_STUDY_SUB_OBJECTS" ) );
99 myCBRemoveEmptyFolder = new QCheckBox( tr( "GEOM_REDUCE_STUDY_REMOVE_EMPTY_FOLDER" ) );
100 myCBRemoveEmptyFolder->setChecked( true );
101 myCBSoftRemoval = new QCheckBox( tr( "GEOM_REDUCE_STUDY_SOFT_REMOVAL" ) );
103 layoutOptions->addWidget( groupIntermediates );
104 layoutOptions->addWidget( groupSubObjects );
105 layoutOptions->addWidget( myCBRemoveEmptyFolder );
106 layoutOptions->addWidget( myCBSoftRemoval );
108 /********************** Buttons **********************/
109 QGroupBox* groupButtons = new QGroupBox();
110 QHBoxLayout* layoutButtons = new QHBoxLayout( groupButtons );
112 QPushButton* buttonOk = new QPushButton( tr( "GEOM_BUT_OK" ) );
113 QPushButton* buttonCancel = new QPushButton( tr( "GEOM_BUT_CANCEL" ) );
114 QPushButton* buttonHelp = new QPushButton( tr( "GEOM_BUT_HELP" ) );
116 layoutButtons->addWidget( buttonOk );
117 layoutButtons->addStretch();
118 layoutButtons->addWidget( buttonCancel );
119 layoutButtons->addWidget( buttonHelp );
121 topLayout->addWidget( groupKeptObjects, 0, 0 );
122 topLayout->addWidget( groupRemoveObjects, 0, 1 );
123 topLayout->addWidget( groupOptions, 1, 0, 1, 2 );
124 topLayout->addWidget( groupButtons, 2, 0, 1, 2 );
126 // Signals and slots connections
128 connect( myTreeKeptObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
129 connect( myTreeRemoveObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
130 connect( myTreeKeptObjects->header(), SIGNAL( sectionClicked ( int ) ), this, SLOT( onHeaderClicked( int ) ) );
131 connect( myTreeRemoveObjects->header(), SIGNAL( sectionClicked ( int ) ), this, SLOT( onHeaderClicked( int ) ) );
133 connect( myGroupIntermediates, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) );
134 connect( myGroupSubObjects, SIGNAL( buttonClicked( int ) ), this, SLOT( update() ) );
136 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
137 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
138 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) );
140 connect( myApp->selectionMgr(), SIGNAL( currentSelectionChanged() ),
141 this, SLOT( selectionChanged() ) );
143 init( getSelectedObjects() );
146 GEOMToolsGUI_ReduceStudyDlg::~GEOMToolsGUI_ReduceStudyDlg()
148 // no need to delete child widgets, Qt does it all for us
151 void GEOMToolsGUI_ReduceStudyDlg::init( const std::set<std::string>& theObjectEntries )
153 myMainEntries.clear();
155 myKeptObjects.clear();
156 myListParents.clear();
157 myListSubObjects.clear();
158 myRemovedObjects.clear();
160 myMainEntries = theObjectEntries;
162 GEOM::string_array_var keptObjects = new GEOM::string_array();
164 keptObjects->length( theObjectEntries.size() );
165 std::set<std::string>::iterator iter;
166 for( iter=theObjectEntries.begin(); iter!=theObjectEntries.end(); ++iter, It++ )
167 keptObjects[ It ] = (*iter).c_str();
169 GEOM::string_array_var parentsObjects = new GEOM::string_array();
170 GEOM::string_array_var subObjects = new GEOM::string_array();
171 GEOM::string_array_var otherObjects = new GEOM::string_array();
173 GeometryGUI::GetGeomGen()->GetEntriesToCleanStudy( myStudy, keptObjects, parentsObjects,
174 subObjects, otherObjects );
176 for ( int i = 0; i < keptObjects->length(); i++ )
177 myKeptObjects.insert( keptObjects[i].in() );
178 for( int i = 0; i< otherObjects->length(); i++ )
179 myRemovedObjects.insert( otherObjects[i].in() );
180 for( int i = 0; i< parentsObjects->length(); i++ )
181 myListParents.insert( parentsObjects[i].in() );
182 for( int i = 0; i< subObjects->length(); i++ )
183 myListSubObjects.insert( subObjects[i].in() );
187 checkVisibleIcon( myTreeKeptObjects );
188 checkVisibleIcon( myTreeRemoveObjects );
191 std::set<std::string> GEOMToolsGUI_ReduceStudyDlg::getSelectedObjects() const
193 std::set<std::string> objects;
195 SALOME_ListIO selected;
196 myApp->selectionMgr()->selectedObjects( selected );
198 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
199 Handle( SALOME_InteractiveObject ) io = It.Value();
200 if( !io->hasEntry() )
202 GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil();
203 geomObject = GEOMBase::ConvertIOinGEOMObject( io );
204 if( geomObject->_is_nil() )
206 QString entry = geomObject->GetEntry();
207 objects.insert( entry.toStdString().c_str() );
212 void GEOMToolsGUI_ReduceStudyDlg::createTreeWidget( QTreeWidget* theTreeWidget )
214 theTreeWidget->setColumnCount( 2 );
215 QStringList columnNames;
216 columnNames.append(tr( "GEOM_REDUCE_STUDY_NAME" ));
217 columnNames.append("");
218 theTreeWidget->setHeaderLabels( columnNames );
219 QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames );
220 theTreeWidget->setHeaderItem ( headerItem );
221 theTreeWidget->header()->moveSection( 1, 0 );
222 theTreeWidget->header()->setClickable( true );
223 theTreeWidget->header()->setMovable( false );
224 theTreeWidget->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
225 theTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
228 QGroupBox* GEOMToolsGUI_ReduceStudyDlg::createButtonGroup( QButtonGroup* theButtonGroup )
230 QGroupBox* groupObjects = new QGroupBox();
231 QHBoxLayout* layoutObjects = new QHBoxLayout( groupObjects );
233 QRadioButton* buttonKeep = new QRadioButton( tr( "GEOM_REDUCE_STUDY_KEEP") );
234 theButtonGroup->addButton( buttonKeep, 0 );
235 QRadioButton* buttonUnpublish = new QRadioButton( tr( "GEOM_REDUCE_STUDY_UNPUBLISH") );
236 theButtonGroup->addButton( buttonUnpublish, 1 );
237 QRadioButton* buttonRemove = new QRadioButton( tr( "GEOM_REDUCE_STUDY_REMOVE") );
238 theButtonGroup->addButton( buttonRemove, 2 );
240 theButtonGroup->button( 0 )->setChecked( true );
241 theButtonGroup->setExclusive( true );
243 layoutObjects->addWidget( buttonKeep );
244 layoutObjects->addWidget( buttonUnpublish );
245 layoutObjects->addWidget( buttonRemove );
250 void GEOMToolsGUI_ReduceStudyDlg::addObjectsToTree( QTreeWidget* theWidget, std::set<std::string>& theObjects )
252 std::set<std::string>::iterator it;
253 for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
254 std::string objectEntry = *it;
255 GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudy->StudyId(), objectEntry.c_str() );
256 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
257 QString studyEntry = GeomBaseObject->GetStudyEntry();
258 if( GeomObject->_is_nil() || studyEntry.isEmpty() )
260 addSubObject( theWidget, theObjects, GeomObject );
264 GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWidget* theWidget,
265 std::set<std::string>& theObjects,
266 GEOM::GEOM_Object_var theObject )
268 GEOMToolsGUI_TreeWidgetItem* item;
269 if( !theObject->IsMainShape() ) {
270 GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() );
271 item = findObjectInTree( theWidget, theObject );
273 item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry() );
276 item = findObjectInTree( theWidget, theObject );
278 item = new GEOMToolsGUI_TreeWidgetItem( theWidget, QStringList() << theObject->GetName(), theObject->GetStudyEntry() );
281 bool isDisplayed = false;
282 if( theObjects.find( theObject->GetEntry() ) != theObjects.end() ) {
283 isDisplayed = myDisplayer.IsDisplayed( theObject->GetStudyEntry() );
285 item->setVisible( true, myVisible );
287 item->setVisible( false, myInvisible );
289 if( myMainEntries.find( theObject->GetEntry() ) != myMainEntries.end() ) {
290 QFont Textfont = item->font(0);
291 Textfont.setBold( true );
292 item->setFont( 0, Textfont );
296 item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
297 item->setTextColor( 0, QColor( 150, 150, 150 ) );
302 GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::findObjectInTree( QTreeWidget* theWidget, GEOM::GEOM_Object_var theObject )
304 QTreeWidgetItemIterator it( theWidget );
306 GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
307 if( QString( item->getStudyEntry() ) == QString( theObject->GetStudyEntry() ) )
314 void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget )
316 bool isInvisible = false;
317 QTreeWidgetItemIterator it( theWidget );
319 GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
320 const char* entry = item->getStudyEntry();
321 if( item->flags() & Qt::ItemIsSelectable )
322 if( !item->isVisible() )
328 theWidget->headerItem()->setIcon( 1, myInvisible );
329 myMapTreeSelectAll[ theWidget ] = false;
332 theWidget->headerItem()->setIcon( 1, myVisible );
333 myMapTreeSelectAll[ theWidget ] = true;
337 void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theObjects )
339 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
340 _PTR(Study) aStudy = appStudy->studyDS();
341 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
342 std::string objectEntry, studyEntry;
343 std::set<std::string>::iterator it;
344 for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
346 GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( aStudy->StudyId(), objectEntry.c_str() );
347 studyEntry = GeomBaseObject->GetStudyEntry();
348 if ( studyEntry == "" )
350 _PTR(SObject) obj ( aStudy->FindObjectID( studyEntry.c_str() ) );
351 _PTR(GenericAttribute) anAttr;
353 _PTR(AttributeDrawable) aDrw = aStudyBuilder->FindOrCreateAttribute( obj, "AttributeDrawable" );
354 aDrw->SetDrawable( false );
355 myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) );
359 myApp->updateObjectBrowser( false );
360 myApp->updateActions();
363 void GEOMToolsGUI_ReduceStudyDlg::removeObjects( std::set<std::string>& theObjects )
365 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
366 _PTR(Study) aStudy = appStudy->studyDS();
367 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
368 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
369 std::string objectEntry, studyEntry;
370 std::set<std::string>::iterator it;
371 for( it = theObjects.begin(); it != theObjects.end(); ++it ) {
373 GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( aStudy->StudyId(), objectEntry.c_str() );
374 studyEntry = GeomBaseObject->GetStudyEntry();
375 if ( studyEntry == "" )
377 _PTR(SObject) obj ( aStudy->FindObjectID( studyEntry.c_str() ) );
379 //Remove visual properties of the object
380 appStudy->removeObjectFromAll(obj->GetID().c_str());
381 // remove objects from study
382 aStudyBuilder->RemoveObjectWithChildren( obj );
383 // remove object from use case tree
384 aUseCaseBuilder->Remove( obj );
385 myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) );
389 myApp->updateObjectBrowser( false );
390 myApp->updateActions();
393 //=================================================================================
394 // function : onItemClicked()
395 // purpose : Called then treeItem clicked
396 //=================================================================================
397 void GEOMToolsGUI_ReduceStudyDlg::onItemClicked( QTreeWidgetItem* theItem, int theColumn )
399 if( theColumn != 1 || !( theItem->flags() & Qt::ItemIsSelectable ) )
402 GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>( theItem );
404 const char* entry = item->getStudyEntry();
405 Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" );
406 if( myDisplayer.IsDisplayed( entry ) ) {
407 item->setVisible( false, myInvisible );
408 myDisplayer.Erase( io );
411 item->setVisible( true, myVisible );
412 myDisplayer.Display( io );
414 myDisplayer.UpdateViewer();
415 checkVisibleIcon( item->treeWidget() );
418 void GEOMToolsGUI_ReduceStudyDlg::onHeaderClicked( int theColumn )
423 QTreeWidget* treeWidget = dynamic_cast<QTreeWidget*>(sender()->parent());
424 if( myMapTreeSelectAll[ treeWidget ] ) {
425 myMapTreeSelectAll[ treeWidget ] = false;
426 treeWidget->headerItem()->setIcon( 1, myInvisible );
427 QTreeWidgetItemIterator it( treeWidget );
429 GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
430 if( ( item->flags() & Qt::ItemIsSelectable ) && item->isVisible() ) {
431 const char* entry = item->getStudyEntry();
432 item->setVisible( false, myInvisible );
433 myDisplayer.Erase( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) );
439 myMapTreeSelectAll[ treeWidget ] = true;
440 treeWidget->headerItem()->setIcon( 1, myVisible );
441 QTreeWidgetItemIterator it( treeWidget );
443 GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
444 if( ( item->flags() & Qt::ItemIsSelectable ) && !item->isVisible() ) {
445 const char* entry = item->getStudyEntry();
446 item->setVisible( true, myVisible );
447 myDisplayer.Display( new SALOME_InteractiveObject( entry, "GEOM", "TEMP_IO" ) );
452 myDisplayer.UpdateViewer();
455 void GEOMToolsGUI_ReduceStudyDlg::selectionChanged()
457 init( getSelectedObjects() );
460 void GEOMToolsGUI_ReduceStudyDlg::update()
462 myTreeKeptObjects->clear();
463 myTreeRemoveObjects->clear();
465 std::set<std::string> keptObjects( myKeptObjects );
466 std::set<std::string> removeObjects( myRemovedObjects );
468 // Intermediate objects
469 if( myGroupIntermediates->checkedId() == 2 ) { // remove
470 std::set<std::string>::iterator iter;
471 for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter)
472 removeObjects.insert( *iter );
474 else { // keep or unpublish
475 std::set<std::string>::iterator iter;
476 for( iter=myListParents.begin(); iter!=myListParents.end(); ++iter)
477 keptObjects.insert( *iter );
481 if( myGroupSubObjects->checkedId() == 2 ) {
482 std::set<std::string>::iterator iter;
483 for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter)
484 removeObjects.insert( *iter );
487 std::set<std::string>::iterator iter;
488 for( iter=myListSubObjects.begin(); iter!=myListSubObjects.end(); ++iter)
489 keptObjects.insert( *iter );
492 addObjectsToTree( myTreeKeptObjects, keptObjects );
493 addObjectsToTree( myTreeRemoveObjects, removeObjects );
495 myTreeKeptObjects->collapseAll();
496 myTreeRemoveObjects->collapseAll();
500 void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
502 std::set<std::string> objectsToBeRemoved = myRemovedObjects;
503 std::set<std::string> objectsToBeUnpublished;
505 std::set<std::string>::iterator iter;
506 if( myGroupIntermediates->checkedId() == 1 ) { // unpublish
507 for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
508 objectsToBeUnpublished.insert( *iter );
510 if( myGroupIntermediates->checkedId() == 2 ) { // remove
511 for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
512 objectsToBeRemoved.insert( *iter );
515 if( myGroupSubObjects->checkedId() == 1 ) { // unpublish
516 for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter )
517 objectsToBeUnpublished.insert( *iter );
519 else if( myGroupSubObjects->checkedId() == 2 ) { // remove
520 for( iter = myListSubObjects.begin(); iter != myListSubObjects.end(); ++iter )
521 objectsToBeRemoved.insert( *iter );
524 if( myCBSoftRemoval->isChecked() ) {
525 for( iter = objectsToBeRemoved.begin(); iter != objectsToBeRemoved.end(); ++iter )
526 objectsToBeUnpublished.insert( *iter );
527 unpublishObjects( objectsToBeUnpublished );
530 unpublishObjects( objectsToBeUnpublished );
531 removeObjects( objectsToBeRemoved );
537 // std::cout<< "\n\n REMOVE:" << std::endl;
538 // std::set<std::string>::iterator it;
539 // for( it = objectsToBeRemoved.begin(); it != objectsToBeRemoved.end(); ++it )
540 // std::cout <<" " << (*it) << std::endl;
542 // SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
543 // if ( !app ) return;
544 // SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
545 // // get currently opened views
546 // QList<SALOME_View*> views;
547 // SALOME_View* view;
548 // ViewManagerList vmans = app->viewManagers();
549 // SUIT_ViewManager* vman;
550 // foreach ( vman, vmans ) {
551 // SUIT_ViewModel* vmod = vman->getViewModel();
552 // view = dynamic_cast<SALOME_View*> ( vmod ); // must work for OCC and VTK views
554 // views.append( view );
556 // _PTR(Study) aStudy = study->studyDS();
559 // _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
560 // _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
562 // for( it = ObjectsToBeRemove.begin(); it != ObjectsToBeRemove.end(); ++it ) {
563 // std::string objectEntry = *it;
564 // GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudyId, objectEntry.c_str() );
565 // GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
566 // _PTR(SObject) obj = aStudy->FindObjectID( objectEntry.c_str() );
568 // //Remove visual properties of the object
569 // study->removeObjectFromAll(objectEntry.c_str());
571 // // remove object from study
572 // aStudyBuilder->RemoveObjectWithChildren( obj );
573 //// // remove object from use case tree
574 //// aUseCaseBuilder->Remove( obj );
576 // // Erase graphical object
577 // QListIterator<SALOME_View*> it( views );
578 // while ( it.hasNext() )
579 // if ( SALOME_View* view = it.next() )
580 // myDisplayer.Erase( GeomObject, true, true, view);
582 // GeometryGUI::GetGeomGen()->RemoveObject( GeomBaseObject );
585 // myDisplayer.UpdateViewer();
586 // GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
587 // aGeomGUI->updateObjBrowser();
588 // app->updateActions(); //SRN: To update a Save button in the toolbar
591 // _PTR(StudyBuilder) B = aStudy->NewBuilder();
592 // for( it = ObjectsToBeUnpublish.begin(); it != ObjectsToBeUnpublish.end(); ++it ) {
593 // std::string objectEntry = *it;
594 // _PTR(SObject) obj ( aStudy->FindObjectID( objectEntry ) );
595 // _PTR(GenericAttribute) anAttr;
597 // _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
598 // aDrw->SetDrawable( false );
599 // myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( objectEntry.c_str(), "GEOM", "TEMP_IO" ) );
603 // app->updateObjectBrowser( false );
604 // app->updateActions();
607 // LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
608 // SALOME_ListIO aSelList;
610 // for( it = ObjectsToBeUnpublish.begin(); it != ObjectsToBeUnpublish.end(); ++it ) {
611 // std::string objectEntry = *it;
612 // GEOM::GEOM_BaseObject_var GeomBaseObject = GeometryGUI::GetGeomGen()->GetObject( myStudyId, objectEntry.c_str() );
613 // GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
614 // QString studyEntry = GeomBaseObject->GetStudyEntry();
615 // Handle(SALOME_InteractiveObject) tmpIO =
616 // new SALOME_InteractiveObject( studyEntry.toStdString().c_str(), "GEOM", "TEMP_IO");
617 // aSelList.Append(tmpIO);
620 // aSelMgr->clearSelected();
621 // aSelMgr->setSelectedObjects(aSelList);
622 // GEOMToolsGUI::OnUnpublishObject();
626 // if( myCBRemoveEmptyFolder->isChecked() ) {
628 // SALOME_ListIO selected;
629 // SalomeApp_Application* app =
630 // dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
634 // LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
635 // SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
636 // if ( !aSelMgr || !appStudy )
640 // aSelMgr->selectedObjects( selected, "ObjectBrowser", false );
641 // if ( selected.IsEmpty() )
644 // _PTR(Study) aStudy = appStudy->studyDS();
645 // _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
647 // // ... and then delete all folders
648 // for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) {
649 // _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
650 // // remove object from GEOM engine
651 // removeObjectWithChildren( obj, aStudy, views, disp );
652 // // remove objects from study
653 // aStudyBuilder->RemoveObjectWithChildren( obj );
654 // // remove object from use case tree
655 // aUseCaseBuilder->Remove( obj );
660 ////=======================================================================
661 //// function : getGeomChildrenAndFolders
662 //// purpose : Get direct (1-level) GEOM objects under each folder, sub-folder, etc. and these folders itself
663 ////=======================================================================
664 //static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
665 // QMap<QString,QString>& geomObjList,
666 // QMap<QString,QString>& folderList ) {
667 // if ( !theSO ) return;
668 // _PTR(Study) aStudy = theSO->GetStudy();
669 // if ( !aStudy ) return;
670 // _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
672 // bool isFolder = false;
673 // _PTR(GenericAttribute) anAttr;
674 // if ( theSO->FindAttribute(anAttr, "AttributeLocalID") ) {
675 // _PTR(AttributeLocalID) aLocalID( anAttr );
676 // isFolder = aLocalID->Value() == 999;
678 // QString anEntry = theSO->GetID().c_str();
679 // QString aName = theSO->GetName().c_str();
681 // folderList.insert( anEntry, aName );
682 // _PTR(UseCaseIterator) ucit ( aUseCaseBuilder->GetUseCaseIterator( theSO ) );
683 // for ( ucit->Init( false ); ucit->More(); ucit->Next() ) {
684 // getGeomChildrenAndFolders( ucit->Value(), geomObjList, folderList );
687 // geomObjList.insert( anEntry, aName );
691 void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp()
697 GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings,
698 char* studyEntry, int type )
699 :QTreeWidgetItem( view, strings, type ),
700 myStudyEntry( studyEntry ),
705 GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidgetItem* parent, const QStringList &strings,
706 char* studyEntry, int type )
707 :QTreeWidgetItem( parent, strings, type ),
708 myStudyEntry( studyEntry ),
713 GEOMToolsGUI_TreeWidgetItem::~GEOMToolsGUI_TreeWidgetItem()
717 bool GEOMToolsGUI_TreeWidgetItem::isVisible()
722 void GEOMToolsGUI_TreeWidgetItem::setVisible( bool theIsVisible, QIcon& theIcon )
724 myVisible = theIsVisible;
725 setIcon( 1, theIcon );
728 char* GEOMToolsGUI_TreeWidgetItem::getStudyEntry() const