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