-#ifndef ModuleBase_IModule_H
-#define ModuleBase_IModule_H
-
-#include "ModuleBase.h"
-#include "ModuleBase_IWorkshop.h"
-
-#include <QString>
-#include <QObject>
-
-
-class QAction;
+#ifndef ModuleBase_IModule_H\r
+#define ModuleBase_IModule_H\r
+\r
+#include "ModuleBase.h"\r
+#include "ModuleBase_IWorkshop.h"\r
+\r
+#include <QString>\r
+#include <QObject>\r
+\r
+\r
+class QAction;\r
class QMouseEvent;\r
class QKeyEvent;\r
-class Config_WidgetAPI;
-class ModuleBase_ModelWidget;
-class ModuleBase_Operation;
-class ModuleBase_IWorkshop;
-
-/**
- * Interface to a module
- */
-class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
-{
- Q_OBJECT
- public:
-
- ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
-
- virtual ~ModuleBase_IModule() {}
-
- /// Reads description of features from XML file
- virtual void createFeatures() = 0;
-
- /// Called on creation of menu item in desktop
- virtual void featureCreated(QAction*) = 0;
-
- /// Creates an operation and send it to loop
- /// \param theCmdId the operation name
- virtual void launchOperation(const QString& theCmdId);
-
- /// Called when it is necessary to update a command state (enable or disable it)
- //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
-
- /// Creates custom widgets for property panel
- virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
- Config_WidgetAPI* theWidgetApi,
- QList<ModuleBase_ModelWidget*>& theModelWidgets)
- {
- return 0;
- }
-
- ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
-
-protected slots:
-
- /// Called on selection changed event
- virtual void onSelectionChanged() {}
-
+class Config_WidgetAPI;\r
+class ModuleBase_ModelWidget;\r
+class ModuleBase_Operation;\r
+class ModuleBase_IWorkshop;\r
+\r
+/**\r
+ * Interface to a module\r
+ */\r
+class MODULEBASE_EXPORT ModuleBase_IModule : public QObject\r
+{\r
+ Q_OBJECT\r
+ public:\r
+\r
+ ModuleBase_IModule(ModuleBase_IWorkshop* theParent);\r
+\r
+ virtual ~ModuleBase_IModule() {}\r
+\r
+ /// Reads description of features from XML file \r
+ virtual void createFeatures() = 0;\r
+\r
+ /// Called on creation of menu item in desktop\r
+ virtual void featureCreated(QAction*) = 0;\r
+\r
+ /// Creates an operation and send it to loop\r
+ /// \param theCmdId the operation name\r
+ virtual void launchOperation(const QString& theCmdId);\r
+\r
+ /// Called when it is necessary to update a command state (enable or disable it)\r
+ //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
+\r
+ /// Creates custom widgets for property panel\r
+ virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
+ Config_WidgetAPI* theWidgetApi,\r
+ QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
+ {\r
+ return 0;\r
+ }\r
+\r
+ ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
+\r
+protected slots:\r
+\r
+ /// Called on selection changed event\r
+ virtual void onSelectionChanged() {}\r
+\r
/// SLOT, that is called by mouse press in the viewer.\r
/// The mouse released point is sent to the current operation to be processed.\r
/// \param theEvent the mouse event\r
/// SLOT, that is called by the key in the viewer is clicked.\r
/// \param theEvent the mouse event\r
virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
-
- protected:
- /// Sends the operation for launching
- /// \param theOperation the operation
- void sendOperation(ModuleBase_Operation* theOperation);
-
- /// Creates a new operation
- /// \param theCmdId the operation name
- /// \param theFeatureKind a kind of feature to get the feature xml description
- virtual ModuleBase_Operation* createOperation(const std::string& theCmdId,
- const std::string& theFeatureKind = "") = 0;
-
-
-protected:
-
- ModuleBase_IWorkshop* myWorkshop;
-
-};
-
-//! This function must return a new module instance.
-extern "C" {
-typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
-}
-
-#define CREATE_MODULE "createModule"
-
-#endif //ModuleBase_IModule
+\r
+ protected:\r
+ /// Sends the operation for launching\r
+ /// \param theOperation the operation\r
+ void sendOperation(ModuleBase_Operation* theOperation);\r
+\r
+ /// Creates a new operation\r
+ /// \param theCmdId the operation name\r
+ /// \param theFeatureKind a kind of feature to get the feature xml description\r
+ virtual ModuleBase_Operation* createOperation(const std::string& theCmdId,\r
+ const std::string& theFeatureKind = "") = 0;\r
+\r
+\r
+protected:\r
+\r
+ ModuleBase_IWorkshop* myWorkshop;\r
+\r
+};\r
+\r
+//! This function must return a new module instance.\r
+extern "C" {\r
+typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
+}\r
+\r
+#define CREATE_MODULE "createModule"\r
+\r
+#endif //ModuleBase_IModule\r
/// \return the state whether the widget can accept the focus
virtual bool focusTo();
+ /// The methiod called when widget is activated
+ virtual void activate() {}
+
+ /// The methiod called when widget is deactivated
+ virtual void deactivate() {}
+
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
virtual QWidget* getControl() const = 0;
}
}
updateSelectionName();
- activateSelection(false);
+ //activateSelection(false);
emit valuesChanged();
}
//********************************************************************
void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
{
+ if (myIsActive == toActivate)
+ return;
myIsActive = toActivate;
updateSelectionName();
//********************************************************************
bool ModuleBase_WidgetShapeSelector::focusTo()
{
- activateSelection(true);
+ //activateSelection(true);
return ModuleBase_ModelWidget::focusTo();
}
//********************************************************************
bool ModuleBase_WidgetShapeSelector::eventFilter(QObject* theObj, QEvent* theEvent)
{
- if (theObj == myTextLine) {
- if (theEvent->type() == QEvent::FocusIn)
- activateSelection(true);
- }
+ //if (theObj == myTextLine) {
+ // if (theEvent->type() == QEvent::FocusIn)
+ // activateSelection(true);
+ //}
return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
}
return false;
}
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::activate()
+{
+ activateSelection(true);
+}
+
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::deactivate()
+{
+ activateSelection(false);
+}
/// \param theValue the wrapped widget value
virtual bool setValue(ModuleBase_WidgetValue* theValue);
+
+ /// The methiod called when widget is activated
+ virtual void activate();
+
+ /// The methiod called when widget is deactivated
+ virtual void deactivate();
+
+
public slots:
/// Activate or deactivate selection
bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
{
- return myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end();
+ return myResult2AISObjectMap.contains(theObject);
}
void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
aContext->Remove(anAIS, isUpdateViewer);
}
}
- myResult2AISObjectMap.erase(theObject);
+ myResult2AISObjectMap.remove(theObject);
}
void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
if (!isVisible(theObject))
return false;
- AISObjectPtr anObj = myResult2AISObjectMap.at(theObject);
+ AISObjectPtr anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
TColStd_ListOfInteger aModes;
if (ic.IsNull())
return;
- ResultToAISMap::iterator aIt;
- for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+ foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
// erase an object
- AISObjectPtr aAISObj = (*aIt).second;
Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anIO.IsNull())
- ic->Remove(anIO, false);
+ ic->Remove(anIO, false);
}
myResult2AISObjectMap.clear();
if (isUpdateViewer)
if (aContext.IsNull())
return;
- ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
- myResult2AISObjectMap.end();
- std::list<ObjectPtr> aRemoved;
- for (; aFIt != aFLast; aFIt++) {
- ObjectPtr aFeature = (*aFIt).first;
+ QList<ObjectPtr> aRemoved;
+ foreach (ObjectPtr aFeature, myResult2AISObjectMap.keys()) {
if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
- AISObjectPtr anObj = (*aFIt).second;
+ AISObjectPtr anObj = myResult2AISObjectMap[aFeature];
if (!anObj)
continue;
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
aContext->Remove(anAIS, false);
- aRemoved.push_back(aFeature);
+ aRemoved.append(aFeature);
}
}
}
- std::list<ObjectPtr>::const_iterator anIt = aRemoved.begin(), aLast = aRemoved.end();
- for (; anIt != aLast; anIt++) {
- myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt));
+ foreach(ObjectPtr aObj, aRemoved) {
+ myResult2AISObjectMap.remove(aObj);
}
if (isUpdateViewer)
void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
{
- AISContext()->ClearSelected(false);
- closeAllContexts(true);
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if ( (!ic.IsNull()) && (ic->HasOpenedContext()) ) {
+ ic->ClearSelected(false);
+ ic->CloseAllContexts(false);
+
+ // Redisplay all object if they were displayed in localContext
+ Handle(AIS_InteractiveObject) aAISIO;
+ foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
+ aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
+ if (ic->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
+ ic->Display(aAISIO, false);
+ ic->SetDisplayMode(aAISIO, Shading, false);
+ }
+ }
+ if (isUpdateViewer)
+ updateViewer();
+ myUseExternalObjects = false;
+ myActiveSelectionModes.clear();
+ }
}
AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
{
AISObjectPtr anIO;
- if (myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end())
- anIO = (myResult2AISObjectMap.find(theObject))->second;
+ if (myResult2AISObjectMap.contains(theObject))
+ anIO = myResult2AISObjectMap[theObject];
return anIO;
}
ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
{
ObjectPtr aFeature;
- ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
- myResult2AISObjectMap.end();
- for (; aFIt != aFLast && !aFeature; aFIt++) {
- AISObjectPtr anObj = (*aFIt).second;
- if (!anObj)
- continue;
- Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
- if (anAIS != theIO)
- continue;
- aFeature = (*aFIt).first;
+ foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
+ AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
+ Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
+ if (anAIS == theIO)
+ return anObj;
}
return aFeature;
}
-void XGUI_Displayer::closeAllContexts(const bool isUpdateViewer)
-{
- Handle(AIS_InteractiveContext) ic = AISContext();
- if (!ic.IsNull()) {
- ic->CloseAllContexts(false);
- if (isUpdateViewer)
- updateViewer();
- myUseExternalObjects = false;
- myActiveSelectionModes.clear();
- }
-}
-
void XGUI_Displayer::updateViewer()
{
Handle(AIS_InteractiveContext) ic = AISContext();
}
}
- ResultToAISMap::iterator aIt;
Handle(AIS_InteractiveObject) anAISIO;
- for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
- anAISIO = (*aIt).second->impl<Handle(AIS_InteractiveObject)>();
+ foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
+ anAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
aContext->Load(anAISIO, -1, true);
if (theModes.size() == 0)
aContext->Activate(anAISIO);
#include "XGUI.h"
-#include <QString>
-#include <memory>
-
#include <GeomAPI_AISObject.h>
-
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_InteractiveContext.hxx>
#include <ModuleBase_Definitions.h>
#include <ModuleBase_ViewerPrs.h>
-#include <map>
-#include <vector>
-#include <list>
+#include <QString>
+#include <QMap>
class XGUI_Viewer;
class ModelAPI_Feature;
int objectsCount() const { return myResult2AISObjectMap.size(); }
protected:
- /// Deactivate local selection
- /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
- void closeAllContexts(const bool isUpdateViewer);
-
/// Returns currently installed AIS_InteractiveContext
Handle(AIS_InteractiveContext) AISContext() const;
protected:
XGUI_Workshop* myWorkshop;
- typedef std::map<ObjectPtr, AISObjectPtr> ResultToAISMap;
+ typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
ResultToAISMap myResult2AISObjectMap;
// A flag of initialization of external objects selection
}
// Normaly focusTo is enough to activate widget
// here is a special case on mouse click in the viewer
- if(aNextWidget == NULL) {
- activateWidget(NULL);
- }
+ //if(aNextWidget == NULL) {
+ activateWidget(aNextWidget);
+ //}
}
void XGUI_PropertyPanel::activateNextWidget()
void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
{
+ // Avoid activation of already actve widget. It could happen on focusIn event many times
+ if (theWidget == myActiveWidget)
+ return;
if(myActiveWidget) {
+ myActiveWidget->deactivate();
myActiveWidget->setHighlighted(false);
}
if(theWidget) {
+ theWidget->activate();
theWidget->setHighlighted(true);
}
myActiveWidget = theWidget;
if (ic->NbSelected() == 0)
myCurrPointType = myPrevPointType;
//if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
- ic->CloseAllContexts();
+ //ic->CloseAllContexts();
myOperation = NOTHING;
myViewPort->setCursor(myCursor);
myCursorIsHand = false;