]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.cpp
Salome HOME
fd8f12fbb020c0d54e541b53ac8895c8bbb69dec
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
1 #include <PartSet_Module.h>
2 #include <PartSet_OperationSketch.h>
3 #include <PartSet_OperationCreateFeature.h>
4 #include <PartSet_OperationCreateConstraint.h>
5 #include <PartSet_OperationFeatureCreate.h>
6 #include <PartSet_OperationFeatureEditMulti.h>
7 #include <PartSet_OperationFeatureEdit.h>
8 #include <ModuleBase_Operation.h>
9 #include <ModuleBase_OperationDescription.h>
10 #include <ModuleBase_WidgetFactory.h>
11 #include <PartSet_Listener.h>
12 #include <PartSet_TestOCC.h>
13
14 #include <ModuleBase_Operation.h>
15 #include <ModelAPI_Object.h>
16
17 #include <ModelAPI_Data.h>
18 #include <GeomDataAPI_Point2D.h>
19 #include <PartSet_Tools.h>
20
21 #include <XGUI_MainWindow.h>
22 #include <XGUI_Displayer.h>
23 #include <XGUI_Viewer.h>
24 #include <XGUI_Workshop.h>
25 #include <XGUI_OperationMgr.h>
26 #include <XGUI_SelectionMgr.h>
27 #include <XGUI_ViewPort.h>
28 #include <XGUI_ActionsMgr.h>
29 #include <XGUI_ViewerProxy.h>
30 #include <XGUI_ContextMenuMgr.h>
31 #include <XGUI_PropertyPanel.h>
32 #include <XGUI_ModuleConnector.h>
33 #include <XGUI_Tools.h>
34
35 #include <SketchPlugin_Line.h>
36
37 #include <Config_PointerMessage.h>
38 #include <Config_ModuleReader.h>
39 #include <Config_WidgetReader.h>
40 #include <Events_Loop.h>
41 #include <Events_Message.h>
42 #include <Events_Error.h>
43
44 #include <GeomAPI_Shape.h>
45
46 #include <AIS_ListOfInteractive.hxx>
47 //#include <AIS_DimensionSelectionMode.hxx>
48
49 #include <QObject>
50 #include <QMouseEvent>
51 #include <QString>
52
53 #ifdef _DEBUG
54 #include <QDebug>
55 #endif
56
57 /*!Create and return new instance of XGUI_Module*/
58 extern "C" PARTSET_EXPORT XGUI_Module* createModule(XGUI_Workshop* theWshop)
59 {
60   return new PartSet_Module(theWshop);
61 }
62
63 PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
64 {
65   myWorkshop = theWshop;
66   myListener = new PartSet_Listener(this);
67
68   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
69
70   connect(anOperationMgr, SIGNAL(operationStarted()),
71           this, SLOT(onOperationStarted()));
72
73   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
74           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
75
76   XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
77   connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), 
78           this, SLOT(onContextMenuCommand(const QString&, bool)));
79
80   connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
81           this, SLOT(onMousePressed(QMouseEvent*)));
82   connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
83           this, SLOT(onMouseReleased(QMouseEvent*)));
84   connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
85           this, SLOT(onMouseMoved(QMouseEvent*)));
86   connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
87           this, SLOT(onKeyRelease(QKeyEvent*)));
88   connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
89           this, SLOT(onMouseDoubleClick(QMouseEvent*)));
90 }
91
92 PartSet_Module::~PartSet_Module()
93 {
94 }
95
96 XGUI_Workshop* PartSet_Module::workshop() const
97 {
98   return myWorkshop;
99 }
100
101 void PartSet_Module::createFeatures()
102 {
103   Config_ModuleReader aXMLReader = Config_ModuleReader();
104   aXMLReader.readAll();
105   myFeaturesInFiles = aXMLReader.featuresInFiles();
106 }
107
108 void PartSet_Module::featureCreated(QAction* theFeature)
109 {
110   connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
111 }
112
113 QStringList PartSet_Module::nestedFeatures(QString)
114 {
115   return QStringList();
116 }
117
118 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
119 {
120   return myFeaturesInFiles[theFeatureId];
121 }
122
123 /*
124  *
125  */
126 void PartSet_Module::onFeatureTriggered()
127 {
128   //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
129   //                                   myWorkshop->viewer()->activeView());
130
131   //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
132   //                                       myWorkshop->viewer()->activeView());
133   QAction* aCmd = dynamic_cast<QAction*>(sender());
134   //Do nothing on uncheck
135   if(aCmd->isCheckable() && !aCmd->isChecked())
136     return;
137   launchOperation(aCmd->data().toString());
138 }
139   
140 void PartSet_Module::launchOperation(const QString& theCmdId)
141 {
142   ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
143   sendOperation(anOperation);
144 }
145
146 void PartSet_Module::onOperationStarted()
147 {
148   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
149                                        myWorkshop->operationMgr()->currentOperation());
150   if (aPreviewOp) {
151     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
152     connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
153             aPropPanel, SLOT(onFocusActivated(const std::string&)));
154
155     connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
156       this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
157   }
158 }
159
160 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
161 {
162   if (!theOperation)
163     return;
164   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
165   if (aPreviewOp) {
166     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
167     disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
168                aPropPanel, SLOT(onFocusActivated(const std::string&)));
169     //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
170     //           this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
171   }
172 }
173
174 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
175 {
176   QFeatureList aFeatures = myWorkshop->selector()->selectedFeatures();
177   if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
178     editFeature(aFeatures.first());
179   }
180 }
181
182 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
183 {
184   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
185                                        myWorkshop->operationMgr()->currentOperation());
186   if (aPreviewOp)
187   {
188     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
189     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
190     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
191
192     aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
193   }
194 }
195
196 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
197 {
198   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
199                                        myWorkshop->operationMgr()->currentOperation());
200   if (aPreviewOp)
201   {
202     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
203     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
204     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
205
206     aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
207   }
208 }
209
210 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
211 {
212   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
213                                        myWorkshop->operationMgr()->currentOperation());
214   if (aPreviewOp)
215     aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
216 }
217
218 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
219 {
220   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
221   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
222   if (aPreviewOp) {
223     aPreviewOp->keyReleased(theEvent->key());
224   }
225 }
226
227 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
228 {
229   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
230                                        myWorkshop->operationMgr()->currentOperation());
231   if (aPreviewOp)
232   {
233     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
234     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
235     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
236     aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
237                                  aHighlighted);
238   }
239 }
240
241 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
242 {
243   myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
244   myWorkshop->actionsMgr()->update();
245
246   //PartSet_TestOCC::testSelection(myWorkshop);
247 }
248
249 void PartSet_Module::onFitAllView()
250 {
251   myWorkshop->viewer()->fitAll();
252 }
253
254 void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeature)
255 {
256   ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
257                                                       theFeature ? theFeature->getKind() : "");
258   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
259   if (aPreviewOp)
260   {
261     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
262     // refill the features list with avoiding of the features, obtained only by vertex shape (TODO)
263     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
264     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
265     aPreviewOp->init(theFeature, aSelected, aHighlighted);
266   } else {
267     anOperation->setEditingFeature(theFeature);
268   }
269   sendOperation(anOperation);
270   myWorkshop->actionsMgr()->updateCheckState();
271 }
272
273 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
274 {
275   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
276   aViewer->enableMultiselection(theEnabled);
277 }
278
279 void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool isStop)
280 {
281   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
282   if (!isStop) {
283     QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
284     for (; anIt != aLast; anIt++) {
285       activateFeature((*anIt), false);
286     }
287   }
288   aDisplayer->stopSelection(theFeatures, isStop, false);
289
290   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
291   aViewer->enableSelection(!isStop);
292
293   aDisplayer->updateViewer();
294 }
295
296 void PartSet_Module::onSetSelection(const QFeatureList& theFeatures)
297 {
298   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
299   aDisplayer->setSelected(theFeatures, false);
300   aDisplayer->updateViewer();
301 }
302
303 void PartSet_Module::onCloseLocalContext()
304 {
305   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
306   aDisplayer->closeLocalContexts();
307 }
308
309 void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
310 {
311   bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
312   visualizePreview(theFeature, isDisplay, false);
313   if (!isDisplay) {
314     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
315     FeaturePtr aSketch;
316     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
317     if (aPrevOp) {
318       std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > aList = aPrevOp->subPreview();
319       XGUI_Displayer* aDisplayer = myWorkshop->displayer();
320       std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
321
322       std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
323                                                              anIt = aList.begin(), aLast = aList.end();
324       for (; anIt != aLast; anIt++) {
325         FeaturePtr aFeature = (*anIt).first;
326         visualizePreview(aFeature, false, false);
327       }
328       aDisplayer->updateViewer();
329     }
330   }
331
332   if (theMode == PartSet_OperationSketchBase::FM_Activation ||
333       theMode == PartSet_OperationSketchBase::FM_Deactivation)
334     activateFeature(theFeature, true);
335 }
336
337 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
338                                                       const std::string& theFeatureKind)
339 {
340   // create the operation
341   ModuleBase_Operation* anOperation = 0;
342   if (theCmdId == PartSet_OperationSketch::Type()) {
343     anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
344   }
345   else {
346     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
347     FeaturePtr aSketch;
348     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
349     if (aPrevOp)
350       aSketch = aPrevOp->sketch();
351     if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
352       anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
353         else if (PartSet_OperationCreateFeature::canProcessKind(theCmdId))
354       anOperation = new PartSet_OperationCreateFeature(theCmdId.c_str(), this, aSketch);
355         else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
356                 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
357     else if (theCmdId == PartSet_OperationFeatureEdit::Type())
358       anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
359     else if (PartSet_OperationCreateConstraint::canProcessKind(theCmdId))
360       anOperation = new PartSet_OperationCreateConstraint(theCmdId.c_str(), this, aSketch);
361   }
362
363   if (!anOperation) {
364     anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
365   }
366
367   // set operation description and list of widgets corresponding to the feature xml definition
368   std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
369
370   std::string aPluginFileName = featureFile(aFeatureKind);
371   Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
372   aWdgReader.readAll();
373   std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
374   std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
375
376   //QString aXmlRepr = QString::fromStdString(aXmlCfg);
377   //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
378   //                                                             myWorkshop->moduleConnector());
379   //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget();
380   //qDeleteAll(aContent->children());
381   //aFactory.createWidget(aContent);
382
383   anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
384   anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
385
386   //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets());
387
388   // connect the operation
389   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
390   if (aPreviewOp) {
391     connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
392             this, SLOT(onFeatureConstructed(FeaturePtr, int)));
393     connect(aPreviewOp, SIGNAL(launchOperation(std::string, FeaturePtr)),
394             this, SLOT(onLaunchOperation(std::string, FeaturePtr)));
395     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
396             this, SLOT(onMultiSelectionEnabled(bool)));
397
398     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
399             this, SLOT(onMultiSelectionEnabled(bool)));
400     connect(aPreviewOp, SIGNAL(stopSelection(const QFeatureList&, const bool)),
401             this, SLOT(onStopSelection(const QFeatureList&, const bool)));
402     connect(aPreviewOp, SIGNAL(setSelection(const QFeatureList&)),
403             this, SLOT(onSetSelection(const QFeatureList&)));
404
405      connect(aPreviewOp, SIGNAL(closeLocalContext()),
406              this, SLOT(onCloseLocalContext()));
407
408     PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
409     if (aSketchOp) {
410       connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
411               this, SLOT(onPlaneSelected(double, double, double)));
412       connect(aSketchOp, SIGNAL(fitAllView()),
413               this, SLOT(onFitAllView()));
414     }
415   }
416
417   return anOperation;
418 }
419
420 void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
421 {
422   //TODO(sbh): Implement static method to extract event id [SEID]
423   static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
424   Config_PointerMessage aMessage(aModuleEvent, this);
425   aMessage.setPointer(theOperation);
426   Events_Loop::loop()->send(aMessage);
427 }
428
429 void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
430                                       const bool isUpdateViewer)
431 {
432   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
433   if (!anOperation)
434     return;
435
436   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
437   if (!aPreviewOp)
438     return;
439
440   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
441   if (isDisplay) {
442     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
443       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
444     if (aSPFeature)
445     {
446       Handle(AIS_InteractiveObject) anAIS = aSPFeature->getAISShape(aDisplayer->getAISObject(theFeature));
447       aDisplayer->redisplay(theFeature, anAIS, false);
448     }
449   }
450   else
451     aDisplayer->erase(theFeature, false);
452
453   if (isUpdateViewer)
454     aDisplayer->updateViewer();
455 }
456
457 void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateViewer)
458 {
459   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
460   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
461   if (aPreviewOp) {
462     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
463     aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
464                                        isUpdateViewer);
465   }
466 }
467
468 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
469 {
470   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
471   if (!anOperation)
472     return;
473
474   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
475   if (!aPreviewOp)
476     return;
477
478   FeaturePtr aFeature = aPreviewOp->feature();
479   if (!aFeature || aFeature->getKind() != theCmdId)
480     return;
481
482   std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > aList = aPreviewOp->subPreview();
483   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
484   std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
485
486   std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
487                                                          anIt = aList.begin(), aLast = aList.end();
488   for (; anIt != aLast; anIt++) {
489     FeaturePtr aFeature = (*anIt).first;
490     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
491       boost::dynamic_pointer_cast<SketchPlugin_Feature>((*anIt).first);
492     if (!aSPFeature)
493       continue;
494
495     Handle(AIS_InteractiveObject) anAIS = aSPFeature->getAISShape(aDisplayer->getAISObject(aFeature));
496     if (!anAIS.IsNull())
497       aDisplayer->redisplay(aFeature, anAIS, false);
498     aDisplayer->activateInLocalContext(aFeature, aModes, false);
499   }
500   aDisplayer->updateViewer();
501 }
502
503 void PartSet_Module::editFeature(FeaturePtr theFeature)
504 {
505   if (!theFeature)
506     return;
507
508 //  if (theFeature->getKind() == SKETCH_KIND) {
509     FeaturePtr aFeature = theFeature;
510     if (XGUI_Tools::isModelObject(aFeature)) {
511       ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
512       aFeature = aObject->featureRef();
513     }
514
515     if (aFeature) {
516       onLaunchOperation(aFeature->getKind(), aFeature);
517       updateCurrentPreview(aFeature->getKind());
518     }
519 //  }
520 }
521
522 void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute)
523 {
524   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
525                                        myWorkshop->operationMgr()->currentOperation());
526   if (!aPreviewOp)
527     return;
528
529   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
530         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
531
532   PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute,
533                                 aPoint->x(), aPoint->y());
534 }