Salome HOME
Porting to SALOME_8.2.0 : Debug visualization selection for AIS_Trihedron axes.
[modules/shaper.git] / src / CollectionPlugin / CollectionPlugin_WidgetField.cpp
index ceab82f125c8d9544decf08ca910e094387b7061..5c0040a916fcb79fc61d45b9c8d088f41ccff9c4 100644 (file)
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ISelection.h>
-
-#include <XGUI_Tools.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_PropertyPanel.h>
+#include <ModuleBase_IPropertyPanel.h>
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeStringArray.h>
@@ -116,7 +113,7 @@ CollectionPlugin_WidgetField::
                                ModuleBase_IWorkshop* theWorkshop,
                                const Config_WidgetAPI* theData):
 ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0),
-  myIsEditing(false), myActivation(false)
+  myIsTabEdit(false), myActivation(false)
 {
   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
 
@@ -284,6 +281,13 @@ void CollectionPlugin_WidgetField::deactivate()
   storeValueCustom();
 }
 
+//**********************************************************************************
+//void CollectionPlugin_WidgetField::showEvent(QShowEvent* theEvent)
+//{
+//  myShapeTypeCombo->setEnabled(!isEditingMode());
+//  myFieldTypeCombo->setEnabled(!isEditingMode());
+//  myNbComponentsSpn->setEnabled(!isEditingMode());
+//}
 
 //**********************************************************************************
 bool CollectionPlugin_WidgetField::eventFilter(QObject* theObject, QEvent* theEvent)
@@ -349,8 +353,7 @@ bool CollectionPlugin_WidgetField::eventFilter(QObject* theObject, QEvent* theEv
   } else if (theEvent->type() == QEvent::FocusIn) {
     QTableWidget* aTable = dynamic_cast<QTableWidget*>(theObject);
     if (aTable) {
-      XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-      XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
+      ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel();
       if (aPanel->activeWidget() != this) {
         myActivation = true;
         aPanel->activateWidget(this, false);
@@ -583,17 +586,19 @@ bool CollectionPlugin_WidgetField::restoreValueCustom()
 //**********************************************************************************
 int CollectionPlugin_WidgetField::getSelectionType(const std::string& theStr) const
 {
-  if (theStr == "vertex")
+  QString aType(theStr.c_str());
+  aType = aType.toLower();
+  if (aType == "vertex")
     return 0;
-  else if (theStr == "edge")
+  else if (aType == "edge")
     return 1;
-  else if (theStr == "face")
+  else if (aType == "face")
     return 2;
-  else if (theStr == "solid")
+  else if (aType == "solid")
     return 3;
-  else if (theStr == "object")
+  else if (aType == "object")
     return 4;
-  else if (theStr == "part")
+  else if (aType == "part")
     return 5;
   return -1;
 }
@@ -786,7 +791,7 @@ void CollectionPlugin_WidgetField::onStepMove(int theStep)
 
 //**********************************************************************************
 bool CollectionPlugin_WidgetField::
-  isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
+  isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
 {
   return (myShapeTypeCombo->currentIndex() == 5)? false : true;
 }
@@ -794,6 +799,9 @@ bool CollectionPlugin_WidgetField::
 //**********************************************************************************
 void CollectionPlugin_WidgetField::onSelectionChanged()
 {
+  //if (isEditingMode())
+  //  return;
+
   if (myActivation) {
     myActivation = false;
     return;
@@ -802,8 +810,7 @@ void CollectionPlugin_WidgetField::onSelectionChanged()
   if (myShapeTypeCombo->currentIndex() == 5)
     return;
 
-  QList<ModuleBase_ViewerPrsPtr> aSelected =
-    myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls);
+  QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
 
   AttributeSelectionListPtr aSelList =
     myFeature->data()->selectionList(CollectionPlugin_Field::SELECTED_ID());
@@ -952,8 +959,8 @@ void CollectionPlugin_WidgetField::onShapeTypeChanged(int theType)
 //**********************************************************************************
 bool CollectionPlugin_WidgetField::processEnter()
 {
-  if (myIsEditing) {
-    myIsEditing = false;
+  if (myIsTabEdit) {
+    myIsTabEdit = false;
     return true;
   }
   return false;
@@ -962,8 +969,8 @@ bool CollectionPlugin_WidgetField::processEnter()
 //**********************************************************************************
 void CollectionPlugin_WidgetField::onFocusChanged(QWidget* theOld, QWidget* theNew)
 {
-  if (theNew && (!myIsEditing))
-    myIsEditing = dynamic_cast<QLineEdit*>(theNew);
+  if (theNew && (!myIsTabEdit))
+    myIsTabEdit = dynamic_cast<QLineEdit*>(theNew);
 }
 
 //**********************************************************************************