ModuleBase_Filter.h
ModuleBase_FilterFactory.h
ModuleBase_FilterValidated.h
- ModuleBase_IDocumentDataModel.h
ModuleBase_IErrorMgr.h
ModuleBase_IModule.h
ModuleBase_IPrefMgr.h
ModuleBase_Filter.cpp
ModuleBase_FilterFactory.cpp
ModuleBase_FilterValidated.cpp
- ModuleBase_IDocumentDataModel.cpp
ModuleBase_IErrorMgr.cpp
ModuleBase_IModule.cpp
ModuleBase_IPrefMgr.cpp
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: ModuleBase_IDocumentDataModel.cpp
-// Created: 28 Apr 2015
-// Author: Vitaly SMETANNIKOV
-
-#include "ModuleBase_IDocumentDataModel.h"
-
-ModuleBase_IDocumentDataModel::ModuleBase_IDocumentDataModel(QObject* theParent) : QAbstractItemModel(theParent)
-{
-
-}
-
-void ModuleBase_IDocumentDataModel::clear()
-{
-
-}
-
-void ModuleBase_IDocumentDataModel::rebuildDataTree()
-{
-
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: ModuleBase_IDocumentDataModel.h
-// Created: 28 Apr 2015
-// Author: Vitaly SMETANNIKOV
-
-
-#ifndef ModuleBase_IDocumentDataModel_H
-#define ModuleBase_IDocumentDataModel_H
-
-#include "ModuleBase.h"
-#include <QAbstractItemModel>
-#include <ModelAPI_Object.h>
-
-class MODULEBASE_EXPORT ModuleBase_IDocumentDataModel : public QAbstractItemModel
-{
-Q_OBJECT
-public:
- ModuleBase_IDocumentDataModel(QObject* theParent);
-
- //! Returns an object by the given Model index.
- //! Returns 0 if the given index is not index of an object
- virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
-
- //! Returns index of the object
- //! \param theObject object to find
- virtual QModelIndex objectIndex(const ObjectPtr theObject) const = 0;
-
- //! Clear internal data
- virtual void clear();
-
- //! Rebuild data tree
- virtual void rebuildDataTree();
-
- /// Returns last history object index
- virtual QModelIndex lastHistoryIndex() const { return QModelIndex(); }
-
-};
-
-#endif
\ No newline at end of file
class ModuleBase_IPropertyPanel;
+/**
+ * \class ModuleBase_IErrorMgr
+ * \ingroup GUI
+ * \brief An interface to Errors manager object
+ */
class MODULEBASE_EXPORT ModuleBase_IErrorMgr : public QObject
{
Q_OBJECT
public:
/// Default constructor
+ /// \param theParent a parent object
ModuleBase_IErrorMgr(QObject* theParent = 0);
/// Virtual destructor
virtual ~ModuleBase_IErrorMgr();
class ModuleBase_ModelWidget;\r
class ModuleBase_Operation;\r
class ModuleBase_IWorkshop;\r
-class ModuleBase_IDocumentDataModel;\r
\r
/**\r
* \ingroup GUI\r
\r
virtual ~ModuleBase_IModule() {}\r
\r
- // Add default selection filters of the module to the current viewer\r
+ /// Add default selection filters of the module to the current viewer\r
virtual void activateSelectionFilters() {};\r
\r
- // Remove default selection filters of the module from the current viewer\r
+ /// Remove default selection filters of the module from the current viewer\r
virtual void deactivateSelectionFilters() {};\r
\r
/// Reads description of features from XML file \r
virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}\r
\r
/// Realizes some functionality by an operation start\r
- /// \param theOperation a started operation\r
virtual ModuleBase_Operation* currentOperation() const = 0;\r
\r
/// Add menu items for viewer into the given menu\r
/// \param theMenu a popup menu to be shown in the object browser\r
virtual void addObjectBrowserMenu(QMenu* theMenu) const {};\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
/// \param theType a type of widget\r
/// \param theParent the parent object\r
/// \param theWidgetApi the widget configuration. The attribute of the model widget is obtained from\r
/// \param theParentId is Id of a parent of the current attribute\r
- /// \param theModelWidgets list of widget objects\r
virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
Config_WidgetAPI* theWidgetApi, std::string theParentId)\r
{\r
/// \returns true if the action is processed\r
virtual bool deleteObjects() { return false; };\r
\r
-#ifdef ModuleDataModel\r
- /// Returns data model object for representation of data tree in Object browser\r
- virtual ModuleBase_IDocumentDataModel* dataModel() const = 0;\r
-#endif\r
-\r
/// Performs functionality on closing document\r
virtual void closeDocument() = 0;\r
\r
virtual QString getFeatureError(const FeaturePtr& theFeature);\r
\r
signals:\r
+ /// Signal which is emitted when operation is launched\r
void operationLaunched();\r
\r
+ /// Segnal emitted when an operation is resumed\r
+ /// \param theOp a resumed operation\r
void operationResumed(ModuleBase_Operation* theOp);\r
\r
public slots:\r
*/
virtual QObjectPtrList selectedObjects() const = 0;
+ /// Set selected objects list
virtual void setSelectedObjects( const QObjectPtrList& ) const = 0;
/**
/// Update current viewer
virtual void update() = 0;
+ /// Returns a scale factor of the given view
+ /// \param theView a view object
const double Scale(const Handle(V3d_View)& theView)
{
if (!myWindowScale.contains(theView))
return myWindowScale[theView];
}
+ /// Remember a scale factor for the view object
+ /// \param theView a view object
+ /// \param theVal a scale factor
void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; }
/// Method returns True if the viewer can process editing objects
/// by mouse drugging. If this is impossible thet it has to return False.
virtual bool canDragByMouse() const { return true; }
- // Fit all along Z (perpendicular to display)
+ /// Fit all along Z (perpendicular to display)
virtual void Zfitall() = 0;
signals:
void viewTransformed(int theTransformation);
protected:
+ /// A map for storing a scale factors dependent on view object
QMap<Handle(V3d_View), double> myWindowScale;
};
virtual ModuleBase_Operation* findStartedOperation(const QString& theId) = 0;
//! Returns true if the operation with id theId can be stopped
- //! \param theId a stopped operation
+ //! \param theOperation a stopped operation
//! \return boolean result
virtual bool canStopOperation(ModuleBase_Operation* theOperation) = 0;
//! Aborts the operation.
- //! \param theId an aborted operation
+ //! \param theOperation an aborted operation
virtual void abortOperation(ModuleBase_Operation* theOperation) = 0;
//! Returns AIS object by data object
+ //! \param theObject a data object
virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0;
//! Returns data object by AIS
+ //! \param theAIS a presentation
virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
//! Select features clearing previous selection.
//! If the list is empty then selection will be cleared
+ //! \param theValues a list of presentations
virtual void setSelected(const QList<ModuleBase_ViewerPrs>& theValues) = 0;
signals:
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped selection values
- /// \param toValidate the boolean value whether the value should be checked by filters
+ /// \param theToValidate the boolean value whether the value should be checked by filters
virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
const bool theToValidate)
{
}
/// Set feature which is processing by active operation
+ /// \param theFeature a feature object
/// \param theToStoreValue a value about necessity to store the widget value to the feature
void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false);
/*!
+ * \ingroup GUI
* Represent a property panel's list of ModuleBase_ModelWidgets.
*/
class MODULEBASE_EXPORT ModuleBase_PageGroupBox : public QGroupBox, public ModuleBase_PageBase
class QGridLayout;
/*!
+ * \ingroup GUI
* Represent a property panel's list of ModuleBase_ModelWidgets.
*/
class MODULEBASE_EXPORT ModuleBase_PageWidget : public QFrame, public ModuleBase_PageBase
{
Q_OBJECT
public:
+ /// A constructor
+ /// \param theParent a parent widget
+ /// \param theData a data of the widget
+ /// \param theParentId an Id of the parent object
ModuleBase_PagedContainer(QWidget* theParent, const Config_WidgetAPI* theData,
const std::string& theParentId);
virtual ~ModuleBase_PagedContainer();
+ /// Add a new page
+ /// \param theWidget a page object
+ /// \param theName a name of the page
+ /// \param theCaseId an Id of the page
+ /// \param theIcon aqn Icon of the page
virtual int addPage( ModuleBase_PageBase* theWidget,
const QString& theName,
const QString& theCaseId,
const QPixmap& theIcon );
- // ModuleBase_ModelWidget
+ /// Redefinition of virtual function
virtual QList<QWidget*> getControls() const;
+
+ /// Redefinition of virtual function
virtual bool focusTo();
+
+ /// Redefinition of virtual function
virtual void setHighlighted(bool isHighlighted);
+
+ /// Redefinition of virtual function
virtual void enableFocusProcessing();
protected:
+ /// Returns index of current page
virtual int currentPageIndex() const = 0;
+
+ /// Set current page by index
virtual void setCurrentPageIndex(int ) = 0;
- // ModuleBase_ModelWidget
+
+ /// Redefinition of virtual function
virtual void activateCustom();
+
+ /// Redefinition of virtual function
virtual bool storeValueCustom() const;
+
+ /// Redefinition of virtual function
virtual bool restoreValueCustom();
protected slots:
+ /// A slot called on page change
void onPageChanged();
private:
#include <string>
#include <iostream>
-/*!
- \class ModuleBase_ParamSpinBox
- */
-
-/*!
- \brief Constructor.
-
- Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
- a step value of 1.0 and a precision of 2 decimal places.
- The value is initially set to 0.00.
- \param parent parent object
- */
ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrecision)
: ModuleBase_DoubleSpinBox(theParent, thePrecision),
myAcceptVariables(true)
this, SLOT(onTextChanged(const QString&)));
}
-/*!
- \brief This function is called when value is changed.
- */
void ModuleBase_ParamSpinBox::onTextChanged(const QString& text)
{
myTextValue = text;
}
-/*!
- \brief Interpret text entered by the user as a value.
- \param text text entered by the user
- \return mapped value
- \sa textFromValue()
- */
double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const
{
if (!hasVariable(theText))
#include <QValidator>
+/**
+* \ingroup GUI
+* An extension of a double spin box which let to use parameters and expressions for value definition
+*/
class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBox
{
Q_OBJECT
enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
public:
+ /*!
+ \brief Constructor.
+
+ Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
+ a step value of 1.0 and a precision of 2 decimal places.
+ The value is initially set to 0.00.
+
+ \param theParent a parent object
+ \param thePrecision a precision of values display
+ */
explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
virtual ~ModuleBase_ParamSpinBox();
virtual void setText(const QString&);
+ /// Set a flag about accepted variable
void setAcceptVariables(const bool);
+
+ /// Returns accepted variables flag
bool isAcceptVariables() const;
- bool hasVariable() const;
-//signals:
- //void textChanged(const QString&);
+ /// Returns True if the input value contains variable
+ bool hasVariable() const;
protected:
+ /// Returns True if the given text contains variable
+ /// \param theText a text string
bool hasVariable(const QString& theText) const;
+
+ /// Returns state of the control
State isValid(const QString&, double&) const;
+ /// Returns True if the given value is within min and max of the control
bool checkRange(const double) const;
- bool findVariable(const QString&, double&) const;
+ /// Finds a variable by its name. Rreturns true in success
+ /// \param theName a name of variable
+ /// \param outValue an output val;ue of the variable
+ bool findVariable(const QString& theName, double& outValue) const;
protected:
- //virtual void keyPressEvent(QKeyEvent*);
virtual void showEvent(QShowEvent*);
protected slots:
+ /// A slot called on text change
void onTextChanged(const QString&);
private:
class QHBoxLayout;
class QStackedWidget;
+/**
+ * \class ModuleBase_ToolBox
+ * \ingroup GUI
+ * \brief An extension of QFrame object
+ */
class MODULEBASE_EXPORT ModuleBase_ToolBox : public QFrame
{
Q_OBJECT
public:
+ /// Constructor
+ /// \param theParent a parent widget
ModuleBase_ToolBox( QWidget* theParent );
virtual ~ModuleBase_ToolBox();
+ /// Add a new item to the tool box
+ /// \param thePage a widget of the new item
+ /// \param theName a name of the item
+ /// \param theIcon an icon of the item
void addItem( QWidget* thePage, const QString& theName, const QPixmap& theIcon );
+
+ /// \return number of items
int count() const;
+
+ /// \return index of current widget
int currentIndex() const;
- void setCurrentIndex( const int );
+
+ /// Set current item
+ /// \param theIdx an index
+ void setCurrentIndex( const int theIdx);
signals:
+ /// A signal which is emited on current item changed
void currentChanged( int );
private slots:
+ /// A slot called on button press
void onButton( int );
private:
Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {}
/// Set working plane
- /// \param thePane plane object
+ /// \param thePlane a plane object
void setPlane(const std::shared_ptr<GeomAPI_Pln>& thePlane) { myPlane = thePlane; }
/// Returns current working plane
class QStringListModel;
class QCompleter;
+/**
+* \ingroup GUI
+* A multi-line text editor which lets to input formula and provides a list of completion strings
+*/
class ExpressionEditor: public QPlainTextEdit
{
Q_OBJECT
-
public:
+ /// Constructor
+ /// \param theParent a parent widget
explicit ExpressionEditor(QWidget* theParent = 0);
virtual ~ExpressionEditor();
+ /// Set list of completion strings
void setCompletionList(QStringList&);
+ /// Set a text which will be shown when the listr is empty
void setPlaceHolderText( const QString& );
+
+ /// Returns placeholder list
QString placeHolderText() const;
public slots:
- void insertCompletion(const QString&, bool isSingleWord = false);
+ /// Insert additional string for completion
+ /// \param theCompletion a string to insert
+ /// \param isSingleWord a flag shows that inserted string is single word or not
+ void insertCompletion(const QString& theCompletion, bool isSingleWord = false);
+
+ /// Perform completion
void performCompletion();
protected:
+ /// Perform completion by prefix
+ /// \param theCompletionPrefix a prefix for looking for completion
void performCompletion(const QString& theCompletionPrefix);
+
+ /// Redefinition of virtual method
+ /// \param theEvent a key press event
virtual void keyPressEvent(QKeyEvent* theEvent);
+
+ /// Key events processing
+ /// theEvent a key event
bool handledCompletedAndSelected(QKeyEvent* theEvent);
+
+ /// Redefinition of virtual method
virtual void paintEvent( QPaintEvent* );
private:
/**
* \ingroup GUI
-* TODO(sbh) add doc
+* A Widget which provides an input of an expression
*/
class MODULEBASE_EXPORT ModuleBase_WidgetExprEditor : public ModuleBase_ModelWidget
{
/// \param theParent the parent object
/// \param theData the widget configuration.
/// \param theParentId is Id of a parent of the current attribute
+ /// \param thePlaceHolder a placeholder string
ModuleBase_WidgetExprEditor( QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId,
const std::string& thePlaceHolder );
virtual ~ModuleBase_WidgetExprEditor();
+ /// Redefinition of virtual method
virtual QList<QWidget*> getControls() const;
public slots:
/// \return True in success
virtual bool storeValueCustom() const;
+ /// Redefinition of virtual method
virtual bool restoreValueCustom();
private:
/// Returns string containing formats
QString filterString() const;
+ /// Add an extension to file name if the extension is not defined
+ /// \param theFileName a file name
+ /// \param theFilter a file filter
+ /// \return the file name with extension
static QString applyExtension(const QString& theFileName, const QString& theFilter);
protected:
#include <memory>
#include <string>
+/**
+* Customization of Line edit control
+*/
class CustomLineEdit : public QLineEdit
{
public:
+ /// Constructor
+ /// \param theParent a parent widget
+ /// \param thePlaceHolder a string which is shown when text is empty
CustomLineEdit( QWidget* theParent, const QString& thePlaceHolder )
: QLineEdit( theParent ), myPlaceHolder( thePlaceHolder )
{
{
}
+ /// Redefiniotion of virtual method
+ /// \param theEvent a paint event
virtual void paintEvent( QPaintEvent* theEvent )
{
QLineEdit::paintEvent( theEvent );
/// \param theParent the parent object
/// \param theData the widget configuration.
/// \param theParentId is Id of a parent of the current attribute
+ /// \param thePlaceHolder a string of placeholder
ModuleBase_WidgetLineEdit( QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId,
const std::string& thePlaceHolder );
virtual ~ModuleBase_WidgetLineEdit();
+ /// Redefinition of virtual method
virtual QList<QWidget*> getControls() const;
public slots:
/// Saves the internal parameters to the given feature
/// \return True in success
virtual bool storeValueCustom() const;
+
+ /// Redefinition of virtual method
virtual bool restoreValueCustom();
private:
#include <memory>
#include <string>
+/**
+* Customization of a List Widget to make it to be placed on full width of container
+*/
class CustomListWidget : public QListWidget
{
public:
+ /// Constructor
+ /// \param theParent a parent widget
CustomListWidget( QWidget* theParent )
: QListWidget( theParent )
{
}
+ /// Redefinition of virtual method
virtual QSize sizeHint() const
{
int aHeight = 2*QFontMetrics( font() ).height();
return QSize( aSize.width(), aHeight );
}
+ /// Redefinition of virtual method
virtual QSize minimumSizeHint() const
{
int aHeight = 2*QFontMetrics( font() ).height();
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped selection values
+ /// \param theToValidate a validation of the values flag
virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
const bool theToValidate);
/// Checks the widget validity. By default, it returns true.
- /// \param theValue a selected presentation in the view
+ /// \param thePrs a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
/// Clear attribute
virtual void clearAttribute();
- // Set the focus on the last item in the list
+ /// Set the focus on the last item in the list
virtual void updateFocus();
/// Computes and updates name of selected object in the widget
/// Variable of GeomSelection
int mySelectionCount; // number of elements in the attribute selection list when store
+ /// A flag to store use_choice parameter state
bool myIsUseChoice;
};
virtual bool isViewerSelector() { return true; }
/// Checks the widget validity. By default, it returns true.
- /// \param theValue a selected presentation in the view
+ /// \param thePrs a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
/// Fills the attribute with the value of the selected owner
- /// \param theOwner a selected owner
+ /// \param thePrs a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
/// The methiod called when widget is deactivated
/// Set an empty value to attribute
virtual void clearAttribute() = 0;
- // Update focus after the attribute value change
+ /// Update focus after the attribute value change
virtual void updateFocus() = 0;
/// Return the attribute values wrapped in a list of viewer presentations
Q_OBJECT
public:
/// Constructor
- /// \param parent a parent widget
+ /// \param theParent the parent object
+ /// \param theData the widget configuration. The attribute of the model widget is obtained from
+ /// \param theParentId is Id of a parent of the current attribute
ModuleBase_WidgetSwitch(QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId);
/// Add a page to the widget
/// \param theWidget a page widget
/// \param theName a name of page
+ /// \param theCaseId an Id of the page
+ /// \param theIcon an icon of the page
virtual int addPage( ModuleBase_PageBase* theWidget,
const QString& theName,
const QString& theCaseId,
const QPixmap& theIcon );
protected:
+ /// Returns index of the current page
virtual int currentPageIndex() const;
- /// Set current page by index
+
+ /// Set current page by index
/// \param index index of the page
virtual void setCurrentPageIndex(int index);
{
Q_OBJECT
public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theData the widget configuration. The attribute of the model widget is obtained from
+ /// \param theParentId is Id of a parent of the current attribute
ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData,
const std::string& theParentId);
virtual ~ModuleBase_WidgetToolbox();
/// \return false because this is an info widget
virtual bool canSetValue() const { return false; };
- /// Overrides ModuleBase_PagedContainer
+ /// Add a page to the widget
+ /// \param theWidget a page widget
+ /// \param theName a name of page
+ /// \param theCaseId an Id of the page
+ /// \param theIcon an icon of the page
virtual int addPage( ModuleBase_PageBase* theWidget,
const QString& theName,
const QString& theCaseId,
protected:
/// Implements ModuleBase_PagedContainer
virtual int currentPageIndex() const;
+
/// Implements ModuleBase_PagedContainer
virtual void setCurrentPageIndex(int);
public:
/// Constructor
/// \param theParent the parent object
+ /// \param theWorkshop a reference to workshop
/// \param theData the widget configuation. The attribute of the model widget is obtained from
/// \param theParentId is Id of a parent of the current attribute
ModuleBase_WidgetValidated(QWidget* theParent,
virtual ~ModuleBase_WidgetValidated();
/// Checks whether all active viewer filters validate the presentation
- /// \param theWorkshop an active workshop
- /// \param theValue a selected presentation in the view
+ /// \param thePrs a selected presentation in the view
/// \return a boolean value
bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
/// The method is called by the current operation to process the operation preselection.
/// It is redefined to check the value validity and if it is, fill the attribute with by value
/// \param theValues the wrapped selection values
+ /// \param theToValidate a flag on validation of the values
virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
const bool theToValidate);
ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
/// It obtains selection filters from the workshop and activates them in the active viewer
- /// \param theWorkshop an active workshop
/// \param toActivate a flag about activation or deactivation the filters
void activateFilters(const bool toActivate);
virtual void restoreAttributeValue(const bool theValid);
/// Checks the widget validity. By default, it returns true.
- /// \param theValue a selected presentation in the view
+ /// \param thePrs a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
/// Fills the attribute with the value of the selected owner
- /// \param theOwner a selected owner
+ /// \param thePrs a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
/// Checks the current attibute in all attribute validators
/// \param theValid a valid state
void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid);
- // Removes all presentations from internal maps.
+ /// Removes all presentations from internal maps.
void clearValidState();
/// Returns a list of selected presentations in the viewer and object browser
void filterPresentations(QList<ModuleBase_ViewerPrs>& theValues);
protected:
- ModuleBase_IWorkshop* myWorkshop; /// Reference to workshop
- bool myIsInValidate; // the widget is in validation mode: store is performed, restore is not
+ /// Reference to workshop
+ ModuleBase_IWorkshop* myWorkshop;
+
+ /// The widget is in validation mode: store is performed, restore is not
+ bool myIsInValidate;
private:
ObjectPtr myPresentedObject; /// back up of the filtered object
virtual QAction* addFeature(const QString& theWBName,
const ActionInfo& theInfo);
+ /// Add a nested feature
+ /// \param theWBName a workbench name
+ /// \param theInfo the action parameters
+ /// \param theNestedActions a list of nested actions
virtual QAction* addFeatureOfNested(const QString& theWBName,
const ActionInfo& theInfo,
const QList<QAction*>& theNestedActions);
//! Returns true if the feature action is a nested action, in other words,
//! it is created by addNestedFeature().
- //! \param theId - an action of a feature
+ //! \param theAction - an action of a feature
//! returns boolean result
virtual bool isFeatureOfNested(const QAction* theAction);
virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
const int theMenuPosition = 10);
+ /// Add an action to a tool bar
+ /// \param theAction an ation to add
+ /// \param theToolBarTitle a name of tool bar
virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
virtual QMainWindow* desktop() const;
/// Create popup menu manager
virtual QtxPopupMgr* popupMgr();
+ /// Abort all operations
virtual bool abortAllOperations();
private:
{
Q_OBJECT
public:
- NewGeom_NestedButton(QObject *parent, const QList<QAction*>& theNestedActions);
+ /// Constructor
+ /// \param theParent a parent objects
+ /// \param theNestedActions a list of nested actions
+ NewGeom_NestedButton(QObject* theParent, const QList<QAction*>& theNestedActions);
virtual ~NewGeom_NestedButton();
private slots:
/// Shows/hides the additional buttons widget
void showAdditionalButtons(bool);
+
+ /// Slot called on action state
void actionStateChanged();
protected:
/// Creates the button representation
+ /// \param theParent a parent widget
virtual QWidget * createWidget(QWidget * theParent);
private:
PartSet_FilterInfinite.h
PartSet_SketcherMgr.h
PartSet_MenuMgr.h
- PartSet_DocumentDataModel.h
- PartSet_PartDataModel.h
- PartSet_DataTreeModel.h
PartSet_WidgetSketchCreator.h
- PartSet_TopDataModel.h
PartSet_IconFactory.h
)
PartSet_FilterInfinite.cpp
PartSet_SketcherMgr.cpp
PartSet_MenuMgr.cpp
- PartSet_DocumentDataModel.cpp
- PartSet_PartDataModel.cpp
- PartSet_DataTreeModel.cpp
PartSet_WidgetSketchCreator.cpp
- PartSet_TopDataModel.cpp
PartSet_IconFactory.cpp
)
class PartSet_CustomPrs
{
public:
+ /// Constructor
+ /// \param theWorkshop a reference to workshop
PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
/// If the presentation is active[displayed], the shapes of the presentation is recomputed
/// and the presentation is redisplayed.
+ /// \param theObject an object to redisplay
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
/// \returns true if the presentation is redisplayed
bool redisplay(const ObjectPtr& theObject, const bool theUpdateViewer);
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#include "PartSet_DataTreeModel.h"
-
-PartSet_FeaturesModel::PartSet_FeaturesModel(QObject* theParent)
-: QAbstractItemModel(theParent),
- myItemsColor(Qt::black)
-{
-
-}
-
-PartSet_PartModel::PartSet_PartModel(QObject* theParent)
-: PartSet_FeaturesModel(theParent)
-{
-
-}
-
-PartSet_PartModel::~PartSet_PartModel()
-{
- myPart = FeaturePtr();
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#ifndef PartSet_DataTreeModel_H
-#define PartSet_DataTreeModel_H
-
-#include "PartSet.h"
-
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_ResultPart.h>
-#include <ModelAPI_Session.h>
-
-#include <QAbstractItemModel>
-#include <QColor>
-
-/**\class PartSet_FeaturesModel
- * \ingroup GUI
- * \brief Abstaract class of model object which operates with features data.
- */
-class PARTSET_EXPORT PartSet_FeaturesModel : public QAbstractItemModel
-{
- public:
- /// Constructor
- /// \param theParent a parent object
- PartSet_FeaturesModel(QObject* theParent);
-
- //! Returns Feature object by the given Model index.
- //! Returns 0 if the given index is not index of a feature
- /// \param theIndex a model index
- virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
-
- //! Returns QModelIndex which corresponds to the given feature
- //! If the feature is not found then index is not valid
- virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
-
- //! Returns parent index of the given feature
- virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
-
- //! Returns index corresponded to the group
- //! \param theGroup a group name
- virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
-
- //! Set color of items
- void setItemsColor(const QColor& theColor)
- {
- myItemsColor = theColor;
- }
-
- //! Returns color of items
- QColor itemsColor() const
- {
- return myItemsColor;
- }
-
- protected:
- /// Color of items
- QColor myItemsColor;
-};
-
-/**\class PartSet_PartModel
- * \ingroup GUI
- * \brief Abstaract class of model object which operates with parts data.
- */
-class PartSet_PartModel : public PartSet_FeaturesModel
-{
- public:
- /// Constructor
- /// \param theParent a parent object
- PartSet_PartModel(QObject* theParent);
- /// Destructor
- ~PartSet_PartModel();
-
- /// Set part id
- /// \param theId a new id
- void setPart(FeaturePtr thePart)
- {
- myPart = thePart;
- }
-
- /// Returns Id of the part
- FeaturePtr part() const { return myPart; }
-
- //! Returns true if the given document is a sub-document of this tree
- //! \param theDoc a document to check
- virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
-
- /// Returns position of the part in history
- int position() const
- {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- return aRootDoc->index(myPart);
- }
-
- protected:
- //! Id of the current part object in the document
- FeaturePtr myPart;
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#include "PartSet_DocumentDataModel.h"
-#include "PartSet_PartDataModel.h"
-#include "PartSet_TopDataModel.h"
-#include "PartSet_Module.h"
-//#include "XGUI_Tools.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_ResultPart.h>
-#include <ModelAPI_Events.h>
-#include <ModelAPI_Object.h>
-
-#include <Events_Loop.h>
-
-#include <Config_FeatureMessage.h>
-#include <ModuleBase_Tools.h>
-#include <ModuleBase_ActionInfo.h>
-
-#include <PartSetPlugin_Part.h>
-
-#include <QIcon>
-#include <QString>
-#include <QBrush>
-#include <QTreeView>
-
-#include <set>
-
-#define ACTIVE_COLOR QColor(0,72,140)
-#define PASSIVE_COLOR Qt::black
-
-QMap<QString, QString> PartSet_DocumentDataModel::myIcons;
-
-
-PartSet_DocumentDataModel::PartSet_DocumentDataModel(QObject* theParent)
- : ModuleBase_IDocumentDataModel(theParent),
- myActivePartModel(0)
-{
- // Create a top part of data tree model
- myModel = new PartSet_TopDataModel(this);
- myModel->setItemsColor(ACTIVE_COLOR);
-
- Events_Loop* aLoop = Events_Loop::loop();
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
- aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT()));
-}
-
-PartSet_DocumentDataModel::~PartSet_DocumentDataModel()
-{
- clearModelIndexes();
- clearSubModels();
-}
-
-void PartSet_DocumentDataModel::processEvent(const std::shared_ptr<Events_Message>& theMessage)
-{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-
-
- // Created object event *******************
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
- std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- std::set<ObjectPtr> aObjects = aUpdMsg->objects();
-
- std::set<ObjectPtr>::const_iterator aIt;
- for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
- ObjectPtr aObject = (*aIt);
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
- if (aFeature && (!aFeature->isInHistory()))
- continue;
-
- DocumentPtr aDoc = aObject->document();
- if (aDoc == aRootDoc) { // If root objects
- if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group
- // Add a new part
- int aStart = aRootDoc->size(ModelAPI_ResultPart::group());
- if (aStart > 0) {
- FeaturePtr aPartFeature = ModelAPI_Feature::feature(aObject);
- PartSet_PartDataModel* aModel = new PartSet_PartDataModel(this);
- int anId = aRootDoc->index(aPartFeature);
- aModel->setPart(aPartFeature);
- myPartModels.append(aModel);
- insertRow(aStart, partFolderNode(0));
- }
- } else { // Update top groups (other except parts
- QModelIndex aIndex = myModel->findParent(aObject);
- int aStart = myModel->rowCount(aIndex) - 1;
- if (aStart < 0)
- aStart = 0;
- aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex));
- insertRow(aStart, aIndex);
- }
- } else { // if sub-objects of first level nodes
- PartSet_PartModel* aPartModel = 0;
- foreach (PartSet_PartModel* aPart, myPartModels) {
- if (aPart->hasDocument(aDoc)) {
- aPartModel = aPart;
- break;
- }
- }
- if (aPartModel) {
- QModelIndex aIndex = aPartModel->findParent(aObject);
- int aStart = aPartModel->rowCount(aIndex); // check this index
- aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex));
- insertRow(aStart, aIndex);
- } else
- reset();
- }
- }
- // Deleted object event ***********************
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
- std::shared_ptr<ModelAPI_ObjectDeletedMessage> aUpdMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
- DocumentPtr aDoc = aUpdMsg->document();
- std::set<std::string> aGroups = aUpdMsg->groups();
-
- std::set<std::string>::const_iterator aIt;
- for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
- std::string aGroup = (*aIt);
- if (aDoc == aRootDoc) { // If root objects
- if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group
- PartSet_PartModel* aDelPartModel = 0;
- foreach (PartSet_PartModel* aPartModel, myPartModels) {
- if (aPartModel->position() == -1) {
- aDelPartModel = aPartModel;
- break;
- }
- }
- if (aDelPartModel) {
- deactivatePart();
- int aStart = myPartModels.size() - 1;
- removeSubModel(aDelPartModel);
- removeRow(aStart, partFolderNode(0));
- }
- } if (aGroup == ModelAPI_Feature::group()) { // Update History node
- int aRow = historyOffset() + aRootDoc->size(ModelAPI_Feature::group());
- removeRow(aRow);
- } else { // Update top groups (other except parts
- QModelIndex aIndex = myModel->findGroup(aGroup);
- int aStart = myModel->rowCount(aIndex);
- aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex));
- removeRow(aStart, aIndex);
- }
- } else {
- PartSet_PartModel* aPartModel = 0;
- foreach (PartSet_PartModel* aPart, myPartModels) {
- if (aPart->hasDocument(aDoc)) {
- aPartModel = aPart;
- break;
- }
- }
- if (aPartModel) {
- QModelIndex aIndex = aPartModel->findGroup(aGroup);
- if (aIndex.isValid()) {
- int aStart = aPartModel->rowCount(aIndex);
- aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex));
- removeRow(aStart, aIndex);
- } else {
- int aRow = aPartModel->rowCount();
- aIndex = createIndex(aPartModel->position() + historyOffset(), 0, HistoryNode);
- removeRow(aRow, aIndex);
- }
- }
- }
- }
- // Deleted object event ***********************
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
- //std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg = std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- //ObjectPtr aFeature = aUpdMsg->feature();
- //DocumentPtr aDoc = aFeature->document();
-
- // TODO: Identify the necessary index by the modified feature
- QModelIndex aIndex;
- emit dataChanged(aIndex, aIndex);
-
- // Reset whole tree **************************
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) {
- std::shared_ptr<Config_FeatureMessage> aFeatureMsg =
- std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
- if (!aFeatureMsg->isInternal()) {
- ActionInfo aFeatureInfo;
- aFeatureInfo.initFrom(aFeatureMsg);
- // Remember features icons
- myIcons[QString::fromStdString(aFeatureMsg->id())] = aFeatureInfo.iconFile;
- }
- } else {
- rebuildDataTree();
- }
-}
-
-void PartSet_DocumentDataModel::rebuildDataTree()
-{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
-
- beginResetModel();
- clearModelIndexes();
-
- // Delete extra models
- ObjectPtr aObj;
- FeaturePtr aFeature;
- QList<PartSet_PartModel*> aDelList;
- foreach (PartSet_PartModel* aPartModel, myPartModels) {
- if (aPartModel->position() == -1)
- aDelList.append(aPartModel);
- }
- foreach (PartSet_PartModel* aPartModel, aDelList) {
- removeSubModel(aPartModel);
- }
- // Add non existing models
- int aHistNb = aRootDoc->size(ModelAPI_Feature::group());
- for (int i = 0; i < aHistNb; i++) {
- aObj = aRootDoc->object(ModelAPI_Feature::group(), i);
- aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
- if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
- if (!findPartModel(aFeature)) {
- PartSet_PartDataModel* aModel = new PartSet_PartDataModel(this);
- aModel->setPart(aFeature);
- myPartModels.append(aModel);
- }
- }
- }
- endResetModel();
-}
-
-QVariant PartSet_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) const
-{
- if (!theIndex.isValid())
- return QVariant();
-
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- QModelIndex aParent = theIndex.parent();
- if ((theIndex.column() == 1) ) {
- if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) {
- if (ModelAPI_Session::get()->activeDocument() == aRootDoc) {
- if (!aParent.isValid()) {
- switch (theRole) {
- case Qt::DecorationRole:
- if (theIndex.row() == lastHistoryRow())
- return QIcon(":pictures/arrow.png");
- }
- }
- }
- } else {
- QModelIndex* aIndex = toSourceModelIndex(theIndex);
- const QAbstractItemModel* aModel = aIndex->model();
- if (isPartSubModel(aModel)) {
- return aModel->data(*aIndex, theRole);
- }
- }
- return QVariant();
- }
-
- switch (theIndex.internalId()) {
- case PartsFolder:
- switch (theRole) {
- case Qt::DisplayRole:
- return tr("Parts") + QString(" (%1)").arg(rowCount(theIndex));
- case Qt::DecorationRole:
- return QIcon(":pictures/constr_folder.png");
- case Qt::ToolTipRole:
- return tr("Parts folder");
- case Qt::ForegroundRole:
- if (myActivePartIndex.isValid())
- return QBrush(PASSIVE_COLOR);
- else
- return QBrush(ACTIVE_COLOR);
- default:
- return QVariant();
- }
- break;
- case HistoryNode:
- {
- int aOffset = historyOffset();
- ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
- if (!aFeature)
- return QVariant();
- switch (theRole) {
- case Qt::DisplayRole:
- if (aFeature)
- return aFeature->data()->name().c_str();
- else
- return QVariant();
- case Qt::DecorationRole:
- return featureIcon(aFeature);
- case Qt::ToolTipRole:
- {
- ResultPtr aResult = aFeature->firstResult();
- bool isResultAndNotLoaded = false;
- if( aResult.get() )
- {
- ResultPartPtr aResultPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>( aResult );
- if( aResultPart.get() )
- isResultAndNotLoaded = !aResultPart->isActivated();
- }
- if( isResultAndNotLoaded )
- return tr( "The part should be activated before the user may edit it" );
- else
- return tr( "Feature object" );
- }
- case Qt::ForegroundRole:
- if (theIndex.row() > lastHistoryRow())
- return QBrush(Qt::lightGray);
- else {
- if (myActivePartIndex.isValid())
- return QBrush(PASSIVE_COLOR);
- else
- return QBrush(ACTIVE_COLOR);
- }
- default:
- return QVariant();
- }
- }
- break;
- case PartResult:
- {
- ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), theIndex.row());
- if (aObject) {
- switch (theRole) {
- case Qt::DisplayRole:
- return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
- case Qt::DecorationRole:
- return QIcon(":pictures/part_ico.png");
- case Qt::ForegroundRole:
- {
- if (theIndex == myActivePartIndex)
- return QBrush(ACTIVE_COLOR);
- else
- return QBrush(PASSIVE_COLOR);
- }
- default:
- return QVariant();
- }
- }
- }
- break;
- }
- if (aParent.internalId() == HistoryNode) {
- int aId = aParent.row() - historyOffset();
- QModelIndex* aIndex = toSourceModelIndex(theIndex);
- return findPartModel(aId)->data(*aIndex, theRole);
- }
- return toSourceModelIndex(theIndex)->data(theRole);
-}
-
-QVariant PartSet_DocumentDataModel::headerData(int theSection, Qt::Orientation theOrient,
- int theRole) const
-{
- return QVariant();
-}
-
-int PartSet_DocumentDataModel::rowCount(const QModelIndex& theParent) const
-{
- SessionPtr aSession = ModelAPI_Session::get();
- if (!aSession->hasModuleDocument())
- return 0;
- DocumentPtr aRootDoc = aSession->moduleDocument();
- if (!theParent.isValid()) {
- // Size of external models
- int aVal = historyOffset();
- // Plus history size
- aVal += aRootDoc->size(ModelAPI_Feature::group());
- return aVal;
- }
- if (theParent.internalId() == PartsFolder) {
- return aRootDoc->size(ModelAPI_ResultPart::group());
- //int aSize = myPartModels.size();
- //return myPartModels.size();
- }
- if (theParent.internalId() == HistoryNode) {
- int aId = theParent.row() - historyOffset();
- PartSet_PartModel* aModel = findPartModel(aId);
- if (aModel)
- return aModel->rowCount(QModelIndex());
- return 0;
- }
- if (theParent.internalId() == PartResult)
- return 0;
-
- QModelIndex* aParent = toSourceModelIndex(theParent);
- const QAbstractItemModel* aModel = aParent->model();
- if (!isSubModel(aModel))
- return 0;
-
- /*if (isPartSubModel(aModel)) {
- if (aModel != myActivePart)
- return 0;
- }*/
- return aModel->rowCount(*aParent);
-}
-
-int PartSet_DocumentDataModel::columnCount(const QModelIndex& theParent) const
-{
- return 2;
-}
-
-QModelIndex PartSet_DocumentDataModel::index(int theRow, int theColumn,
- const QModelIndex& theParent) const
-{
- QModelIndex aIndex;
- if (!theParent.isValid()) {
- int aOffs = myModel->rowCount();
- if (theRow < aOffs) {
- aIndex = myModel->index(theRow, theColumn, theParent);
- aIndex = createIndex(theRow, theColumn, (void*) getModelIndex(aIndex));
- } else {
- if (theRow == aOffs) // Create Parts node
- aIndex = partFolderNode(theColumn);
- else {
- // create history node
- aIndex = createIndex(theRow, theColumn, HistoryNode);
- }
- }
- } else {
- if (theParent.internalId() == PartsFolder) {
- aIndex = createIndex(theRow, theColumn, PartResult);
- } else {
- if (theParent.internalId() == HistoryNode) {
- int aId = theParent.row() - historyOffset();
- aIndex = findPartModel(aId)->index(theRow, theColumn, QModelIndex());
- } else {
- QModelIndex* aParent = (QModelIndex*) theParent.internalPointer();
- aIndex = aParent->model()->index(theRow, theColumn, (*aParent));
- }
- aIndex = createIndex(theRow, theColumn, (void*) getModelIndex(aIndex));
- }
- }
- return aIndex;
-}
-
-QModelIndex PartSet_DocumentDataModel::parent(const QModelIndex& theIndex) const
-{
- if ((theIndex.internalId() == PartsFolder) || (theIndex.internalId() == HistoryNode))
- return QModelIndex();
-
- if (theIndex.internalId() == PartResult)
- return partFolderNode(0);
-
- QModelIndex* aIndex = toSourceModelIndex(theIndex);
- const QAbstractItemModel* aModel = aIndex->model();
- if (!isSubModel(aModel))
- return QModelIndex();
-
- QModelIndex aIndex1 = aModel->parent(*aIndex);
- const PartSet_PartModel* aPartModel = dynamic_cast<const PartSet_PartModel*>(aModel);
- if (aPartModel && (!aIndex1.isValid())) {
- int aId = aPartModel->position();
- int aRow = aId + historyOffset();
- return createIndex(aRow, 0, (qint32) HistoryNode);
- }
-
- if (aIndex1.isValid())
- return createIndex(aIndex1.row(), 0, (void*) getModelIndex(aIndex1));
- return aIndex1;
-}
-
-bool PartSet_DocumentDataModel::hasChildren(const QModelIndex& theParent) const
-{
- if (!theParent.isValid())
- return true;
- return rowCount(theParent) > 0;
-}
-
-QModelIndex* PartSet_DocumentDataModel::toSourceModelIndex(const QModelIndex& theProxy) const
-{
- QModelIndex* aIndexPtr = static_cast<QModelIndex*>(theProxy.internalPointer());
- return aIndexPtr;
-}
-
-QModelIndex* PartSet_DocumentDataModel::findModelIndex(const QModelIndex& theIndex) const
-{
- QList<QModelIndex*>::const_iterator aIt;
- for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt) {
- QModelIndex* aIndex = (*aIt);
- if ((*aIndex) == theIndex)
- return aIndex;
- }
- return 0;
-}
-
-QModelIndex* PartSet_DocumentDataModel::getModelIndex(const QModelIndex& theIndex) const
-{
- QModelIndex* aIndexPtr = findModelIndex(theIndex);
- if (!aIndexPtr) {
- aIndexPtr = new QModelIndex(theIndex);
- PartSet_DocumentDataModel* that = (PartSet_DocumentDataModel*) this;
- that->myIndexes.append(aIndexPtr);
- }
- return aIndexPtr;
-}
-
-void PartSet_DocumentDataModel::clearModelIndexes()
-{
- foreach (QModelIndex* aIndex, myIndexes)
- delete aIndex;
- myIndexes.clear();
-}
-
-void PartSet_DocumentDataModel::clearSubModels()
-{
- foreach (PartSet_PartModel* aPart, myPartModels)
- delete aPart;
- myPartModels.clear();
- myActivePartModel = 0;
-}
-
-ObjectPtr PartSet_DocumentDataModel::object(const QModelIndex& theIndex) const
-{
- if (theIndex.internalId() == PartsFolder)
- return ObjectPtr();
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- if (theIndex.internalId() == HistoryNode) {
- int aOffset = historyOffset();
- return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset);
- }
- if (theIndex.internalId() == PartResult) {
- return aRootDoc->object(ModelAPI_ResultPart::group(), theIndex.row());
- }
- QModelIndex* aIndex = toSourceModelIndex(theIndex);
- if (!isSubModel(aIndex->model()))
- return ObjectPtr();
-
- const PartSet_FeaturesModel* aModel = dynamic_cast<const PartSet_FeaturesModel*>(aIndex->model());
- return aModel->object(*aIndex);
-}
-
-bool PartSet_DocumentDataModel::insertRows(int theRow, int theCount, const QModelIndex& theParent)
-{
- beginInsertRows(theParent, theRow, theRow + theCount - 1);
- //endInsertRows();
-
- // Update history
- QModelIndex aRoot;
- int aRow = rowCount(aRoot);
- beginInsertRows(aRoot, aRow, aRow);
- endInsertRows();
-
- return true;
-}
-
-bool PartSet_DocumentDataModel::removeRows(int theRow, int theCount, const QModelIndex& theParent)
-{
- beginRemoveRows(theParent, theRow, theRow + theCount - 1);
- endRemoveRows();
- return true;
-}
-
-void PartSet_DocumentDataModel::removeSubModel(int theModelId)
-{
- PartSet_PartModel* aModel = myPartModels.at(theModelId);
- removeSubModel(aModel);
-}
-
-void PartSet_DocumentDataModel::removeSubModel(PartSet_PartModel* theModel)
-{
- QIntList aToRemove;
- for (int i = 0; i < myIndexes.size(); i++) {
- if (myIndexes.at(i)->model() == theModel)
- aToRemove.append(i);
- }
- int aId;
- while (aToRemove.size() > 0) {
- aId = aToRemove.last();
- delete myIndexes.at(aId);
- myIndexes.removeAt(aId);
- aToRemove.removeLast();
- }
- if (theModel == myActivePartModel)
- myActivePartModel = 0;
- myPartModels.removeAll(theModel);
- delete theModel;
-}
-
-
-bool PartSet_DocumentDataModel::isSubModel(const QAbstractItemModel* theModel) const
-{
- if (theModel == myModel)
- return true;
- return isPartSubModel(theModel);
-}
-
-bool PartSet_DocumentDataModel::isPartSubModel(const QAbstractItemModel* theModel) const
-{
- return myPartModels.contains((PartSet_PartModel*) theModel);
-}
-
-QModelIndex PartSet_DocumentDataModel::partFolderNode(int theColumn) const
-{
- int aPos = myModel->rowCount(QModelIndex());
- return createIndex(aPos, theColumn, PartsFolder);
-}
-
-int PartSet_DocumentDataModel::historyOffset() const
-{
- // Nb of rows of top model + Parts folder
- return myModel->rowCount(QModelIndex()) + 1;
-}
-
-bool PartSet_DocumentDataModel::activatePart(const QModelIndex& theIndex)
-{
- if ((theIndex.internalId() == PartsFolder) || (theIndex.internalId() == HistoryNode))
- return false;
-
- if (theIndex.isValid() && (theIndex.internalId() == PartResult)) {
- myActivePartIndex = theIndex;
- myModel->setItemsColor(PASSIVE_COLOR);
- if (myActivePartModel)
- myActivePartModel->setItemsColor(PASSIVE_COLOR);
-
- // Find activated part feature by its ID
- ResultPartPtr aPartRes = activePart();
- FeaturePtr aFeature = ModelAPI_Feature::feature(aPartRes);
- if (aFeature.get()) {
- myActivePartModel = findPartModel(aFeature);
- myActivePartModel->setItemsColor(ACTIVE_COLOR);
- }
- }
- return true;
-}
-
-ResultPartPtr PartSet_DocumentDataModel::activePart() const
-{
- if (myActivePartIndex.isValid()) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myActivePartIndex.row());
- return std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
- }
- return ResultPartPtr();
-}
-
-QModelIndex PartSet_DocumentDataModel::activePartTree() const
-{
- if (myActivePartModel) {
- return createIndex(myActivePartModel->position() + historyOffset(), 0, HistoryNode);
- }
- return QModelIndex();
-}
-
-void PartSet_DocumentDataModel::deactivatePart()
-{
- if (myActivePartIndex.isValid()) {
- if (myActivePartModel)
- myActivePartModel->setItemsColor(PASSIVE_COLOR);
- myActivePartModel = 0;
- myActivePartIndex = QModelIndex();
- myModel->setItemsColor(ACTIVE_COLOR);
- }
-}
-
-Qt::ItemFlags PartSet_DocumentDataModel::flags(const QModelIndex& theIndex) const
-{
- if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) {
- Qt::ItemFlags aFlags = Qt::ItemIsSelectable;
- if (object(theIndex).get()) {
- aFlags |= Qt::ItemIsEditable;
- }
- // Disable items which are below of last history row
- // Do not disable second column
- if (theIndex.internalId() == HistoryNode) {
- if (theIndex.row() <= lastHistoryRow() || (theIndex.column() == 1))
- aFlags |= Qt::ItemIsEnabled;
- } else
- aFlags |= Qt::ItemIsEnabled;
- return aFlags;
- } else {
- QModelIndex* aIndex = toSourceModelIndex(theIndex);
- const QAbstractItemModel* aModel = aIndex->model();
- Qt::ItemFlags aFlags = aModel->flags(*aIndex);
- if (aModel == myModel) {
- if (myModel->object(*aIndex).get())
- aFlags |= Qt::ItemIsEditable;
- }
- return aFlags;
- }
-}
-
-QModelIndex PartSet_DocumentDataModel::partIndex(const ResultPartPtr& theObject) const
-{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- int aNb = aRootDoc->size(ModelAPI_ResultPart::group());
- for (int aId = 0; aId < aNb; aId++) {
- if (theObject == aRootDoc->object(ModelAPI_ResultPart::group(), aId))
- return createIndex(aId, 0, PartResult);
- }
- return QModelIndex();
-}
-
-QModelIndex PartSet_DocumentDataModel::objectIndex(const ObjectPtr theObject) const
-{
- // Check that this feature belongs to root document
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- DocumentPtr aDoc = theObject->document();
- if (aDoc == aRootDoc) {
- // This feature belongs to histrory or top model
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
- if (aFeature) {
- int aId;
- int aNb = aRootDoc->size(ModelAPI_Feature::group());
- for (aId = 0; aId < aNb; aId++) {
- if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
- break;
- }
- if (aId < aNb)
- return index(aId + historyOffset(), 0, QModelIndex());
- } else {
- QModelIndex aIndex = myModel->objectIndex(theObject);
- return
- aIndex.isValid() ?
- createIndex(aIndex.row(), 0, (void*) getModelIndex(aIndex)) :
- QModelIndex();
- }
- } else {
- PartSet_PartModel* aPartModel = 0;
- foreach(PartSet_PartModel* aModel, myPartModels) {
- if (aModel->hasDocument(aDoc)) {
- aPartModel = aModel;
- break;
- }
- }
- if (aPartModel) {
- QModelIndex aIndex = aPartModel->objectIndex(theObject);
- return aIndex.isValid() ?
- createIndex(aIndex.row(), 0, (void*) getModelIndex(aIndex)) :
- QModelIndex();
- }
- }
- return QModelIndex();
-}
-
-
-void PartSet_DocumentDataModel::clear()
-{
- clearModelIndexes();
- clearSubModels();
- //myActivePart = 0;
- myActivePartIndex = QModelIndex();
- myModel->setItemsColor(ACTIVE_COLOR);
-}
-
-int PartSet_DocumentDataModel::lastHistoryRow() const
-{
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- FeaturePtr aFeature = aRootDoc->currentFeature(true);
- if (aFeature.get())
- return historyOffset() + aRootDoc->index(aFeature);
- else
- return historyOffset() - 1;
-}
-
-void PartSet_DocumentDataModel::setLastHistoryItem(const QModelIndex& theIndex)
-{
- SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aRootDoc = aMgr->moduleDocument();
- std::string aOpName = tr("History change").toStdString();
- if (theIndex.internalId() == HistoryNode) {
- ObjectPtr aObject = object(theIndex);
- aMgr->startOperation(aOpName);
- aRootDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObject), true);
- aMgr->finishOperation();
- } else {
- aMgr->startOperation(aOpName);
- aRootDoc->setCurrentFeature(FeaturePtr(), true);
- aMgr->finishOperation();
- }
-}
-
-QModelIndex PartSet_DocumentDataModel::lastHistoryItem() const
-{
- return index(lastHistoryRow(), 1);
-}
-
-
-QIcon PartSet_DocumentDataModel::featureIcon(const FeaturePtr& theFeature)
-{
- QIcon anIcon;
-
- std::string aKind = theFeature->getKind();
- QString aId(aKind.c_str());
- if (!myIcons.contains(aId))
- return anIcon;
-
- QString anIconString = myIcons[aId];
-
- ModelAPI_ExecState aState = theFeature->data()->execState();
- switch(aState) {
- case ModelAPI_StateDone:
- case ModelAPI_StateNothing: {
- anIcon = QIcon(anIconString);
- }
- break;
- case ModelAPI_StateMustBeUpdated: {
- anIcon = ModuleBase_Tools::lighter(anIconString);
- }
- break;
- case ModelAPI_StateExecFailed: {
- anIcon = ModuleBase_Tools::composite(":icons/exec_state_failed.png", anIconString);
- }
- break;
- case ModelAPI_StateInvalidArgument: {
- anIcon = ModuleBase_Tools::composite(":icons/exec_state_invalid_parameters.png",
- anIconString);
- }
- break;
- default: break;
- }
- return anIcon;
-}
-
-void PartSet_DocumentDataModel::onMouseDoubleClick(const QModelIndex& theIndex)
-{
- if (theIndex.column() != 1)
- return;
- if (flags(theIndex) == 0)
- return;
- QTreeView* aTreeView = dynamic_cast<QTreeView*>(sender());
- if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) {
- if (myActivePartModel)
- // It means that the root document is not active
- return;
- QModelIndex aNewIndex;
- if (theIndex.internalId() == HistoryNode)
- aNewIndex = theIndex;
- int aOldId = lastHistoryRow();
- setLastHistoryItem(theIndex);
- int aStartRow = std::min(aOldId, theIndex.row());
- int aEndRow = std::max(aOldId, theIndex.row());
- for (int i = aStartRow; i <= aEndRow; i++) {
- aTreeView->update(createIndex(i, 0, HistoryNode));
- aTreeView->update(createIndex(i, 1, HistoryNode));
- }
-
- } else {
- QModelIndex* aIndex = toSourceModelIndex(theIndex);
- const QAbstractItemModel* aModel = aIndex->model();
- if (isPartSubModel(aModel)) {
- PartSet_PartDataModel* aPartModel = (PartSet_PartDataModel*)aModel;
- QModelIndex aOldItem = aPartModel->lastHistoryItem();
- aPartModel->setLastHistoryItem(*aIndex);
- QModelIndex aOldIndex = createIndex(aOldItem.row(), aOldItem.column(), (void*) getModelIndex(aOldItem));
- int aStartRow = std::min(aOldItem.row(), aIndex->row());
- int aEndRow = std::max(aOldItem.row(), aIndex->row());
- for (int i = aStartRow; i <= aEndRow; i++) {
- QModelIndex aInd1 = aPartModel->index(i, 0);
- QModelIndex aInd2 = createIndex(i, 0, (void*) getModelIndex(aInd1));
- aTreeView->update(aInd2);
- aInd1 = aPartModel->index(i, 1);
- aInd2 = createIndex(i, 1, (void*) getModelIndex(aInd1));
- aTreeView->update(aInd2);
- }
- }
- }
-}
-
-
-PartSet_PartModel* PartSet_DocumentDataModel::findPartModel(FeaturePtr thePart) const
-{
- foreach (PartSet_PartModel* aModel, myPartModels) {
- if (aModel->part() == thePart)
- return aModel;
- }
- return 0;
-}
-
-PartSet_PartModel* PartSet_DocumentDataModel::findPartModel(int thePosition) const
-{
- foreach (PartSet_PartModel* aModel, myPartModels) {
- if (aModel->position() == thePosition)
- return aModel;
- }
- return 0;
-}
\ No newline at end of file
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#ifndef PartSet_DocumentDataModel_H
-#define PartSet_DocumentDataModel_H
-
-#include "PartSet.h"
-#include <ModuleBase_Definitions.h>
-#include <ModelAPI_ResultPart.h>
-#include <ModelAPI_Feature.h>
-#include <ModuleBase_IDocumentDataModel.h>
-
-#include <Events_Listener.h>
-#include <QList>
-#include <QMap>
-
-class ModelAPI_Document;
-class PartSet_PartModel;
-class PartSet_TopDataModel;
-
-/**\class PartSet_DocumentDataModel
- * \ingroup GUI
- * \brief This is a proxy data model for Object Browser (QTreeView).
- * It contains several sub-models for generation of each sub-part of data tree.
- */
-class PARTSET_EXPORT PartSet_DocumentDataModel : public ModuleBase_IDocumentDataModel, public Events_Listener
-{
-Q_OBJECT
- public:
- /// Constructor
- /// \param theParent a parent object
- PartSet_DocumentDataModel(QObject* theParent);
- virtual ~PartSet_DocumentDataModel();
-
- /// Event Listener method
- /// \param theMessage an event message
- virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
-
- /// Returns the data stored under the given role for the item referred to by the index.
- /// \param theIndex a model index
- /// \param theRole a data role (see Qt::ItemDataRole)
- virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
-
- /// Returns the data for the given role and section in the header with the specified orientation.
- /// \param theSection a section
- /// \param theOrient an orientation
- /// \param theRole a data role (see Qt::ItemDataRole)
- virtual QVariant headerData(int theSection, Qt::Orientation theOrient, int theRole =
- Qt::DisplayRole) const;
-
- /// Returns the number of rows under the given parent. When the parent is valid it means that
- /// rowCount is returning the number of children of parent.
- /// \param theParent a parent model index
- virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const;
-
- /// Returns the number of columns for the children of the given parent.
- /// It has a one column
- /// \param theParent a parent model index
- virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const;
-
- /// Returns the index of the item in the model specified by the given row, column and parent index.
- /// \param theRow a row
- /// \param theColumn a column
- /// \param theParent a parent model index
- virtual QModelIndex index(int theRow, int theColumn, const QModelIndex &theParent =
- QModelIndex()) const;
-
- /// Returns the parent of the model item with the given index.
- /// If the item has no parent, an invalid QModelIndex is returned.
- /// \param theIndex a model index
- virtual QModelIndex parent(const QModelIndex& theIndex) const;
-
- /// Returns true if parent has any children; otherwise returns false.
- /// \param theParent a parent model index
- virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
-
- /// Inserts count rows into the model before the given row.
- /// Items in the new row will be children of the item represented by the parent model index.
- /// \param theRow a start row
- /// \param theCount a nember of rows to insert
- /// \param theParent a parent model index
- bool insertRows(int theRow, int theCount, const QModelIndex& theParent = QModelIndex());
-
- /// Removes count rows starting with the given row under parent parent from the model.
- /// \param theRow a start row
- /// \param theCount a nember of rows to remove
- /// \param theParent a parent model index
- bool removeRows(int theRow, int theCount, const QModelIndex& theParent = QModelIndex());
-
- /// Returns the item flags for the given index.
- /// \param theIndex a model index
- virtual Qt::ItemFlags flags(const QModelIndex& theIndex) const;
-
- //! Returns an object by the given Model index.
- //! Returns 0 if the given index is not index of an object
- virtual ObjectPtr object(const QModelIndex& theIndex) const;
-
- //! Returns index of the object
- //! \param theObject object to find
- virtual QModelIndex objectIndex(const ObjectPtr theObject) const;
-
- //! Returns QModelIndex which corresponds to the given part
- //! If the object is not found then index is not valid
- //! \param thePart a part for analysis
- QModelIndex partIndex(const ResultPartPtr& thePart) const;
-
- //! Activates a part data model if the index is a Part node index.
- //! Returns true if active part changed.
- //! \param theIndex a model index
- bool activatePart(const QModelIndex& theIndex);
-
- //! Retrurns active part
- ResultPartPtr activePart() const;
-
- //! Retrurns QModelIndex of active part
- QModelIndex activePartIndex() const
- {
- return myActivePartIndex;
- }
-
- //! Returns parent index of active part tree (index of Part feature)
- QModelIndex activePartTree() const;
-
- //! Deactivates a Part
- void deactivatePart();
-
- //! Rebuild data tree
- virtual void rebuildDataTree();
-
- //! Clear internal data
- virtual void clear();
-
- //! Set an Index which will be considered as a last history index
- //! \param theIndex a last index for history
- void setLastHistoryItem(const QModelIndex& theIndex);
-
- //! Returns last history item
- QModelIndex lastHistoryItem() const;
-
- //! Returns icon name according to feature
- static QIcon featureIcon(const FeaturePtr& theFeature);
-
- public slots:
- void onMouseDoubleClick(const QModelIndex& theIndex);
-
- private:
-
- enum
- {
- PartsFolder,
- HistoryNode,
- PartResult
- };
-
- //! Converts QModelIndex of this model to QModelIndex of a one of sub-models.
- QModelIndex* toSourceModelIndex(const QModelIndex& theProxy) const;
-
- //! Finds a pointer on QModelIndex which is equal to the given one
- QModelIndex* findModelIndex(const QModelIndex& theIndex) const;
-
- //! Returns pointer on QModelIndex which is equal to the given one.
- QModelIndex* getModelIndex(const QModelIndex& theIndex) const;
-
- //! Deletes all saved pointers on QModelIndex objects.
- void clearModelIndexes();
-
- //! Deletes all saved pointers on QModelIndex objects.
- void clearSubModels();
-
- //! Removes sub-model on removing a part object. Also it removes QModelIndex-es which refer to this model
- void removeSubModel(int theModelId);
-
- //! Removes sub-model on removing a part object. Also it removes QModelIndex-es which refer to this model
- void removeSubModel(PartSet_PartModel* theModel);
-
- //! Returns true if the given model is a one of sub-models (of both types)
- bool isSubModel(const QAbstractItemModel* theModel) const;
-
- //! Returns true if the given model is a one of sub-models of Part type
- bool isPartSubModel(const QAbstractItemModel* theModel) const;
-
- //! Returns Parts Folder node
- //! \param theColumn an Id of column
- QModelIndex partFolderNode(int theColumn) const;
-
- int lastHistoryRow() const;
-
- int historyOffset() const;
-
- PartSet_PartModel* findPartModel(FeaturePtr thePart) const;
-
- PartSet_PartModel* findPartModel(int thePosition) const;
-
- //! Data model of top part of data tree (not parts object)
- PartSet_TopDataModel* myModel;
-
- //! Data models for Parts data tree representation (one data model per a one part)
- QList<PartSet_PartModel*> myPartModels;
-
- //! Active part in part editing mode
- PartSet_PartModel* myActivePartModel;
-
- QModelIndex myActivePartIndex;
-
- //! List of saved QModelIndexes created by sub-models
- QList<QModelIndex*> myIndexes;
-
- static QMap<QString, QString> myIcons;
-};
-
-#endif
/// Returns the state whether the external object is used
bool useExternal() const { return myUseExternal; }
+ /// Checks validity of the given object
+ /// \param theObject an object to check
+ /// \return valid or not valid
bool isValidObject(const ObjectPtr& theObject);
/// Finds or create and external object
public:
/// Constructor
- /// \param theExternal the external state
- /// \param theDefaultValue the default value for the external object using
+ /// \param theParent a parent object
+ /// \param theWorkshop a reference to workshop
PartSet_LockApplyMgr(QObject* theParent,
ModuleBase_IWorkshop* theWorkshop);
virtual ~PartSet_LockApplyMgr() {}
+ /// Activates the object
void activate();
+
+ /// Deactivates the object
void deactivate();
+
+ /// Unlocks validation in operations manager
void valuesChanged();
protected slots:
- // Set lock validating in the operation manager. Set apply is disabled
+ /// Set lock validating in the operation manager. Set apply is disabled
void onLockValidating();
- // Set unlock validating in the operation manager. Call method to update the apply state.
+
+ /// Set unlock validating in the operation manager. Call method to update the apply state.
void onUnlockValidating();
private:
new PartSet_IconFactory();
mySketchMgr = new PartSet_SketcherMgr(this);
-#ifdef ModuleDataModel
- myDataModel = new PartSet_DocumentDataModel(this);
-#endif
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
XGUI_Workshop* aWorkshop = aConnector->workshop();
aOB->treeView()->setExpandsOnDoubleClick(false);
connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)),
SLOT(onTreeViewDoubleClick(const QModelIndex&)));
-#ifdef ModuleDataModel
- connect(aOB, SIGNAL(headerMouseDblClicked(const QModelIndex&)),
- SLOT(onTreeViewDoubleClick(const QModelIndex&)));
- connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)),
- myDataModel, SLOT(onMouseDoubleClick(const QModelIndex&)));
-#endif
}
}
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aActiveDoc = aMgr->activeDocument();
-#ifdef ModuleDataModel
- QModelIndex aOldIndex = myDataModel->activePartTree();
- DocumentPtr aDoc = aMgr->moduleDocument();
- if (aActiveDoc == aDoc) {
- if (aOldIndex.isValid())
- aTreeView->setExpanded(aOldIndex, false);
- myDataModel->deactivatePart();
- aPalet.setColor(QPalette::Text, QColor(0, 72, 140));
- } else {
- std::string aGrpName = ModelAPI_ResultPart::group();
- for (int i = 0; i < aDoc->size(aGrpName); i++) {
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aDoc->object(aGrpName, i));
- if (aPart->partDoc() == aActiveDoc) {
- QModelIndex aIndex = myDataModel->partIndex(aPart);
- if (myDataModel->activatePart(aIndex)) {
- if (aOldIndex.isValid())
- aTreeView->setExpanded(aOldIndex, false);
- aTreeView->setExpanded(myDataModel->activePartTree(), true);
- aPalet.setColor(QPalette::Text, Qt::black);
- }
- break;
- }
- }
- }
-#else
if (aActivePartIndex.isValid())
aTreeView->setExpanded(aActivePartIndex, false);
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
aActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
if (aActivePartIndex.isValid())
aTreeView->setExpanded(aActivePartIndex, true);
-#endif
+
aLabel->setPalette(aPalet);
aWorkshop->updateCommandStatus();
}
if (theIndex.column() != 0) // Use only first column
return;
-#ifdef ModuleDataModel
- ObjectPtr aObj = myDataModel->object(theIndex);
-#else
+
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
XGUI_Workshop* aWorkshop = aConnector->workshop();
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0)
return;
ObjectPtr aObj = aDataModel->object(theIndex);
-#endif
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
if (!aPart.get()) { // Probably this is Feature
#define PartSet_Module_H
#include "PartSet.h"
-#include "PartSet_DocumentDataModel.h"
#include <ModuleBase_IModule.h>
#include <ModuleBase_Definitions.h>
#include <QMap>
#include <QMenu>
#include <QObject>
+#include <QModelIndex>
#include <string>
/// \return true if items are added and there is no necessity to provide standard menu
bool isMouseOverWindow();
+ /// Returns sketch manager object
PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
-#ifdef ModuleDataModel
- /// Returns data model object for representation of data tree in Object browser
- virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; }
-#endif
-
/// Performs functionality on closing document
virtual void closeDocument();
int myVisualLayerId;
bool myHasConstraintShown;
-#ifdef ModuleDataModel
- PartSet_DocumentDataModel* myDataModel;
-#endif
QModelIndex aActivePartIndex;
};
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#include "PartSet_PartDataModel.h"
-#include "PartSet_Module.h"
-#include "PartSet_DocumentDataModel.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Result.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDocRef.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_ResultPart.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultGroup.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_Events.h>
-#include <ModelAPI_Tools.h>
-
-#include <Events_Loop.h>
-
-#include <QIcon>
-#include <QBrush>
-
-
-PartSet_PartDataModel::PartSet_PartDataModel(QObject* theParent)
- : PartSet_PartModel(theParent)
-{
-}
-
-PartSet_PartDataModel::~PartSet_PartDataModel()
-{
-}
-
-QVariant PartSet_PartDataModel::data(const QModelIndex& theIndex, int theRole) const
-{
- DocumentPtr aPartDoc = partDocument();
- if (theIndex.column() == 1) {
- DocumentPtr aActiveDoc = ModelAPI_Session::get()->activeDocument();
- QModelIndex aParent = theIndex.parent();
- if (aActiveDoc == aPartDoc) {
- if (!aParent.isValid()) {
- switch (theRole) {
- case Qt::DecorationRole:
- if (theIndex.row() == lastHistoryRow())
- return QIcon(":pictures/arrow.png");
- }
- }
- }
- return QVariant();
- }
-
- if (theIndex.internalId() >= 0) {
- ObjectPtr aObj = object(theIndex);
- switch (theRole) {
- case Qt::DisplayRole:
- return aObj->data()->name().c_str();
- case Qt::DecorationRole:
- {
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
- if (aFeature)
- return PartSet_DocumentDataModel::featureIcon(aFeature);
- }
- break;
- case Qt::ForegroundRole:
- if (theIndex.internalId() > lastHistoryRow())
- return QBrush(Qt::lightGray);
- return QBrush(myItemsColor);
- }
- }
-
- switch (theRole) {
- case Qt::DisplayRole:
- // return a name
- switch (theIndex.internalId()) {
- //case MyRoot: {
- // DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- // ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
- // if (aObject)
- // return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
- //}
- case ParamsFolder:
- return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
- case ConstructFolder:
- return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
- case BodiesFolder:
- return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
- case GroupsFolder:
- return tr("Groups") + QString(" (%1)").arg(rowCount(theIndex));
- case ParamObject: {
- ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultParameter::group(), theIndex.row());
- if (aObject) {
- ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObject);
- AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
- QString aVal = QString::number(aValueAttribute->value());
- QString aTitle = QString(aObject->data()->name().c_str());
- return aTitle + " = " + aVal;
- }
- }
- break;
- case ConstructObject: {
- ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- if (aObject)
- return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
- }
- break;
- case BodiesObject: {
- ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultBody::group(), theIndex.row());
- if (aObject)
- return aObject->data()->name().c_str();
- }
- break;
- case GroupObject: {
- ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultGroup::group(), theIndex.row());
- if (aObject)
- return aObject->data()->name().c_str();
- }
- case HistoryObject: {
- ObjectPtr aObject = aPartDoc->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
- if (aObject)
- return aObject->data()->name().c_str();
- }
- }
- break;
- case Qt::DecorationRole:
- // return an Icon
- switch (theIndex.internalId()) {
- //case MyRoot:
- // return QIcon(":pictures/part_ico.png");
- case ParamsFolder:
- return QIcon(":pictures/params_folder.png");
- case ConstructFolder:
- case BodiesFolder:
- return QIcon(":pictures/constr_folder.png");
- case GroupsFolder:
- return QIcon(":pictures/constr_folder.png");
- case ConstructObject:
- case GroupObject:
- case BodiesObject: {
- std::string aGroup;
- if (theIndex.internalId() == ConstructObject)
- aGroup = ModelAPI_ResultConstruction::group();
- else if (theIndex.internalId() == BodiesObject)
- aGroup = ModelAPI_ResultBody::group();
- else if (theIndex.internalId() == GroupObject)
- aGroup = ModelAPI_ResultGroup::group();
- if (aGroup.length() > 0) {
- ObjectPtr anObject = aPartDoc->object(aGroup, theIndex.row());
- if (anObject && anObject->data() &&
- anObject->data()->execState() == ModelAPI_StateMustBeUpdated) {
- return QIcon(":pictures/constr_object_modified.png");
- }
- }
- return QIcon(":pictures/constr_object.png");
- }
- case HistoryObject: {
- ObjectPtr aObject = aPartDoc->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
- if (aFeature)
- return PartSet_DocumentDataModel::featureIcon(aFeature);
- }
- }
- break;
- case Qt::ToolTipRole:
- // return Tooltip
- break;
- case Qt::ForegroundRole:
- if (theIndex.internalId() == HistoryObject) {
- if (theIndex.row() > lastHistoryRow())
- return QBrush(Qt::lightGray);
- }
- return QBrush(myItemsColor);
- }
- return QVariant();
-}
-
-QVariant PartSet_PartDataModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- return QVariant();
-}
-
-int PartSet_PartDataModel::rowCount(const QModelIndex& parent) const
-{
- if (!parent.isValid()) {
- DocumentPtr aDoc = partDocument();
- if (aDoc.get()) {
- return getRowsNumber() + aDoc->size(ModelAPI_Feature::group());
- } else
- return 0;
- }
- switch (parent.internalId()) {
- case ParamsFolder:
- return partDocument()->size(ModelAPI_ResultParameter::group());
- case ConstructFolder:
- return partDocument()->size(ModelAPI_ResultConstruction::group());
- case BodiesFolder:
- return partDocument()->size(ModelAPI_ResultBody::group());
- case GroupsFolder:
- return partDocument()->size(ModelAPI_ResultGroup::group());
- case HistoryObject:
- {
- ObjectPtr aObj = object(parent);
- CompositeFeaturePtr aCompFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aObj);
- if (aCompFeature.get()) {
- return aCompFeature->numberOfSubs(true);
- }
- }
- }
- return 0;
-}
-
-int PartSet_PartDataModel::columnCount(const QModelIndex &parent) const
-{
- return 2;
-}
-
-QModelIndex PartSet_PartDataModel::index(int theRow, int theColumn, const QModelIndex &theParent) const
-{
- if (!theParent.isValid()) {
- switch (theRow) {
- case 0:
- return createIndex(theRow, theColumn, (qint32) ParamsFolder);
- case 1:
- return createIndex(theRow, theColumn, (qint32) ConstructFolder);
- case 2:
- return createIndex(theRow, theColumn, (qint32) BodiesFolder);
- case 3:
- {
- int aSize = partDocument()->size(ModelAPI_ResultGroup::group());
- if (aSize > 0)
- return createIndex(theRow, theColumn, (qint32) GroupsFolder);
- else
- return createIndex(theRow, theColumn, (qint32) HistoryObject);
- }
- default:
- return createIndex(theRow, theColumn, (qint32) HistoryObject);
- }
- } else {
- int aId = (int) theParent.internalId();
- switch (aId) {
- case ParamsFolder:
- return createIndex(theRow, theColumn, (qint32) ParamObject);
- case ConstructFolder:
- return createIndex(theRow, theColumn, (qint32) ConstructObject);
- case BodiesFolder:
- return createIndex(theRow, theColumn, (qint32) BodiesObject);
- case GroupsFolder:
- return createIndex(theRow, theColumn, (qint32) GroupObject);
- case HistoryObject:
- {
- return createIndex(theRow, theColumn, (qint32) theParent.row());
- }
- }
- }
- return QModelIndex();
-}
-
-QModelIndex PartSet_PartDataModel::parent(const QModelIndex& theIndex) const
-{
- if (theIndex.internalId() >= 0) {
- int aPRow = theIndex.internalId();
- return createIndex(aPRow, 0, (qint32) HistoryObject);
- }
- switch (theIndex.internalId()) {
- case ParamsFolder:
- case ConstructFolder:
- case BodiesFolder:
- case GroupsFolder:
- case HistoryObject:
- return QModelIndex();
-
- case ParamObject:
- return createIndex(0, 0, (qint32) ParamsFolder);
- case ConstructObject:
- return createIndex(1, 0, (qint32) ConstructFolder);
- case BodiesObject:
- return createIndex(2, 0, (qint32) BodiesFolder);
- case GroupObject:
- return createIndex(3, 0, (qint32) GroupsFolder);
- }
- return QModelIndex();
-}
-
-bool PartSet_PartDataModel::hasChildren(const QModelIndex& theParent) const
-{
- return rowCount(theParent) > 0;
-}
-
-DocumentPtr PartSet_PartDataModel::partDocument() const
-{
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(myPart->firstResult());
- if (aPart.get()) // this may be null is Part feature is disabled
- return aPart->partDoc();
- return DocumentPtr();
-}
-
-ObjectPtr PartSet_PartDataModel::object(const QModelIndex& theIndex) const
-{
- if (theIndex.internalId() >= 0) {
- int aPRow = theIndex.internalId();
- ObjectPtr aObj =
- partDocument()->object(ModelAPI_Feature::group(), aPRow - getRowsNumber());
- CompositeFeaturePtr aCompFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aObj);
- if (aCompFeature.get()) {
- return aCompFeature->subFeature(theIndex.row(), true);
- }
- return ObjectPtr();
- }
- switch (theIndex.internalId()) {
- case ParamsFolder:
- case ConstructFolder:
- case BodiesFolder:
- case GroupsFolder:
- return ObjectPtr();
-
- case ParamObject:
- return partDocument()->object(ModelAPI_ResultParameter::group(), theIndex.row());
- case ConstructObject:
- return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- case BodiesObject:
- return partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row());
- case GroupObject:
- return partDocument()->object(ModelAPI_ResultGroup::group(), theIndex.row());
- case HistoryObject:
- return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
- }
- return ObjectPtr();
-}
-
-bool PartSet_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
-{
- return (partDocument() == theDoc);
-}
-
-QModelIndex PartSet_PartDataModel::findParent(const ObjectPtr& theObject) const
-{
- return findGroup(theObject->groupName().c_str());
-}
-
-QModelIndex PartSet_PartDataModel::findGroup(const std::string& theGroup) const
-{
- if (theGroup == ModelAPI_ResultParameter::group())
- return createIndex(0, 0, (qint32) ParamsFolder);
- if (theGroup == ModelAPI_ResultConstruction::group())
- return createIndex(1, 0, (qint32) ConstructFolder);
- if (theGroup == ModelAPI_ResultBody::group())
- return createIndex(2, 0, (qint32) BodiesFolder);
- if (theGroup == ModelAPI_ResultGroup::group())
- return createIndex(3, 0, (qint32) GroupsFolder);
- return QModelIndex();
-}
-
-QModelIndex PartSet_PartDataModel::objectIndex(const ObjectPtr& theObject) const
-{
- QModelIndex aIndex;
- if (theObject) {
- if (part() == theObject)
- return aIndex;
-
- std::string aGroup = theObject->groupName();
- DocumentPtr aDoc = theObject->document();
- int aNb = aDoc->size(aGroup);
- int aRow = -1;
- for (int i = 0; i < aNb; i++) {
- if (aDoc->object(aGroup, i) == theObject) {
- aRow = i;
- break;
- }
- }
- if (aRow == -1)
- return aIndex;
- if (aGroup == ModelAPI_ResultParameter::group())
- return createIndex(aRow, 0, (qint32) ParamObject);
- else if (aGroup == ModelAPI_ResultConstruction::group())
- return createIndex(aRow, 0, (qint32) ConstructObject);
- else if (aGroup == ModelAPI_ResultBody::group())
- return createIndex(aRow, 0, (qint32) BodiesObject);
- else if (aGroup == ModelAPI_ResultGroup::group())
- return createIndex(aRow, 0, (qint32) GroupObject);
- else
- return createIndex(aRow + getRowsNumber(), 0, (qint32) HistoryObject);
- }
- return aIndex;
-}
-
-
-int PartSet_PartDataModel::getRowsNumber() const
-{
- int aSize = partDocument()->size(ModelAPI_ResultGroup::group());
- if (aSize == 0) // If there are no groups then do not show group folder
- return 3;
- return 4;
-}
-
-int PartSet_PartDataModel::lastHistoryRow() const
-{
- DocumentPtr aDoc = partDocument();
- FeaturePtr aFeature = aDoc->currentFeature(true);
- if (aFeature.get())
- return getRowsNumber() + aDoc->index(aFeature);
- else
- return getRowsNumber() - 1;
-}
-
-void PartSet_PartDataModel::setLastHistoryItem(const QModelIndex& theIndex)
-{
- SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aDoc = partDocument();
- std::string aOpName = tr("History change").toStdString();
- if (theIndex.internalId() == HistoryObject) {
- ObjectPtr aObject = object(theIndex);
- aMgr->startOperation(aOpName);
- aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObject), true);
- aMgr->finishOperation();
- } else {
- aMgr->startOperation(aOpName);
- aDoc->setCurrentFeature(FeaturePtr(), true);
- aMgr->finishOperation();
- }
-}
-
-QModelIndex PartSet_PartDataModel::lastHistoryItem() const
-{
- return index(lastHistoryRow(), 1);
-}
-
-Qt::ItemFlags PartSet_PartDataModel::flags(const QModelIndex& theIndex) const
-{
- // Disable sub-features at column 1
- if ((theIndex.column() == 1) && (theIndex.internalId() >= 0))
- return 0;
-
- Qt::ItemFlags aFlags = Qt::ItemIsSelectable;
- if (object(theIndex)) {
- aFlags |= Qt::ItemIsEditable;
- }
-
- if (theIndex.internalId() == HistoryObject) {
- if (theIndex.row() <= lastHistoryRow() || (theIndex.column() == 1))
- aFlags |= Qt::ItemIsEnabled;
- } else
- aFlags |= Qt::ItemIsEnabled;
- return aFlags;
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#ifndef PartSet_PartDataModel_H
-#define PartSet_PartDataModel_H
-
-#include "PartSet.h"
-#include "PartSet_DataTreeModel.h"
-
-
-/**\class PartSet_PartDataModel
- * \ingroup GUI
- * \brief This is a data model for Object Browser (QTreeView).
- * It represents data tree only of a one part
- */
-class PartSet_PartDataModel : public PartSet_PartModel
-{
-Q_OBJECT
- public:
- /// Constructor
- /// \param theParent a parent object
- PartSet_PartDataModel(QObject* theParent);
- virtual ~PartSet_PartDataModel();
-
- // Reimpl from QAbstractItemModel
-
- /// Returns the data stored under the given role for the item referred to by the index.
- /// \param theIndex a model index
- /// \param theRole a data role (see Qt::ItemDataRole)
- virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
-
- /// Returns the data for the given role and section in the header with the specified orientation.
- /// \param theSection a section
- /// \param theOrient an orientation
- /// \param theRole a data role (see Qt::ItemDataRole)
- virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
- int theRole = Qt::DisplayRole) const;
-
- /// Returns the number of rows under the given parent. When the parent is valid it means that
- /// rowCount is returning the number of children of parent.
- /// \param theParent a parent model index
- virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const;
-
- /// Returns the number of columns for the children of the given parent.
- /// It has a one column
- /// \param theParent a parent model index
- virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const;
-
- /// Returns the item flags for the given index.
- /// \param theIndex a model index
- virtual Qt::ItemFlags flags(const QModelIndex& theIndex) const;
-
- /// Returns the index of the item in the model specified by the given row, column and parent index.
- /// \param theRow a row
- /// \param theColumn a column
- /// \param theParent a parent model index
- virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
- QModelIndex()) const;
-
- /// Returns the parent of the model item with the given index.
- /// If the item has no parent, an invalid QModelIndex is returned.
- /// \param theIndex a model index
- virtual QModelIndex parent(const QModelIndex& theIndex) const;
-
- /// Returns true if parent has any children; otherwise returns false.
- /// \param theParent a parent model index
- virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
-
- //! Returns object by the given Model index.
- //! Returns 0 if the given index is not index of a object
- virtual ObjectPtr object(const QModelIndex& theIndex) const;
-
- //! Returns QModelIndex which corresponds to the given object
- //! If the object is not found then index is not valid
- virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
-
- //! Returns true if the given document is a sub-document of this tree
- virtual bool hasDocument(const DocumentPtr& theDoc) const;
-
- //! Returns parent index of the given object
- virtual QModelIndex findParent(const ObjectPtr& theObject) const;
-
- //! Returns index corresponded to the group
- virtual QModelIndex findGroup(const std::string& theGroup) const;
-
- //! Set an Index which will be considered as a last history index
- //! \param theIndex a last index for history
- void setLastHistoryItem(const QModelIndex& theIndex);
-
- //! Returns last history item
- QModelIndex lastHistoryItem() const;
-
- private:
-
- //! Returns document of the current part
- DocumentPtr partDocument() const;
-
- //! Returns defult number of rows
- int getRowsNumber() const;
-
- int lastHistoryRow() const;
-
- //! Types of QModelIndexes
- //! All types have negative Id's. Positive Id means sub-feature and contains row of its parent
- enum DataIds
- {
- //MyRoot,
- ParamsFolder = -100,
- ParamObject,
- ConstructFolder,
- ConstructObject,
- BodiesFolder,
- BodiesObject,
- GroupsFolder,
- GroupObject,
- HistoryObject
- };
-};
-
-#endif
/// Saves the current selection in the viewer into an internal container
/// It obtains the selected attributes. The highlighted objects can be processes as the selected ones
- /// \param theHighlightedUse a boolean flag
+ /// \param theHighlightedOnly a boolean flag
void storeSelection(const bool theHighlightedOnly = false);
/// Restores previously saved selection state
/// Returns pointer to the root document.
static std::shared_ptr<ModelAPI_Document> document();
- /// Find an attribute which corresponds to a given pont coordinates
- /// \param theSketch the sketch feature
- /// \param theX X coordinate
- /// \param theY Y coordinate
- /// \param theTolerance tolerance
- /// \param theIgnore list of features which has to be ignored
- //static std::shared_ptr<GeomDataAPI_Point2D> findAttributePoint(CompositeFeaturePtr theSketch,
- // double theX, double theY, double theTolerance, const QList<FeaturePtr>& theIgnore = QList<FeaturePtr>());
-
- /// Returns a point attribute of the feature by the coordinates if it is
- /// \param theFeature the feature
- /// \param theX the horizontal coordinate
- /// \param theY the vertical coordinate
- //static std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(FeaturePtr theFeature,
- // double theX, double theY);
-
/// \brief Save the double to the feature. If the attribute is double, it is filled.
/// \param theFeature the feature
/// \param theX the horizontal coordinate
/**
* Finds an attribute value in attribute reference attribute value
* \param theAttribute - an attribure reference filled with an attribute
+ * \param theWorkshop a reference to workshop
* \return a geometry shape
*/
static GeomShapePtr findShapeBy2DPoint(const AttributePtr& theAttribute,
ModuleBase_IWorkshop* theWorkshop);
- /* Returns point of coincidence feature
+ /**
+ * Returns point of coincidence feature
* \param theFeature the coincidence feature
* \param theAttribute the attribute name
*/
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-#include "PartSet_TopDataModel.h"
-#include "PartSet_Module.h"
-#include "PartSet_DocumentDataModel.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Result.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDocRef.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_ResultPart.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultGroup.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_Events.h>
-
-#include <Events_Loop.h>
-
-#include <QIcon>
-#include <QBrush>
-
-
-PartSet_TopDataModel::PartSet_TopDataModel(QObject* theParent)
- : PartSet_FeaturesModel(theParent)
-{
-}
-
-PartSet_TopDataModel::~PartSet_TopDataModel()
-{
-}
-
-QVariant PartSet_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
-{
- if (theIndex.column() == 1)
- return QVariant();
-
- switch (theRole) {
- case Qt::DisplayRole:
- // return a name
- switch (theIndex.internalId()) {
- case ParamsFolder:
- return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex));
- case ParamObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row());
- if (aObject) {
- ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObject);
- AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
- QString aVal = QString::number(aValueAttribute->value());
- QString aTitle = QString(aObject->data()->name().c_str());
- return aTitle + " = " + aVal;
- }
- }
- break;
- case ConstructFolder:
- return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex));
- case ConstructObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(),
- theIndex.row());
- if (aObject)
- return aObject->data()->name().c_str();
- }
- break;
- //case GroupsFolder:
- // return tr("Groups") + QString(" (%1)").arg(rowCount(theIndex));
- //case GroupObject: {
- // DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- // ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultGroup::group(),
- // theIndex.row());
- // if (aObject)
- // return aObject->data()->name().c_str();
- //}
- // break;
- }
- break;
-
- case Qt::DecorationRole:
- {
- // return an Icon
- switch (theIndex.internalId()) {
- case ParamsFolder:
- return QIcon(":pictures/params_folder.png");
- case ConstructFolder:
- return QIcon(":pictures/constr_folder.png");
- case ConstructObject:
- return QIcon(":pictures/constr_object.png");
- //case GroupsFolder:
- // return QIcon(":pictures/constr_folder.png");
- }
- }
- break;
-
- case Qt::ToolTipRole:
- // return Tooltip
- break;
- case Qt::ForegroundRole:
- return QBrush(myItemsColor);
- break;
- }
- return QVariant();
-}
-
-QVariant PartSet_TopDataModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- return QVariant();
-}
-
-int PartSet_TopDataModel::rowCount(const QModelIndex& theParent) const
-{
- if (!theParent.isValid())
- return 2; // In case of groups using it has to be +1
-
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- if (theParent.internalId() == ParamsFolder)
- return aRootDoc->size(ModelAPI_ResultParameter::group());
-
- if (theParent.internalId() == ConstructFolder)
- return aRootDoc->size(ModelAPI_ResultConstruction::group());
-
- //if (theParent.internalId() == GroupsFolder)
- // return aRootDoc->size(ModelAPI_ResultGroup::group());
-
- return 0;
-}
-
-int PartSet_TopDataModel::columnCount(const QModelIndex &parent) const
-{
- return 1;
-}
-
-QModelIndex PartSet_TopDataModel::index(int theRow, int theColumn, const QModelIndex& theParent) const
-{
- if (!theParent.isValid()) {
- switch (theRow) {
- case 0:
- return createIndex(theRow, theColumn, (qint32) ParamsFolder);
- case 1:
- return createIndex(theRow, theColumn, (qint32) ConstructFolder);
- //case 2:
- // return createIndex(theRow, theColumn, (qint32) GroupsFolder);
- }
- } else {
- if (theParent.internalId() == ParamsFolder)
- return createIndex(theRow, theColumn, (qint32) ParamObject);
-
- if (theParent.internalId() == ConstructFolder)
- return createIndex(theRow, theColumn, (qint32) ConstructObject);
-
- //if (theParent.internalId() == GroupsFolder)
- // return createIndex(theRow, theColumn, (qint32) GroupObject);
- }
- return QModelIndex();
-}
-
-QModelIndex PartSet_TopDataModel::parent(const QModelIndex& theIndex) const
-{
- int aId = (int) theIndex.internalId();
- switch (aId) {
- case ParamsFolder:
- case ConstructFolder:
- //case GroupsFolder:
- return QModelIndex();
- case ParamObject:
- return createIndex(0, 0, (qint32) ParamsFolder);
- case ConstructObject:
- return createIndex(1, 0, (qint32) ConstructFolder);
- //case GroupObject:
- // return createIndex(2, 0, (qint32) GroupsFolder);
- }
- return QModelIndex();
-}
-
-bool PartSet_TopDataModel::hasChildren(const QModelIndex& theParent) const
-{
- return rowCount(theParent) > 0;
-}
-
-ObjectPtr PartSet_TopDataModel::object(const QModelIndex& theIndex) const
-{
- switch (theIndex.internalId()) {
- case ParamsFolder:
- case ConstructFolder:
- return ObjectPtr();
- case ParamObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- return aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row());
- }
- case ConstructObject: {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- }
- //case GroupObject: {
- // DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- // return aRootDoc->object(ModelAPI_ResultGroup::group(), theIndex.row());
- //}
- }
- return ObjectPtr();
-}
-
-QModelIndex PartSet_TopDataModel::findParent(const ObjectPtr& theObject) const
-{
- return findGroup(theObject->groupName().c_str());
-}
-
-QModelIndex PartSet_TopDataModel::findGroup(const std::string& theGroup) const
-{
- if (theGroup == ModelAPI_ResultParameter::group())
- return createIndex(0, 0, (qint32) ParamsFolder);
- if (theGroup == ModelAPI_ResultConstruction::group())
- return createIndex(1, 0, (qint32) ConstructFolder);
- //if (theGroup == ModelAPI_ResultGroup::group())
- // return createIndex(2, 0, (qint32) ConstructFolder);
- return QModelIndex();
-}
-
-QModelIndex PartSet_TopDataModel::objectIndex(const ObjectPtr& theObject) const
-{
- QModelIndex aIndex;
- if (theObject) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- std::string aGroup = theObject->groupName();
- int aNb = aRootDoc->size(aGroup);
- int aRow = -1;
- for (int i = 0; i < aNb; i++) {
- if (aRootDoc->object(aGroup, i) == theObject) {
- aRow = i;
- break;
- }
- }
- if (aRow != -1) {
- if (aGroup == ModelAPI_ResultParameter::group())
- return createIndex(aRow, 0, (qint32) ParamObject);
- if (aGroup == ModelAPI_ResultConstruction::group())
- return createIndex(aRow, 0, (qint32) ConstructObject);
- //if (aGroup == ModelAPI_ResultGroup::group())
- // return createIndex(aRow, 0, (qint32) GroupObject);
- }
- }
- return aIndex;
-}
-
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-#ifndef PartSet_TopDataModel_H
-#define PartSet_TopDataModel_H
-
-#include "PartSet.h"
-#include "PartSet_DataTreeModel.h"
-
-/**\class PartSet_TopDataModel
- * \ingroup GUI
- * \brief This is a data model for Object Browser (QTreeView).
- * It represents only upper part of data tree (non-parts tree items)
- */
-class PARTSET_EXPORT PartSet_TopDataModel : public PartSet_FeaturesModel
-{
-Q_OBJECT
- public:
- /// Constructor
- /// \param theParent a parent object
- PartSet_TopDataModel(QObject* theParent);
- virtual ~PartSet_TopDataModel();
-
- // Reimpl from QAbstractItemModel
-
- /// Returns the data stored under the given role for the item referred to by the index.
- /// \param theIndex a model index
- /// \param theRole a data role (see Qt::ItemDataRole)
- virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
-
- /// Returns the data for the given role and section in the header with the specified orientation.
- /// \param theSection a section
- /// \param theOrient an orientation
- /// \param theRole a data role (see Qt::ItemDataRole)
- virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
- int theRole = Qt::DisplayRole) const;
-
- /// Returns the number of rows under the given parent. When the parent is valid it means that
- /// rowCount is returning the number of children of parent.
- /// \param theParent a parent model index
- virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const;
-
- /// Returns the number of columns for the children of the given parent.
- /// It has a one column
- /// \param theParent a parent model index
- virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const;
-
-
- /// Returns the index of the item in the model specified by the given row, column and parent index.
- /// \param theRow a row
- /// \param theColumn a column
- /// \param theParent a parent model index
- virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
- QModelIndex()) const;
-
- /// Returns the parent of the model item with the given index.
- /// If the item has no parent, an invalid QModelIndex is returned.
- /// \param theIndex a model index
- virtual QModelIndex parent(const QModelIndex& theIndex) const;
-
- /// Returns true if parent has any children; otherwise returns false.
- /// \param theParent a parent model index
- virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
-
- //! Returns object by the given Model index.
- //! Returns 0 if the given index is not index of a object
- virtual ObjectPtr object(const QModelIndex& theIndex) const;
-
- //! Returns QModelIndex which corresponds to the given object
- //! If the object is not found then index is not valid
- virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
-
- //! Returns parent index of the given object
- virtual QModelIndex findParent(const ObjectPtr& theObject) const;
-
- //! Returns index corresponded to the group
- virtual QModelIndex findGroup(const std::string& theGroup) const;
-
- private:
- //! Types of QModelIndexes
- enum DataIds
- {
- ParamsFolder,
- ParamObject,
- ConstructFolder,
- ConstructObject
- //GroupsFolder,
- //GroupObject
- };
-
-};
-
-#endif
\ No newline at end of file
//! Returns true if the attribute is good for the feature attribute
//! \param theAttribute an attribute
//! \param theArguments a list of arguments (names of attributes to check)
+ //! \param theError an output error string
virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;
//! Returns true if the attribute is good for the feature attribute
//! \param theAttribute an attribute
//! \param theArguments a list of arguments (names of attributes to check)
+ //! \param theError an output error string
virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;
//! returns true if attribute is valid
//! \param theAttribute the checked attribute
//! \param theArguments arguments of the attribute
+ //! \param theError an output error string
virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;
protected:
/// Checks the widget validity. By default, it returns true.
- /// \param theValue a selected presentation in the view
+ /// \param thePrs a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
GeomShapePtr& theShape);
protected:
+ /// Manager of external objects
PartSet_ExternalObjectsMgr* myExternalObjectMgr;
+
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
};
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped widget values
+ /// \param theToValidate a validation flag
virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
const bool theToValidate);
/// Returns true if the feature contains Point2D attribute with the same coordinates
/// The attribute of the widget is not processed.
+ /// \param theFeature a feature
/// \param theX the X coordinate
/// \param theY the Y coordinate
/// \return boolean result
void onValuesChanged();
protected:
+ /// A reference to workshop
ModuleBase_IWorkshop* myWorkshop;
- PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
+
+ /// A manager to lock/unlock Apply button in PP
+ PartSet_LockApplyMgr* myLockApplyMgr;
+ /// A name of the first point
std::string myFirstPntName;
+
+ /// Reference to sketch
CompositeFeaturePtr mySketch;
};
protected:
/// Checks the widget validity. By default, it returns true.
- /// \param theValue a selected presentation in the view
+ /// \param thePrs a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
void setPointAttribute(ObjectPtr theSelectedObject, GeomShapePtr theShape);
protected:
+ /// A reference to external objects manager
PartSet_ExternalObjectsMgr* myExternalObjectMgr;
+
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
};
public:
/// Constructor
/// \param theParent the parent object
+ /// \param theModule a reference to a module object
/// \param theData the widget configuation. The attribute of the model widget is obtained from
/// \param theParentId is Id of a parent of the current attribute
PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule,
public:
/// Constructor
/// \param theParent the parent object
+ /// \param theWorkshop a reference to workshop
/// \param theData the widget configuation. The attribute of the model widget is obtained from
/// \param theParentId is Id of a parent of the current attribute
+ /// \param toShowConstraints a current show constraints state
PartSet_WidgetSketchLabel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const std::string& theParentId, bool toShowConstraints);
/// The method is called by the current operation to process the operation preselection.
/// It is redefined to do nothing if the plane of the sketch has been already set.
/// \param theValues the wrapped selection values
+ /// \param theToValidate a validation flag
virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
const bool theToValidate);
virtual void setHighlighted(bool) { /*do nothing*/ };
virtual void enableFocusProcessing();
+ /// Set show constraints state
+ /// \param theOn a flag show constraints or not
void showConstraints(bool theOn);
signals:
/// Signal on plane selection
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+ /// A show constraint toggled signal
void showConstraintToggled(bool);
protected:
virtual void restoreAttributeValue(const bool theValid);
/// Fills the attribute with the value of the selected owner
- /// \param theOwner a selected owner
+ /// \param thePrs a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
/// Saves the internal parameters to the given feature
/// Connect to viewer from workshop. Has to called at creation of viewer.
void connectViewer();
+ /// Add menu items for Object browser pop-up
void addObjBrowserMenu(QMenu*) const;
+
+ /// Add menu items for Viewer pop-up
void addViewerMenu(QMenu*) const;
/// Returns a list of object group names of the action
virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
+ /// Returns color of a result object
+ /// \param theResult a result object
+ /// \param theColor a color in form of RGB vector
static void getResultColor(ResultPtr theResult, std::vector<int>& theColor);
};
// Constructor *************************************************
-XGUI_DataModel::XGUI_DataModel(QObject* theParent) : ModuleBase_IDocumentDataModel(theParent)
+XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent)
{
myXMLReader.readAll();
#include <ModelAPI_Object.h>
#include <ModelAPI_Document.h>
#include <Config_DataModelReader.h>
-#include <ModuleBase_IDocumentDataModel.h>
#include <Events_Listener.h>
+#include <QAbstractItemModel>
/**\class XGUI_DataModel
* \ingroup GUI
* - An index which contains internal pointer as ModelAPI_Object its the object
* - An index which contains internal pointer as ModelAPI_Document is a folder which belongs to this document
*/
-class XGUI_EXPORT XGUI_DataModel : public ModuleBase_IDocumentDataModel, public Events_Listener
+class XGUI_EXPORT XGUI_DataModel : public QAbstractItemModel, public Events_Listener
{
Q_OBJECT
public:
+ /// Constructor
+ /// \param theParent a parent object
XGUI_DataModel(QObject* theParent);
/// Event Listener method
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
void closeLocalContexts(const bool theUpdateViewer = true);
- // Remove default selection filters of the module from the current viewer
+ /// Remove default selection filters of the module from the current viewer
void deactivateSelectionFilters();
/// \brief Add selection filter
void updateViewer() const;
/// Activate interactive context
- /// \param theIO
- /// \param theMode
+ /// \param theIO an interactive object
+ /// \param theMode activation mode
+ /// \param theUpdateViewer update viewer flag
void activateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode,
const bool theUpdateViewer) const;
/// Activate interactive context. It is necessary to call ClearOutdatedSelection after deactivation
+ /// \param theIO an interactive object
+ /// \param theMode a mode to deactivate. When theMode=-1 then all modes will be deactivated
void deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode = -1) const;
/// Searches the interactive object by feature
/// Activates in local context displayed outside of the context.
/// \param theModes - modes on which it has to be activated (can be empty)
/// \param theObjList - list of objects which has to be activated.
+ /// \param theUpdateViewer an update viewer flag
void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
const bool theUpdateViewer = true);
class QDialog;
class QLabel;
+/**
+ * \class XGUI_ErrorMgr
+ * \ingroup GUI
+ * \brief Class of Errors manager object
+ */
class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr
{
Q_OBJECT
public:
+ /// Constructor
+ /// \param theParent a parent object
+ /// \param theWorkshop a workshop object
XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
/// Virtual destructor
virtual ~XGUI_ErrorMgr();
+ /// Update actions for the given feature
+ /// \param theFeature a feature
void updateActions(const FeaturePtr& theFeature);
/// Update enable state of AcceptAll action if the feature uses it
virtual ModuleBase_Operation* findStartedOperation(const QString& theId);
//! Returns true if the operation with id theId can be stopped. The operation manager is called.
- //! \param theId a stopped operation
+ //! \param theOperation a stopped operation
//! \return boolean result
virtual bool canStopOperation(ModuleBase_Operation* theOperation);
//! Aborts the operation. The operation manager is called.
- //! \param theId an aborted operation
+ //! \param theOperation an aborted operation
void abortOperation(ModuleBase_Operation* theOperation);
//! Returns AIS object by data object
#include <ModelAPI_Tools.h>
#include <ModuleBase_Tools.h>
-#include <ModuleBase_IDocumentDataModel.h>
#include <QLayout>
#include <QLabel>
{
QLineEdit* aEditor = dynamic_cast<QLineEdit*>(editor);
if (aEditor) {
- ModuleBase_IDocumentDataModel* aModel = myTreedView->dataModel();
+ XGUI_DataModel* aModel = myTreedView->dataModel();
ObjectPtr aObj = aModel->object(index);
if (aObj.get() != NULL) {
aEditor->setText(aObj->data()->name().c_str());
setItemDelegateForColumn(0, new XGUI_TreeViewItemDelegate(this));
-#ifndef ModuleDataModel
connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
SLOT(onDoubleClick(const QModelIndex&)));
-#endif
}
XGUI_DataTree::~XGUI_DataTree()
{
}
-ModuleBase_IDocumentDataModel* XGUI_DataTree::dataModel() const
+XGUI_DataModel* XGUI_DataTree::dataModel() const
{
- return static_cast<ModuleBase_IDocumentDataModel*>(model());
+ return static_cast<XGUI_DataModel*>(model());
}
void XGUI_DataTree::contextMenuEvent(QContextMenuEvent* theEvent)
if (aEditor) {
QString aName = aEditor->text();
QModelIndexList aIndexList = selectionModel()->selectedIndexes();
- ModuleBase_IDocumentDataModel* aModel = dataModel();
+ XGUI_DataModel* aModel = dataModel();
ObjectPtr aObj = aModel->object(aIndexList.first());
SessionPtr aMgr = ModelAPI_Session::get();
aMgr->startOperation("Rename");
void XGUI_DataTree::clear()
{
- ModuleBase_IDocumentDataModel* aModel = dataModel();
- aModel->clear();
+ dataModel()->clear();
reset();
}
// When operation is opened then we can not change history
if (aMgr->isOperation())
return;
- ModuleBase_IDocumentDataModel* aModel = dataModel();
+ XGUI_DataModel* aModel = dataModel();
if (aModel->flags(theIndex) == 0)
return;
ObjectPtr aObj = aModel->object(theIndex);
aLabelWgt->setFrameShape(myTreeView->frameShape());
aLabelWgt->setFrameShadow(myTreeView->frameShadow());
-#ifndef ModuleDataModel
myDocModel = new XGUI_DataModel(this);
myTreeView->setModel(myDocModel);
QItemSelectionModel* aSelMod = myTreeView->selectionModel();
connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
-#endif
connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this,
SLOT(onLabelContextMenuRequested(const QPoint&)));
myTreeView->clear();
}
-#ifdef ModuleDataModel
-void XGUI_ObjectsBrowser::setDataModel(ModuleBase_IDocumentDataModel* theModel)
-{
- myDocModel = theModel;
- //myDocModel = new XGUI_DataModel(this);
- myTreeView->setModel(myDocModel);
- QItemSelectionModel* aSelMod = myTreeView->selectionModel();
- connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
-}
-#endif
-
void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
const QItemSelection& theDeselected)
{
{
QObjectPtrList aList;
QModelIndexList aIndexes = selectedIndexes();
-#ifdef ModuleDataModel
- ModuleBase_IDocumentDataModel* aModel = dataModel();
-#else
XGUI_DataModel* aModel = dataModel();
-#endif
QModelIndexList::const_iterator aIt;
for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
if ((*aIt).column() == 0) {
class QLineEdit;
class XGUI_DataModel;
-//#define ModuleDataModel
-
/**
* \ingroup GUI
* Implementation of Data Tree object for Object Browser
virtual ~XGUI_DataTree();
/// Returns current data model
- ModuleBase_IDocumentDataModel* dataModel() const;
+ XGUI_DataModel* dataModel() const;
signals:
//! Emited on context menu request
/// Commit modified data (used for renaming of objects)
virtual void commitData(QWidget* theEditor);
+ /// A slot which is called on mouse double click
void onDoubleClick(const QModelIndex&);
protected:
virtual ~XGUI_ObjectsBrowser();
//! Returns Model which provides access to data objects
-#ifdef ModuleDataModel
- ModuleBase_IDocumentDataModel* dataModel() const
- {
- return myDocModel;
- }
-#else
XGUI_DataModel* dataModel() const
{
return myDocModel;
}
-#endif
//! Returns list of currently selected objects
//! \param theIndexes - output list of corresponded indexes (can be NULL)
/// Resets the object browser into initial state
void clearContent();
- /// Set Data Model for the Object Browser
-#ifdef ModuleDataModel
- void setDataModel(ModuleBase_IDocumentDataModel* theModel);
-#endif
-
public slots:
//! Called on Edit command request
void onEditItem();
void closeDocNameEditing(bool toSave);
//! Internal model
-#ifdef ModuleDataModel
- ModuleBase_IDocumentDataModel* myDocModel;
-#else
XGUI_DataModel* myDocModel;
-#endif
QLineEdit* myActiveDocLbl;
XGUI_DataTree* myTreeView;
};
public:
/// Constructor
/// \param theParent the parent
+ /// \param theWorkshop a reference to workshop
XGUI_OperationMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
+
/// Destructor
virtual ~XGUI_OperationMgr();
+ /// Set reference to workshop
+ /// \param theWorkshop reference to workshop
void setWorkshop(ModuleBase_IWorkshop* theWorkshop)
{ myWorkshop = theWorkshop; };
/// Emitted when current operation is aborted
void operationAborted(ModuleBase_Operation* theOperation);
- /// Signal is emitted after the apply enable state changed.
- //void validationStateChanged(bool);
-
- /// Signal is emitted after the model is modified. It is emitted for all active operations.
- /// \param theFeatureKind a feature id
- /// \param theState validity of the operation with the feature kind
- //void nestedStateChanged(const std::string& theFeatureKind, const bool theState);
-
/// Signal is emitted after the current operation is filled with existing preselection.
void operationActivatedByPreselection();
virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
protected:
+ /// A header widget
QWidget* myHeaderWidget;
private:
//! Creates a feature (command) in SALOME desktop
//! \param theWBName - name of toolbar (workbench)
//! \param theInfo - information about action (icon, text, etc)
+ //! \param theNestedActions a list of nested actions
virtual QAction* addFeatureOfNested(const QString& theWBName,
const ActionInfo& theInfo,
const QList<QAction*>& theNestedActions) = 0;
//! Returns true if the feature action is a nested action, in other words,
//! it is created by addFeatureOfNested().
- //! \param theId - an action of a feature
+ //! \param theAction - an action of a feature
//! returns boolean result
virtual bool isFeatureOfNested(const QAction* theAction) = 0;
virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
const int theMenuPosition = 10) = 0;
+ /// Add an action into tool bar
+ /// \param theAction the Action object
+ /// \param theToolBarTitle the toolbar name
virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) = 0;
//! Returns desktop window of SALOME
*/
QString XGUI_EXPORT addSlash(const QString& path);
-/// The model concerning tools
+// The model concerning tools
/*!
Returns true if the feature is a model object
all objects in the list are not PartSet document.
It shows the warning control if the result is false.
\param theParent a parent for the warning control
- \param theList a list of object
+ \param aList a list of object
\return a boolean value
*/
bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const QObjectPtrList& aList);
/*!
- Returns true if theObject can be renamed in theName
+ Check possibility to rename object
+ \param theParent a parent widget
+ \param theObject an object to rename
+ \param theName a name
*/
bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName);
/*!
Returns true if there are no parts in the document, which are not activated
+ \param theNotActivatedNames out string which contains not activated names
\return a boolean value
*/
bool XGUI_EXPORT allDocumentsActivated(QString& theNotActivatedNames);
which has the object as a sub object.
\param theSourceObject an object, which references are searched
\param theObject an intermediate recursive object, should be set in the source object
+ \param theDirectRefFeatures direct references
+ \param theIndirectRefFeatures indirect references
\param theAlreadyProcessed set of processed elements, used for optimization (do not reanalyse processed)
\return a boolean value
*/
aObjDock->setStyleSheet(
"::title { position: relative; padding-left: 5px; text-align: left center }");
myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
-#ifdef ModuleDataModel
- myObjectBrowser->setDataModel(myModule->dataModel());
-#endif
myModule->customizeObjectBrowser(myObjectBrowser);
aObjDock->setWidget(myObjectBrowser);
//! Starting of the application
void startApplication();
- // Activates the module controls. Should be called after module creation
+ /// Activates the module controls. Should be called after module creation
void activateModule();
- // Deactivates the module controls. Should be called after module creation
+ /// Deactivates the module controls. Should be called after module creation
void deactivateModule();
//! Returns main window (Desktop) of the application
{
Q_OBJECT
public:
- /// Constructor
- /// \param theConnector a Salome connector object.
- /// Used only if the workshop is launched in Salome environment
+ /// Constructor. Used only if the workshop is launched in Salome environment
+ /// \param theWorkshop a reference to workshop.
XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop);
virtual ~XGUI_WorkshopListener();
/// Emitted when error in applivation happens
void errorOccurred(const QString&);
-protected slots:
- /// Updates Apply All button state of the feature to the state if the feature has the button
- /// \param theFeatureId an index of the feature, the action is searched, which state is to be changed
- /// \param theState an action enable state
- //void onNestedStateChanged(const std::string& theFeatureId, const bool theState);
-
protected:
/// Procedure to process postponed events
bool event(QEvent * theEvent);