1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
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_WidgetConstraintShapeSelector.h>
11 #include <PartSet_SketcherMgr.h>
13 #include <ModuleBase_Operation.h>
14 #include <ModuleBase_IViewer.h>
15 #include <ModuleBase_IViewWindow.h>
16 #include <ModuleBase_IPropertyPanel.h>
17 #include <ModuleBase_WidgetEditor.h>
18 #include <ModuleBase_FilterFactory.h>
19 #include <ModuleBase_FilterLinearEdge.h>
20 #include <ModuleBase_FilterFace.h>
21 #include <ModuleBase_FilterMulti.h>
22 #include <ModuleBase_FilterCustom.h>
23 #include <ModuleBase_FilterNoConsructionSubShapes.h>
25 #include <ModelAPI_Object.h>
26 #include <ModelAPI_Events.h>
27 #include <ModelAPI_Validator.h>
28 #include <ModelAPI_Data.h>
29 #include <ModelAPI_Session.h>
30 #include <ModelAPI_ShapeValidator.h>
32 #include <GeomDataAPI_Point2D.h>
33 #include <GeomDataAPI_Point.h>
34 #include <GeomDataAPI_Dir.h>
36 #include <XGUI_Displayer.h>
37 #include <XGUI_Workshop.h>
38 #include <XGUI_OperationMgr.h>
39 #include <XGUI_PropertyPanel.h>
40 #include <XGUI_ModuleConnector.h>
41 #include <XGUI_Tools.h>
43 #include <SketchPlugin_Feature.h>
44 #include <SketchPlugin_Sketch.h>
45 #include <SketchPlugin_Line.h>
46 //#include <SketchPlugin_Arc.h>
47 //#include <SketchPlugin_Circle.h>
48 #include <SketchPlugin_ConstraintLength.h>
49 #include <SketchPlugin_ConstraintDistance.h>
50 #include <SketchPlugin_ConstraintParallel.h>
51 #include <SketchPlugin_ConstraintPerpendicular.h>
52 #include <SketchPlugin_ConstraintRadius.h>
53 //#include <SketchPlugin_ConstraintRigid.h>
55 #include <Events_Loop.h>
56 #include <Config_PropManager.h>
58 #include <StdSelect_TypeOfFace.hxx>
59 #include <TopoDS_Vertex.hxx>
61 #include <TopoDS_Shape.hxx>
62 #include <BRep_Tool.hxx>
65 #include <QMouseEvent>
68 #include <QApplication>
69 #include <QMessageBox>
70 #include <QMainWindow>
72 #include <GeomAlgoAPI_FaceBuilder.h>
73 #include <GeomDataAPI_Dir.h>
79 /*!Create and return new instance of XGUI_Module*/
80 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
82 return new PartSet_Module(theWshop);
85 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
86 : ModuleBase_IModule(theWshop),
87 myRestartingMode(RM_None)
89 //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
90 mySketchMgr = new PartSet_SketcherMgr(this);
92 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
93 XGUI_Workshop* aWorkshop = aConnector->workshop();
95 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
96 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
97 connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
98 this, SLOT(onOperationActivatedByPreselection()));
100 ModuleBase_IViewer* aViewer = theWshop->viewer();
101 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
102 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
107 PartSet_Module::~PartSet_Module()
109 if (!myDocumentShapeFilter.IsNull())
110 myDocumentShapeFilter.Nullify();
113 void PartSet_Module::registerValidators()
115 //Registering of validators
116 SessionPtr aMgr = ModelAPI_Session::get();
117 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
118 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
119 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
120 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
121 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
122 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
123 aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
124 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
125 aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
126 aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
129 void PartSet_Module::registerFilters()
131 //Registering of selection filters
132 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
133 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
135 aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
136 aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
137 aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
138 Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
139 aFactory->registerFilter("NoConstructionSubShapesFilter",
140 new ModuleBase_FilterCustom(aSelectFilter));
143 void PartSet_Module::registerProperties()
145 Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
147 Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
148 Config_Prop::Integer, SKETCH_WIDTH);
151 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
153 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
154 mySketchMgr->commitNestedSketch(theOperation);
157 if (theOperation->isEditOperation())
159 // the selection is cleared after commit the create operation
160 // in order to do not use the same selected objects in the restarted operation
161 // for common behaviour, the selection is cleared even if the operation is not restarted
162 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
163 if (!aContext.IsNull())
164 aContext->ClearSelected();
166 /// Restart sketcher operations automatically
167 FeaturePtr aFeature = theOperation->feature();
168 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
169 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
170 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
171 myRestartingMode == RM_EmptyFeatureUsed)) {
172 myLastOperationId = theOperation->id();
173 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
175 launchOperation(myLastOperationId);
177 breakOperationSequence();
180 void PartSet_Module::breakOperationSequence()
182 myLastOperationId = "";
183 myLastFeature = FeaturePtr();
184 myRestartingMode = RM_None;
187 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
189 breakOperationSequence();
192 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
194 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
195 mySketchMgr->startSketch(theOperation);
197 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
198 mySketchMgr->startNestedSketch(theOperation);
201 if (myDocumentShapeFilter.IsNull())
202 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
203 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
206 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
208 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
209 mySketchMgr->stopSketch(theOperation);
211 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
212 mySketchMgr->stopNestedSketch(theOperation);
214 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
217 bool PartSet_Module::canUndo() const
219 bool aCanUndo = false;
220 SessionPtr aMgr = ModelAPI_Session::get();
221 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
222 aCanUndo = !aMgr->isOperation();
223 if (!aCanUndo) // check the enable state additionally by sketch manager
224 aCanUndo = aMgr->canUndo();
229 bool PartSet_Module::canRedo() const
231 bool aCanRedo = false;
232 SessionPtr aMgr = ModelAPI_Session::get();
233 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
234 aCanRedo = !aMgr->isOperation();
235 if (!aCanRedo) // check the enable state additionally by sketch manager
236 aCanRedo = aMgr->canRedo();
241 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
243 bool aCanDisplay = false;
244 if (!mySketchMgr->canDisplayObject())
246 CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
247 if (aSketchFeature.get() != NULL) {
248 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
250 // MPV: the second and third conditions to avoid crash on exit for application
251 if (aFeature.get() != NULL && aFeature->data().get() && aFeature->data()->isValid()) {
252 if (aFeature == aSketchFeature) {
255 else if (aSketchFeature.get() && aSketchFeature->data().get() &&
256 aSketchFeature->data()->isValid()) {
257 for (int i = 0; i < aSketchFeature->numberOfSubs() && !aCanDisplay; i++) {
258 FeaturePtr aSubFeature = aSketchFeature->subFeature(i);
259 std::list<ResultPtr> aResults = aSubFeature->results();
260 std::list<ResultPtr>::const_iterator aIt;
261 for (aIt = aResults.begin(); aIt != aResults.end() && !aCanDisplay; ++aIt) {
262 if (theObject == (*aIt))
265 if (aSubFeature == theObject)
272 aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
277 void PartSet_Module::addViewerItems(QMenu* theMenu) const
279 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
280 if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
281 !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
284 ModuleBase_ISelection* aSelection = myWorkshop->selection();
285 QObjectPtrList aObjects = aSelection->selectedPresentations();
286 if (aObjects.size() > 0) {
287 bool hasFeature = false;
288 foreach(ObjectPtr aObject, aObjects)
290 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
291 if (aFeature.get() != NULL) {
296 theMenu->addAction(action("DELETE_PARTSET_CMD"));
300 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
302 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
303 if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
304 // we have to manually activate the sketch label in edit mode
305 aPanel->activateWidget(aPanel->modelWidgets().first());
309 // Restart last operation type
310 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
311 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
312 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
313 // Initialise new line with first point equal to end of previous
314 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
316 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
317 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
318 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
320 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
321 PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
322 aWgt->attributeID(), aPoint->x(), aPoint->y());
323 aPanel->activateNextWidget(aPnt2dWgt);
328 // Start editing constraint
329 if (theOperation->isEditOperation()) {
330 // TODO: #391 - to be removed
331 std::string aId = theOperation->id().toStdString();
332 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
333 PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
334 // Find and activate widget for management of point for dimension line position
335 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
336 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
337 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
339 aPanel->activateWidget(aPntWgt);
349 void PartSet_Module::onSelectionChanged()
351 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
355 bool isSketcherOp = false;
356 // An edit operation is enable only if the current opeation is the sketch operation
357 if (mySketchMgr->activeSketch()) {
358 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
359 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
362 // Editing of constraints can be done on selection
363 ModuleBase_ISelection* aSelect = myWorkshop->selection();
364 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
365 if (aSelected.size() == 1) {
366 ModuleBase_ViewerPrs aPrs = aSelected.first();
367 ObjectPtr aObject = aPrs.object();
368 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
370 std::string aId = aFeature->getKind();
371 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
372 (aId == SketchPlugin_ConstraintLength::ID()) ||
373 (aId == SketchPlugin_ConstraintDistance::ID())) {
374 editFeature(aFeature);
381 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
383 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
384 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
385 anOpMgr->onKeyReleased(theEvent);
388 void PartSet_Module::onEnterReleased()
390 myRestartingMode = RM_EmptyFeatureUsed;
393 void PartSet_Module::onOperationActivatedByPreselection()
395 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
396 if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
397 // Set final definitions if they are necessary
398 //propertyPanelDefined(aOperation);
400 /// Commit sketcher operations automatically
401 anOperation->commit();
405 void PartSet_Module::onNoMoreWidgets()
407 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
408 if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
410 if (myRestartingMode != RM_Forbided)
411 myRestartingMode = RM_LastFeatureUsed;
412 anOperation->commit();
417 void PartSet_Module::onVertexSelected()
419 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
420 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
421 /// If last line finished on vertex the lines creation sequence has to be break
422 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
423 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
424 if (aWidgets.last() == aPanel->activeWidget()) {
425 myRestartingMode = RM_Forbided;
430 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
431 Config_WidgetAPI* theWidgetApi, std::string theParentId,
432 QList<ModuleBase_ModelWidget*>& theModelWidgets)
434 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
435 XGUI_Workshop* aWorkshop = aConnector->workshop();
436 if (theType == "sketch-start-label") {
437 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
438 aWgt->setWorkshop(aWorkshop);
439 connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
440 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
441 theModelWidgets.append(aWgt);
442 return aWgt->getControl();
444 } else if (theType == "sketch-2dpoint_selector") {
445 PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
446 aWgt->setWorkshop(aWorkshop);
447 aWgt->setSketch(mySketchMgr->activeSketch());
449 connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
451 theModelWidgets.append(aWgt);
452 return aWgt->getControl();
454 } if (theType == "point2ddistance") {
455 PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
456 aWgt->setWorkshop(aWorkshop);
457 aWgt->setSketch(mySketchMgr->activeSketch());
459 theModelWidgets.append(aWgt);
460 return aWgt->getControl();
462 } if (theType == "sketch_shape_selector") {
463 PartSet_WidgetShapeSelector* aWgt =
464 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
465 aWgt->setSketcher(mySketchMgr->activeSketch());
467 theModelWidgets.append(aWgt);
468 return aWgt->getControl();
470 } if (theType == "sketch_constraint_shape_selector") {
471 PartSet_WidgetConstraintShapeSelector* aWgt =
472 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
473 aWgt->setSketcher(mySketchMgr->activeSketch());
475 theModelWidgets.append(aWgt);
476 return aWgt->getControl();
482 void PartSet_Module::createActions()
484 QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
485 addAction("DELETE_PARTSET_CMD", aAction);
488 QAction* PartSet_Module::action(const QString& theId) const
490 if (myActions.contains(theId))
491 return myActions[theId];
495 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
497 if (myActions.contains(theId))
498 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
499 theAction->setData(theId);
500 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
501 myActions[theId] = theAction;
504 void PartSet_Module::onAction(bool isChecked)
506 QAction* aAction = static_cast<QAction*>(sender());
507 QString anId = aAction->data().toString();
509 if (anId == "DELETE_PARTSET_CMD") {
514 void PartSet_Module::deleteObjects()
516 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
517 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
518 if (!isSketchOp && !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
521 // sketch feature should be skipped, only sub-features can be removed
522 // when sketch operation is active
523 CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
525 // selected objects should be collected before the current operation abort because
526 // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
527 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
528 ModuleBase_ISelection* aSel = aConnector->selection();
529 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
531 XGUI_Workshop* aWorkshop = aConnector->workshop();
532 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
533 if (!isSketchOp && anOpMgr->canStopOperation()) {
534 ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
539 std::set<FeaturePtr> aRefFeatures;
540 foreach (ObjectPtr aObj, aSelectedObj)
542 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
544 // TODO: check for what there is this condition. It is placed here historicaly because
545 // ther is this condition during remove features.
547 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
548 if (aFeature.get() != NULL) {
549 aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
553 QString aDescription = tr("Delete");
555 // according to #355 feature, it is not necessary to inform about dependencies during
556 // sketch delete operation
558 if (!aRefFeatures.empty()) {
559 QStringList aRefNames;
560 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
561 aLast = aRefFeatures.end();
562 for (; anIt != aLast; anIt++) {
563 FeaturePtr aFeature = (*anIt);
564 if (aFeature == aSketch)
566 aRefNames.append((*anIt)->name().c_str());
568 if (!aRefNames.empty()) {
569 QString aNames = aRefNames.join(", ");
570 aDescription += aNames.prepend(" ");
572 QMainWindow* aDesktop = aWorkshop->desktop();
573 QMessageBox::StandardButton aRes = QMessageBox::warning(
574 aDesktop, tr("Delete features"),
575 QString(tr("Selected features are used in the following features: %1.\
576 These features will be deleted also. Would you like to continue?")).arg(aNames),
577 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
578 if (aRes != QMessageBox::Yes)
583 SessionPtr aMgr = ModelAPI_Session::get();
584 aMgr->startOperation(aDescription.toStdString());
585 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
586 aLast = aRefFeatures.end();
587 for (; anIt != aLast; anIt++) {
588 FeaturePtr aRefFeature = (*anIt);
589 if (aRefFeature == aSketch)
591 aRefFeature->document()->removeFeature(aRefFeature);
594 foreach (ObjectPtr aObj, aSelectedObj)
596 DocumentPtr aDoc = aObj->document();
597 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
599 // if (aDoc == aMgr->activeDocument()) {
603 //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
604 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
605 if (aFeature.get() != NULL) {
606 aDoc->removeFeature(aFeature);
610 aWorkshop->displayer()->updateViewer();
611 //myDisplayer->updateViewer();
612 aMgr->finishOperation();