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