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_SketcherMgr.h>
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>
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 #include <ModelAPI_ShapeValidator.h>
31 #include <GeomDataAPI_Point2D.h>
32 #include <GeomDataAPI_Point.h>
33 #include <GeomDataAPI_Dir.h>
35 #include <XGUI_Displayer.h>
36 #include <XGUI_Workshop.h>
37 #include <XGUI_OperationMgr.h>
38 #include <XGUI_PropertyPanel.h>
39 #include <XGUI_ModuleConnector.h>
40 #include <XGUI_Tools.h>
42 #include <SketchPlugin_Feature.h>
43 #include <SketchPlugin_Sketch.h>
44 #include <SketchPlugin_Line.h>
45 //#include <SketchPlugin_Arc.h>
46 //#include <SketchPlugin_Circle.h>
47 #include <SketchPlugin_ConstraintLength.h>
48 #include <SketchPlugin_ConstraintDistance.h>
49 #include <SketchPlugin_ConstraintParallel.h>
50 #include <SketchPlugin_ConstraintPerpendicular.h>
51 #include <SketchPlugin_ConstraintRadius.h>
52 //#include <SketchPlugin_ConstraintRigid.h>
54 #include <Events_Loop.h>
55 #include <Config_PropManager.h>
57 #include <StdSelect_TypeOfFace.hxx>
58 #include <TopoDS_Vertex.hxx>
60 #include <TopoDS_Shape.hxx>
61 #include <BRep_Tool.hxx>
64 #include <QMouseEvent>
67 #include <QApplication>
68 #include <QMessageBox>
69 #include <QMainWindow>
71 #include <GeomAlgoAPI_FaceBuilder.h>
72 #include <GeomDataAPI_Dir.h>
78 /*!Create and return new instance of XGUI_Module*/
79 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
81 return new PartSet_Module(theWshop);
84 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
85 : ModuleBase_IModule(theWshop),
86 myRestartingMode(RM_None)
88 //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
89 mySketchMgr = new PartSet_SketcherMgr(this);
91 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
92 XGUI_Workshop* aWorkshop = aConnector->workshop();
94 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
95 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
96 connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
97 this, SLOT(onOperationActivatedByPreselection()));
99 ModuleBase_IViewer* aViewer = theWshop->viewer();
100 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
101 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
106 PartSet_Module::~PartSet_Module()
108 if (!myDocumentShapeFilter.IsNull())
109 myDocumentShapeFilter.Nullify();
112 void PartSet_Module::registerValidators()
114 //Registering of validators
115 SessionPtr aMgr = ModelAPI_Session::get();
116 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
117 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
118 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
119 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
120 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
121 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
122 aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
123 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
124 aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
125 aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
128 void PartSet_Module::registerFilters()
130 //Registering of selection filters
131 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
132 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
134 aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
135 aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
136 aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
137 Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
138 aFactory->registerFilter("NoConstructionSubShapesFilter",
139 new ModuleBase_FilterCustom(aSelectFilter));
142 void PartSet_Module::registerProperties()
144 Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
146 Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
147 Config_Prop::Integer, SKETCH_WIDTH);
150 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
152 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
153 mySketchMgr->commitNestedSketch(theOperation);
156 if (theOperation->isEditOperation())
158 // the selection is cleared after commit the create operation
159 // in order to do not use the same selected objects in the restarted operation
160 // for common behaviour, the selection is cleared even if the operation is not restarted
161 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
162 if (!aContext.IsNull())
163 aContext->ClearSelected();
165 /// Restart sketcher operations automatically
166 FeaturePtr aFeature = theOperation->feature();
167 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
168 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
169 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
170 myRestartingMode == RM_EmptyFeatureUsed)) {
171 myLastOperationId = theOperation->id();
172 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
174 launchOperation(myLastOperationId);
176 breakOperationSequence();
179 void PartSet_Module::breakOperationSequence()
181 myLastOperationId = "";
182 myLastFeature = FeaturePtr();
183 myRestartingMode = RM_None;
186 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
188 breakOperationSequence();
191 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
193 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
194 mySketchMgr->startSketch(theOperation);
196 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
197 mySketchMgr->startNestedSketch(theOperation);
200 if (myDocumentShapeFilter.IsNull())
201 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
202 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
205 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
207 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
208 mySketchMgr->stopSketch(theOperation);
210 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
211 mySketchMgr->stopNestedSketch(theOperation);
213 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
216 bool PartSet_Module::canUndo() const
218 bool aCanUndo = false;
219 SessionPtr aMgr = ModelAPI_Session::get();
220 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
221 aCanUndo = !aMgr->isOperation();
222 if (!aCanUndo) // check the enable state additionally by sketch manager
223 aCanUndo = aMgr->canUndo();
228 bool PartSet_Module::canRedo() const
230 bool aCanRedo = false;
231 SessionPtr aMgr = ModelAPI_Session::get();
232 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
233 aCanRedo = !aMgr->isOperation();
234 if (!aCanRedo) // check the enable state additionally by sketch manager
235 aCanRedo = aMgr->canRedo();
240 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
242 bool aCanDisplay = false;
243 if (!mySketchMgr->canDisplayObject())
245 CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
246 if (aSketchFeature.get() != NULL) {
247 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
249 // MPV: the second and third conditions to avoid crash on exit for application
250 if (aFeature.get() != NULL && aFeature->data().get() && aFeature->data()->isValid()) {
251 if (aFeature == aSketchFeature) {
254 else if (aSketchFeature.get() && aSketchFeature->data().get() &&
255 aSketchFeature->data()->isValid()) {
256 for (int i = 0; i < aSketchFeature->numberOfSubs() && !aCanDisplay; i++) {
257 FeaturePtr aSubFeature = aSketchFeature->subFeature(i);
258 std::list<ResultPtr> aResults = aSubFeature->results();
259 std::list<ResultPtr>::const_iterator aIt;
260 for (aIt = aResults.begin(); aIt != aResults.end() && !aCanDisplay; ++aIt) {
261 if (theObject == (*aIt))
264 if (aSubFeature == theObject)
271 aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
276 void PartSet_Module::addViewerItems(QMenu* theMenu) const
278 if (!PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation()) &&
279 !isSketchFeatureOperationActive())
281 ModuleBase_ISelection* aSelection = myWorkshop->selection();
282 QObjectPtrList aObjects = aSelection->selectedPresentations();
283 if (aObjects.size() > 0) {
284 bool hasFeature = false;
285 foreach(ObjectPtr aObject, aObjects)
287 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
288 if (aFeature.get() != NULL) {
293 theMenu->addAction(action("DELETE_PARTSET_CMD"));
297 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
299 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
300 if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
301 // we have to manually activate the sketch label in edit mode
302 aPanel->activateWidget(aPanel->modelWidgets().first());
306 // Restart last operation type
307 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
308 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
309 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
310 // Initialise new line with first point equal to end of previous
311 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
313 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
314 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
315 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
317 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
318 PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
319 aWgt->attributeID(), aPoint->x(), aPoint->y());
320 aPanel->activateNextWidget(aPnt2dWgt);
325 // Start editing constraint
326 if (theOperation->isEditOperation()) {
327 // TODO: #391 - to be removed
328 std::string aId = theOperation->id().toStdString();
329 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
330 PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
331 // Find and activate widget for management of point for dimension line position
332 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
333 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
334 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
336 aPanel->activateWidget(aPntWgt);
346 void PartSet_Module::onSelectionChanged()
348 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
352 bool isSketcherOp = false;
353 // An edit operation is enable only if the current opeation is the sketch operation
354 if (mySketchMgr->activeSketch()) {
355 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
356 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
359 // Editing of constraints can be done on selection
360 ModuleBase_ISelection* aSelect = myWorkshop->selection();
361 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
362 if (aSelected.size() == 1) {
363 ModuleBase_ViewerPrs aPrs = aSelected.first();
364 ObjectPtr aObject = aPrs.object();
365 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
367 std::string aId = aFeature->getKind();
368 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
369 (aId == SketchPlugin_ConstraintLength::ID()) ||
370 (aId == SketchPlugin_ConstraintDistance::ID())) {
371 editFeature(aFeature);
378 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
380 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
381 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
382 anOpMgr->onKeyReleased(theEvent);
385 void PartSet_Module::onEnterReleased()
387 myRestartingMode = RM_EmptyFeatureUsed;
390 void PartSet_Module::onOperationActivatedByPreselection()
392 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
393 if(aOperation && isSketchFeatureOperationActive()) {
394 // Set final definitions if they are necessary
395 //propertyPanelDefined(aOperation);
397 /// Commit sketcher operations automatically
398 aOperation->commit();
402 void PartSet_Module::onNoMoreWidgets()
404 if (isSketchFeatureOperationActive()) {
405 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
407 if (myRestartingMode != RM_Forbided)
408 myRestartingMode = RM_LastFeatureUsed;
409 aOperation->commit();
414 void PartSet_Module::onVertexSelected()
416 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
417 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
418 /// If last line finished on vertex the lines creation sequence has to be break
419 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
420 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
421 if (aWidgets.last() == aPanel->activeWidget()) {
422 myRestartingMode = RM_Forbided;
427 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
428 Config_WidgetAPI* theWidgetApi, std::string theParentId,
429 QList<ModuleBase_ModelWidget*>& theModelWidgets)
431 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
432 XGUI_Workshop* aWorkshop = aConnector->workshop();
433 if (theType == "sketch-start-label") {
434 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
435 aWgt->setWorkshop(aWorkshop);
436 connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
437 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
438 theModelWidgets.append(aWgt);
439 return aWgt->getControl();
441 } else if (theType == "sketch-2dpoint_selector") {
442 PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
443 aWgt->setWorkshop(aWorkshop);
444 aWgt->setSketch(mySketchMgr->activeSketch());
446 connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
448 theModelWidgets.append(aWgt);
449 return aWgt->getControl();
451 } if (theType == "point2ddistance") {
452 PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
453 aWgt->setWorkshop(aWorkshop);
454 aWgt->setSketch(mySketchMgr->activeSketch());
456 theModelWidgets.append(aWgt);
457 return aWgt->getControl();
459 } if (theType == "sketch_shape_selector") {
460 PartSet_WidgetShapeSelector* aWgt =
461 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
462 aWgt->setSketcher(mySketchMgr->activeSketch());
464 theModelWidgets.append(aWgt);
465 return aWgt->getControl();
467 } if (theType == "sketch_constraint_shape_selector") {
468 PartSet_WidgetConstraintShapeSelector* aWgt =
469 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
470 aWgt->setSketcher(mySketchMgr->activeSketch());
472 theModelWidgets.append(aWgt);
473 return aWgt->getControl();
479 bool PartSet_Module::isSketchFeatureOperationActive() const
481 bool isCurrentSketchOp = false;
482 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
484 FeaturePtr aFeature = aOperation->feature();
485 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
486 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
487 isCurrentSketchOp = aSPFeature.get() != NULL;
489 return isCurrentSketchOp;
492 void PartSet_Module::createActions()
494 QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
495 addAction("DELETE_PARTSET_CMD", aAction);
498 QAction* PartSet_Module::action(const QString& theId) const
500 if (myActions.contains(theId))
501 return myActions[theId];
505 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
507 if (myActions.contains(theId))
508 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
509 theAction->setData(theId);
510 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
511 myActions[theId] = theAction;
514 void PartSet_Module::onAction(bool isChecked)
516 QAction* aAction = static_cast<QAction*>(sender());
517 QString anId = aAction->data().toString();
519 if (anId == "DELETE_PARTSET_CMD") {
524 void PartSet_Module::deleteObjects()
526 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation());
527 if (!isSketchOp && !isSketchFeatureOperationActive())
530 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
531 XGUI_Workshop* aWorkshop = aConnector->workshop();
533 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
534 if (!isSketchOp && anOpMgr->canStopOperation()) {
535 ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
540 // sketch feature should be skipped, only sub-features can be removed
541 // when sketch operation is active
542 CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
544 ModuleBase_ISelection* aSel = aConnector->selection();
545 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
547 std::set<FeaturePtr> aRefFeatures;
548 foreach (ObjectPtr aObj, aSelectedObj)
550 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
552 // TODO: check for what there is this condition. It is placed here historicaly because
553 // ther is this condition during remove features.
555 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
556 if (aFeature.get() != NULL) {
557 aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
562 QString aDescription = tr("Delete");
563 if (!aRefFeatures.empty()) {
564 QStringList aRefNames;
565 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
566 aLast = aRefFeatures.end();
567 for (; anIt != aLast; anIt++) {
568 FeaturePtr aFeature = (*anIt);
569 if (aFeature == aSketch)
571 aRefNames.append((*anIt)->name().c_str());
573 if (!aRefNames.empty()) {
574 QString aNames = aRefNames.join(", ");
575 aDescription += aNames.prepend(" ");
577 QMainWindow* aDesktop = aWorkshop->desktop();
578 QMessageBox::StandardButton aRes = QMessageBox::warning(
579 aDesktop, tr("Delete features"),
580 QString(tr("Selected features are used in the following features: %1.\
581 These features will be deleted also. Would you like to continue?")).arg(aNames),
582 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
583 if (aRes != QMessageBox::Yes)
588 SessionPtr aMgr = ModelAPI_Session::get();
589 aMgr->startOperation(aDescription.toStdString());
590 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
591 aLast = aRefFeatures.end();
592 for (; anIt != aLast; anIt++) {
593 FeaturePtr aRefFeature = (*anIt);
594 if (aRefFeature == aSketch)
596 aRefFeature->document()->removeFeature(aRefFeature);
599 foreach (ObjectPtr aObj, aSelectedObj)
601 DocumentPtr aDoc = aObj->document();
602 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
604 // if (aDoc == aMgr->activeDocument()) {
608 //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
609 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
610 if (aFeature.get() != NULL) {
611 aDoc->removeFeature(aFeature);
615 aWorkshop->displayer()->updateViewer();
616 //myDisplayer->updateViewer();
617 aMgr->finishOperation();