Salome HOME
Issue #2480 Error: sub shape is not initialized when split sketch
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include <XGUI_ActionsMgr.h>
22 #include <XGUI_ActiveControlMgr.h>
23 #include <XGUI_SelectionActivate.h>
24 #include <XGUI_ActiveControlSelector.h>
25 #include <XGUI_PropertyPanel.h>
26 #include <XGUI_PropertyPanelSelector.h>
27 #include <XGUI_OperationMgr.h>
28 #include <XGUI_Tools.h>
29 #include <XGUI_Workshop.h>
30
31 //#include <AppElements_Constants.h>
32 #include <ModuleBase_WidgetMultiSelector.h>
33 #include <ModuleBase_Tools.h>
34 #include <ModuleBase_PageBase.h>
35 #include <ModuleBase_PageWidget.h>
36 #include <ModuleBase_WidgetFactory.h>
37 #include <ModuleBase_OperationDescription.h>
38 #include <ModuleBase_Events.h>
39 #include <ModuleBase_IModule.h>
40 #include <ModuleBase_IWorkshop.h>
41
42 #include <Events_Loop.h>
43
44 #include <ModelAPI_Session.h>
45 #include <ModelAPI_Validator.h>
46
47 #include <QEvent>
48 #include <QFrame>
49 #include <QIcon>
50 #include <QKeyEvent>
51 #include <QLayoutItem>
52 #include <QToolButton>
53 #include <QVBoxLayout>
54 #include <QGridLayout>
55 #include <QWidget>
56 #include <QAction>
57
58 #ifdef _DEBUG
59 #include <iostream>
60 #endif
61
62 //#define DEBUG_TAB_WIDGETS
63
64 //#define DEBUG_ACTIVE_WIDGET
65
66 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr)
67     : ModuleBase_IPropertyPanel(theParent),
68     myActiveWidget(NULL),
69     myPreselectionWidget(NULL),
70     myInternalActiveWidget(NULL),
71     myPanelPage(NULL),
72     myOperationMgr(theMgr)
73 {
74   setWindowTitle(tr("Property Panel"));
75   QAction* aViewAct = toggleViewAction();
76   setObjectName(PROP_PANEL);
77   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
78
79   QWidget* aContent = new QWidget(this);
80   QGridLayout* aMainLayout = new QGridLayout(aContent);
81   const int kPanelColumn = 0;
82   int aPanelRow = 0;
83   aMainLayout->setContentsMargins(3, 3, 3, 3);
84   setWidget(aContent);
85
86   QFrame* aFrm = new QFrame(aContent);
87   aFrm->setFrameStyle(QFrame::Raised);
88   aFrm->setFrameShape(QFrame::Panel);
89   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
90   ModuleBase_Tools::zeroMargins(aBtnLay);
91   aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
92
93   myHeaderWidget = aFrm;
94
95   QStringList aBtnNames;
96   aBtnNames << QString(PROP_PANEL_HELP)
97             << QString(PROP_PANEL_OK)
98             << QString(PROP_PANEL_OK_PLUS)
99             << QString(PROP_PANEL_CANCEL);
100   foreach(QString eachBtnName, aBtnNames) {
101     QToolButton* aBtn = new QToolButton(aFrm);
102     aBtn->setObjectName(eachBtnName);
103     aBtn->setAutoRaise(true);
104     aBtnLay->addWidget(aBtn);
105   }
106   aBtnLay->insertStretch(1, 1);
107
108   myPanelPage = new ModuleBase_PageWidget(aContent);
109   myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
110   aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
111
112   // spit to make the preview button on the bottom of the panel
113   aMainLayout->setRowStretch(aPanelRow++, 1);
114
115   // preview button on the bottom of panel
116   aFrm = new QFrame(aContent);
117   aBtnLay = new QHBoxLayout(aFrm);
118   aBtnLay->addStretch(1);
119   ModuleBase_Tools::zeroMargins(aBtnLay);
120   aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
121
122   QToolButton* aBtn = new QToolButton(aFrm);
123   aBtn->setObjectName(PROP_PANEL_PREVIEW);
124   aBtnLay->addWidget(aBtn);
125 }
126
127 XGUI_PropertyPanel::~XGUI_PropertyPanel()
128 {
129 }
130
131 void XGUI_PropertyPanel::cleanContent()
132 {
133   if (myActiveWidget)
134     myActiveWidget->deactivate();
135
136   XGUI_ActiveControlSelector* aPPSelector = XGUI_Tools::workshop(myOperationMgr->workshop())->
137     activeControlMgr()->getSelector(XGUI_PropertyPanelSelector::Type());
138   aPPSelector->reset(); // it removes need to be updated widget link
139
140   /// as the widgets are deleted later, it is important that the signals
141   /// of these widgets are not processed. An example of the error is issue 986.
142   /// In the given case, the property panel is firstly filled by new widgets
143   /// of restarted operation and after that the mouse release signal come from
144   /// the widget of the previous operation (Point2d widget about mouse is released
145   /// and focus is out of this widget)
146   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
147                                                  aLast = myWidgets.end();
148   for (; anIt != aLast; anIt++) {
149     QWidget* aWidget = *anIt;
150     if (aWidget) {
151       aWidget->blockSignals(true);
152     }
153   }
154
155   myWidgets.clear();
156   myPanelPage->clearPage();
157   myActiveWidget = NULL;
158   emit propertyPanelDeactivated();
159   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
160   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
161 #ifdef DEBUG_ACTIVE_WIDGET
162   std::cout << "myActiveWidget = NULL" << std::endl;
163 #endif
164
165   findButton(PROP_PANEL_PREVIEW)->setVisible(false); /// by default it is hidden
166   setWindowTitle(tr("Property Panel"));
167 }
168
169 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
170 {
171   myWidgets = theWidgets;
172   if (theWidgets.empty())
173     return;
174   foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
175     connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
176             this,    SLOT(onFocusInWidget(ModuleBase_ModelWidget*)));
177     connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
178             this,    SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
179     connect(aWidget, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
180             this,    SIGNAL(keyReleased(QObject*, QKeyEvent*)));
181     connect(aWidget, SIGNAL(enterClicked(QObject*)),
182             this,    SIGNAL(enterClicked(QObject*)));
183   }
184 }
185
186 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
187 {
188   return myWidgets;
189 }
190
191 ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
192 {
193   return static_cast<ModuleBase_PageBase*>(myPanelPage);
194 }
195
196 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
197 {
198   // Invalid feature case on abort of the operation
199   if (theFeature.get() == NULL)
200     return;
201   if (theFeature->isAction() || !theFeature->data())
202     return;
203   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
204     if (!eachWidget->feature().get())
205       eachWidget->setFeature(theFeature);
206     eachWidget->restoreValue();
207   }
208   // the repaint is used here to immediately react in GUI to the values change.
209   repaint();
210 }
211
212 void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature)
213 {
214   // Invalid feature case on abort of the operation
215   if (theFeature.get() == NULL)
216     return;
217   if (theFeature->isAction() || !theFeature->data())
218     return;
219
220   if (myWidgets.empty()) {
221     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
222     QString aXmlRepr = anOperation->getDescription()->xmlRepresentation();
223
224     ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myOperationMgr->workshop());
225     aFactory.createPanel(contentWidget(), theFeature);
226     /// Apply button should be update if the feature was modified by the panel
227     myOperationMgr->onValidateOperation();
228   }
229   std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
230     myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
231   if (aFeatureInfo.get())
232     findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
233 }
234
235 ModuleBase_ModelWidget* XGUI_PropertyPanel::activeWidget(const bool isUseCustomWidget) const
236 {
237   if (isUseCustomWidget && myInternalActiveWidget)
238     return myInternalActiveWidget;
239
240   return myActiveWidget;
241 }
242
243 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
244 {
245   // it is possible that the property panel widgets have not been visualized
246   // (e.g. on start operation), so it is strictly important to do not check visualized state
247   activateNextWidget(theWidget, false);
248 }
249
250 void XGUI_PropertyPanel::onFocusInWidget(ModuleBase_ModelWidget* theWidget)
251 {
252 #ifdef DEBUG_ACTIVE_WIDGET
253   std::cout << "onFocusInWidget" << std::endl;
254 #endif
255   if (theWidget->canAcceptFocus())
256     activateWidget(theWidget);
257 }
258
259 void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
260 {
261   // this slot happens when some widget lost focus, the next widget which accepts the focus
262   // should be shown, so the second parameter is true
263   // it is important for features where in cases the same attributes are used, isCase for this
264   // attribute returns true, however it can be placed in hidden stack widget(extrusion: elements,
265   // sketch multi rotation -> single/full point)
266   // it is important to check the widget visibility to do not check of the next widget visible
267   // state if the current is not shown. (example: sketch circle re-entrant operation after mouse
268   // release in the viewer, next, radius,
269   // widget should be activated but the first is not visualized)
270   bool isVisible = theWidget->isVisible();
271   activateNextWidget(theWidget, isVisible);
272 }
273
274
275 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
276                                             const bool isCheckVisibility)
277 {
278   // TO CHECK: Editing operation does not have automatical activation of widgets
279   if (isEditingMode()) {
280     activateWidget(NULL);
281     return;
282   }
283   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
284
285   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
286   bool isFoundWidget = false;
287   ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
288   for (; anIt != aLast; anIt++) {
289     ModuleBase_ModelWidget* aCurrentWidget = *anIt;
290     if (isFoundWidget || !theWidget) {
291
292       if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
293         continue; // this attribute does not participate in the current case
294       if (isCheckVisibility && !aCurrentWidget->isInternal()) {
295         if (!aCurrentWidget->isVisible())
296           continue;
297       }
298       if (!aCurrentWidget->isObligatory())
299         continue; // not obligatory widgets are not activated automatically
300
301       if (!aCurrentWidget->canAcceptFocus())
302         continue; // do not set focus if it can not be accepted, case: optional choice
303
304       if (aCurrentWidget->focusTo()) {
305         aCurrentWidget->emitFocusInWidget();
306         return;
307       }
308     }
309     isFoundWidget = isFoundWidget || (*anIt) == theWidget;
310   }
311   // set focus to Ok/Cancel button in Property panel if there are no more active widgets
312   // it should be performed before activateWidget(NULL) because it emits some signals which
313   // can be processed by moudule for example as to activate another widget with setting focus
314   QWidget* aNewFocusWidget = 0;
315   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
316   if (anOkBtn->isEnabled())
317     aNewFocusWidget = anOkBtn;
318   else {
319     QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
320     if (aCancelBtn->isEnabled())
321       aNewFocusWidget = aCancelBtn;
322   }
323   if (aNewFocusWidget)
324     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
325
326   activateWidget(NULL);
327 }
328
329 void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
330 {
331   QList<QWidget*> aWidgets;
332
333   if (theParent) {
334     QLayout* aLayout = theParent->layout();
335     if (aLayout) {
336       for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
337         QLayoutItem* anItem = aLayout->itemAt(i);
338         QWidget* aWidget = anItem ? anItem->widget() : 0;
339         if (aWidget) {
340           if (aWidget->isVisible()) {
341             if (aWidget->focusPolicy() != Qt::NoFocus)
342               theWidgets.append(aWidget);
343             findDirectChildren(aWidget, theWidgets, false);
344           }
345         }
346         else if (anItem->layout()) {
347           QLayout* aLayout = anItem->layout();
348           for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
349             QLayoutItem* anItem = aLayout->itemAt(i);
350             QWidget* aWidget = anItem ? anItem->widget() : 0;
351             if (aWidget) {
352               if (aWidget->isVisible()) {
353                 if (aWidget->focusPolicy() != Qt::NoFocus)
354                   theWidgets.append(aWidget);
355                 findDirectChildren(aWidget, theWidgets, false);
356               }
357             }
358             else {
359               // TODO: improve recursive search for the case when here QLayout is used
360               // currently, the switch widget uses only 1 level of qlayout in qlayout using for
361               // example for construction plane feature. If there are more levels,
362               // it should be implemented here
363             }
364           }
365         }
366       }
367     }
368   }
369 #ifdef DEBUG_TAB_WIDGETS
370   if (theDebug) {
371     QStringList aWidgetTypes;
372     QList<QWidget*>::const_iterator anIt =  theWidgets.begin(), aLast = theWidgets.end();
373     for (; anIt != aLast; anIt++) {
374       QWidget* aWidget = *anIt;
375       if (aWidget)
376         aWidgetTypes.append(aWidget->objectName());
377     }
378     QString anInfo = QString("theWidgets[%1]: %2")
379       .arg(theWidgets.count()).arg(aWidgetTypes.join(","));
380     qDebug(anInfo.toStdString().c_str());
381   }
382 #endif
383 }
384
385 bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
386 {
387   return focusNextPrevChild(theIsNext);
388 }
389
390 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
391 {
392   // it wraps the Tabs clicking to follow in the chain:
393   // controls, last control, Apply, Cancel, first control, controls
394   bool isChangedFocus = false;
395
396   QWidget* aFocusWidget = focusWidget();
397 #ifdef DEBUG_TAB_WIDGETS
398   if (aFocusWidget) {
399     QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName());
400     qDebug(anInfo.toStdString().c_str());
401   }
402 #endif
403   ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
404                                                                          aFocusWidget);
405   if (aFocusMWidget)
406     aFocusMWidget->setHighlighted(false);
407
408   QWidget* aNewFocusWidget = 0;
409   if (aFocusWidget) {
410     QList<QWidget*> aChildren;
411     findDirectChildren(this, aChildren, true);
412     int aChildrenCount = aChildren.count();
413     int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget);
414     QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
415     if (aFocusWidgetIndex >= 0) {
416       if (theIsNext) {
417         if (aFocusWidgetIndex == aChildrenCount-1) {
418           // after the last widget focus should be set to "Apply"
419           if (anOkBtn->isEnabled())
420             aNewFocusWidget = anOkBtn;
421           else {
422             QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
423             if (aCancelBtn->isEnabled())
424               aNewFocusWidget = aCancelBtn;
425           }
426         }
427         else {
428           aNewFocusWidget = aChildren[aFocusWidgetIndex+1];
429         }
430       }
431       else {
432         if (aFocusWidgetIndex == 0) {
433           // before the first widget, the last should accept focus
434           aNewFocusWidget = aChildren[aChildrenCount - 1];
435         }
436         else {
437           // before the "Apply" button, the last should accept focus for consistency with "Next"
438           if (aFocusWidget == anOkBtn) {
439             aNewFocusWidget = aChildren[aChildrenCount - 1];
440           }
441           else {
442             aNewFocusWidget = aChildren[aFocusWidgetIndex-1];
443           }
444         }
445       }
446     }
447   }
448   if (aNewFocusWidget) {
449     if (myActiveWidget) {
450       bool isFirstControl = !theIsNext;
451       QWidget* aLastFocusControl = myActiveWidget->getControlAcceptingFocus(isFirstControl);
452       if (aFocusWidget == aLastFocusControl) {
453         setActiveWidget(NULL, false);
454       }
455     }
456
457     // we want to have property panel as an active window to enter values in double control
458     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
459
460     ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
461                                                                               aNewFocusWidget);
462     if (aNewFocusMWidget)
463       aNewFocusMWidget->emitFocusInWidget();
464     isChangedFocus = true;
465   }
466   return isChangedFocus;
467 }
468
469 void XGUI_PropertyPanel::activateNextWidget()
470 {
471   activateNextWidget(myActiveWidget);
472 }
473
474 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal)
475 {
476   std::string aPreviosAttributeID;
477   if(myActiveWidget)
478     aPreviosAttributeID = myActiveWidget->attributeID();
479
480   // Avoid activation of already actve widget. It could happen on focusIn event many times
481   setActiveWidget(theWidget, theEmitSignal);
482 }
483
484 bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal)
485 {
486   // Avoid activation of already actve widget. It could happen on focusIn event many times
487   if (theWidget == myActiveWidget) {
488     return false;
489   }
490   std::string aPreviosAttributeID;
491   ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL;
492   if(myActiveWidget) {
493     aPreviosAttributeID = myActiveWidget->attributeID();
494     myActiveWidget->processValueState();
495     myActiveWidget->deactivate();
496     myActiveWidget->setHighlighted(false);
497     aDeactivatedWidget = myActiveWidget;
498   }
499   if(theWidget) {
500     emit beforeWidgetActivated(theWidget);
501     theWidget->setHighlighted(true);
502     theWidget->activate();
503     anActivatedWidget = theWidget;
504   }
505   myActiveWidget = theWidget;
506
507 #ifdef DEBUG_ACTIVE_WIDGET
508   std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
509 #endif
510   bool aHasMoreWidgets = true;
511   if (isEmitSignal) {
512     //emit widgetActivated(myActiveWidget);
513     if (!myActiveWidget && !isEditingMode()) {
514       aHasMoreWidgets = false;
515       emit noMoreWidgets(aPreviosAttributeID);
516     }
517   }
518   if (myActiveWidget)
519     emit propertyPanelActivated();
520   else
521     emit propertyPanelDeactivated();
522   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
523   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
524
525   if (aHasMoreWidgets && aDeactivatedWidget)
526     aDeactivatedWidget->updateAfterDeactivation();
527   if (aHasMoreWidgets && anActivatedWidget)
528     anActivatedWidget->updateAfterActivation();
529
530   if (aHasMoreWidgets && myActiveWidget)
531   {
532     // restore widget selection should be done after selection modes of widget activating
533     static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
534     Events_Loop::loop()->flush(anEvent);
535   }
536   return true;
537 }
538
539 void XGUI_PropertyPanel::setFocusOnOkButton()
540 {
541   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
542   ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
543 }
544
545 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
546 {
547   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
548   anCancelBtn->setEnabled(theEnabled);
549 }
550
551 bool XGUI_PropertyPanel::isCancelEnabled() const
552 {
553   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
554   return anCancelBtn->isEnabled();
555 }
556
557 void XGUI_PropertyPanel::setEditingMode(bool isEditing)
558 {
559   ModuleBase_IPropertyPanel::setEditingMode(isEditing);
560   foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
561     aWgt->setEditingMode(isEditing);
562   }
563 }
564
565 void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
566 {
567   QStringList aButtonNames;
568   aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL
569                << PROP_PANEL_HELP << PROP_PANEL_PREVIEW;
570   QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
571   aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort
572              << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview;
573   for (int i = 0; i < aButtonNames.size(); ++i) {
574     QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str());
575     QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
576     aBtn->setDefaultAction(anAct);
577   }
578 }
579
580 void XGUI_PropertyPanel::onAcceptData()
581 {
582   foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
583     aWidget->onFeatureAccepted();
584   }
585 }
586
587 void XGUI_PropertyPanel::setInternalActiveWidget(ModuleBase_ModelWidget* theWidget)
588 {
589   if (theWidget)
590   {
591     myInternalActiveWidget = theWidget;
592     emit propertyPanelActivated();
593   }
594   else
595   {
596     if (myInternalActiveWidget)
597     {
598       delete myInternalActiveWidget;
599       myInternalActiveWidget = 0;
600     }
601     emit propertyPanelDeactivated();
602   }
603   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
604   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
605 }
606
607 ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
608 {
609   return myPreselectionWidget;
610 }
611
612 void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget)
613 {
614   myPreselectionWidget = theWidget;
615 }
616
617
618 void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
619 {
620   ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
621   if (aOp) {
622     if (myOperationMgr->canStopOperation(aOp)) {
623       myOperationMgr->abortOperation(aOp);
624       if (myOperationMgr->hasOperation())
625         theEvent->ignore();
626       else
627         theEvent->accept();
628     } else
629       theEvent->ignore();
630   } else
631     ModuleBase_IPropertyPanel::closeEvent(theEvent);
632 }
633
634 QToolButton* XGUI_PropertyPanel::findButton(const char* theInternalName) const
635 {
636   return findChild<QToolButton*>(theInternalName);
637 }