Salome HOME
65180f91a4761a0aea3893114e149fb32a6c600f
[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   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
159   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
160 #ifdef DEBUG_ACTIVE_WIDGET
161   std::cout << "myActiveWidget = NULL" << std::endl;
162 #endif
163
164   findButton(PROP_PANEL_PREVIEW)->setVisible(false); /// by default it is hidden
165   setWindowTitle(tr("Property Panel"));
166 }
167
168 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
169 {
170   myWidgets = theWidgets;
171   if (theWidgets.empty())
172     return;
173   foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
174     connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
175             this,    SLOT(onFocusInWidget(ModuleBase_ModelWidget*)));
176     connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
177             this,    SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
178     connect(aWidget, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
179             this,    SIGNAL(keyReleased(QObject*, QKeyEvent*)));
180     connect(aWidget, SIGNAL(enterClicked(QObject*)),
181             this,    SIGNAL(enterClicked(QObject*)));
182   }
183 }
184
185 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
186 {
187   return myWidgets;
188 }
189
190 ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
191 {
192   return static_cast<ModuleBase_PageBase*>(myPanelPage);
193 }
194
195 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
196 {
197   // Invalid feature case on abort of the operation
198   if (theFeature.get() == NULL)
199     return;
200   if (theFeature->isAction() || !theFeature->data())
201     return;
202   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
203     if (!eachWidget->feature().get())
204       eachWidget->setFeature(theFeature);
205     eachWidget->restoreValue();
206   }
207   // the repaint is used here to immediately react in GUI to the values change.
208   repaint();
209 }
210
211 void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature)
212 {
213   // Invalid feature case on abort of the operation
214   if (theFeature.get() == NULL)
215     return;
216   if (theFeature->isAction() || !theFeature->data())
217     return;
218
219   if (myWidgets.empty()) {
220     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
221     QString aXmlRepr = anOperation->getDescription()->xmlRepresentation();
222
223     ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myOperationMgr->workshop());
224     aFactory.createPanel(contentWidget(), theFeature);
225     /// Apply button should be update if the feature was modified by the panel
226     myOperationMgr->onValidateOperation();
227   }
228   updateApplyPlusButton(theFeature);
229 }
230
231 void XGUI_PropertyPanel::updateApplyPlusButton(FeaturePtr theFeature)
232 {
233   if (theFeature.get()) {
234     std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
235       myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
236     if (aFeatureInfo.get()) {
237       findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
238       return;
239     }
240   }
241   findButton(PROP_PANEL_OK_PLUS)->setVisible(false);
242 }
243
244 ModuleBase_ModelWidget* XGUI_PropertyPanel::activeWidget(const bool isUseCustomWidget) const
245 {
246   if (isUseCustomWidget && myInternalActiveWidget)
247     return myInternalActiveWidget;
248
249   return myActiveWidget;
250 }
251
252 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
253 {
254   // it is possible that the property panel widgets have not been visualized
255   // (e.g. on start operation), so it is strictly important to do not check visualized state
256   activateNextWidget(theWidget, false);
257 }
258
259 void XGUI_PropertyPanel::onFocusInWidget(ModuleBase_ModelWidget* theWidget)
260 {
261 #ifdef DEBUG_ACTIVE_WIDGET
262   std::cout << "onFocusInWidget" << std::endl;
263 #endif
264   if (theWidget->canAcceptFocus())
265     activateWidget(theWidget);
266 }
267
268 void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
269 {
270   // this slot happens when some widget lost focus, the next widget which accepts the focus
271   // should be shown, so the second parameter is true
272   // it is important for features where in cases the same attributes are used, isCase for this
273   // attribute returns true, however it can be placed in hidden stack widget(extrusion: elements,
274   // sketch multi rotation -> single/full point)
275   // it is important to check the widget visibility to do not check of the next widget visible
276   // state if the current is not shown. (example: sketch circle re-entrant operation after mouse
277   // release in the viewer, next, radius,
278   // widget should be activated but the first is not visualized)
279   bool isVisible = theWidget->isVisible();
280   activateNextWidget(theWidget, isVisible);
281 }
282
283
284 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
285                                             const bool isCheckVisibility)
286 {
287   // TO CHECK: Editing operation does not have automatical activation of widgets
288   if (isEditingMode()) {
289     activateWidget(NULL);
290     return;
291   }
292   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
293
294   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
295   bool isFoundWidget = false;
296   ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
297   for (; anIt != aLast; anIt++) {
298     ModuleBase_ModelWidget* aCurrentWidget = *anIt;
299     if (isFoundWidget || !theWidget) {
300
301       if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
302         continue; // this attribute does not participate in the current case
303       if (isCheckVisibility && !aCurrentWidget->isInternal()) {
304         if (!aCurrentWidget->isVisible())
305           continue;
306       }
307       if (!aCurrentWidget->isObligatory())
308         continue; // not obligatory widgets are not activated automatically
309
310       if (!aCurrentWidget->canAcceptFocus())
311         continue; // do not set focus if it can not be accepted, case: optional choice
312
313       if (aCurrentWidget->focusTo()) {
314         aCurrentWidget->emitFocusInWidget();
315         return;
316       }
317     }
318     isFoundWidget = isFoundWidget || (*anIt) == theWidget;
319   }
320   // set focus to Ok/Cancel button in Property panel if there are no more active widgets
321   // it should be performed before activateWidget(NULL) because it emits some signals which
322   // can be processed by moudule for example as to activate another widget with setting focus
323   QWidget* aNewFocusWidget = 0;
324   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
325   if (anOkBtn->isEnabled())
326     aNewFocusWidget = anOkBtn;
327   else {
328     QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
329     if (aCancelBtn->isEnabled())
330       aNewFocusWidget = aCancelBtn;
331   }
332   if (aNewFocusWidget)
333     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
334
335   activateWidget(NULL);
336 }
337
338 void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
339 {
340   QList<QWidget*> aWidgets;
341
342   if (theParent) {
343     QLayout* aLayout = theParent->layout();
344     if (aLayout) {
345       for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
346         QLayoutItem* anItem = aLayout->itemAt(i);
347         QWidget* aWidget = anItem ? anItem->widget() : 0;
348         if (aWidget) {
349           if (aWidget->isVisible()) {
350             if (aWidget->focusPolicy() != Qt::NoFocus)
351               theWidgets.append(aWidget);
352             findDirectChildren(aWidget, theWidgets, false);
353           }
354         }
355         else if (anItem->layout()) {
356           QLayout* aLayout = anItem->layout();
357           for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
358             QLayoutItem* anItem = aLayout->itemAt(i);
359             QWidget* aWidget = anItem ? anItem->widget() : 0;
360             if (aWidget) {
361               if (aWidget->isVisible()) {
362                 if (aWidget->focusPolicy() != Qt::NoFocus)
363                   theWidgets.append(aWidget);
364                 findDirectChildren(aWidget, theWidgets, false);
365               }
366             }
367             else {
368               // TODO: improve recursive search for the case when here QLayout is used
369               // currently, the switch widget uses only 1 level of qlayout in qlayout using for
370               // example for construction plane feature. If there are more levels,
371               // it should be implemented here
372             }
373           }
374         }
375       }
376     }
377   }
378 #ifdef DEBUG_TAB_WIDGETS
379   if (theDebug) {
380     QStringList aWidgetTypes;
381     QList<QWidget*>::const_iterator anIt =  theWidgets.begin(), aLast = theWidgets.end();
382     for (; anIt != aLast; anIt++) {
383       QWidget* aWidget = *anIt;
384       if (aWidget)
385         aWidgetTypes.append(aWidget->objectName());
386     }
387     QString anInfo = QString("theWidgets[%1]: %2")
388       .arg(theWidgets.count()).arg(aWidgetTypes.join(","));
389     qDebug(anInfo.toStdString().c_str());
390   }
391 #endif
392 }
393
394 bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
395 {
396   return focusNextPrevChild(theIsNext);
397 }
398
399 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
400 {
401   // it wraps the Tabs clicking to follow in the chain:
402   // controls, last control, Apply, Cancel, first control, controls
403   bool isChangedFocus = false;
404
405   QWidget* aFocusWidget = focusWidget();
406 #ifdef DEBUG_TAB_WIDGETS
407   if (aFocusWidget) {
408     QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName());
409     qDebug(anInfo.toStdString().c_str());
410   }
411 #endif
412   ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
413                                                                          aFocusWidget);
414   //if (aFocusMWidget)
415   //  aFocusMWidget->setHighlighted(false);
416
417   QWidget* aNewFocusWidget = 0;
418   if (aFocusWidget) {
419     QList<QWidget*> aChildren;
420     findDirectChildren(this, aChildren, true);
421     int aChildrenCount = aChildren.count();
422     int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget);
423     QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
424     if (aFocusWidgetIndex >= 0) {
425       if (theIsNext) {
426         if (aFocusWidgetIndex == aChildrenCount-1) {
427           // after the last widget focus should be set to "Apply"
428           if (anOkBtn->isEnabled())
429             aNewFocusWidget = anOkBtn;
430           else {
431             QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
432             if (aCancelBtn->isEnabled())
433               aNewFocusWidget = aCancelBtn;
434           }
435         }
436         else {
437           aNewFocusWidget = aChildren[aFocusWidgetIndex+1];
438         }
439       }
440       else {
441         if (aFocusWidgetIndex == 0) {
442           // before the first widget, the last should accept focus
443           aNewFocusWidget = aChildren[aChildrenCount - 1];
444         }
445         else {
446           // before the "Apply" button, the last should accept focus for consistency with "Next"
447           if (aFocusWidget == anOkBtn) {
448             aNewFocusWidget = aChildren[aChildrenCount - 1];
449           }
450           else {
451             aNewFocusWidget = aChildren[aFocusWidgetIndex-1];
452           }
453         }
454       }
455     }
456   }
457   if (aNewFocusWidget) {
458     if (myActiveWidget) {
459       bool isFirstControl = !theIsNext;
460       QWidget* aLastFocusControl = myActiveWidget->getControlAcceptingFocus(isFirstControl);
461       if (aFocusWidget == aLastFocusControl) {
462         setActiveWidget(NULL, false);
463       }
464     }
465
466     // we want to have property panel as an active window to enter values in double control
467     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
468
469     ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
470                                                                               aNewFocusWidget);
471     if (aNewFocusMWidget) {
472       if (aFocusMWidget) {
473         aFocusMWidget->setHighlighted(false);
474       }
475       aNewFocusMWidget->emitFocusInWidget();
476       isChangedFocus = true;
477     }
478   }
479   return isChangedFocus;
480 }
481
482 void XGUI_PropertyPanel::activateNextWidget()
483 {
484   activateNextWidget(myActiveWidget);
485 }
486
487 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal)
488 {
489   std::string aPreviosAttributeID;
490   if(myActiveWidget)
491     aPreviosAttributeID = myActiveWidget->attributeID();
492
493   // Avoid activation of already actve widget. It could happen on focusIn event many times
494   setActiveWidget(theWidget, theEmitSignal);
495 }
496
497 bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal)
498 {
499   // Avoid activation of already actve widget. It could happen on focusIn event many times
500   if (theWidget == myActiveWidget) {
501     return false;
502   }
503   std::string aPreviosAttributeID;
504   ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL;
505   if(myActiveWidget) {
506     aPreviosAttributeID = myActiveWidget->attributeID();
507     myActiveWidget->processValueState();
508     myActiveWidget->deactivate();
509     myActiveWidget->setHighlighted(false);
510     aDeactivatedWidget = myActiveWidget;
511   }
512   if(theWidget) {
513     emit beforeWidgetActivated(theWidget);
514     theWidget->setHighlighted(true);
515     theWidget->activate();
516     anActivatedWidget = theWidget;
517   }
518   myActiveWidget = theWidget;
519
520 #ifdef DEBUG_ACTIVE_WIDGET
521   std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
522 #endif
523   bool aHasMoreWidgets = true;
524   if (isEmitSignal) {
525     //emit widgetActivated(myActiveWidget);
526     if (!myActiveWidget && !isEditingMode()) {
527       aHasMoreWidgets = false;
528       emit noMoreWidgets(aPreviosAttributeID);
529     }
530   }
531   if (myActiveWidget)
532     emit propertyPanelActivated();
533   else
534     emit propertyPanelDeactivated();
535   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
536   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
537
538   if (aHasMoreWidgets && aDeactivatedWidget)
539     aDeactivatedWidget->updateAfterDeactivation();
540   if (aHasMoreWidgets && anActivatedWidget)
541     anActivatedWidget->updateAfterActivation();
542
543   if (aHasMoreWidgets && myActiveWidget)
544   {
545     // restore widget selection should be done after selection modes of widget activating
546     static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
547     Events_Loop::loop()->flush(anEvent);
548   }
549   return true;
550 }
551
552 void XGUI_PropertyPanel::setFocusOnOkButton()
553 {
554   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
555   ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
556 }
557
558 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
559 {
560   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
561   anCancelBtn->setEnabled(theEnabled);
562 }
563
564 bool XGUI_PropertyPanel::isCancelEnabled() const
565 {
566   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
567   return anCancelBtn->isEnabled();
568 }
569
570 void XGUI_PropertyPanel::setEditingMode(bool isEditing)
571 {
572   ModuleBase_IPropertyPanel::setEditingMode(isEditing);
573   foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
574     aWgt->setEditingMode(isEditing);
575   }
576 }
577
578 void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
579 {
580   QStringList aButtonNames;
581   aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL
582                << PROP_PANEL_HELP << PROP_PANEL_PREVIEW;
583   QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
584   aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort
585              << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview;
586   for (int i = 0; i < aButtonNames.size(); ++i) {
587     QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str());
588     QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
589     aBtn->setDefaultAction(anAct);
590   }
591 }
592
593 void XGUI_PropertyPanel::onAcceptData()
594 {
595   foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
596     aWidget->onFeatureAccepted();
597   }
598 }
599
600 void XGUI_PropertyPanel::setInternalActiveWidget(ModuleBase_ModelWidget* theWidget)
601 {
602   if (theWidget)
603   {
604     myInternalActiveWidget = theWidget;
605     emit propertyPanelActivated();
606   }
607   else
608   {
609     if (myInternalActiveWidget)
610     {
611       delete myInternalActiveWidget;
612       myInternalActiveWidget = 0;
613     }
614     emit propertyPanelDeactivated();
615   }
616   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
617   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
618 }
619
620 ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
621 {
622   return myPreselectionWidget;
623 }
624
625 void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget)
626 {
627   myPreselectionWidget = theWidget;
628 }
629
630
631 void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
632 {
633   ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
634   if (aOp) {
635     if (myOperationMgr->canStopOperation(aOp)) {
636       myOperationMgr->abortOperation(aOp);
637       if (myOperationMgr->hasOperation())
638         theEvent->ignore();
639       else
640         theEvent->accept();
641     } else
642       theEvent->ignore();
643   } else
644     ModuleBase_IPropertyPanel::closeEvent(theEvent);
645 }
646
647 QToolButton* XGUI_PropertyPanel::findButton(const char* theInternalName) const
648 {
649   return findChild<QToolButton*>(theInternalName);
650 }