]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.cpp
Salome HOME
b3f9f28f77709dd5accdea298fd2c88093a6e902
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include "PartSet_Module.h"
4 #include <PartSet_WidgetSketchLabel.h>
5 #include <PartSet_Validators.h>
6 #include <PartSet_Tools.h>
7 #include <PartSet_WidgetPoint2d.h>
8 #include <PartSet_WidgetPoint2dDistance.h>
9 #include <PartSet_WidgetShapeSelector.h>
10 #include <PartSet_SketcherMgr.h>
11
12 #include <ModuleBase_Operation.h>
13 #include <ModuleBase_IViewer.h>
14 #include <ModuleBase_IViewWindow.h>
15 #include <ModuleBase_IPropertyPanel.h>
16 #include <ModuleBase_WidgetEditor.h>
17 #include <ModuleBase_FilterFactory.h>
18 #include <ModuleBase_FilterLinearEdge.h>
19 #include <ModuleBase_FilterFace.h>
20 #include <ModuleBase_FilterMulti.h>
21 #include <ModuleBase_FilterCustom.h>
22 #include <ModuleBase_FilterNoConsructionSubShapes.h>
23
24 #include <ModelAPI_Object.h>
25 #include <ModelAPI_Events.h>
26 #include <ModelAPI_Validator.h>
27 #include <ModelAPI_Data.h>
28 #include <ModelAPI_Session.h>
29
30 #include <GeomDataAPI_Point2D.h>
31 #include <GeomDataAPI_Point.h>
32 #include <GeomDataAPI_Dir.h>
33
34 #include <XGUI_Displayer.h>
35 #include <XGUI_Workshop.h>
36 #include <XGUI_OperationMgr.h>
37 #include <XGUI_PropertyPanel.h>
38 #include <XGUI_ModuleConnector.h>
39 #include <XGUI_Tools.h>
40
41 #include <SketchPlugin_Feature.h>
42 #include <SketchPlugin_Sketch.h>
43 #include <SketchPlugin_Line.h>
44 //#include <SketchPlugin_Arc.h>
45 //#include <SketchPlugin_Circle.h>
46 #include <SketchPlugin_ConstraintLength.h>
47 #include <SketchPlugin_ConstraintDistance.h>
48 #include <SketchPlugin_ConstraintParallel.h>
49 #include <SketchPlugin_ConstraintPerpendicular.h>
50 #include <SketchPlugin_ConstraintRadius.h>
51 //#include <SketchPlugin_ConstraintRigid.h>
52
53 #include <Events_Loop.h>
54
55 #include <StdSelect_TypeOfFace.hxx>
56 #include <TopoDS_Vertex.hxx>
57 #include <TopoDS.hxx>
58 #include <TopoDS_Shape.hxx>
59 #include <BRep_Tool.hxx>
60
61 #include <QObject>
62 #include <QMouseEvent>
63 #include <QString>
64 #include <QTimer>
65 #include <QApplication>
66 #include <QMessageBox>
67 #include <QMainWindow>
68
69 #include <GeomAlgoAPI_FaceBuilder.h>
70 #include <GeomDataAPI_Dir.h>
71
72 #ifdef _DEBUG
73 #include <QDebug>
74 #endif
75
76 /*!Create and return new instance of XGUI_Module*/
77 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
78 {
79   return new PartSet_Module(theWshop);
80 }
81
82 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
83   : ModuleBase_IModule(theWshop), 
84   myRestartingMode(RM_None)
85 {
86   //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
87   mySketchMgr = new PartSet_SketcherMgr(this);
88
89   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
90   XGUI_Workshop* aWorkshop = aConnector->workshop();
91
92   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
93   connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
94   connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
95           this, SLOT(onOperationActivatedByPreselection()));
96
97   ModuleBase_IViewer* aViewer = theWshop->viewer();
98   connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
99           this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
100
101   createActions();
102 }
103
104 PartSet_Module::~PartSet_Module()
105 {
106   if (!myDocumentShapeFilter.IsNull())
107     myDocumentShapeFilter.Nullify();
108 }
109
110 void PartSet_Module::registerValidators()
111 {
112   //Registering of validators
113   SessionPtr aMgr = ModelAPI_Session::get();
114   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
115   aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
116   aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
117   aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
118   aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
119   aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
120   aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
121   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
122   aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
123 }
124
125 void PartSet_Module::registerFilters()
126 {
127   //Registering of selection filters
128   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
129   ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
130
131   aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
132   aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
133   aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
134   Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
135   aFactory->registerFilter("NoConstructionSubShapesFilter",
136             new ModuleBase_FilterCustom(aSelectFilter));
137 }
138
139 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) 
140 {
141   if (theOperation->isEditOperation())
142     return;
143   // the selection is cleared after commit the create operation
144   // in order to do not use the same selected objects in the restarted operation
145   // for common behaviour, the selection is cleared even if the operation is not restarted
146   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
147   if (!aContext.IsNull())
148     aContext->ClearSelected();
149
150   /// Restart sketcher operations automatically
151   FeaturePtr aFeature = theOperation->feature();
152   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
153             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
154   if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
155                      myRestartingMode == RM_EmptyFeatureUsed)) {
156     myLastOperationId = theOperation->id();
157     myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
158     
159     launchOperation(myLastOperationId);
160   }
161   breakOperationSequence();
162 }
163
164 void PartSet_Module::breakOperationSequence()
165 {
166   myLastOperationId = "";
167   myLastFeature = FeaturePtr();
168   myRestartingMode = RM_None;
169 }
170
171 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
172 {
173   breakOperationSequence();
174 }
175
176 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
177 {
178   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
179     mySketchMgr->startSketch(theOperation);
180   }
181   if (myDocumentShapeFilter.IsNull())
182     myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
183   myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
184 }
185
186 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
187 {
188   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
189     mySketchMgr->stopSketch(theOperation);
190   }
191   myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
192 }
193
194 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
195 {
196   bool aCanDisplay = false;
197   if (mySketchMgr->activeSketch()) {
198     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
199
200     if (aFeature.get() != NULL) {
201       if (aFeature == mySketchMgr->activeSketch()) {
202         aCanDisplay = false;
203       }
204       else {
205         aCanDisplay = mySketchMgr->sketchOperationIdList().contains(aFeature->getKind().c_str());
206       }
207     }
208   }
209   else {
210     aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
211   }
212   return aCanDisplay;
213
214 void PartSet_Module::addViewerItems(QMenu* theMenu) const
215 {
216   if (isSketchOperationActive()) {
217     ModuleBase_ISelection* aSelection = myWorkshop->selection();
218     QObjectPtrList aObjects = aSelection->selectedPresentations();
219     if (aObjects.size() > 0) {
220       bool hasFeature = false;
221       foreach(ObjectPtr aObject, aObjects)
222       {
223         FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
224         if (aFeature.get() != NULL) {
225           hasFeature = true;
226         }
227       }
228       if (hasFeature)
229         theMenu->addAction(action("DELETE_PARTSET_CMD"));
230     }
231   }
232 }
233
234 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
235 {
236   ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
237   if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) && 
238     (theOperation->isEditOperation())) {
239     // we have to manually activate the sketch label in edit mode
240       aPanel->activateWidget(aPanel->modelWidgets().first());
241       return;
242   }
243
244   // Restart last operation type 
245   if ((theOperation->id() == myLastOperationId) && myLastFeature) {
246     ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
247     if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
248       // Initialise new line with first point equal to end of previous
249       PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
250       if (aPnt2dWgt) {
251         std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
252         std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
253           std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
254         if (aPoint) {
255           aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
256           PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(), 
257             aWgt->attributeID(), aPoint->x(), aPoint->y());
258           aPanel->activateNextWidget(aPnt2dWgt);
259         }
260       }
261     }
262   } else {
263     // Start editing constraint
264     if (theOperation->isEditOperation()) {
265       // TODO: #391 - to be removed
266       std::string aId = theOperation->id().toStdString();
267       if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
268         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
269             (aId == SketchPlugin_ConstraintLength::ID()) || 
270             (aId == SketchPlugin_ConstraintDistance::ID())) {
271           // Find and activate widget for management of point for dimension line position
272           QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
273           foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
274             PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
275             if (aPntWgt) {
276               aPanel->activateWidget(aPntWgt);
277               return;
278             }
279           }
280         } 
281       }
282     }
283   }
284 }
285
286
287 void PartSet_Module::onSelectionChanged()
288 {
289   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
290   if (!aOperation)
291     return;
292
293   bool isSketcherOp = false;
294   // An edit operation is enable only if the current opeation is the sketch operation
295   if (mySketchMgr->activeSketch()) {
296     if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
297       isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
298   }
299   if (isSketcherOp) {
300     // Editing of constraints can be done on selection
301     ModuleBase_ISelection* aSelect = myWorkshop->selection();
302     QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
303     if (aSelected.size() == 1) {
304       ModuleBase_ViewerPrs aPrs = aSelected.first();
305       ObjectPtr aObject = aPrs.object();
306       FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
307       if (aFeature) {
308         std::string aId = aFeature->getKind();
309         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
310             (aId == SketchPlugin_ConstraintLength::ID()) || 
311             (aId == SketchPlugin_ConstraintDistance::ID())) {
312           editFeature(aFeature);
313         }
314       }
315     }
316   } 
317 }
318
319 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
320 {
321   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
322   XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
323   anOpMgr->onKeyReleased(theEvent);
324 }
325
326 void PartSet_Module::onEnterReleased()
327 {
328   myRestartingMode = RM_EmptyFeatureUsed;
329 }
330
331 void PartSet_Module::onOperationActivatedByPreselection()
332 {
333   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
334   if(aOperation && isSketchOperationActive()) {
335     // Set final definitions if they are necessary
336     //propertyPanelDefined(aOperation);
337
338     /// Commit sketcher operations automatically
339     aOperation->commit();
340   }
341 }
342
343 void PartSet_Module::onNoMoreWidgets()
344 {
345   if (isSketchOperationActive()) {
346     ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
347     if (aOperation) {
348       if (myRestartingMode != RM_Forbided)
349         myRestartingMode = RM_LastFeatureUsed;
350       aOperation->commit();
351     }
352   }
353 }
354
355 void PartSet_Module::onVertexSelected()
356 {
357   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
358   if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
359     /// If last line finished on vertex the lines creation sequence has to be break
360     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
361     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
362     if (aWidgets.last() == aPanel->activeWidget()) {
363       myRestartingMode = RM_Forbided;
364     }
365   }
366 }
367
368 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
369                                             Config_WidgetAPI* theWidgetApi, std::string theParentId,
370                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
371 {
372   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
373   XGUI_Workshop* aWorkshop = aConnector->workshop();
374   if (theType == "sketch-start-label") {
375     PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
376     aWgt->setWorkshop(aWorkshop);
377     connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
378       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
379     theModelWidgets.append(aWgt);
380     return aWgt->getControl();
381
382   } else if (theType == "sketch-2dpoint_selector") {
383     PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
384     aWgt->setWorkshop(aWorkshop);
385     aWgt->setSketch(mySketchMgr->activeSketch());
386
387     connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
388
389     theModelWidgets.append(aWgt);
390     return aWgt->getControl();
391
392   } if (theType == "point2ddistance") {
393     PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
394     aWgt->setWorkshop(aWorkshop);
395     aWgt->setSketch(mySketchMgr->activeSketch());
396
397     theModelWidgets.append(aWgt);
398     return aWgt->getControl();
399
400   } if (theType == "sketch_shape_selector") {
401     PartSet_WidgetShapeSelector* aWgt = 
402       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
403     aWgt->setSketcher(mySketchMgr->activeSketch());
404
405     theModelWidgets.append(aWgt);
406     return aWgt->getControl();
407
408   } if (theType == "sketch_constraint_shape_selector") {
409     PartSet_WidgetConstraintShapeSelector* aWgt = 
410       new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
411     aWgt->setSketcher(mySketchMgr->activeSketch());
412
413     theModelWidgets.append(aWgt);
414     return aWgt->getControl();
415
416   } else
417     return 0;
418 }
419
420 bool PartSet_Module::isSketchOperationActive() const
421 {
422   bool isCurrentSketchOp = false;
423   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
424   if (aOperation) {
425     FeaturePtr aFeature = aOperation->feature();
426     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
427               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
428     isCurrentSketchOp = aSPFeature.get() != NULL;
429   }
430   return isCurrentSketchOp;
431 }
432
433 void PartSet_Module::createActions()
434 {
435   QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
436   addAction("DELETE_PARTSET_CMD", aAction);
437 }
438
439 QAction* PartSet_Module::action(const QString& theId) const
440 {
441   if (myActions.contains(theId))
442     return myActions[theId];
443   return 0;
444 }
445
446 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
447 {
448   if (myActions.contains(theId))
449     qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
450   theAction->setData(theId);
451   connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
452   myActions[theId] = theAction;
453 }
454
455 void PartSet_Module::onAction(bool isChecked)
456 {
457   QAction* aAction = static_cast<QAction*>(sender());
458   QString anId = aAction->data().toString();
459
460   if (anId == "DELETE_PARTSET_CMD") {
461     deleteObjects();
462   }
463 }
464
465 void PartSet_Module::deleteObjects()
466 {
467   if (!isSketchOperationActive())
468     return;
469
470   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
471   XGUI_Workshop* aWorkshop = aConnector->workshop();
472
473   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
474   if(anOpMgr->canAbortOperation()) {
475     ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
476     if (aCurrentOp) {
477       bool isSketchOp = aCurrentOp->id().toStdString() == SketchPlugin_Sketch::ID();
478       if (!isSketchOp)
479         aCurrentOp->abort();
480     }
481   }
482   // sketch feature should be skipped, only sub-features can be removed
483   // when sketch operation is active
484   CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
485
486   ModuleBase_ISelection* aSel = aConnector->selection();
487   QObjectPtrList aSelectedObj = aSel->selectedPresentations();
488
489   std::set<FeaturePtr> aRefFeatures;
490   foreach (ObjectPtr aObj, aSelectedObj)
491   {
492     //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
493     //if (aPart) {
494       // TODO: check for what there is this condition. It is placed here historicaly because
495       // ther is this condition during remove features.
496     //} else {
497     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
498     if (aFeature.get() != NULL) {
499       aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
500     }
501     //}
502   }
503
504   if (!aRefFeatures.empty()) {
505     QStringList aRefNames;
506     std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
507                                          aLast = aRefFeatures.end();
508     for (; anIt != aLast; anIt++) {
509       FeaturePtr aFeature = (*anIt);
510       if (aFeature == aSketch)
511         continue;
512       aRefNames.append((*anIt)->name().c_str());
513     }
514     if (!aRefNames.empty()) {
515       QString aNames = aRefNames.join(", ");
516
517       QMainWindow* aDesktop = aWorkshop->desktop();
518       QMessageBox::StandardButton aRes = QMessageBox::warning(
519           aDesktop, tr("Delete features"),
520           QString(tr("Selected features are used in the following features: %1.\
521   These features will be deleted also. Would you like to continue?")).arg(aNames),
522           QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
523       if (aRes != QMessageBox::Yes)
524         return;
525     }
526   }
527
528   SessionPtr aMgr = ModelAPI_Session::get();
529   aMgr->startOperation();
530   std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
531                                        aLast = aRefFeatures.end();
532   for (; anIt != aLast; anIt++) {
533     FeaturePtr aRefFeature = (*anIt);
534     if (aRefFeature == aSketch)
535       continue;
536     aRefFeature->document()->removeFeature(aRefFeature);
537   }
538
539   foreach (ObjectPtr aObj, aSelectedObj)
540   {
541     DocumentPtr aDoc = aObj->document();
542     //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
543     //if (aPart) {
544     //  if (aDoc == aMgr->activeDocument()) {
545     //    aDoc->close();
546     //  }
547     //} else {
548       //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
549     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
550     if (aFeature.get() != NULL) {
551       aDoc->removeFeature(aFeature);
552     }
553     //}
554   }
555   aWorkshop->displayer()->updateViewer();
556   //myDisplayer->updateViewer();
557   aMgr->finishOperation();
558 }