Config
XGUI
${QT_LIBRARIES}
+ ${suit}
+ ${std}
${LightApp}
${CAM}
${OCCViewer}
#include <LightApp_Application.h>
#include <OCCViewer_ViewModel.h>
+
#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+
#include <QtxActionMenuMgr.h>
return action(aId);
}
return 0;
+}
+
+//******************************************************
+Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
+{
+ Handle(AIS_InteractiveContext) aContext;
+ SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
+ if (aMgr) {
+ OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+ aContext = aViewer->getAISContext();
+ }
+ return aContext;
}
\ No newline at end of file
class XGUI_Workshop;
+/**
+* An implementation of SALOME connector class for implementation of
+* XGUI functionality as a module of SALOME
+*/
class NewGeom_EXPORT NewGeom_Module: public LightApp_Module, public XGUI_SalomeConnector
{
Q_OBJECT
virtual QAction* command(const QString& theId) const;
+ //! Returns AIS_InteractiveContext from current OCCViewer
+ virtual Handle(AIS_InteractiveContext) AISContext() const;
+
public slots:
bool activateModule( SUIT_Study* theStudy);
bool deactivateModule( SUIT_Study* theStudy);
#include <AIS_Shape.hxx>
-XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
-: myViewer(theViewer)
+XGUI_Displayer::XGUI_Displayer(const Handle(AIS_InteractiveContext)& theAIS)
{
+ myAISContext = theAIS;
}
XGUI_Displayer::~XGUI_Displayer()
void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape, const bool isUpdateViewer)
{
- Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+ Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
std::vector<Handle(AIS_InteractiveObject)> aDispAIS = myFeature2AISObjectMap[theFeature];
std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIt = aDispAIS.begin(),
aLast = aDispAIS.end();
- Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+ Handle(AIS_InteractiveContext) aContext = AISContext();
for (; anIt != aLast; anIt++) {
Handle(AIS_InteractiveObject) anAIS = *anIt;
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
const TopoDS_Shape& theShape,
const int theMode, const bool isUpdateViewer)
{
- Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+ Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
AIS_ListOfInteractive anAISList;
anAISList.Append(anAIS);
- myViewer->setLocalSelection(anAISList, theMode, true);
+ setLocalSelection(anAISList, theMode, true);
}
void XGUI_Displayer::GlobalSelection(const bool isUpdateViewer)
{
- myViewer->setGlobalSelection(true);
+ setGlobalSelection(true);
}
+void XGUI_Displayer::setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+ const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ // Open local context if there is no one
+ bool allObjects = false; // calculate by AIS shape
+ if (!ic->HasOpenedContext()) {
+ ic->ClearCurrents(false);
+ ic->OpenLocalContext(allObjects, true, true);
+ }
+
+ // Activate selection of objects from prs
+ AIS_ListIteratorOfListOfInteractive aIter(theAISObjects);
+ for (; aIter.More(); aIter.Next()) {
+ Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+ if (!anAIS.IsNull()) {
+ if (anAIS->IsKind(STANDARD_TYPE(AIS_Shape))) {
+ ic->Load(anAIS, -1, false);
+ ic->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theMode));
+ }
+ else if (anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron)) {
+ ic->Load(anAIS, -1, false);
+ ic->Activate(anAIS, theMode);
+ }
+ }
+ }
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::setGlobalSelection(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if (!ic.IsNull()) {
+ ic->CloseAllContexts(false);
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+ }
+}
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
#include <map>
#include <vector>
public:
/// Constructor
/// \param theViewer the viewer
- XGUI_Displayer(XGUI_Viewer* theViewer);
+ XGUI_Displayer(const Handle(AIS_InteractiveContext)& theAIS);
/// Destructor
virtual ~XGUI_Displayer();
+ /// Set AIS_InteractiveContext object in case if it was changed
+ /// or can not be initialized in constructor
+ void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
+
/// Display the feature. Obtain the visualized object from the feature.
/// \param theFeature a feature instance
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void GlobalSelection(const bool isUpdateViewer = true);
+ /// Activate local selection
+ /// \param theAIS the list of objects
+ /// \param theMode the selection mode
+ /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
+ void setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+ const bool isUpdateViewer);
+ /// Deactivate local selection
+ /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
+ void setGlobalSelection(const bool isUpdateViewer);
+
+ /// Returns currently installed AIS_InteractiveContext
+ Handle(AIS_InteractiveContext) AISContext() const { return myAISContext; }
+
protected:
- XGUI_Viewer* myViewer; ///< the viewer where the objects should be visualized
+ ///< the viewer where the objects should be visualized
+ Handle(AIS_InteractiveContext) myAISContext;
std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
};
#include "XGUI.h"
+#include <AIS_InteractiveContext.hxx>
#include <QString>
class QMainWindow;
+/**
+* An interface which provides a connection of XGUI functionality
+* with functionality of SALOME module interface.
+*/
class XGUI_EXPORT XGUI_SalomeConnector
{
public:
+ //! Creates a feature (command) in SALOME desktop
+ //! \param theWBName - a workbench name
+ //! \param theId - an id of the feature
+ //! \param theTitle - a menu item string
+ //! \param theTip - a tooltip string (help)
+ //! \param theIcon - icon
+ //! \param isCheckable - is checkable or not
+ //! \param reciever - QObject which will react on the command call
+ //! \param member - a method of receiver which will be called on the command
+ //! \param theKeys - hot keys
virtual void addFeature(const QString& theWBName,
const QString& theId,
const QString& theTitle,
const char* member,
const QKeySequence& theKeys) = 0;
+ //! Creates a command in Edit menu of SALOME desktop
+ //! \param theId - an id of the feature
+ //! \param theTitle - a menu item string
+ //! \param theTip - a tooltip string (help)
+ //! \param theIcon - icon
+ //! \param isCheckable - is checkable or not
+ //! \param reciever - QObject which will react on the command call
+ //! \param member - a method of receiver which will be called on the command
+ //! \param theKeys - hot keys
virtual void addEditCommand(const QString& theId,
const QString& theTitle,
const QString& theTip,
QObject* reciever,
const char* member,
const QKeySequence& theKeys) = 0;
+
+ //! Insert separator into Edit menu of SALOME desktop
virtual void addEditMenuSeparator() = 0;
+ //! Returns desktop window of SALOME
virtual QMainWindow* desktop() const = 0;
+ //! Returns command string Id by QAction instance
virtual QString commandId(const QAction* theCmd) const = 0;
+
+ //! Returns QAction instance by command string Id
virtual QAction* command(const QString& theId) const = 0;
+
+ //! Returns AIS_InteractiveContext from current OCCViewer
+ virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
};
#endif
\ No newline at end of file
return aWnd;
}
-void XGUI_Viewer::setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
- const bool isUpdateViewer)
-{
- Handle(AIS_InteractiveContext) ic = AISContext();
-
- // Open local context if there is no one
- bool allObjects = false; // calculate by AIS shape
- if (!ic->HasOpenedContext()) {
- ic->ClearCurrents(false);
- ic->OpenLocalContext(allObjects, true, true);
- }
-
- // Activate selection of objects from prs
- AIS_ListIteratorOfListOfInteractive aIter(theAISObjects);
- for (; aIter.More(); aIter.Next()) {
- Handle(AIS_InteractiveObject) anAIS = aIter.Value();
- if (!anAIS.IsNull()) {
- if (anAIS->IsKind(STANDARD_TYPE(AIS_Shape))) {
- ic->Load(anAIS, -1, false);
- ic->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theMode));
- }
- else if (anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron)) {
- ic->Load(anAIS, -1, false);
- ic->Activate(anAIS, theMode);
- }
- }
- }
- if (isUpdateViewer)
- ic->UpdateCurrentViewer();
-}
-
-void XGUI_Viewer::setGlobalSelection(const bool isUpdateViewer)
-{
- Handle(AIS_InteractiveContext) ic = AISContext();
- if (!ic.IsNull()) {
- ic->CloseAllContexts(false);
- if (isUpdateViewer)
- ic->UpdateCurrentViewer();
- }
-}
void XGUI_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
{
return myAISContext;
}
- //! Activate local selection
- //! \param theAIS the list of objects
- //! \param theMode the selection mode
- //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
- void setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
- const bool isUpdateViewer);
- //! Deactivate local selection
- //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
- void setGlobalSelection(const bool isUpdateViewer);
-
/// Return objects selected in 3D viewer
/// \param theList - list to be filled with selected objects
void getSelectedObjects(AIS_ListOfInteractive& theList);
private:
XGUI_MainWindow* myMainWindow;
- Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext;
+ Handle(V3d_Viewer) myV3dViewer;
+ Handle(AIS_Trihedron) myTrihedron;
+ Handle(AIS_InteractiveContext) myAISContext;
XGUI::InteractionStyle myInteractionStyle;
myPartSetModule(NULL),
mySalomeConnector(theConnector),
myPropertyPanelDock(0),
- myObjectBrowser(0)
+ myObjectBrowser(0),
+ myDisplayer(0)
{
myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
+
+ // In SALOME viewer is accessible only when module is initialized
+ // and in SALOME mode myDisplayer object has to be created later
+ // So, displayer will be created on demand.
+
mySelector = new XGUI_SelectionMgr(this);
- myDisplayer = myMainWindow? new XGUI_Displayer(myMainWindow->viewer()) : 0;
myOperationMgr = new XGUI_OperationMgr(this);
connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
myPartSetModule->launchOperation(aId);
}
}
+
+//******************************************************
+XGUI_Displayer* XGUI_Workshop::displayer() const
+{
+ // In SALOME viewer is accessible only when module is initialized
+ // and in SALOME mode myDisplayer object has to be created later (on demand)
+ if (!myDisplayer) {
+ XGUI_Workshop* that = (XGUI_Workshop*)this;
+ that->myDisplayer = isSalomeMode() ?
+ new XGUI_Displayer(salomeConnector()->AISContext()):
+ new XGUI_Displayer(myMainWindow->viewer()->AISContext());
+ }
+ return myDisplayer;
+}
XGUI_SelectionMgr* selector() const { return mySelector; }
//! Returns displayer
- XGUI_Displayer* displayer() const { return myDisplayer; }
+ XGUI_Displayer* displayer() const;
//! ! Returns operation manager.
XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }