]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMBase/GEOMBase_Helper.cxx
Salome HOME
rnc:
[modules/geom.git] / src / GEOMBase / GEOMBase_Helper.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  GEOM GEOMGUI : GUI for Geometry component
24 //  File   : GEOMBase_Helper.cxx
25 //  Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
26 //
27 #include "GEOMBase_Helper.h"
28 #include "GEOMBase.h"
29 #include "GEOM_Operation.h"
30
31 #include <GeometryGUI.h>
32
33 #include <SUIT_Desktop.h>
34 #include <SUIT_Session.h>
35 #include <SUIT_ViewManager.h>
36 #include <SUIT_ViewWindow.h>
37 #include <SUIT_ViewModel.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_OverrideCursor.h>
40
41 #include <SalomeApp_Module.h>
42 #include <SalomeApp_Application.h>
43 #include <SalomeApp_Study.h>
44 #include <LightApp_SelectionMgr.h>
45 #include <LightApp_DataOwner.h>
46 #include <SalomeApp_Tools.h>
47 #include <SALOME_ListIteratorOfListIO.hxx>
48
49 #include <SALOME_Prs.h>
50
51 #include <OCCViewer_ViewModel.h>
52 #include <SVTK_ViewModel.h>
53
54 #include <TColStd_MapOfInteger.hxx>
55 #include <TCollection_AsciiString.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
57
58 //To disable automatic genericobj management, the following line should be commented.
59 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
60 #define WITHGENERICOBJ
61
62 //================================================================
63 // Function : getActiveView
64 // Purpose  : Get active view window, returns 0 if no open study frame
65 //================================================================
66 static SUIT_ViewWindow* getActiveView()
67 {
68   SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
69   if ( activeStudy )
70     return SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
71
72   return 0;
73 }
74
75
76 //================================================================
77 // Function : getGeomEngine
78 // Purpose  : Static method
79 //================================================================
80 GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
81 {
82   return GeometryGUI::GetGeomGen();
83 }
84
85 //================================================================
86 // Function : GEOMBase_Helper
87 // Purpose  :
88 //================================================================
89 GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
90   : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ),
91     myIsApplyAndClose( false ), myIsOptimizedBrowsing( false )
92 {
93 }
94
95 //================================================================
96 // Function : ~GEOMBase_Helper
97 // Purpose  :
98 //================================================================
99 GEOMBase_Helper::~GEOMBase_Helper()
100 {
101   //rnv: Fix for the "IPAL21922 : WinTC5.1.4: incorrect quit salome"
102   if ( !SUIT_Session::session()->activeApplication() || !SUIT_Session::session()->activeApplication()->desktop() )
103     return;
104
105   if ( myPreview.size() )
106     erasePreview();
107   if ( hasCommand() )
108     abortCommand();
109   SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
110   if (app) {
111     GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
112     if(aGeomGUI)
113       globalSelection(aGeomGUI->getLocalSelectionMode() , true );
114   }
115
116   if (myDisplayer)
117     delete myDisplayer;
118   if ( !CORBA::is_nil( myOperation ) )
119     myOperation->UnRegister();
120 }
121
122 //================================================================
123 // Function : display
124 // Purpose  :
125 //================================================================
126 void GEOMBase_Helper::display( const ObjectList& objList, const bool updateView )
127 {
128   ObjectList::const_iterator it;
129   for ( it = objList.begin(); it != objList.end(); it++ ) {
130     display( *it, false );
131   }
132   if ( !objList.empty() && updateView )
133     getDisplayer()->UpdateViewer();
134 }
135
136 //================================================================
137 // Function  : display
138 // Purpose   : Display object.
139 // Important : Object must be already in study
140 //================================================================
141 void GEOMBase_Helper::display( GEOM::GEOM_Object_ptr object, const bool updateView )
142 {
143   // Unset color of shape ( this color may be set during preview displaying )
144   // Default color will be used
145 //   getDisplayer()->UnsetColor();
146   getDisplayer()->UnsetWidth();
147   
148   MESSAGE("GEOMBase_Helper::display myTexture = "<<getDisplayer()->GetTexture())
149
150   // Enable activisation of selection
151   getDisplayer()->SetToActivate( true );
152
153   // Display object
154   getDisplayer()->Display( object, updateView );
155 }
156
157 //================================================================
158 // Function : erase
159 // Purpose  :
160 //================================================================
161 void GEOMBase_Helper::erase( const ObjectList& objList, const bool updateView )
162 {
163   ObjectList::const_iterator it = objList.begin();
164   for ( ; it != objList.end(); it++ ) {
165     erase( *it, false );
166   }
167   if ( !objList.empty() && updateView )
168     getDisplayer()->UpdateViewer();
169 }
170
171 //================================================================
172 // Function : erase
173 // Purpose  :
174 //================================================================
175 void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView )
176 {
177   if ( !object->_is_nil() ) {
178     QString entry = getEntry( object );
179     getDisplayer()->Erase( new SALOME_InteractiveObject(
180       entry.toLatin1().constData(), 
181       "GEOM", strdup( GEOMBase::GetName( object ).toLatin1().constData() ) ), true, updateView );
182   }
183 }
184
185 //================================================================
186 // Function : redisplay
187 // Purpose  :
188 //================================================================
189 void GEOMBase_Helper::redisplay( const ObjectList& objList,
190                                  const bool withChildren,
191                                  const bool updateView )
192 {
193   ObjectList::const_iterator it = objList.begin();
194   for ( ; it != objList.end(); it++ ) {
195     redisplay( *it, withChildren, false );
196   }
197   if ( !objList.empty() && updateView )
198     getDisplayer()->UpdateViewer();
199 }
200
201 //================================================================
202 // Function : redisplay
203 // Purpose  :
204 //================================================================
205 void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
206                                  const bool withChildren,
207                                  const bool updateView )
208 {
209   if ( !object->_is_nil() ) {
210     // Unset color of shape ( this color may be set during preview displaying )
211     // Default color will be used
212     getDisplayer()->UnsetColor();
213     getDisplayer()->UnsetWidth();
214
215     // Enable activisation of selection
216     getDisplayer()->SetToActivate( true );
217
218     QString entry = getEntry( object );
219     getDisplayer()->Redisplay(new SALOME_InteractiveObject
220                               (entry.toLatin1().constData(), "GEOM", strdup(GEOMBase::GetName(object).toLatin1().constData())), false);
221   }
222
223   if ( withChildren ) {
224     SalomeApp_Study* aDoc = getStudy();
225     if ( aDoc && aDoc->studyDS() ) {
226       _PTR(Study) aStudy = aDoc->studyDS();
227       CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(object);
228       _PTR(SObject) aSObj (aStudy->FindObjectIOR(std::string(objStr.in())));
229       if ( aSObj  ) {
230         _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
231         for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
232           GEOM::GEOM_Object_var aChild = GEOM::GEOM_Object::_narrow
233             (GeometryGUI::ClientSObjectToObject(anIt->Value()));
234           if ( !CORBA::is_nil( aChild ) ) {
235             if ( !aChild->_is_nil() ) {
236               QString entry = getEntry( aChild );
237               getDisplayer()->Redisplay( new SALOME_InteractiveObject(
238                 entry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( aChild ).toLatin1().constData() ) ), false );
239             }
240           }
241         }
242       }
243     }
244   }
245
246   if ( updateView )
247     getDisplayer()->UpdateViewer();
248 }
249
250 //================================================================
251 // Function : displayPreview
252 // Purpose  : Method for displaying preview based on execute() results
253 //================================================================
254 void GEOMBase_Helper::displayPreview( const bool   display,
255                                       const bool   activate,
256                                       const bool   update,
257                                       const bool   toRemoveFromEngine,
258                                       const double lineWidth,
259                                       const int    displayMode,
260                                       const int    color )
261 {
262   if(!display) {
263     erasePreview( update );
264     return;
265   }
266   
267   isPreview = true;
268   QString msg;
269   if ( !isValid( msg ) )
270   {
271     erasePreview( update );
272     isPreview = false;
273     return;
274   }
275
276   erasePreview( false );
277
278   try {
279     SUIT_OverrideCursor wc;
280     ObjectList objects;
281     if ( !execute( objects ) || !getOperation()->IsDone() ) {
282       wc.suspend();
283     }
284     else {
285       for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it )
286       {
287             GEOM::GEOM_Object_var obj=*it;
288         displayPreview( obj, true, activate, false, lineWidth, displayMode, color );
289         if ( toRemoveFromEngine )
290               obj->UnRegister();
291       }
292     }
293   }
294   catch( const SALOME::SALOME_Exception& e ) {
295     SalomeApp_Tools::QtCatchCorbaException( e );
296   }
297
298   isPreview = false;
299
300   if ( update )
301     updateViewer();
302 }
303
304 //================================================================
305 // Function : displayPreview
306 // Purpose  : Method for displaying preview of resulting shape
307 //================================================================
308 void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object,
309                                       const bool            append,
310                                       const bool            activate,
311                                       const bool            update,
312                                       const double          lineWidth,
313                                       const int             displayMode,
314                                       const int             color )
315 {
316   // Set color for preview shape
317   getDisplayer()->SetColor( color == -1 ? Quantity_NOC_VIOLET : color );
318
319   // set width of displayed shape
320   getDisplayer()->SetWidth( lineWidth );
321
322   // set display mode of displayed shape
323   int aPrevDispMode = getDisplayer()->SetDisplayMode( displayMode );
324
325   // Disable activation of selection
326   getDisplayer()->SetToActivate( activate );
327
328   // Make a reference to GEOM_Object
329   CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string( object );
330   getDisplayer()->SetName( objStr.in() );
331
332   // Build prs
333   SALOME_Prs* aPrs = getDisplayer()->BuildPrs( object );
334   if ( aPrs == 0 || aPrs->IsNull() )
335     return;
336
337   // Display prs
338   displayPreview( aPrs, append, update );
339
340   getDisplayer()->UnsetName();
341   getDisplayer()->UnsetColor();
342   getDisplayer()->SetDisplayMode( aPrevDispMode );
343
344   // Enable activation of displayed objects
345   getDisplayer()->SetToActivate( true );
346 }
347
348 //================================================================
349 // Function : displayPreview
350 // Purpose  : Method for displaying arbitrary preview objects (not limited to shapes)
351 //================================================================
352 void GEOMBase_Helper::displayPreview( const SALOME_Prs* prs,
353                                       const bool        append,
354                                       const bool        update )
355 {
356   if ( !append )
357     erasePreview( false );
358
359   // remember current view frame to make correct erase preview later
360   myViewWindow = getActiveView();
361
362   if ( myViewWindow == 0 )
363     return;
364   
365   // Display prs
366   SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
367   if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
368        aViewManager->getType() == SVTK_Viewer::Type() )
369     {
370       SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
371       SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
372       if (aView)
373         aView->Display( prs );
374     }
375
376   // Add prs to the preview list
377   myPreview.push_back( (SALOME_Prs*)prs );
378
379   // Update viewer
380   if ( update )
381     getDisplayer()->UpdateViewer();
382 }
383
384 //================================================================
385 // Function : erasePreview
386 // Purpose  :
387 //================================================================
388 void GEOMBase_Helper::erasePreview( const bool update )
389 {
390   // check view frame where the preview was displayed
391   bool vfOK = checkViewWindow() && myViewWindow;
392   // Iterate through presentations and delete them
393   for ( PrsList::iterator anIter = myPreview.begin(); anIter != myPreview.end(); ++anIter ) {
394     if ( vfOK )
395       {
396          SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
397          if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
398               aViewManager->getType() == SVTK_Viewer::Type() )
399            {
400              SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
401              SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
402              if (aView)
403                aView->Erase( *anIter, true );
404            }
405       }
406     delete *anIter;
407   }
408   myPreview.clear();
409
410   // Update viewer
411   if ( update )
412     updateViewer();
413 }
414
415 //================================================================
416 // Function  : localSelection
417 // Purpose   : Activate selection of objects of a given type
418 // IMPORTANT : Works after localSelection( ... ) method call only
419 //================================================================
420 void GEOMBase_Helper::activate( const int theType )
421 {
422   if (!getStudy()) return;
423   _PTR(Study) aStudy = getStudy()->studyDS();
424   _PTR(SComponent) aGeom ( aStudy->FindComponent( "GEOM" ) );
425   if ( !aGeom )
426     return;
427
428   SALOME_ListIO aList;
429   _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( aGeom ) );
430   for ( ; anIter->More(); anIter->Next() )
431   {
432     _PTR(SObject) aSO ( anIter->Value() );
433     if ( aSO )
434     {
435       _PTR(SObject) aRefSO;
436       if ( !aSO->ReferencedObject( aRefSO ) )
437       {
438         GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow
439           (GeometryGUI::ClientSObjectToObject(aSO));
440         if ( !anObj->_is_nil() && anObj->GetType() == theType )
441           aList.Append( new SALOME_InteractiveObject( aSO->GetID().c_str(), "GEOM", aSO->GetName().c_str()) );
442       }
443     }
444   }
445
446   getDisplayer()->LocalSelection( aList, 0 );
447 }
448
449 //================================================================
450 // Function : localSelection
451 // Purpose  : Activate selection of subshapes in accordance with mode
452 //            theMode is from TopAbs_ShapeEnum
453 //================================================================
454 void GEOMBase_Helper::localSelection( const ObjectList& theObjs, const int theMode )
455 {
456   SALOME_ListIO aListOfIO;
457
458   ObjectList::const_iterator anIter = theObjs.begin();
459   for ( ; anIter != theObjs.end(); ++anIter )
460   {
461     GEOM::GEOM_Object_ptr anObj = *anIter;
462     if ( anObj->_is_nil() )
463       continue;
464     QString anEntry = getEntry( anObj );
465     if ( anEntry != "" )
466       aListOfIO.Append( new SALOME_InteractiveObject(
467         anEntry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( anObj ).toLatin1().constData() ) ) );
468   }
469
470   getDisplayer()->LocalSelection( aListOfIO, theMode );
471 }
472
473 //================================================================
474 // Function : localSelection
475 // Purpose  : Activate selection of subshapes in accordance with mode
476 //            theMode is from TopAbs_ShapeEnum
477 //================================================================
478 void GEOMBase_Helper::localSelection( GEOM::GEOM_Object_ptr obj, const int mode )
479 {
480   // If object is null local selection for all objects is activated
481   if ( obj->_is_nil() ) {
482     getDisplayer()->LocalSelection( Handle(SALOME_InteractiveObject)(), mode );
483     return;
484   }
485
486   ObjectList objList;
487   objList.push_back( obj );
488   localSelection( objList, mode );
489 }
490
491
492 //================================================================
493 // Function : globalSelection
494 // Purpose  : Activate selection of subshapes. Set selection filters
495 //            in accordance with mode. theMode is from GEOMImpl_Types
496 //================================================================
497 void GEOMBase_Helper::globalSelection( const int theMode, const bool update )
498 {
499   getDisplayer()->GlobalSelection( theMode, update );
500 }
501
502 //================================================================
503 // Function : globalSelection
504 // Purpose  : Activate selection of subshapes. Set selection filters
505 //            in accordance with mode. theMode is from GEOMImpl_Types
506 //================================================================
507 void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes,
508                                        const bool update )
509 {
510   getDisplayer()->GlobalSelection( theModes, update );
511 }
512
513 //================================================================
514 // Function : globalSelection
515 // Purpose  : Activate selection of subshapes. Set selection filters
516 //            in accordance with mode. theMode is from GEOMImpl_Types
517 //================================================================
518 void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes,
519                                        const QList<int>& subShapes,
520                                        const bool update )
521 {
522   getDisplayer()->GlobalSelection( theModes, update, &subShapes );
523 }
524
525 //================================================================
526 // Function : addInStudy
527 // Purpose  : Add object in study
528 //================================================================
529 QString GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* theName )
530 {
531   if ( !hasCommand() )
532     return QString();
533
534   _PTR(Study) aStudy = getStudy()->studyDS();
535   if ( !aStudy || theObj->_is_nil() )
536     return QString();
537
538   SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy);
539
540   GEOM::GEOM_Object_ptr aFatherObj = getFather( theObj );
541
542   SALOMEDS::SObject_var aSO =
543     getGeomEngine()->AddInStudy(aStudyDS, theObj, theName, aFatherObj);
544
545   QString anEntry;
546   if ( !aSO->_is_nil() )
547     anEntry = aSO->GetID();
548
549   // Each dialog is responsible for this method implementation,
550   // default implementation does nothing
551   restoreSubShapes(aStudyDS, aSO);
552   aSO->UnRegister();
553
554   return anEntry;
555 }
556
557 //================================================================
558 // Function : restoreSubShapes
559 // Purpose  : restore tree of argument's sub-shapes under the resulting shape
560 //================================================================
561 void GEOMBase_Helper::restoreSubShapes (SALOMEDS::Study_ptr   /*theStudy*/,
562                                         SALOMEDS::SObject_ptr /*theSObject*/)
563 {
564   // do nothing by default
565
566   // example of implementation in particular dialog:
567   // GEOM::ListOfGO anArgs;
568   // anArgs.length(0); // empty list means that all arguments should be restored
569   // getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
570   //                                     /*theFindMethod=*/GEOM::FSM_GetInPlace,
571   //                                     /*theInheritFirstArg=*/false);
572 }
573
574 //================================================================
575 // Function : updateObjBrowser
576 // Purpose  : Update object browser
577 //================================================================
578 void GEOMBase_Helper::updateObjBrowser() const
579 {
580   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
581   if (app) {
582     CAM_Module* module = app->module( "Geometry" );
583     SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>( module );
584     if ( appMod ) {
585       appMod->updateObjBrowser( true );
586     }
587   }
588 }
589
590 //================================================================
591 // Function : updateViewer
592 // Purpose  : Update active 3D view
593 //================================================================
594 void GEOMBase_Helper::updateViewer()
595 {
596   getDisplayer()->UpdateViewer();
597 }
598
599 //================================================================
600 // Function : getStudyId
601 // Purpose  : Get study Id
602 //================================================================
603 int GEOMBase_Helper::getStudyId() const
604 {
605   int anId = -1;
606   if ( getStudy() )
607     anId = getStudy()->id();
608   return anId;
609 }
610
611 //================================================================
612 // Function : getStudy
613 // Purpose  : Returns the active study. It is recommended to use
614 //            this method instead of direct desktop->getActiveStudy() calls
615 //================================================================
616 SalomeApp_Study* GEOMBase_Helper::getStudy() const
617 {
618   SUIT_Desktop* aDesktop = getDesktop();
619   if (!aDesktop)
620     return 0;
621
622   QList<SUIT_Application*> anAppList = SUIT_Session::session()->applications();
623
624   SUIT_Application* anApp = 0;
625   QListIterator<SUIT_Application*> it( anAppList );
626   while ( it.hasNext() )
627     {
628       anApp = it.next();
629       if ( anApp && anApp->desktop() == aDesktop )
630         break;
631     }
632
633   return dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
634 }
635
636 //================================================================
637 // Function : getEntry
638 // Purpose  :
639 //================================================================
640 QString GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const
641 {
642   SalomeApp_Study* study = getStudy();
643   if ( study )  {
644     QString objIOR = GEOMBase::GetIORFromObject( object );
645     if ( objIOR != "" ) {
646       _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( objIOR.toLatin1().constData() ) );
647       if ( SO )
648         return QString::fromStdString(SO->GetID());
649     }
650   }
651   return "";
652 }
653
654 //================================================================
655 // Function : getDisplayer
656 // Purpose  :
657 //================================================================
658 GEOM_Displayer* GEOMBase_Helper::getDisplayer()
659 {
660   if ( !myDisplayer )
661     myDisplayer = new GEOM_Displayer( getStudy() );
662   return myDisplayer;
663 }
664
665 //================================================================
666 // Function : clearShapeBuffer
667 // Purpose  :
668 //================================================================
669 void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
670 {
671   if ( CORBA::is_nil( theObj ) )
672     return;
673
674   CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
675   TCollection_AsciiString asciiIOR( (char *)IOR.in() );
676   GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
677
678   if ( !getStudy() || !getStudy()->studyDS() )
679     return;
680
681   _PTR(Study) aStudy = getStudy()->studyDS();
682   _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
683   if ( !aSObj )
684     return;
685
686   _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
687   for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
688     _PTR(GenericAttribute) anAttr;
689     if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
690       _PTR(AttributeIOR) anIOR ( anAttr );
691       TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
692       GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
693     }
694   }
695 }
696
697 //================================================================
698 // Function : openCommand
699 // Purpose  :
700 //================================================================
701 bool GEOMBase_Helper::openCommand()
702 {
703   bool res = false;
704   if ( !getStudy() || hasCommand() )
705   {
706     MESSAGE("Getting out from openCommand()")
707     return res;
708   }
709
710   GEOM::GEOM_IOperations_var anOp = GEOM::GEOM_IOperations::_narrow( getOperation() );
711   if ( !anOp->_is_nil() ) {
712     myCommand = new GEOM_Operation( SUIT_Session::session()->activeApplication(), anOp.in() );
713     myCommand->start();
714     res = true;
715   }
716   else
717   {
718     MESSAGE("anOp->_is_nil() = true")
719   }
720
721   return res;
722 }
723
724 //================================================================
725 // Function : abortCommand
726 // Purpose  :
727 //================================================================
728 bool GEOMBase_Helper::abortCommand()
729 {
730   if ( !hasCommand() )
731     return false;
732
733   myCommand->abort();
734   delete myCommand; // I don't know where to delete this object here ?
735   myCommand = 0;
736
737   return true;
738 }
739
740 //================================================================
741 // Function : commitCommand
742 // Purpose  :
743 //================================================================
744 bool GEOMBase_Helper::commitCommand( const char* )
745 {
746   if ( !hasCommand() )
747     return false;
748
749   myCommand->commit();
750   delete myCommand; // I don't know where to delete this object here ?
751   myCommand = 0;
752
753   return true;
754 }
755
756 //================================================================
757 // Function : hasCommand
758 // Purpose  :
759 //================================================================
760 bool GEOMBase_Helper::hasCommand() const
761 {
762   bool res = (bool) myCommand;
763   MESSAGE("hasCommand = "<<res)
764   return (bool)myCommand;
765 }
766
767 //================================================================
768 // Function : getOperation
769 // Purpose  :
770 //================================================================
771 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::getOperation()
772 {
773   if ( myOperation->_is_nil() )
774     myOperation = createOperation();
775
776   return myOperation;
777 }
778
779
780
781 //================================================================
782 // Function : checkViewWindow
783 // Purpose  :
784 //================================================================
785 bool GEOMBase_Helper::checkViewWindow()
786 {
787   if ( myViewWindow ){
788     QList<SUIT_ViewWindow*> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
789     QListIterator<SUIT_ViewWindow*> it( aViewWindowsList );
790     while ( it.hasNext() )
791       {
792         if ( myViewWindow == it.next() )
793           return true;
794       }
795   }
796   myViewWindow = 0;
797   return false;
798 }
799
800 //================================================================
801 // Function : onAccept
802 // Purpose  : This method should be called from dialog's slots onOk() and onApply()
803 //            It perfroms user input validation, then it
804 //            performs a proper operation and manages transactions, etc.
805 //================================================================
806 bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
807 {
808   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
809   if ( !appStudy ) 
810   {
811     MESSAGE("appStudy is empty")
812     return false;
813   }
814   _PTR(Study) aStudy = appStudy->studyDS();
815
816   bool aLocked = (_PTR(AttributeStudyProperties) (aStudy->GetProperties()))->IsLocked();
817   if ( aLocked ) {
818     MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
819     SUIT_MessageBox::warning ( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(),
820                                QObject::tr("WRN_WARNING"),
821                                QObject::tr("WRN_STUDY_LOCKED"),
822                                QObject::tr("BUT_OK") );
823     return false;
824   }
825
826   QString msg;
827   if ( !isValid( msg ) ) {
828     showError( msg );
829     return false;
830   }
831
832   erasePreview( false );
833
834   bool result = false;
835
836   try {
837     if ( ( !publish && !useTransaction ) || openCommand() ) {
838       SUIT_OverrideCursor wc;
839       SUIT_Session::session()->activeApplication()->putInfo( "" );
840       ObjectList objects;
841       if ( !execute( objects ) || !getOperation()->IsDone() ) {
842         wc.suspend();
843         abortCommand();
844         showError();
845       }
846       else {
847         addSubshapesToStudy(); // add Subshapes if local selection
848         const int nbObjs = objects.size();
849         QStringList anEntryList;
850         int aNumber = 1;
851         for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
852           GEOM::GEOM_Object_var obj=*it;
853           if ( publish ) {
854             QString aName = getNewObjectName();
855             if ( nbObjs > 1 ) {
856               if (aName.isEmpty())
857                 aName = getPrefix(obj);
858               if (nbObjs <= 30) {
859                 // Try to find a unique name
860                 aName = GEOMBase::GetDefaultName(aName, extractPrefix());
861               } else {
862                 // Don't check name uniqueness in case of numerous objects
863                 aName = aName + "_" + QString::number(aNumber++);
864               }
865             } else {
866               // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
867               if ( aName.isEmpty() )
868                 aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
869             }
870             anEntryList << addInStudy( obj, aName.toLatin1().constData() );
871             // updateView=false
872             display( obj, false );
873 #ifdef WITHGENERICOBJ
874             // obj has been published in study. Its refcount has been incremented.
875             // It is safe to decrement its refcount
876             // so that it will be destroyed when the entry in study will be removed
877             obj->UnRegister();
878 #endif
879           }
880           else {
881             // asv : fix of PAL6454. If publish==false, then the original shape
882             // was modified, and need to be re-cached in GEOM_Client before redisplay
883             clearShapeBuffer( obj );
884             // withChildren=true, updateView=false
885             redisplay( obj, true, false );
886           }
887         }
888
889         if ( nbObjs ) {
890           commitCommand();
891           updateObjBrowser();
892           if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) {
893             if( LightApp_Application* aLightApp = dynamic_cast<LightApp_Application*>( anApp ) )
894               aLightApp->browseObjects( anEntryList, isApplyAndClose(), isOptimizedBrowsing() );
895             anApp->putInfo( QObject::tr("GEOM_PRP_DONE") );
896           }
897           result = true;
898         }
899         else
900           abortCommand();
901       }
902     }
903   }
904   catch( const SALOME::SALOME_Exception& e ) {
905     SalomeApp_Tools::QtCatchCorbaException( e );
906     abortCommand();
907     MESSAGE("Exception catched")
908   }
909
910   updateViewer();
911
912   MESSAGE("result ="<<result)
913   return result;
914 }
915
916
917 //================================================================
918 // Function : showError
919 // Purpose  : Shows a message box with infromation about an error taken from getOperation()->GetErrorCode()
920 //================================================================
921 void GEOMBase_Helper::showError()
922 {
923   QString msg;
924   if ( !getOperation()->_is_nil() )
925     msg = QObject::tr( getOperation()->GetErrorCode() );
926
927   if ( msg.isEmpty() )
928     msg = QObject::tr( "GEOM_PRP_ABORT" );
929
930   SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
931                              QObject::tr( "GEOM_ERROR_STATUS" ),
932                              msg,
933                              QObject::tr( "BUT_OK" ) );
934 }
935
936 //================================================================
937 // Function : showError
938 // Purpose  : Shows a error message followed by <msg>
939 //================================================================
940 void GEOMBase_Helper::showError( const QString& msg )
941 {
942   QString str( QObject::tr( "GEOM_INCORRECT_INPUT" ) );
943   if ( !msg.isEmpty() )
944     str += "\n" + msg;
945   SUIT_MessageBox::critical(SUIT_Session::session()->activeApplication()->desktop(), QObject::tr( "GEOM_ERROR" ), str, QObject::tr( "BUT_OK" ) );
946 }
947
948 //////////////////////////////////////////////////////////////////
949 // Virtual methods to be redefined in dialogs
950 //////////////////////////////////////////////////////////////////
951
952 //================================================================
953 // Function : createOperation
954 // Purpose  : Redefine this method to return proper IOperation reference
955 //================================================================
956 GEOM::GEOM_IOperations_ptr GEOMBase_Helper::createOperation()
957 {
958   GEOM::GEOM_IOperations_var aNilOp;
959   return aNilOp._retn();
960 }
961
962 //================================================================
963 // Function : isValid
964 // Purpose  : Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
965 //================================================================
966 bool GEOMBase_Helper::isValid( QString& )
967 {
968   return true;
969 }
970
971 //================================================================
972 // Function : execute
973 // Purpose  : This method is called by onAccept().
974 //            It should perform the required operation and put all new or modified objects into
975 //            <objects> argument.Should return <false> if some error occurs during its execution.
976 //================================================================
977 bool GEOMBase_Helper::execute( ObjectList& objects )
978 {
979   return false;
980 }
981
982 //================================================================
983 // Function : getFather
984 // Purpose  : This method is called by addInStudy(). It should return a father object
985 //            for <theObj> or a nil reference if <theObj> should be published
986 //            as a top-level object.
987 //================================================================
988 GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj )
989 {
990   return GEOM::GEOM_Object::_nil();
991 }
992
993 //================================================================
994 // Function : getNewObjectName
995 // Purpose  : Redefine this method to return proper name for a new object
996 //================================================================
997 QString GEOMBase_Helper::getNewObjectName() const
998 {
999   return QString::null;
1000 }
1001
1002 //================================================================
1003 // Function : extractPrefix
1004 // Purpose  : Redefine this method to return \c true if necessary
1005 //            to extract prefix when generating new name for the
1006 //            object(s) being created
1007 //================================================================
1008 bool GEOMBase_Helper::extractPrefix() const
1009 {
1010   return false;
1011 }
1012
1013 //================================================================
1014 // Function : getPrefix
1015 // Purpose  : Get prefix for name of created object
1016 //================================================================
1017 QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const
1018 {
1019   if ( !myPrefix.isEmpty() || theObj->_is_nil() )
1020     return myPrefix;
1021
1022   GEOM::shape_type aType = theObj->GetShapeType();
1023
1024   switch ( aType )
1025   {
1026     case GEOM::VERTEX   : return QObject::tr( "GEOM_VERTEX" );
1027     case GEOM::EDGE     : return QObject::tr( "GEOM_EDGE" );
1028     case GEOM::WIRE     : return QObject::tr( "GEOM_WIRE" );
1029     case GEOM::FACE     : return QObject::tr( "GEOM_FACE" );
1030     case GEOM::SHELL    : return QObject::tr( "GEOM_SHELL" );
1031     case GEOM::SOLID    : return QObject::tr( "GEOM_SOLID" );
1032     case GEOM::COMPSOLID: return QObject::tr( "GEOM_COMPOUNDSOLID" );
1033     case GEOM::COMPOUND : return QObject::tr( "GEOM_COMPOUND" );
1034     default : return "";
1035   }
1036 }
1037
1038 //================================================================
1039 // Function : getDesktop
1040 // Purpose  : Returns myDesktop field. Initialized in constructor,
1041 //            usually as dynamic_cast<SUIT_Desktop*>(parentWidget())
1042 //================================================================
1043 SUIT_Desktop* GEOMBase_Helper::getDesktop() const
1044 {
1045   return myDesktop;
1046 }
1047
1048 //================================================================
1049 // Function : selectObjects
1050 // Purpose  : Selects list of objects
1051 //================================================================
1052 bool GEOMBase_Helper::selectObjects( ObjectList& objects )
1053 {
1054   SUIT_DataOwnerPtrList aList;
1055   ObjectList::iterator anIter;
1056   for ( anIter = objects.begin(); anIter != objects.end(); ++anIter )
1057   {
1058     QString anEntry = getEntry( *anIter );
1059     LightApp_DataOwner* anOwher = new LightApp_DataOwner( anEntry );
1060     aList.append( anOwher );
1061   }
1062
1063   SUIT_Session* session = SUIT_Session::session();
1064   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1065   if ( !app )
1066     return false;
1067
1068   LightApp_SelectionMgr* aMgr = app->selectionMgr();
1069   if ( !aMgr )
1070     return false;
1071
1072   aMgr->setSelected( aList, false );
1073
1074   return true;
1075 }
1076
1077 //================================================================
1078 // Function : findObjectInFather
1079 // Purpose  : It should return an object if its founded in study or
1080 //            return Null object if the object is not founded
1081 //================================================================
1082 GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather (GEOM::GEOM_Object_ptr theFather,
1083                                                            const QString& theName)
1084 {
1085   SalomeApp_Application* app =
1086     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1087   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1088   _PTR(Study) aDStudy = appStudy->studyDS();
1089   QString IOR = GEOMBase::GetIORFromObject( theFather );
1090   _PTR(SObject) SObj ( aDStudy->FindObjectIOR( IOR.toLatin1().constData() ) );
1091
1092   bool inStudy = false;
1093   GEOM::GEOM_Object_var aReturnObject;
1094   for (_PTR(ChildIterator) iit (aDStudy->NewChildIterator( SObj )); iit->More() && !inStudy; iit->Next()) {
1095     _PTR(SObject) child (iit->Value());
1096     QString aChildName = child->GetName().c_str();
1097     if (aChildName == theName) {
1098       inStudy = true;
1099       CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(iit->Value());
1100       aReturnObject = GEOM::GEOM_Object::_narrow( corbaObj );
1101     }
1102   }
1103   if (inStudy)
1104     return aReturnObject._retn();
1105   
1106   return GEOM::GEOM_Object::_nil();
1107 }
1108
1109 //================================================================
1110 // Function : findObjectInFather
1111 // Purpose  : It should return an object if its founded in study or
1112 //            return Null object if the object is not founded
1113 //================================================================
1114 GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr theFather,
1115                                                            int theIndex )
1116 {
1117   GEOM::GEOM_Object_var object;
1118   bool found = false;
1119   
1120   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1121   if ( study ) {
1122     _PTR(Study) studyDS = study->studyDS();
1123     QString IOR = GEOMBase::GetIORFromObject( theFather );
1124     _PTR(SObject) sobject( studyDS->FindObjectIOR( IOR.toLatin1().constData() ) );
1125     if ( sobject ) {
1126       _PTR(ChildIterator) it( studyDS->NewChildIterator( sobject ) );
1127       for ( ; it->More() && !found; it->Next() ) {
1128         GEOM::GEOM_Object_var cobject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( it->Value() ) );
1129         if ( !CORBA::is_nil( cobject ) ) {
1130           GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices();
1131           int length = indices->length();
1132           for ( int i = 0; i < length && !found; i++ ) {
1133             if ( indices[i] == theIndex ) {
1134               object = cobject;
1135               found = true;
1136             }
1137           }
1138         }
1139       }
1140     }
1141   }
1142   
1143   return object._retn();
1144 }
1145
1146 //================================================================
1147 // Function : addSubshapesToStudy
1148 // Purpose  : Virtual method to add subshapes if needs
1149 //================================================================
1150 void GEOMBase_Helper::addSubshapesToStudy()
1151 {
1152   //Impemented in Dialogs, called from Accept method
1153 }
1154
1155 //================================================================
1156 // Function : getSelected
1157 // Purpose  : Get selected object by specified type
1158 //
1159 // Returns valid object if only one object of the specified type is selected
1160 // (no matter global or local selection is activated). If \a type is TopAbs_SHAPE,
1161 // geometrical object of any valid type is expected.
1162 // 
1163 // \param type type of the object to be obtained from selection
1164 // \return selected geometrical object or nil object if selection is not satisfactory
1165 //================================================================
1166 GEOM::GeomObjPtr GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type )
1167 {
1168   QList<TopAbs_ShapeEnum> types;
1169   types << type;
1170   return getSelected( types );
1171 }
1172
1173 //================================================================
1174 // Function : getSelected
1175 // Purpose  : Get selected object by specified types
1176 //
1177 // Returns valid object if only one object of the specified type is selected
1178 // (no matter global or local selection is activated). The list of allowed
1179 // shape types is passed via \a types. If \a types includes TopAbs_SHAPE,
1180 // geometrical object of any valid type is expected.
1181 // 
1182 // \param types list of allowed shape types for the objects to be obtained from selection
1183 // \return selected geometrical object or nil object if selection is not satisfactory
1184 //================================================================
1185 GEOM::GeomObjPtr GEOMBase_Helper::getSelected( const QList<TopAbs_ShapeEnum>& types )
1186 {
1187   QList<GEOM::GeomObjPtr> selected = getSelected( types, 1 );
1188   return selected.count() > 0 ? selected[0] : GEOM::GeomObjPtr();
1189 }
1190
1191 //================================================================
1192 // Function : getSelected
1193 // Purpose  : Get selected object(s) by specified type
1194 //
1195 // Returns list of selected objects if selection satisfies specifies selection options.
1196 // (no matter global or local selection is activated). If \a type is TopAbs_SHAPE,
1197 // geometrical objects of any valid type are expected.
1198 //
1199 // The \a type parameter specifies allowed type of the object(s) being selected.
1200 // The \a count parameter specifies exact number of the objects to be retrieved from selection.
1201 // The \a strict parameter specifies policy being applied to the selection. 
1202 // If \a count < 0, then any number of the selected objects is valid (including 0).
1203 // In this case, if \a strict is \c true (default), all selected objects should satisfy
1204 // the specified \a type.
1205 // If \a count > 0, only specified number of the objects is retrieved from the selection.
1206 // In this case, if \a strict is \c true (default), function returns empty list if total number of selected
1207 // objects does not correspond to the \a count parameter. Otherwise (if \a strict is \c false),
1208 // function returns valid list of objects if at least \a count objects satisfy specified \a type.
1209 // 
1210 // \param type type of the object(s) to be obtained from selection
1211 // \param count number of items to be retrieved from selection
1212 // \param strict selection policy
1213 // \return list of selected geometrical objects or empty list if selection is not satisfactory
1214 //================================================================
1215 QList<GEOM::GeomObjPtr> GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type, int count, bool strict )
1216 {
1217   QList<TopAbs_ShapeEnum> types;
1218   types << type;
1219   return getSelected( types, count, strict );
1220 }
1221
1222 static bool typeInList( TopAbs_ShapeEnum type, const QList<TopAbs_ShapeEnum>& types )
1223 {
1224   bool ok = false;
1225   for ( int i = 0; i < types.count() && !ok; i++ )
1226     ok = types[i] == TopAbs_SHAPE || types[i] == type;
1227   return ok;
1228 }
1229
1230 //================================================================
1231 // Function : getSelected
1232 // Purpose  : Get selected objects by specified types
1233 //
1234 // Returns list of selected objects if selection satisfies specifies selection options.
1235 // (no matter global or local selection is activated). If \a types includes TopAbs_SHAPE,
1236 // geometrical objects of any valid type are expected.
1237 //
1238 // The \a types parameter specifies allowed types of the object(s) being selected.
1239 // The \a count parameter specifies exact number of the objects to be retrieved from selection.
1240 // The \a strict parameter specifies policy being applied to the selection. 
1241 // If \a count < 0, then any number of the selected objects is valid (including 0).
1242 // In this case, if \a strict is \c true (default), all selected objects should satisfy
1243 // the specified \a type.
1244 // If \a count > 0, only specified number of the objects is retrieved from the selection.
1245 // In this case, if \a strict is \c true (default), function returns empty list if total number of selected
1246 // objects does not correspond to the \a count parameter. Otherwise (if \a strict is \c false),
1247 // function returns valid list of objects if at least \a count objects satisfy specified \a type.
1248 // 
1249 // \param types list of allowed shape types for the objects to be obtained from selection
1250 // \param count number of items to be retrieved from selection
1251 // \param strict selection policy
1252 // \return list of selected geometrical objects or empty list if selection is not satisfactory
1253 //================================================================
1254 QList<GEOM::GeomObjPtr> GEOMBase_Helper::getSelected( const QList<TopAbs_ShapeEnum>& types, int count, bool strict )
1255 {
1256   SUIT_Session* session = SUIT_Session::session();
1257   QList<GEOM::GeomObjPtr> result;
1258
1259   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1260   if ( app ) {
1261     LightApp_SelectionMgr* selMgr = app->selectionMgr();
1262     if ( selMgr ) {
1263       SALOME_ListIO selected;
1264       selMgr->selectedObjects( selected );
1265       SALOME_ListIteratorOfListIO it( selected );
1266       bool stopped = false;
1267       for ( ; it.More() && !stopped; it.Next() ) {
1268         Handle(SALOME_InteractiveObject) IO = it.Value();
1269         GEOM::GeomObjPtr object = GEOMBase::ConvertIOinGEOMObject( IO );
1270         if ( object ) {
1271           TColStd_IndexedMapOfInteger subShapes;
1272           selMgr->GetIndexes( IO, subShapes );
1273           int nbSubShapes = subShapes.Extent();
1274           if ( nbSubShapes == 0 ) {
1275             // global selection
1276             if ( typeInList( (TopAbs_ShapeEnum)(object->GetShapeType()), types ) ) {
1277               result << object;
1278               if ( count > 0 ) {
1279                 if ( strict && result.count() > count ) {
1280                   result.clear();
1281                   stopped = true;
1282                 }
1283                 else if ( !strict && result.count() == count )
1284                   stopped = true;
1285               }
1286             }
1287             else if ( strict ) {
1288               result.clear();
1289               stopped = true;
1290             }
1291           }
1292           else {
1293             // local selection
1294             for ( int i = 1; i <= nbSubShapes && !stopped; i++ ) {
1295               int idx = subShapes( i );
1296               GEOM::GeomObjPtr subShape = findObjectInFather( object.get(), idx );
1297               if ( !subShape ) {
1298                 // sub-shape is not yet published in the study
1299                 GEOM::ShapesOpPtr shapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
1300                 subShape.take( shapesOp->GetSubShape( object.get(), idx ) ); // take ownership!
1301               }
1302               if ( typeInList( (TopAbs_ShapeEnum)(subShape->GetShapeType()), types ) ) {
1303                 result << subShape;
1304                 if ( count > 0 ) {
1305                   if ( strict && result.count() > count ) {
1306                     result.clear();
1307                     stopped = true;
1308                   }
1309                   else if ( !strict && result.count() == count )
1310                     stopped = true;
1311                 }
1312               }
1313               else if ( strict ) {
1314                 result.clear();
1315                 stopped = true;
1316               }
1317             }
1318           }
1319         }
1320       }
1321     }
1322   }
1323   return result;
1324 }
1325
1326 //================================================================
1327 // Function : setIsApplyAndClose
1328 // Purpose  : Set value of the flag indicating that the dialog is
1329 //            accepted by Apply & Close button
1330 //================================================================
1331 void GEOMBase_Helper::setIsApplyAndClose( const bool theFlag )
1332 {
1333   myIsApplyAndClose = theFlag;
1334 }
1335
1336 //================================================================
1337 // Function : isApplyAndClose
1338 // Purpose  : Get value of the flag indicating that the dialog is
1339 //            accepted by Apply & Close button
1340 //================================================================
1341 bool GEOMBase_Helper::isApplyAndClose() const
1342 {
1343   return myIsApplyAndClose;
1344 }
1345
1346 //================================================================
1347 // Function : setIsOptimizedBrowsing
1348 // Purpose  : Set value of the flag switching to optimized
1349 //            browsing mode (to select the first published
1350 //            object only)
1351 //================================================================
1352 void GEOMBase_Helper::setIsOptimizedBrowsing( const bool theFlag )
1353 {
1354   myIsOptimizedBrowsing = theFlag;
1355 }
1356
1357 //================================================================
1358 // Function : isOptimizedBrowsing
1359 // Purpose  : Get value of the flag switching to optimized
1360 //            browsing mode (to select the first published
1361 //            object only)
1362 //================================================================
1363 bool GEOMBase_Helper::isOptimizedBrowsing() const
1364 {
1365   return myIsOptimizedBrowsing;
1366 }