--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+
+// =======================================================================
+// function : ReadShape
+// purpose :
+// =======================================================================
+TopoDS_Shape Convert_Tools::ReadShape (const TCollection_AsciiString& theFileName)
+{
+ TopoDS_Shape aShape;
+
+ BRep_Builder aBuilder;
+ BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
+ return aShape;
+}
+
+//=======================================================================
+//function : ConvertStreamToPresentations
+//purpose :
+//=======================================================================
+void Convert_Tools::ConvertStreamToPresentations (const Standard_SStream&,
+ const Standard_Integer,
+ const Standard_Integer,
+ NCollection_List<Handle(Standard_Transient)>&)
+{
+}
+
+//=======================================================================
+//function : ConvertStreamToColor
+//purpose :
+//=======================================================================
+Standard_Boolean Convert_Tools::ConvertStreamToColor (const Standard_SStream&,
+ Quantity_Color&)
+{
+ return Standard_False;
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef Convert_Tools_H
+#define Convert_Tools_H
+
+#include <NCollection_List.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_SStream.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_Shape.hxx>
+
+//! \class Convert_Tools
+//! \brief The tool that gives auxiliary methods converting.
+class Convert_Tools
+{
+public:
+ //! Reads Shape using BREP reader
+ //! \param theFileName a file name
+ //! \return shape or NULL
+ Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+
+
+ //! Creates shape presentations on the stream if possible. Tries to init some OCCT base for a new presentation
+ //! \param theStream source of presentation
+ //! \param thePresentations container to collect new presentations
+ Standard_EXPORT static void ConvertStreamToPresentations (const Standard_SStream& theSStream,
+ const Standard_Integer theStartPos,
+ const Standard_Integer theLastPos,
+ NCollection_List<Handle(Standard_Transient)>& thePresentations);
+
+ //! Converts stream to color if possible. It processes Quantity_Color, Quantity_ColorRGBA
+ //! \param theStream source of presentation
+ //! \param theColor [out] converted color
+ //! \returns true if done
+ Standard_EXPORT static Standard_Boolean ConvertStreamToColor (const Standard_SStream& theSStream,
+ Quantity_Color& theColor);
+};
+
+#endif
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef Convert_TransientShape_H
+#define Convert_TransientShape_H
+
+#include <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+
+#include <TopoDS_Shape.hxx>
+
+//! \class Convert_TransientShape
+//! \brief An interface to covert a shape into a transient object to use it in arguments
+class Convert_TransientShape : public Standard_Transient
+{
+public:
+
+ //! Constructor
+ Convert_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); }
+
+ //! Destructor
+ virtual ~Convert_TransientShape() {}
+
+ //! Returns current shape
+ const TopoDS_Shape Shape() const { return myShape; }
+
+ //! Fills current shape
+ void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; }
+
+ DEFINE_STANDARD_RTTI_INLINE (Convert_TransientShape, Standard_Transient)
+
+private:
+ TopoDS_Shape myShape; //!< the shape
+};
+
+#endif
--- /dev/null
+Convert_Tools.cxx
+Convert_Tools.hxx
+Convert_TransientShape.hxx
myPaneMode = theMode;
if (myPaneMode == DFBrowser_AttributePaneType_SearchView)
{
- //! clear highlight in tree model
+ // clear highlight in tree model
DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
if (aModel && aModel->HasHighlighted())
aModel->SetHighlighted (QModelIndexList());
if (myPaneMode != DFBrowser_AttributePaneType_ItemView)
return;
- //! clear highlight in tree model
+ // clear highlight in tree model
DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
if (aModel && aModel->HasHighlighted())
aModel->SetHighlighted (QModelIndexList());
Standard_EXPORT DFBrowser_Communicator();
//! Destructor
- virtual ~DFBrowser_Communicator() Standard_OVERRIDE {}
+ virtual ~DFBrowser_Communicator() {}
//! Provides the container with a parent where this container should be inserted.
//! If Qt implementation, it should be QWidget with QLayout set inside
//! \param theParameters a parameters container
Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE;
- //! Provide container for actions available in inspector on general level
+ //! Provides container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
Standard_EXPORT virtual void FillActionsMenu (void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
DFBrowser_DumpView (QWidget* theParent) : QObject(theParent), myTextEdit( new QPlainTextEdit(theParent) ) {}
//! Destructor
- virtual ~DFBrowser_DumpView() Standard_OVERRIDE {}
+ virtual ~DFBrowser_DumpView() {}
//! \return the text edit control
QWidget* GetControl() const { return myTextEdit; }
public slots:
- //! Slots listen selection change and update the current control content by selection
+ //! Listens selection change and update the current control content by selection
//! \param theSelected container of selected items
//! \param theDeselected container of items that become deselected
Standard_EXPORT void OnTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
DFBrowser_HighlightDelegate (QObject* theParent = 0) : QItemDelegate (theParent) {}
//! Destructor
- virtual ~DFBrowser_HighlightDelegate() Standard_OVERRIDE {}
+ virtual ~DFBrowser_HighlightDelegate() {}
- //! Redefine of the parent virtual method to color the cell rectangle in highlight style
+ //! Redefines of the parent virtual method to color the cell rectangle in highlight style
//! \param thePainter a painter
//! \param theOption a paint options
//! \param theIndex a view index
#include <QObject>
#include <Standard_WarningsRestore.hxx>
+//#define USE_DUMPJSON
+
// =======================================================================
// function : hasAttribute
// purpose :
return DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(), theItemRole, Column());
}
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void DFBrowser_Item::initStream (Standard_OStream& theOStream) const
+{
+ if (!HasAttribute())
+ return;
+
+#ifdef USE_DUMPJSON
+ Handle(TDF_Attribute) anAttribute = GetAttribute();
+ if (!anAttribute.IsNull())
+ anAttribute->DumpJson (theOStream);
+#else
+ (void)theOStream;
+#endif
+}
+
// =======================================================================
// function : GetAttributeInfo
// purpose :
public:
//! Creates an item wrapped by a shared pointer
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
//! \return the pointer to the created item
static DFBrowser_ItemPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return DFBrowser_ItemPtr (new DFBrowser_Item (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~DFBrowser_Item() Standard_OVERRIDE {};
+ virtual ~DFBrowser_Item() {}
//! \return true if the attribute is set in the item, otherwise it is initialized by a label
Standard_EXPORT bool HasAttribute() const;
//! Resets the cached item values, set null attribute and calls reset of the parent class
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
- //! Init item and calls cachedValue() for the role
+ //! Inits item and calls cachedValue() for the role
//! \param theItemRole a value role
//! \return the value
Standard_EXPORT QVariant GetAttributeInfo(int theRole) const;
//! \return number of children.
virtual int initRowCount() const Standard_OVERRIDE;
- //! Return data value for the role:
+ //! Returns data value for the role:
//! - if content is label, calls DFBrowser_ItemBase;
//! - if content is attribute, if the fole is extended display, asks additional info text or ask module about info
//! \param theItemRole a value role
//! \return the value
virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
+
//! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theParent a parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
DFBrowser_Item (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: DFBrowser_ItemBase (theParent, theRow, theColumn) {}
- //! Initialize the current item. It creates a backup of the specific item information
+ //! Initializes the current item. It creates a backup of the specific item information
void initItem() const;
//! Sets the item attribute
{ return DFBrowser_ItemApplicationPtr (new DFBrowser_ItemApplication (theParent)); }
//! Destructor
- virtual ~DFBrowser_ItemApplication() Standard_OVERRIDE {};
+ virtual ~DFBrowser_ItemApplication() {}
//! Sets the item label
//! \param theLabel an object where the child items structure is found
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
DFBrowser_ItemApplication(TreeModel_ItemBasePtr theParent) : DFBrowser_ItemBase(theParent, 0, 0) {}
private:
if (DFBrowser_Tools::IsEmptyLabel(GetLabel()))
aValue = QColor (Qt::lightGray);
else
- { //! TEMPORARY HERE : should be moved in the pane of TDataStd_Name kind of attribute
+ { // TEMPORARY HERE : should be moved in the pane of TDataStd_Name kind of attribute
Handle(TDataStd_Name) aName;
if (useAdditionalInfo() && myLabel.FindAttribute (TDataStd_Name::GetID(), aName))
aValue = QColor (Qt::darkGreen);
//! \return the current module
DFBrowser_Module* GetModule() const { return myModule; }
- //! Change using of additional information in item. It it does not use additional info,
+ //! Changes using of additional information in item. If it does not use additional info,
//! it will not return extended text in initValue().
//! \param theValue a new value
//! \return the previous value
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
- //! Initialize the current item. It creates a backup of the specific item information
- virtual void initItem() const {};
+ //! Initializes the current item. It creates a backup of the specific item information
+ virtual void initItem() const {}
protected:
//! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theParent a parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
private:
public:
//! Creates an item wrapped by a shared pointer
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
//! \return the pointer to the created item
static DFBrowser_ItemDocumentPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return DFBrowser_ItemDocumentPtr (new DFBrowser_ItemDocument (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~DFBrowser_ItemDocument() Standard_OVERRIDE {};
+ virtual ~DFBrowser_ItemDocument() {}
//! Returns the current label
//! \return a label
protected:
- //! Initialize the current item. It is empty because Reset() is also empty.
+ //! Initializes the current item. It is empty because Reset() is also empty.
virtual void initItem() const Standard_OVERRIDE;
- //!
+ //! Initializes the current item. It creates a backup of the specific item information
virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
protected:
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
DFBrowser_ItemDocument(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: DFBrowser_ItemBase (theParent, theRow, theColumn) {}
// =======================================================================
void DFBrowser_Module::CreateViewModel (void* theParent)
{
- myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
+ myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent);
+ myOCAFViewModel->InitColumns();
+ myOCAFViewModel->SetModule (this);
}
// =======================================================================
// function : GetAttributePane
// purpose :
// =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Standard_CString theAttributeName)
{
DFBrowserPane_AttributePaneAPI* aPane = 0;
// function : GetAttributeInfo
// purpose :
// =======================================================================
-QVariant DFBrowser_Module::GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+QVariant DFBrowser_Module::GetAttributeInfo (Standard_CString theAttributeName, DFBrowser_Module* theModule,
int theRole, int theColumnId)
{
DFBrowserPane_AttributePane* anAttributePane = 0;
// function : CreateAttributePane
// purpose :
// =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowser_Module::CreateAttributePane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::CreateAttributePane (Standard_CString theAttributeName)
{
DFBrowserPane_AttributePaneAPI* aPane = 0;
// iteration should be performed from the tail of the list, as latest added creator has
Standard_EXPORT DFBrowser_Module();
//! Destructor
- virtual ~DFBrowser_Module() Standard_OVERRIDE {};
+ virtual ~DFBrowser_Module() {}
//! Creates tree model for OCAF application
Standard_EXPORT void CreateViewModel (void* theParent);
//! \return an application instance
Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
- //! Rebuild an OCAF tree view model
+ //! Rebuilds an OCAF tree view model
Standard_EXPORT void UpdateTreeModel();
//! Sets initial selection in OCAF tree view, it is an application(root) item
//! \return an attribute
Standard_EXPORT Handle(TDF_Attribute) FindAttribute (const QModelIndex& theIndex);
- //! Append creator of a pane by attribute type
+ //! Appends creator of a pane by attribute type
//! \param thePaneCreator
void RegisterPaneCreator (DFBrowserPane_AttributePaneCreatorAPI* thePaneCreator)
{ myPaneCreators.append (thePaneCreator); }
//! internal map and the module processes this kind of attribute
//! \param theAttributeGUID an attribute key
//! \return attribute pane
- Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (const Standard_CString& theAttributeName);
+ Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (Standard_CString theAttributeName);
//! Finds the attribute pane according to the give attribute and returns its information
//! \param theAttribute a source attribute
//! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
//! \param theColumnId a tree model column
//! \return value, interpreted by tree model depending on the role
- Standard_EXPORT static QVariant GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+ Standard_EXPORT static QVariant GetAttributeInfo (Standard_CString theAttributeName, DFBrowser_Module* theModule,
int theRole, int theColumnId);
signals:
//! Tries to create attribute pane for the attribute name using registered attribute pane creators
//! \param theAttributeName a source attribute
//! \return attribute pane or NULL
- DFBrowserPane_AttributePaneAPI* CreateAttributePane (const Standard_CString& theAttributeName);
+ DFBrowserPane_AttributePaneAPI* CreateAttributePane (Standard_CString theAttributeName);
private:
#include <BinLDrivers.hxx>
#include <BinXCAFDrivers.hxx>
#include <PCDM_ReadWriter.hxx>
-#include <Standard_Version.hxx>
#include <StdDrivers.hxx>
#include <StdLDrivers.hxx>
#include <STEPCAFControl_Reader.hxx>
return anApplication;
}
-#if OCC_VERSION_HEX > 0x060901
// Load static variables for STEPCAF (ssv; 16.08.2012)
STEPCAFControl_Controller::Init();
PCDM_ReaderStatus aStatus = anApplication->Open (theFileName, aDocument);
if (aStatus != PCDM_RS_OK)
return Handle(TDocStd_Application)();
-#endif
return anApplication;
}
namespace DFBrowser_OpenApplication
{
- //! Open the application by the name.
+ //! Opens the application by the name.
//! \param theFileName a name of the file initialized the application
//! \param isSTEPFile an output parameter, true if the file name is a STEP file
//! \return an opened application
Standard_EXPORT DFBrowser_PropertyPanel (QWidget* theParent);
//! Destructor
- virtual ~DFBrowser_PropertyPanel() Standard_OVERRIDE {}
+ virtual ~DFBrowser_PropertyPanel() {}
//! Returns main control
QWidget* GetControl() const { return myMainWindow; }
const QItemSelection& theDeselected);
private:
- QWidget* myMainWindow; //! < parent of attribute stack control
- DFBrowser_AttributePaneStack* myAttributesStack; //! < panes stack
+ QWidget* myMainWindow; //!< parent of attribute stack control
+ DFBrowser_AttributePaneStack* myAttributesStack; //!< panes stack
};
#endif
Standard_EXPORT DFBrowser_SearchLine (QWidget* theParent);
//! Destructor
- virtual ~DFBrowser_SearchLine() Standard_OVERRIDE {}
+ virtual ~DFBrowser_SearchLine() {}
//! Creates search line model filled by the module. It is necessary for auto completion of line edit
//! \param theModule a current module
Standard_EXPORT void ClearValues();
//! Returns completer model
- Standard_EXPORT QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); }
+ QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); }
//! Returns completion completer model
- Standard_EXPORT QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); }
+ QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); }
//! Returns the current line edit text
QString Text() const { return myLineControl->text(); }
//! Updates icon of search button depending on text is empty and emits searchActivated signal
void onTextChanged (const QString& theText);
- //! Set completion prefix in completer model
+
+ //! Sets completion prefix in completer model
void onReturnPressed() { myLineControl->completer()->setCompletionPrefix (myLineControl->text()); }
- //! Set empty text if the current text is not empty: new search is started
+
+ //! Sets empty text if the current text is not empty: new search is started
void onSearchButtonClicked();
private:
QLineEdit* myLineControl; //!< line editor control
- QToolButton* mySearchButton; //! < search button
+ QToolButton* mySearchButton; //!< search button
};
#endif
Standard_EXPORT DFBrowser_SearchLineModel (QObject* theParent, DFBrowser_Module* theModule);
//! Destructor
- virtual ~DFBrowser_SearchLineModel() Standard_OVERRIDE {}
+ virtual ~DFBrowser_SearchLineModel() {}
//! Separator as attribute name is divided from the label entry in information text
static QString SplitSeparator() { return ": "; }
//! Returns the data stored under the given role for the item referred to by the index.
//! \param theIndex a model index
//! \param theRole an enumeration value of role for data obtaining
-
Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
//! Returns the number of rows under the given parent.
virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return myRowCount; }
+
//! Returns the number of columns for the children of the given parent.
//! \param theParent a parent model index
//! \return the number of columns
-
virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return 3; }
Standard_EXPORT DFBrowser_SearchView (QWidget* theParent);
//! Destructor
- virtual ~DFBrowser_SearchView() Standard_OVERRIDE {}
+ virtual ~DFBrowser_SearchView() {}
//! Returns search parent control
QWidget* GetControl() const { return myMainWindow; }
DFBrowser_QThread (QObject* theParent) : QThread (theParent), myItem (0) {}
//! Destructor
- virtual ~DFBrowser_QThread() Standard_OVERRIDE {}
+ virtual ~DFBrowser_QThread() {}
//! Sets thread item to be processed
//! \param theItem a thread item
//! internal containers for search functionality
Standard_EXPORT virtual void Run() Standard_OVERRIDE;
- //! Set filled containers into search line
+ //! Sets filled containers into search line
Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
- //! Clear search line values
+ //! Clears search line values
Standard_EXPORT static void ClearValues (DFBrowser_SearchLine* theSearchLine);
private:
void addLabel (const TDF_Label& theLabel, const QStringList& theCurrentPath,
QMap<QString, DFBrowser_SearchItemInfo>& theValues, QStringList& theInfoValues);
- //! Add attribute information, it is either attribute kind or attribure value for TDataStd_Name or TDataStd_Comment
+ //! Adds attribute information, it is either attribute kind or attribure value for TDataStd_Name or TDataStd_Comment
//! \parm theAttribute a current attribute
//! \param theCurrentPath it contains the current path to the label (stores in container)
//! \param theValues container of document item values
Standard_EXPORT DFBrowser_TreeLevelLine (QWidget* theParent);
//! Destructor
- virtual ~DFBrowser_TreeLevelLine() Standard_OVERRIDE {}
+ virtual ~DFBrowser_TreeLevelLine() {}
//! Clears history of selected items
Standard_EXPORT void ClearHistory();
//! Destructor
virtual ~DFBrowser_TreeLevelLineDelegate() {}
- //! Draw an icon in the cell and highlight cell if mouse is over the cell
+ //! Draws an icon in the cell and highlight cell if mouse is over the cell
//! \param thePainter a painter
//! \param theOption a paint options
//! \param theIndex a view index
if (theRole == Qt::DecorationRole) //! do not show icons presented in tree view
return aValue;
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (aTreeIndex);
- if (anItemBase)
- {
- DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
- bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
- aValue = aDBrowserItem->data (aTreeIndex, theRole);
- aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
+ if (!anItemBase)
+ return aValue;
+
+ DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
+ if (!aDBrowserItem)
+ return aValue;
+
+ bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
+ aValue = aDBrowserItem->data (aTreeIndex, theRole);
+ aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
- }
if (theRole == Qt::DisplayRole)
aValue = aValue.toString() + " "; //! TEMPORARY to leave place for the action icon
}
//! Destructor
virtual ~DFBrowser_TreeLevelLineModel() {}
- //!
+ //! Resets the cached values
void Reset() { myLevelItems.clear(); }
//! Inits the model by the index
//! Returns true if the tree model index is filled
bool IsInitialized() const { return myTreeIndex.isValid(); }
- //! Return OCAF tree view model index on level defined by column of the parameter index
+ //! Returns OCAF tree view model index on level defined by column of the parameter index
//! \param theIndex a tree level view model index
//! \return model index
const QModelIndex& GetTreeViewIndex (const QModelIndex& theIndex) const
private:
QModelIndex myTreeIndex; //!< the current OCAF tree view model index
- QList<QModelIndex> myLevelItems; //! cached parent indices of myTreeIndex for quick access to item information
+ QList<QModelIndex> myLevelItems; //!< cached parent indices of myTreeIndex for quick access to item information
};
#endif
Standard_EXPORT DFBrowser_TreeLevelView (QWidget* theParent);
//! Destructor
- virtual ~DFBrowser_TreeLevelView() Standard_OVERRIDE {}
+ virtual ~DFBrowser_TreeLevelView() {}
//! Returns parent control
QWidget* GetControl() const { return myMainWindow; }
- //! Clear selection of the table view selection model
+ //! Clears selection of the table view selection model
Standard_EXPORT void ClearSelection();
//! Returns true if this control may be filled by the index
//! \return boolean result
Standard_EXPORT static bool ProcessItem (const QModelIndex& theIndex);
- //! Init view by the first selected item in OCAF tree view
+ //! Inits view by the first selected item in OCAF tree view
//! \param theSelected selected items
//! \param theDeselected deselected items
Standard_EXPORT void UpdateByTreeSelectionChanged (const QItemSelection& theSelected,
if (theIndex.column() == 0)
{
DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
+ if (!aDBrowserItem)
+ return QVariant();
+
bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
aValue = anItemBase->data (anIndex, theRole);
aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
DFBrowser_TreeLevelViewModel (QObject* theParent) : QAbstractTableModel (theParent), myRowCount (0) {}
//! Destructor
- virtual ~DFBrowser_TreeLevelViewModel() Standard_OVERRIDE {}
+ virtual ~DFBrowser_TreeLevelViewModel() {}
- //! Reset OCAF tree model index
+ //! Resets OCAF tree model index
void Reset() { myIndex = QModelIndex(); }
//! Fills OCAF tree model index
//! Returns true if the index is filled
bool IsInitialized() const { return myIndex.isValid(); }
- //! Return OCAF tree view model index on level defined by column of the parameter index
+ //! Returns OCAF tree view model index on level defined by column of the parameter index
//! \param theIndex a tree level view model index
//! \return model index
Standard_EXPORT QModelIndex GetTreeViewIndex (const QModelIndex& theIndex) const;
//! Emits the layoutChanged signal from outside of this class
void EmitLayoutChanged() { emit layoutChanged(); }
- //! It returns value only for DisplayRole for column = 1
+ //! Returns value only for DisplayRole for column = 1
//! \param theSection an index of value in the container
//! \param theIndex a model index
//! \param theRole a view role
// function : Constructor
// purpose :
// =======================================================================
-DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule)
+DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent)
: TreeModel_ModelBase (theParent)
{
- SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+}
- DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::InitColumns()
+{
+ SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::SetModule (DFBrowser_Module* theModule)
+{
+ DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
aRootItem->SetModule (theModule);
}
// function : createRootItem
// purpose :
// =======================================================================
-void DFBrowser_TreeModel::createRootItem (const int)
+TreeModel_ItemBasePtr DFBrowser_TreeModel::createRootItem (const int)
{
- m_pRootItem = DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
+ return DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
}
// =======================================================================
// =======================================================================
void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplication)
{
- DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+ DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
Reset();
aRootItem->SetApplication (theApplication);
EmitLayoutChanged();
// =======================================================================
Handle(TDocStd_Application) DFBrowser_TreeModel::GetTDocStdApplication() const
{
- DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+ DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
return aRootItem->GetApplication();
}
if (aPathId == aPathCount && anItem->HasAttribute())
{
// processing attribute in theValue
- DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(m_pRootItem);
+ DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(RootItem (0));
QString anAttributeInfo = DFBrowser_Module::GetAttributeInfo (anItem->GetAttribute(), aRootAppItem->GetModule(),
Qt::DisplayRole, 0).toString();
if (anAttributeInfo == anEntry)
public:
//! Constructor
- Standard_EXPORT DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule);
+ Standard_EXPORT DFBrowser_TreeModel (QObject* theParent);
//! Destructor
- virtual ~DFBrowser_TreeModel() Standard_OVERRIDE {};
+ virtual ~DFBrowser_TreeModel() {}
+
+ //! Creates model columns and root items.
+ Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
//! Fills the root item by the application
Standard_EXPORT void Init (const Handle(TDocStd_Application)& theApplication);
+ //! Fills root item by the module
+ Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
+
//! Returns an OCAF application or NULL
//! \return an application instance
Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
protected:
//! Creates root item
//! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId);
+ Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
private:
#include <inspector/TreeModel_ContextMenu.hxx>
#include <inspector/TreeModel_Tools.hxx>
+#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_TreeView.hxx>
-#include <inspector/View_Tools.hxx>
-
#include <OSD_Directory.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Protection.hxx>
const int DEFAULT_PROPERTY_PANEL_HEIGHT = 200;
const int DEFAULT_BROWSER_HEIGHT = 800;
+//#define USE_DUMPJSON
+
// =======================================================================
// function : Constructor
// purpose :
connect (aLevelView, SIGNAL (indexDoubleClicked (const QModelIndex&)),
this, SLOT (onLevelDoubleClicked (const QModelIndex&)));
+ // property widget
QDockWidget* aPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
aPropertyPanelWidget->setObjectName (aPropertyPanelWidget->windowTitle());
aPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
aPropertyPanelWidget->setWidget (myPropertyPanel->GetControl());
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aPropertyPanelWidget);
+ // property view
+#ifdef USE_DUMPJSON
+ myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel (DumpJson)"), myMainWindow);
+ myPropertyView = new ViewControl_PropertyView (myMainWindow,
+ QSize(DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT));
+ myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
+ myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
+ myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
+ myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
+#endif
+
// dump view window
QWidget* aDumpWidget = new QWidget(myMainWindow);
QVBoxLayout* aDumpLay = new QVBoxLayout(aDumpWidget);
// view
myViewWindow = new View_Window (myMainWindow);
- myViewWindow->GetView()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
+ myViewWindow->ViewWidget()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
- aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
+ aViewDockWidget->setTitleBarWidget (myViewWindow->ViewToolBar()->GetControl());
aViewDockWidget->setWidget (myViewWindow);
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
QColor aHColor (229, 243, 255);
- myViewWindow->GetDisplayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
- aHColor.blue() / 255., Quantity_TOC_RGB), View_PresentationType_Additional);
+ myViewWindow->Displayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
+ aHColor.blue() / 255., Quantity_TOC_RGB), View_PresentationType_Additional);
- myMainWindow->splitDockWidget(aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
+ myMainWindow->splitDockWidget (aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
+
+#ifdef USE_DUMPJSON
+ myMainWindow->tabifyDockWidget (aDumpDockWidget, myPropertyPanelWidget);
+ myMainWindow->tabifyDockWidget (myPropertyPanelWidget, aViewDockWidget);
+#else
myMainWindow->tabifyDockWidget (aDumpDockWidget, aViewDockWidget);
+#endif
myTreeView->resize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH, DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
QMap<QString, QString> anItems;
TreeModel_Tools::SaveState (myTreeView, anItems);
- View_Tools::SaveState(myViewWindow, anItems);
+ View_Window::SaveState(myViewWindow, anItems);
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
continue;
- else if (View_Tools::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+ else if (View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
continue;
}
}
}
return;
}
+ else
+ {
+ if (anApplication.IsNull() && CDF_Session::Exists())
+ anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
+ }
myModule = new DFBrowser_Module();
myModule->CreateViewModel (myMainWindow);
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
{
int aLevels = 2;
- setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
}
QApplication::restoreOverrideCursor();
}
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
{
int aLevels = -1;
- setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
}
QApplication::restoreOverrideCursor();
}
QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++) {
int aLevels = -1;
- setExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
}
}
{
if (!myModule)
return;
+
+#ifdef USE_DUMPJSON
+ if (myPropertyPanelWidget->toggleViewAction()->isChecked())
+ myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+#endif
+
// previuos selection should be cleared in the panel selectors
DFBrowser_AttributePaneStack* anAttributePaneStack = myPropertyPanel->GetAttributesStack();
anAttributePaneStack->GetPaneSelector()->ClearSelected();
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 0);
myTreeView->scrollTo (aSelectedIndex);
- View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+ View_Displayer* aDisplayer = myViewWindow->Displayer();
aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
{
TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
QString aMessage = QString ("TShape %1 is sent to %2.")
- .arg (DFBrowserPane_Tools::GetPointerInfo (aParameters.Last()).ToCString())
+ .arg (Standard_Dump::GetPointerInfo (aParameters.Last()).ToCString())
.arg (aPluginShortName.ToCString());
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
.arg (aPluginShortName.ToCString()).toStdString().c_str();
// make the shape visualized
QModelIndex aSelectedIndex = aSelectedIndices.first();
- View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+ View_Displayer* aDisplayer = myViewWindow->Displayer();
aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
// highlight and scroll to the referenced item if it exists
QModelIndexList anIndices;
anIndices.append (theIndex);
highlightIndices (anIndices);
- View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+ View_Displayer* aDisplayer = myViewWindow->Displayer();
aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
aDisplayer->DisplayPresentation (findPresentation (theIndex), View_PresentationType_Main);
}
thePresentations.Append (aPresentation);
}
}
-
-// =======================================================================
-// function : setExpanded
-// purpose :
-// =======================================================================
-void DFBrowser_Window::setExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
- int& theLevels)
-{
- bool isToExpand = theLevels == -1 || theLevels > 0;
- if (!isToExpand)
- return;
-
- theTreeView->setExpanded (theIndex, isExpanded);
- if (theLevels != -1)
- theLevels--;
-
- QAbstractItemModel* aModel = theTreeView->model();
- for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
- {
- int aLevels = theLevels;
- setExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
- }
-}
class DFBrowser_TreeLevelLine;
class ViewControl_MessageDialog;
+class ViewControl_PropertyView;
class View_ToolBar;
class View_Window;
class QAbstractItemModel;
class QAction;
+class QDockWidget;
class QTreeView;
class QWidget;
Standard_EXPORT DFBrowser_Window();
//! Destructor
- Standard_EXPORT virtual ~DFBrowser_Window() Standard_OVERRIDE;
+ Standard_EXPORT virtual ~DFBrowser_Window();
//! Appends main window into layout of the parent if the parent is child of QWidget
//! \param theParent a parent class
//! \param theParameters a parameters container
void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
- //! Provide container for actions available in inspector on general level
+ //! Provides container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
//! \param thePosition a clicked point
void onTreeViewContextMenuRequested (const QPoint& thePosition);
- //! Expand two next levels for all selected item
+ //! Expands two next levels for all selected item
void onExpand();
- //! Expand all levels for all selected items
+ //! Expands all levels for all selected items
void onExpandAll();
- //! Collapse all levels for all selected items
+ //! Collapses all levels for all selected items
void onCollapseAll();
//! Udpates all controls by changed selection in OCAF tree view
//! \return container of presentations or NULL
void findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations);
- //! Recursive items expanding in tree view staring from the index
- //! \param theTreeView an OCAF tree view
- //! \param theParentIndex an index which children should be expanded
- //! \param isExpanded a boolean state if the item should be expanded or collapsed
- //! \param theLevels a number of levels to be expanded, or -1 for all levels
- static void setExpanded (QTreeView* theTreeView, const QModelIndex& theParentIndex, const bool isExpanded, int& theLevels);
-
private:
DFBrowser_Module* myModule; //!< current module
QMainWindow* myMainWindow; //!< main control for all components
DFBrowser_TreeLevelLine* myTreeLevelLine; //!< navigate line of tree levels to the selected item
QTreeView* myTreeView; //!< OCAF tree view
+ QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
DFBrowser_PropertyPanel* myPropertyPanel; //!< property panel shows full information about attribute or search view
+ ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
View_Window* myViewWindow; //!< V3d view to visualize presentations/references if it can be build for a selected item
DFBrowser_DumpView* myDumpView; //!< Text editor where "Dump" method output is shown
DFBrowser_Thread* myThread; //!< Threads manipulator, starting thread items, listens finalizing
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef DFBROWSERPANE_H
-#define DFBROWSERPANE_H
-
-#ifdef __DFBrowserPane_DLL
- #ifdef _WIN32
- #define DFBROWSERPANE_EXPORT __declspec(dllexport)
- #else
- #define DFBROWSERPANE_EXPORT
- #endif
-#else
- #ifdef _WIN32
- #define DFBROWSERPANE_EXPORT __declspec(dllimport)
- #else
- #define DFBROWSERPANE_EXPORT
- #endif
-#endif
-
-#endif
// function : GetAttributeInfoByType
// purpose :
// =======================================================================
-QVariant DFBrowserPane_AttributePane::GetAttributeInfoByType (const Standard_CString& theAttributeName,
+QVariant DFBrowserPane_AttributePane::GetAttributeInfoByType (Standard_CString theAttributeName,
int theRole, int theColumnId)
{
if (theColumnId != 0)
//! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
//! \param theColumnId a tree model column
//! \return value, interpreted by tree model depending on the role
- Standard_EXPORT static QVariant GetAttributeInfoByType(const Standard_CString& theAttributeName, int theRole, int theColumnId);
+ Standard_EXPORT static QVariant GetAttributeInfoByType(Standard_CString theAttributeName, int theRole, int theColumnId);
//! Returns information for the given attribute
//! \param theAttribute a current attribute
// function : Constructor
// purpose :
// =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowserPane_AttributePaneCreator::CreateAttributePane (
- const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowserPane_AttributePaneCreator::CreateAttributePane (Standard_CString theAttributeName)
{
DFBrowserPane_AttributePaneAPI* aPane = 0;
if (theAttributeName == STANDARD_TYPE (TDF_Reference)->Name())
//! Creates attribute pane for TDF, TDataStd, TDocStd, TPrsStd, TNaming and TFunction attribute types
//! \param theAttributeName a standard type of attribute
//! \return an attribute pane if it can be created for this type
- Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane(const Standard_CString& theAttributeName) Standard_OVERRIDE;
+ Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane(Standard_CString theAttributeName) Standard_OVERRIDE;
};
#endif
//! Creates attribute pane for attribute types
//! \param theAttributeName a standard type of attribute
//! \return an attribute pane if it can be created for this type
- virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane (const Standard_CString& theAttributeName) = 0;
+ virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane (Standard_CString theAttributeName) = 0;
};
#endif
virtual ~DFBrowserPane_AttributePaneModel() {}
//! Sets direction of the values applying, whether it should be placed by rows or by columns
- //! \param theOrientation if horizontal, the values are applyed by rows, otherwise by columns
+ //! \param theOrientation if horizontal, the values are applied by rows, otherwise by columns
void SetOrientation (const Qt::Orientation& theOrientation) { myOrientation = theOrientation; }
//! Returns table orientation for setting data values
#ifndef DFBrowserPane_HelperExport_H
#define DFBrowserPane_HelperExport_H
-#include <inspector/DFBrowserPane.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
//! It contains a conainer of shapes for model indices. If button is pressed for index where the
//! shape exists, this shape is exported to BREP file.
//! It contains a container of shapes, it is important to clear this helper after using.
-class DFBROWSERPANE_EXPORT DFBrowserPane_HelperExport : public QObject
+class DFBrowserPane_HelperExport : public QObject
{
Q_OBJECT
public:
//! Returns shape for the index
//! \param theIndex a model view index
//! \return a cached shape
- const TopoDS_Shape& GetShape (const QModelIndex& theIndex) { return myShapes[theIndex]; }
+ const TopoDS_Shape& Shape (const QModelIndex& theIndex) { return myShapes[theIndex]; }
public slots:
: DFBrowserPane_AttributePane(), myTreeNodeView (0)
{
myModel = new DFBrowserPane_TDataStdTreeNodeModel (0);
+ myModel->InitColumns();
mySelectionModels.clear(); // do not use selection model of parent pane
mySelectionModels.push_back (new QItemSelectionModel (myModel));
}
}
- DFBrowserPane_TDataStdTreeNodeModel* aModel = dynamic_cast<DFBrowserPane_TDataStdTreeNodeModel*> (myModel);
- aModel->Reset();
+ myModel->Reset();
if (!aTreeNode.IsNull())
{
Handle(TDataStd_TreeNode) aRootItem = aTreeNode->Root();
- aModel->SetAttribute (aRootItem);
+ myModel->SetAttribute (aRootItem);
- QModelIndex anIndex = aModel->FindIndex (theAttribute, QModelIndex());
+ QModelIndex anIndex = myModel->FindIndex (theAttribute, QModelIndex());
if (myTreeNodeView && anIndex.isValid())
{
myTreeNodeView->setExpanded (anIndex.parent(), true);
anAttributeNodeItem->setCurrentAttribute (true);
}
}
- aModel->EmitLayoutChanged();
+ myModel->EmitLayoutChanged();
}
// =======================================================================
#include <Standard.hxx>
-class QAbstractItemModel;
+class DFBrowserPane_TDataStdTreeNodeModel;
class QTreeView;
//! \class DFBrowserPane_TDataStdTreeNode
private:
- QAbstractItemModel* myModel;
+ DFBrowserPane_TDataStdTreeNodeModel* myModel;
QTreeView* myTreeNodeView;
};
public:
//! Creates an item wrapped by a shared pointer
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
//! \return the pointer to the created item
static DFBrowserPane_TDataStdTreeNodeItemPtr CreateItem (TreeModel_ItemBasePtr theParent,
const int theRow, const int theColumn)
{ return DFBrowserPane_TDataStdTreeNodeItemPtr (new DFBrowserPane_TDataStdTreeNodeItem (theParent, theRow, theColumn)); }
//!Destructor
- virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {};
+ virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {}
//! Store a current attribute
//! \param theAttribute an attribute
protected:
//! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theParent a parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
DFBrowserPane_TDataStdTreeNodeItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: TreeModel_ItemBase (theParent, theRow, theColumn), myIsCurrentItem (false) {}
- //! Initialize the current item. It creates a backup of the specific item information
+ //! Initializes the current item. It creates a backup of the specific item information
void initItem() const;
//! Returns number of children attributes, initializes item is necessary
DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent)
: TreeModel_ModelBase (theParent)
{
- createRootItem(0);
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeModel::InitColumns()
+{
+ SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
}
// =======================================================================
// function : createRootItem
// purpose :
// =======================================================================
-void DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
{
- m_pRootItem = DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
+ return DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
}
// =======================================================================
// =======================================================================
void DFBrowserPane_TDataStdTreeNodeModel::SetAttribute (const Handle(TDF_Attribute)& theAttribute)
{
- DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(m_pRootItem);
+ DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(RootItem (0));
Reset();
aRootItem->SetAttribute (theAttribute);
EmitLayoutChanged();
Standard_EXPORT DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent);
//! Destructor
- virtual ~DFBrowserPane_TDataStdTreeNodeModel() Standard_OVERRIDE {};
+ virtual ~DFBrowserPane_TDataStdTreeNodeModel() Standard_OVERRIDE {}
+
+ //! Creates model columns and root items.
+ Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
//! Initializes the tree model by the attribute
//! \param theAttribute a current attribute
protected:
//! Creates root item
//! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+ Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
private:
#include <TDocStd_Owner.hxx>
#include <TDF_Delta.hxx>
#include <TDF_ListIteratorOfDeltaList.hxx>
-#include <Standard_Version.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QGridLayout>
if (aDocument.IsNull())
return;
- TCollection_AsciiString aDocumentInfo = DFBrowserPane_Tools::GetPointerInfo (aDocument).ToCString();
+ TCollection_AsciiString aDocumentInfo = Standard_Dump::GetPointerInfo (aDocument).ToCString();
TColStd_SequenceOfExtendedString anExtensions;
aDocument->Extensions(anExtensions);
TCollection_AsciiString aSeparationStr = "---------------------------";
// TDocStd_Document methods
TCollection_AsciiString aDocumentDataInfo = !aDocument->GetData().IsNull()
- ? DFBrowserPane_Tools::GetPointerInfo (aDocument->GetData()).ToCString() : "";
+ ? Standard_Dump::GetPointerInfo (aDocument->GetData()).ToCString() : "";
theValues << aSeparationStr.ToCString() << aSeparationStr.ToCString()
<< STANDARD_TYPE (TDocStd_Document)->Name() << ""
<< aSeparationStr.ToCString() << aSeparationStr.ToCString()
<< "GetUndos" << convertToString (aDocument->GetUndos())
<< "GetAvailableRedos" << QString::number (aDocument->GetAvailableRedos())
<< "GetRedos" << convertToString (aDocument->GetRedos())
-#if OCC_VERSION_HEX > 0x070100
<< "EmptyLabelsSavingMode" << DFBrowserPane_Tools::BoolToStr (aDocument->EmptyLabelsSavingMode())
-#endif
<< "IsNestedTransactionMode" << DFBrowserPane_Tools::BoolToStr (aDocument->IsNestedTransactionMode())
<< "ModificationMode" << DFBrowserPane_Tools::BoolToStr (aDocument->ModificationMode());
}
aFreeRows << 0 << 1;
TopoDS_Shape aShape = aShapeAttr->Get();
- TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()) : "";
+ TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? Standard_Dump::GetPointerInfo (aShape.TShape()) : "";
aValues << "Shape" << aShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (aShape) << "" << "";
aShapes.Append (aShape);
if (aShape.IsNull())
TopoDS_Shape aCurrentShape = TNaming_Tool::CurrentShape (aShapeAttr);
TCollection_AsciiString aCurrentShapeInfo = !aCurrentShape.IsNull() ?
- DFBrowserPane_Tools::GetPointerInfo (aCurrentShape.TShape()) : "";
+ Standard_Dump::GetPointerInfo (aCurrentShape.TShape()) : "";
aValues << "CurrentShape" << aCurrentShapeInfo.ToCString()
<< DFBrowserPane_Tools::ShapeTypeInfo (aCurrentShape) << "" << "";
aShapes.Append (aCurrentShape);
TopoDS_Shape anOriginalShape = TNaming_Tool::OriginalShape (aShapeAttr);
TCollection_AsciiString anOriginalShapeInfo = !anOriginalShape.IsNull() ?
- DFBrowserPane_Tools::GetPointerInfo (anOriginalShape.TShape()) : "";
+ Standard_Dump::GetPointerInfo (anOriginalShape.TShape()) : "";
aValues << "OriginalShape" << anOriginalShapeInfo.ToCString()
<< DFBrowserPane_Tools::ShapeTypeInfo (anOriginalShape) << "" << "";
aShapes.Append (anOriginalShape);
aLabelInfo = QString (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString());
}
if (!aNewShape.IsNull())
- aValues << DFBrowserPane_Tools::GetPointerInfo (aNewShape.TShape()->This()).ToCString()
+ aValues << Standard_Dump::GetPointerInfo (aNewShape.TShape()->This()).ToCString()
<< DFBrowserPane_Tools::ShapeTypeInfo (aNewShape)
<< "";
else
aValues << "-" << "-" << "";
aValues << "Old:";
if (!anOldShape.IsNull())
- aValues << DFBrowserPane_Tools::GetPointerInfo (anOldShape.TShape()->This()).ToCString()
+ aValues << Standard_Dump::GetPointerInfo (anOldShape.TShape()->This()).ToCString()
<< DFBrowserPane_Tools::ShapeTypeInfo (anOldShape)
<< aLabelInfo
<< "";
if (aSelectedIndex.column() != 4)
return;
- const TopoDS_Shape& aShape = myHelperExport.GetShape (aSelectedIndex);
+ const TopoDS_Shape& aShape = myHelperExport.Shape (aSelectedIndex);
if (aShape.IsNull())
return;
theParameters.Append (aShape.TShape());
QModelIndex anIndex = *anIt;
if (!myHelperExport.HasShape (anIndex))
continue;
- aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
+ aBuilder.Add (aComp, myHelperExport.Shape (anIndex));
aHasShapes = true;
}
QModelIndex anIndex = *anIt;
if (!myHelperExport.HasShape (anIndex))
continue;
- aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
+ aBuilder.Add (aComp, myHelperExport.Shape (anIndex));
aHasShapes = true;
}
if (aHasShapes)
theValues.append (QString::number (aNamingName.Index()));
TopoDS_Shape aShape = aNamingName.Shape();
theValues.append ("Shape(TShape)");
- theValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
+ theValues.append (!aShape.IsNull() ? Standard_Dump::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
TDF_Label aContextLabel = aNamingName.ContextLabel();
theValues.append ("ContextLabel");
theValues.append (!aContextLabel.IsNull() ? DFBrowserPane_Tools::GetEntry (aContextLabel).ToCString() : "");
if (!aShape.IsNull())
{
theValues.append(DFBrowserPane_Tools::ToName(DB_SHAPE_TYPE, aShape.ShapeType()).ToCString());
- theValues.append(DFBrowserPane_Tools::GetPointerInfo(aShape.TShape()->This()).ToCString());
+ theValues.append(Standard_Dump::GetPointerInfo(aShape.TShape()->This()).ToCString());
}
else
theValues << "EMPTY SHAPE" << "";
{
theValues.append(DFBrowserPane_Tools::GetEntry(aPtrRefShape->Label()).ToCString());
const TopoDS_Shape& aValueShape = aPtrRefShape->Shape();
- theValues.append(!aValueShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo(aValueShape.TShape()->This()).ToCString() : "");
+ theValues.append(!aValueShape.IsNull() ? Standard_Dump::GetPointerInfo(aValueShape.TShape()->This()).ToCString() : "");
}
else
theValues << "" << "";
<< "GetAIS" << (anIO.IsNull() ? "Null" : anAttribute->DynamicType()->Name())
<< "IsDisplayed" << DFBrowserPane_Tools::BoolToStr (anAttribute->IsDisplayed())
<< "GetContext()" << ((!anIO.IsNull() && !anIO->GetContext().IsNull()) ?
- DFBrowserPane_Tools::GetPointerInfo (anIO->GetContext()).ToCString() : "")
+ Standard_Dump::GetPointerInfo (anIO->GetContext()).ToCString() : "")
<< "HasOwnMaterial" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnMaterial())
<< "Material" << (anAttribute->HasOwnMaterial() ?
DFBrowserPane_Tools::ToName (DB_MATERIAL_TYPE, anAttribute->Material()) : "").ToCString()
Handle(AIS_InteractiveContext) aContext = aViewerAttribute->GetInteractiveContext();
TCollection_AsciiString aPointerInfo = !aContext.IsNull()
- ? DFBrowserPane_Tools::GetPointerInfo (aContext).ToCString() : "";
+ ? Standard_Dump::GetPointerInfo (aContext).ToCString() : "";
theValues << "GetInteractiveContext" << aPointerInfo.ToCString();
#include <CDM_CanCloseStatus.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
-#include <Standard_Version.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDataStd.hxx>
#include <TDataStd_RealEnum.hxx>
return anAsciiEntry;
}
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString DFBrowserPane_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- std::ostringstream aPtrStr;
- aPtrStr << thePointer.operator->();
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend("0x");
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
// =======================================================================
// function : ShapeTypeInfo
// purpose :
//! \return the string value
Standard_EXPORT static TCollection_AsciiString GetEntry (const TDF_Label& theLabel);
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo = true);
-
//! Returns string value corresponded to the shape type if it is not null.
//! \param theShape a checked shape
//! \return string value or empty string value
-DFBrowserPane.hxx
DFBrowserPane.qrc
DFBrowserPane_AttributePane.cxx
DFBrowserPane_AttributePane.hxx
// function : ProcessAttribute
// purpose :
// =======================================================================
-bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (const Standard_CString& theAttributeType)
+bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (Standard_CString theAttributeType)
{
if (AttributeTypes.empty())
{
//! have difference in presentation (TDataStd_TreeNode, TDF_Reference, TNaming_NamedShape and TDataStd_UAttribute).
//! Also it contains XCAFDoc attributes (should be implemented in this package or pane will be empty)
//! \param theAttributeType an attribute type
- Standard_EXPORT static bool ProcessAttribute (const Standard_CString& theAttributeType);
+ Standard_EXPORT static bool ProcessAttribute (Standard_CString theAttributeType);
//! Creates table view and call create widget of array table helper
//! \param theParent a parent widget
#include <inspector/DFBrowserPaneXDE_XCAFDocShapeMapTool.hxx>
#include <inspector/DFBrowserPaneXDE_XCAFDocShapeTool.hxx>
-#include <Standard_Version.hxx>
-
#include <XCAFDoc_Area.hxx>
#include <XCAFDoc_Centroid.hxx>
#include <XCAFDoc_Color.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_Datum.hxx>
-#if OCC_VERSION_HEX > 0x060901
#include <XCAFDoc_Dimension.hxx>
#include <XCAFDoc_GeomTolerance.hxx>
-#endif
#include <XCAFDoc_DimTol.hxx>
#include <XCAFDoc_DimTolTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
// function : CreateAttributePane
// purpose :
// =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAttributePane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAttributePane (Standard_CString theAttributeName)
{
DFBrowserPane_AttributePaneAPI* aPane = 0;
if (DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (theAttributeName))
// function : createXDEPane
// purpose :
// =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDEPane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDEPane (Standard_CString theAttributeName)
{
DFBrowserPane_AttributePaneAPI* aPane = 0;
if (theAttributeName == STANDARD_TYPE (XCAFDoc_ShapeMapTool)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocColorTool();
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Datum)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocDatum();
-#if OCC_VERSION_HEX > 0x060901
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Dimension)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocDimension();
-#endif
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DimTol)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocDimTol();
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DimTolTool)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocDimTolTool();
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DocumentTool)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocDocumentTool();
-#if OCC_VERSION_HEX > 0x060901
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_GeomTolerance)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocGeomTolerance();
-#endif
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_GraphNode)->Name())
aPane = new DFBrowserPaneXDE_XCAFDocGraphNode();
else if (theAttributeName == STANDARD_TYPE (XCAFDoc_LayerTool)->Name())
//! \param theAttributeName a type of attribute
//! \return an attribute pane if it can be created for this type
Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane
- (const Standard_CString& theAttributeName) Standard_OVERRIDE;
+ (Standard_CString theAttributeName) Standard_OVERRIDE;
protected:
//! Cretates pane for XCAFDoc attribute name
//! \param theAttributeName a type of attribute
//! \return an attribute pane if it can be created for this type
- DFBrowserPane_AttributePaneAPI* createXDEPane (const Standard_CString& theAttributeName);
+ DFBrowserPane_AttributePaneAPI* createXDEPane (Standard_CString theAttributeName);
private:
#include <inspector/DFBrowserPane_AttributePaneModel.hxx>
-#include <Standard_Version.hxx>
#include <TCollection_HAsciiString.hxx>
#include <XCAFDoc_Datum.hxx>
-#if OCC_VERSION_HEX > 0x060901
#include <XCAFDimTolObjects_DatumObject.hxx>
-#endif
// =======================================================================
// function : Constructor
<< "Description" << (!aDescription.IsNull() ? aDescription->ToCString() : QString (""))
<< "Indentification" << (!anIndentification.IsNull() ? anIndentification->ToCString() : QString (""));
-#if OCC_VERSION_HEX > 0x060901
Handle(XCAFDimTolObjects_DatumObject) anObject = anAttr->GetObject();
Handle(TCollection_HAsciiString) anObjectName;
if (!anObject.IsNull())
anObjectName = anObject->GetName();
theValues << "Object" << (!anObjectName.IsNull() ? anObjectName->ToCString() : "Empty Name");
-#endif
}
// =======================================================================
const TopoDS_Shape& aShape = aShapeMap(aShapeValueId);
if (!aShape.IsNull())
- theValues << DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString()
+ theValues << Standard_Dump::GetPointerInfo (aShape.TShape()->This()).ToCString()
<< DFBrowserPane_Tools::ShapeTypeInfo (aShape)
<< "";
else
#include <XCAFDoc_Color.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_DimTol.hxx>
-#include <Standard_Version.hxx>
-#if OCC_VERSION_HEX > 0x060901
#include <XCAFDoc_Dimension.hxx>
#include <XCAFDoc_GeomTolerance.hxx>
-#endif
#include <XCAFDoc_Datum.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_GraphNode.hxx>
else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
type = "DatumToler Link";
}
-#if OCC_VERSION_HEX > 0x060901
else if ( att->ID() == XCAFDoc::DimensionRefFirstGUID() ) {
type = "Dimension Link First";
}
else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ){
type = "GeomTolerance Link";
}
-#endif
else
return TCollection_AsciiString();
ShapeView.qrc
ShapeView_Communicator.cxx
ShapeView_Communicator.hxx
-ShapeView_ItemBase.hxx
ShapeView_ItemRoot.cxx
ShapeView_ItemRoot.hxx
ShapeView_ItemShape.cxx
ShapeView_Communicator() : TInspectorAPI_Communicator(), myWindow (new ShapeView_Window (0)) {}
//! Destructor
- virtual ~ShapeView_Communicator() Standard_OVERRIDE { myWindow->RemoveAllShapes(); }
+ virtual ~ShapeView_Communicator() { myWindow->RemoveAllShapes(); }
//! Provides the container with a parent where this container should be inserted.
//! If Qt implementation, it should be QWidget with QLayout set inside
virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE
{ myWindow->SetParameters (theParameters); }
- //! Provide container for actions available in inspector on general level
+ //! Provides container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
- Standard_EXPORT virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
+ virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
//! Returns plugin preferences, empty implementation by default
//! \param theItem container of preference elements
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ShapeView_ItemBase_H
-#define ShapeView_ItemBase_H
-
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-class ShapeView_ItemBase;
-typedef QExplicitlySharedDataPointer<ShapeView_ItemBase> ShapeView_ItemBasePtr;
-
-//! \class ShapeView_ItemBase
-// \brief Declaration of the tree model base item.
-class ShapeView_ItemBase : public TreeModel_ItemBase
-{
-public:
-
- //! Resets cached values
- virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- virtual void initItem() const {};
-
- //! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- ShapeView_ItemBase(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : TreeModel_ItemBase (theParent, theRow, theColumn) {}
-};
-
-#endif
\ No newline at end of file
#include <inspector/ShapeView_ItemShape.hxx>
// =======================================================================
-// function : GetShape
+// function : Shape
// purpose :
// =======================================================================
-const TopoDS_Shape& ShapeView_ItemRoot::GetShape (const int theRowId)
+const TopoDS_Shape& ShapeView_ItemRoot::Shape (const int theRowId)
{
NCollection_List<TopoDS_Shape>::Iterator aShapesIt (myShapes);
for (int aRowId = 0; aShapesIt.More(); aShapesIt.Next(), aRowId++)
#define ShapeView_ItemRoot_H
#include <NCollection_List.hxx>
-#include <inspector/ShapeView_ItemBase.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
#include <Standard.hxx>
#include <TopoDS_Shape.hxx>
//! Collects shapes that should be visualized in tree view. Shapes are cached and if shapes are not needed,
//! cache should be cleared using RemoveAllShapes.
//! Parent is NULL, children are ShapeView_ItemShape items.
-class ShapeView_ItemRoot : public ShapeView_ItemBase
+class ShapeView_ItemRoot : public TreeModel_ItemBase
{
public:
{ return ShapeView_ItemRootPtr (new ShapeView_ItemRoot (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~ShapeView_ItemRoot() Standard_OVERRIDE {};
+ virtual ~ShapeView_ItemRoot() {}
//! Appends new shape
//! \param theShape a shape instance
//! Returns shape by the number
//! \param theRowId an index of the shape in the internal container.
- Standard_EXPORT const TopoDS_Shape& GetShape (const int theRowId);
+ Standard_EXPORT const TopoDS_Shape& Shape (const int theRowId);
protected:
- //! Return data value for the role.
+ //! Returns data value for the role.
//! \param theItemRole a value role
//! \return the value
virtual QVariant initValue(const int theItemRole) const;
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
ShapeView_ItemRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : ShapeView_ItemBase (theParent, theRow, theColumn) {}
+ : TreeModel_ItemBase (theParent, theRow, theColumn) {}
private:
#include <inspector/ShapeView_ItemShape.hxx>
-#include <Adaptor3d_Curve.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-
-#include <GCPnts_AbscissaPoint.hxx>
-#include <Geom_Curve.hxx>
-#include <GeomAdaptor_Curve.hxx>
-
#include <inspector/ShapeView_ItemRoot.hxx>
#include <inspector/ShapeView_ItemShape.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <TopAbs.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
-#include <TopoDS_Vertex.hxx>
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QObject>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-QString ToString (const Standard_Boolean& theValue)
-{
- return theValue ? "1" : "0";
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-QString ToString (const gp_Pnt& thePoint)
-{
- return QString ("(%1, %2, %3)").arg (thePoint.X()).arg (thePoint.Y()).arg (thePoint.Z());
-}
-
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-QString ToName (const TopAbs_ShapeEnum& theShapeType)
-{
- Standard_SStream aSStream;
- TopAbs::Print (theShapeType, aSStream);
- return QString (aSStream.str().c_str());
-}
-
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-QString ToName (const TopAbs_Orientation& theOrientation)
-{
- Standard_SStream aSStream;
- TopAbs::Print(theOrientation, aSStream);
- return QString (aSStream.str().c_str());
-}
-
-// =======================================================================
-// function : ToName
+// function : Shape
// purpose :
// =======================================================================
-QString ToName (const GeomAbs_Shape& theType)
+TopoDS_Shape ShapeView_ItemShape::Shape (const int theRowId) const
{
- switch (theType)
+ if (myChildShapes.IsEmpty())
{
- case GeomAbs_C0: return "GeomAbs_C0";
- case GeomAbs_G1: return "GeomAbs_G1";
- case GeomAbs_C1: return "GeomAbs_C1";
- case GeomAbs_G2: return "GeomAbs_G2";
- case GeomAbs_C2: return "GeomAbs_C2";
- case GeomAbs_C3: return "GeomAbs_C3";
- case GeomAbs_CN: return "GeomAbs_CN";
- default: break;
- }
- return QString();
-}
+ ShapeView_ItemShape* aThis = (ShapeView_ItemShape*)this;
-// =======================================================================
-// function : ToOtherInfo
-// purpose :
-// =======================================================================
-void ToOtherInfo (const TopoDS_Shape& theShape, QVariant& theValue, QVariant& theInfo)
-{
- switch (theShape.ShapeType())
- {
- case TopAbs_COMPOUND:
- case TopAbs_COMPSOLID:
- case TopAbs_SOLID:
- case TopAbs_SHELL:
- case TopAbs_FACE:
- case TopAbs_WIRE:
- break;
- case TopAbs_EDGE:
+ if (myExplodeType != TopAbs_SHAPE)
{
- TopoDS_Edge anEdge = TopoDS::Edge(theShape);
- double aFirst, aLast;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
-
- GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
- gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
- gp_Pnt aLastPnt = aAdaptor.Value(aLast);
-
- BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
- Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
-
- QStringList aValues, anInfo;
- aValues.append (QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d)));
- anInfo.append ("Length");
-
- aValues.append (aCurve->DynamicType()->Name());
- anInfo.append ("DynamicType");
-
- aValues.append (ToString (aFirstPnt));
- anInfo.append (QString ("First" + QString::number (aFirst)));
-
- aValues.append (ToString (aLastPnt));
- anInfo.append (QString ("Last" + QString::number (aLast)));
-
- aValues.append (ToName (aCurve->Continuity()));
- anInfo.append ("Continuity");
-
- aValues.append (ToString (aCurve->IsClosed()));
- anInfo.append ("IsClosed");
-
- if (aCurve->IsPeriodic()) {
- aValues.append (QString::number (aCurve->Period()));
- anInfo.append ("IsPeriodic");
- }
- else
+ TopExp::MapShapes(myShape, myExplodeType, aThis->myChildShapes);
+ }
+ else
+ {
+ TopoDS_Iterator aSubShapeIt (myShape);
+ for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
{
- aValues.append (ToString (aCurve->IsPeriodic()));
- anInfo.append ("IsPeriodic");
+ aThis->myChildShapes.Add (aSubShapeIt.Value());
}
- theValue = aValues.join (" / ");
- theInfo = QString ("%1:\n%2").arg (anInfo.join (" / ")).arg (aValues.join ("\n"));
- break;
}
- case TopAbs_SHAPE:
- default:
- break;
}
-}
+ if (myChildShapes.Extent() >= theRowId + 1)
+ return myChildShapes(theRowId + 1);
-// =======================================================================
-// function : locationInfo
-// purpose :
-// =======================================================================
-QString locationInfo (const TopLoc_Location& theLocation)
-{
- QString anInfo;
-
- gp_Trsf aTrsf = theLocation.Transformation();
- QStringList aValues, aRowValues;
- for (int aRowId = 1; aRowId <= 3; aRowId++)
- {
- aRowValues.clear();
- for (int aColumnId = 1; aColumnId <= 4; aColumnId++)
- aRowValues.append (QString::number (aTrsf.Value(aRowId, aColumnId)));
- aValues.append (aRowValues.join (","));
- }
- anInfo.append (aValues.join (" "));
- return anInfo;
-}
-
-// =======================================================================
-// function : GetShape
-// purpose :
-// =======================================================================
-TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
-{
- TopoDS_Iterator aSubShapeIt (myShape);
- for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
- {
- if (aCurrentIndex != theRowId)
- continue;
- break;
- }
- return aSubShapeIt.Value();
+ return TopoDS_Shape();
}
// =======================================================================
// =======================================================================
QVariant ShapeView_ItemShape::initValue(const int theRole) const
{
+ QVariant aParentValue = TreeModel_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
TopoDS_Shape aShape = getShape();
if (aShape.IsNull())
return QVariant();
switch (Column())
{
- case 0: return ToName (aShape.ShapeType());
- case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
- case 3: return TShapePointer().ToCString();
- case 4: return ToName(aShape.Orientation());
- case 5: return locationInfo(aShape.Location());
- case 6: return ToString (aShape.Checked());
- case 7: return ToString (aShape.Closed());
- case 8: return ToString (aShape.Infinite());
- case 9: return ToString (aShape.Locked());
- case 10: return ToString (aShape.Modified());
- case 11: return ToString (aShape.Orientable());
- case 12:
- {
- if (aShape.ShapeType() != TopAbs_VERTEX)
- return QVariant();
- TopoDS_Vertex aVertex = TopoDS::Vertex (aShape);
- gp_Pnt aPoint = BRep_Tool::Pnt (aVertex);
- return ToString (aPoint);
- }
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- {
- if (aShape.ShapeType() != TopAbs_EDGE)
- return QVariant();
-
- TopoDS_Edge anEdge = TopoDS::Edge(aShape);
- double aFirst, aLast;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
-
- GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
- gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
- gp_Pnt aLastPnt = aAdaptor.Value(aLast);
-
- BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
- Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
-
- switch (Column())
- {
- case 13: return QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d));
- case 14: return aCurve->DynamicType()->Name();
- case 15: return ToString (aFirstPnt);
- case 16: return ToString (aLastPnt);
- case 17: return ToName (aCurve->Continuity());
- case 18: return ToString (aCurve->IsClosed());
- case 19: return aCurve->IsPeriodic() ? QString::number (aCurve->Period()) : ToString (aCurve->IsPeriodic());
- }
- }
+ case 0: return TopAbs::ShapeTypeToString (aShape.ShapeType());
default: break;
}
return QVariant();
return 0;
int aRowsCount = 0;
- for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
- aRowsCount++;
+ if (myExplodeType != TopAbs_SHAPE)
+ {
+ TopTools_IndexedMapOfShape aSubShapes;
+ TopExp::MapShapes(aShape, myExplodeType, aSubShapes);
+ aRowsCount = aSubShapes.Extent();
+ }
+ else
+ {
+ for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
+ aRowsCount++;
+ }
return aRowsCount;
}
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void ShapeView_ItemShape::initStream (Standard_OStream& theOStream) const
+{
+ TopoDS_Shape aShape = getShape();
+ if (aShape.IsNull())
+ return;
+
+ aShape.DumpJson (theOStream);
+}
+
// =======================================================================
// function : createChild
// purpose :
{
ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot> (Parent());
ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape> (Parent());
- myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
+ myShape = aRootItem ? aRootItem->Shape (Row()) : aShapeItem->Shape (Row());
+
+ TreeModel_ItemBase::Init();
}
// =======================================================================
return myShape;
}
-// =======================================================================
-// function : getPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- std::ostringstream aPtrStr;
- aPtrStr << thePointer.operator->();
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend("0x");
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
// =======================================================================
// function : Reset
// purpose :
void ShapeView_ItemShape::Reset()
{
myFileName = QString();
+ myChildShapes.Clear();
+ myShape = TopoDS_Shape();
- ShapeView_ItemBase::Reset();
+ TreeModel_ItemBase::Reset();
}
// =======================================================================
return;
const_cast<ShapeView_ItemShape*>(this)->Init();
}
-
#ifndef ShapeView_ItemShape_H
#define ShapeView_ItemShape_H
-#include <inspector/ShapeView_ItemBase.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
//! \class ShapeView_ItemShape
//! This item is connected to TopoDS_Shape.
//! Parent is either ShapeView_ItemRoot or ShapeView_ItemShape, children are ShapeView_ItemShape or no children
-class ShapeView_ItemShape : public ShapeView_ItemBase
+class ShapeView_ItemShape : public TreeModel_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
//! \return the pointer to the created item
static ShapeView_ItemShapePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return ShapeView_ItemShapePtr (new ShapeView_ItemShape (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
+ virtual ~ShapeView_ItemShape() {}
+
+ //! Returns explode type of the item
+ TopAbs_ShapeEnum ExplodeType() const { return myExplodeType; }
+
+ //! Sets explore type
+ //! \param theType type of item explode. If TopAbs_SHAPE, no explode, only iteration by shape
+ void SetExplodeType (const TopAbs_ShapeEnum theType) { myExplodeType = theType; }
//! Returns the current shape
const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
//! Returns child(extracted) shape for the current shape by the index
//! \param theRowId an index of child shape
//! \returns shape instance or NULL
- Standard_EXPORT TopoDS_Shape GetShape (const int theRowId) const;
+ Standard_EXPORT TopoDS_Shape Shape (const int theRowId) const;
//! Returns name of BREP file for the shape if exists
//! \return string valuie
//! \return string valuie
void SetFileName (const QString& theFileName) { myFileName = theFileName; }
- //! Returns TShape pointer info of the current TopoDS Shape
- //! \return string value
- TCollection_AsciiString TShapePointer() const { return getPointerInfo (myShape.TShape()); }
-
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
- //! Return data value for the role.
+ //! Returns data value for the role.
//! \param theRole a value role
//! \return the value
Standard_EXPORT virtual QVariant initValue(const int theRole) const;
//! \return number of children.
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
+
protected:
- //! Initialize the current item. It is empty because Reset() is also empty.
+ //! Initializes the current item. It is empty because Reset() is also empty.
virtual void initItem() const Standard_OVERRIDE;
//! Creates a child item in the given position.
//! \return shape value
TopoDS_Shape getShape() const;
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- static TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo = true);
-
private:
//! Constructor
- ShapeView_ItemShape(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : ShapeView_ItemBase(theParent, theRow, theColumn) {}
+ ShapeView_ItemShape (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : TreeModel_ItemBase (theParent, theRow, theColumn), myExplodeType (TopAbs_SHAPE) {}
private:
+ TopAbs_ShapeEnum myExplodeType; //!< type of explore own shape and get children
TopoDS_Shape myShape; //!< current shape
QString myFileName; //!< BREP file name
+
+ TopTools_IndexedMapOfShape myChildShapes; //!< cached container of child shapes
};
#endif
QString myDataDir; //!< samples directory
QString myFileName; //!< result file name
- QTableView* mySamplesView; //! <view of sample file names
+ QTableView* mySamplesView; //!< view of sample file names
QLineEdit* mySelectedName; //!< alternative control to open file
- QToolButton* myFolderApplyOpen; //! button to open file
+ QToolButton* myFolderApplyOpen; //!< button to open file
};
#endif
class QObject;
class QPainter;
-//! \class TInspectorEXE_OpenFileItemDelegate
+//! \class ShapeView_OpenFileItemDelegate
//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
class ShapeView_OpenFileItemDelegate : public QItemDelegate
{
//! Destructor
virtual ~ShapeView_OpenFileItemDelegate() {}
- //! Draw an icon in the cell
+ //! Draws an icon in the cell
//! \param thePainter a painter
//! \param theOption a paint options
//! \param theIndex a view index
QColor myColor; //!< highlight color
};
-//! \class TInspectorEXE_OpenFileViewModel
+//! \class ShapeView_OpenFileViewModel
//! Table model that visualizes container of string values (file names)
//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
class ShapeView_OpenFileViewModel : public QAbstractTableModel
//! Destructor
virtual ~ShapeView_OpenFileViewModel() {}
- //! Store values
+ //! Stores values
//! \param theValues a container of values to fill model
void Init (const QStringList& theValues);
// commercial license or contractual agreement.
#include <inspector/ShapeView_Tools.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
-#include <AIS_Shape.hxx>
// =======================================================================
-// function : ReadShape
+// function : IsPossibleToExplode
// purpose :
// =======================================================================
-TopoDS_Shape ShapeView_Tools::ReadShape (const TCollection_AsciiString& theFileName)
+Standard_Boolean ShapeView_Tools::IsPossibleToExplode (const TopoDS_Shape& theShape,
+ NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes)
{
- TopoDS_Shape aShape;
+ TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+
+ if (!theExplodeTypes.Contains (aShapeType))
+ theExplodeTypes.Append(aShapeType);
+
+ if (theExplodeTypes.Extent() == TopAbs_SHAPE + 1) // all types are collected, stop
+ return Standard_True;
- BRep_Builder aBuilder;
- BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
- return aShape;
+ TopoDS_Iterator aSubShapeIt (theShape);
+ for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
+ {
+ if (IsPossibleToExplode (aSubShapeIt.Value(), theExplodeTypes))
+ return Standard_True;
+ }
+ return Standard_False;
}
#include <Standard.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <NCollection_List.hxx>
#include <TCollection_AsciiString.hxx>
#include <Standard_Transient.hxx>
#include <TopoDS_Shape.hxx>
+#include <inspector/ViewControl_TableModelValues.hxx>
+
+#include <GeomAbs_Shape.hxx>
+#include <Standard_WarningsDisable.hxx>
+#include <QList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
//! \class ShapeView_Tools
//! It gives auxiliary methods for TopoDS_Shape manipulation
class ShapeView_Tools
{
public:
- //! Read Shape using BREP reader
- //! \param theFileName a file name
- //! \return shape or NULL
- Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+ //! Checks whether it is possible to explode the shape. The search is recursive until all types are collected.
+ //! \param theShape [in] source shape object
+ //! \param theExplodeTypes [out] container of possible shape types to be exploded
+ //! \return true if explode is finished, all types are collected.
+ Standard_EXPORT static Standard_Boolean IsPossibleToExplode(const TopoDS_Shape& theShape,
+ NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes);
+
};
#endif
#include <inspector/ShapeView_ItemRoot.hxx>
#include <inspector/ShapeView_ItemShape.hxx>
-const int COLUMN_NAME_WIDTH = 190;
-const int COLUMN_SIZE_WIDTH = 30;
-const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
-
-const int COLUMN_ORIENTATION_WIDTH = 70;
-const int COLUMN_LOCATION_WIDTH = 120;
-
// =======================================================================
// function : Constructor
// purpose :
ShapeView_TreeModel::ShapeView_TreeModel (QObject* theParent)
: TreeModel_ModelBase (theParent)
{
- SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
- // column 1 is reserved for visiblity state
- SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
- SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (4, TreeModel_HeaderSection ("Orientation", COLUMN_ORIENTATION_WIDTH));
- SetHeaderItem (5, TreeModel_HeaderSection ("Location", COLUMN_LOCATION_WIDTH));
-
- SetHeaderItem (6, TreeModel_HeaderSection ("Checked", -1, true));
- SetHeaderItem (7, TreeModel_HeaderSection ("Closed", -1, true));
- SetHeaderItem (8, TreeModel_HeaderSection ("Infinite", -1, true));
- SetHeaderItem (9, TreeModel_HeaderSection ("Locked", -1, true));
- SetHeaderItem (10, TreeModel_HeaderSection ("Modified", -1, true));
- SetHeaderItem (11, TreeModel_HeaderSection ("Orientable", -1, true));
-
- SetHeaderItem (12, TreeModel_HeaderSection ("VERTEX: (X, Y, Z)", -1, true));
-
- SetHeaderItem (13, TreeModel_HeaderSection ("EDGE: Length", -1, true));
- SetHeaderItem (14, TreeModel_HeaderSection ("DynamicType", -1, true));
- SetHeaderItem (15, TreeModel_HeaderSection ("First", -1, true));
- SetHeaderItem (16, TreeModel_HeaderSection ("Last", -1, true));
- SetHeaderItem (17, TreeModel_HeaderSection ("Continuity", -1, true));
- SetHeaderItem (18, TreeModel_HeaderSection ("IsClosed", -1, true));
- SetHeaderItem (19, TreeModel_HeaderSection ("IsPeriodic", -1, true));
}
// =======================================================================
// function : createRootItem
// purpose :
// =======================================================================
-void ShapeView_TreeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr ShapeView_TreeModel::createRootItem (const int theColumnId)
{
- myRootItems.insert (theColumnId, ShapeView_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
- if (theColumnId == 0)
- m_pRootItem = myRootItems[0];
+ return ShapeView_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
}
// =======================================================================
#ifndef ShapeView_TreeModel_H
#define ShapeView_TreeModel_H
-#include <inspector/ShapeView_ItemBase.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
#include <Standard.hxx>
#include <TopoDS_Shape.hxx>
#include <inspector/TreeModel_ModelBase.hxx>
Standard_EXPORT ShapeView_TreeModel (QObject* theParent);
//! Destructor
- virtual ~ShapeView_TreeModel() Standard_OVERRIDE {};
+ virtual ~ShapeView_TreeModel() {}
- //! Add shape, append it to the model root item
+ //! Adds shape, append it to the model root item
//! \param theShape a shape instance
Standard_EXPORT void AddShape (const TopoDS_Shape& theShape);
- //! Remove all shapes in the model root item
+ //! Removes all shapes in the model root item
Standard_EXPORT void RemoveAllShapes();
- //! Returns root item by column
- //! \param theColumn an index of the column
- //! \return root item instance
- virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE
- { return myRootItems[theColumn]; }
-
//! Returns model index of the shape.
//! \param theShape a shape object
//! \return the model index
protected:
//! Creates root item
//! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+ Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
-private:
- QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
};
#endif
#include <inspector/ShapeView_ItemShape.hxx>
+// =======================================================================
+// function : OnClicked
+// purpose :
+// =======================================================================
+void ShapeView_VisibilityState::OnClicked (const QModelIndex& theIndex)
+{
+ processClicked (theIndex);
+ emit itemClicked (theIndex);
+}
+
// =======================================================================
// function : SetVisible
// purpose :
// =======================================================================
bool ShapeView_VisibilityState::SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged)
{
- TopoDS_Shape aShape = GetShape (theIndex);
+ TopoDS_Shape aShape = Shape (theIndex);
if (aShape.IsNull())
return false;
}
// =======================================================================
-// function : GetShape
+// function : Shape
// purpose :
// =======================================================================
-TopoDS_Shape ShapeView_VisibilityState::GetShape (const QModelIndex& theIndex) const
+TopoDS_Shape ShapeView_VisibilityState::Shape (const QModelIndex& theIndex) const
{
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
if (!anItemBase)
//! \class ShapeView_VisibilityState
//! \brief Class provides connection between model and visualization control
-class ShapeView_VisibilityState : public TreeModel_VisibilityState
+class ShapeView_VisibilityState : public QObject, public TreeModel_VisibilityState
{
+ Q_OBJECT
public:
//! Constructor
ShapeView_VisibilityState (TreeModel_ModelBase* theModel) : TreeModel_VisibilityState (theModel),
//! Returns true if visibility of the item can be changed
//! \param theIndex tree model index
//! \return boolean value
- virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE { return !GetShape (theIndex).IsNull(); }
+ virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE { return !Shape (theIndex).IsNull(); }
//! Sets visibility state
//! \theIndex tree model index
//! Returns visibility state value
virtual bool IsVisible (const QModelIndex& theIndex) const Standard_OVERRIDE
- { return myDisplayer->IsVisible (GetShape (theIndex), myPresentationType); }
+ { return myDisplayer->IsVisible (Shape (theIndex), myPresentationType); }
+
+public slots:
+ //! Processes the mouse clicked on the index.
+ //! It changes the item visibility if model allows to change it.
+ //! \theIndex tree model index
+ void OnClicked (const QModelIndex& theIndex);
+
+signals:
+ //! Signal after OnClicked is performed
+ //! \theIndex tree model index
+ void itemClicked (const QModelIndex& theIndex);
protected:
//! Gets shape of the view model by the parameter index if it has a shape
//! \param theIndex tree model index
//! \return shape instance
- TopoDS_Shape GetShape (const QModelIndex& theIndex) const;
+ TopoDS_Shape Shape (const QModelIndex& theIndex) const;
private:
- View_Displayer* myDisplayer; //! view displayer
- View_PresentationType myPresentationType; //! presentation type
+ View_Displayer* myDisplayer; //!< view displayer
+ View_PresentationType myPresentationType; //!< presentation type
};
#endif
#include <inspector/ShapeView_TreeModel.hxx>
#include <inspector/ShapeView_VisibilityState.hxx>
+#include <inspector/Convert_Tools.hxx>
+
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
+#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/ViewControl_TreeView.hxx>
#include <inspector/View_Displayer.hxx>
#include <inspector/View_PresentationType.hxx>
-#include <inspector/View_Tools.hxx>
#include <inspector/View_ToolBar.hxx>
#include <inspector/View_Widget.hxx>
#include <inspector/View_Window.hxx>
// purpose :
// =======================================================================
ShapeView_Window::ShapeView_Window (QWidget* theParent)
-: QObject (theParent), myNextPosition (0)
+: QObject (theParent)
{
myMainWindow = new QMainWindow (theParent);
this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
new TreeModel_ContextMenu (myTreeView);
ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
+ aModel->InitColumns();
+
myTreeView->setModel (aModel);
ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState (aModel);
aModel->SetVisibilityState (aVisibilityState);
TreeModel_Tools::UseVisibilityColumn (myTreeView);
+ QObject::connect (myTreeView, SIGNAL (clicked (const QModelIndex&)),
+ aVisibilityState, SLOT (OnClicked(const QModelIndex&)));
+
+ QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
+ myTreeView->setSelectionModel (aSelModel);
+ connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
myTreeView->setExpanded (aParentIndex, true);
myMainWindow->setCentralWidget (myTreeView);
+ // property view
+ myPropertyView = new ViewControl_PropertyView (myMainWindow,
+ QSize(SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT));
+ myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
+ myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
+ myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
+ myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
+ myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
+
// view
- myViewWindow = new View_Window (myMainWindow, false);
+ myViewWindow = new View_Window (myMainWindow, NULL, false);
connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
- aVisibilityState->SetDisplayer (myViewWindow->GetDisplayer());
+ aVisibilityState->SetDisplayer (myViewWindow->Displayer());
aVisibilityState->SetPresentationType (View_PresentationType_Main);
- myViewWindow->GetView()->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
+ myViewWindow->ViewWidget()->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
aViewDockWidget->setWidget (myViewWindow);
- aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
+ aViewDockWidget->setTitleBarWidget (myViewWindow->ViewToolBar()->GetControl());
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
+ myMainWindow->splitDockWidget(myPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
+
myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
}
// =======================================================================
ShapeView_Window::~ShapeView_Window()
{
- onCloseAllBREPViews();
}
// =======================================================================
QMap<QString, QString> anItems;
TreeModel_Tools::SaveState (myTreeView, anItems);
- View_Tools::SaveState(myViewWindow, anItems);
+ View_Window::SaveState(myViewWindow, anItems);
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
}
myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
continue;
- else if (View_Tools::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+ else if (View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
continue;
}
}
// =======================================================================
void ShapeView_Window::OpenFile(const TCollection_AsciiString& theFileName)
{
- TopoDS_Shape aShape = ShapeView_Tools::ReadShape (theFileName);
+ TopoDS_Shape aShape = Convert_Tools::ReadShape (theFileName);
if (!aShape.IsNull())
addShape(aShape);
}
{
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
aModel->RemoveAllShapes();
-
- onCloseAllBREPViews();
}
// =======================================================================
aMenu->addAction (ViewControl_Tools::CreateAction ("Remove all shape items", SLOT (onClearView()), myMainWindow, this));
}
else {
- if (!GetTemporaryDirectory().IsEmpty())
- aMenu->addAction (ViewControl_Tools::CreateAction ("BREP view", SLOT (onBREPView()), myMainWindow, this));
- aMenu->addAction (ViewControl_Tools::CreateAction ("Close All BREP views", SLOT (onCloseAllBREPViews()), myMainWindow, this));
- aMenu->addAction (ViewControl_Tools::CreateAction ("BREP directory", SLOT (onBREPDirectory()), myMainWindow, this));
+ aMenu->addAction (ViewControl_Tools::CreateAction ("Export to BREP", SLOT (onExportToBREP()), myMainWindow, this));
+ ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+ const TopoDS_Shape& aShape = aShapeItem->GetItemShape();
+ TopAbs_ShapeEnum anExplodeType = aShapeItem->ExplodeType();
+ NCollection_List<TopAbs_ShapeEnum> anExplodeTypes;
+ ShapeView_Tools::IsPossibleToExplode (aShape, anExplodeTypes);
+ if (anExplodeTypes.Size() > 0)
+ {
+ QMenu* anExplodeMenu = aMenu->addMenu ("Explode");
+ for (NCollection_List<TopAbs_ShapeEnum>::Iterator anExpIterator (anExplodeTypes); anExpIterator.More();
+ anExpIterator.Next())
+ {
+ TopAbs_ShapeEnum aType = anExpIterator.Value();
+ QAction* anAction = ViewControl_Tools::CreateAction (TopAbs::ShapeTypeToString (aType), SLOT (onExplode()), myMainWindow, this);
+ anExplodeMenu->addAction (anAction);
+ if (anExplodeType == aType)
+ {
+ anAction->setCheckable (true);
+ anAction->setChecked (true);
+ }
+ }
+ QAction* anAction = ViewControl_Tools::CreateAction ("NONE", SLOT (onExplode()), myMainWindow, this);
+ anExplodeMenu->addSeparator();
+ anExplodeMenu->addAction (anAction);
+ }
}
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec (aPoint);
}
+// =======================================================================
+// function : onTreeViewSelectionChanged
+// purpose :
+// =======================================================================
+void ShapeView_Window::onTreeViewSelectionChanged (const QItemSelection&,
+ const QItemSelection&)
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ if (myPropertyPanelWidget->toggleViewAction()->isChecked())
+ myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+
+ QApplication::restoreOverrideCursor();
+}
+
// =======================================================================
// function : onEraseAllPerformed
// purpose :
}
// =======================================================================
-// function : onBREPDirectory
+// function : onExplode
// purpose :
// =======================================================================
-void ShapeView_Window::onBREPDirectory()
+void ShapeView_Window::onExplode()
{
- QString aFilter (tr ("BREP file (*.brep*)"));
- QString aSelectedFilter;
- QString aFileName = QFileDialog::getOpenFileName (0, tr ("Export shape to BREP file"),
- GetTemporaryDirectory().ToCString(), aSelectedFilter);
- if (!aFileName.isEmpty())
- viewFile (aFileName);
+ QItemSelectionModel* aModel = myTreeView->selectionModel();
+ if (!aModel)
+ return;
+
+ QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
+ if (!anItemBase)
+ return;
+
+ ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+ if (!aShapeItem)
+ return;
+
+ QAction* anAction = (QAction*)sender();
+ if (!anAction)
+ return;
+
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ TopAbs_ShapeEnum aShapeType;
+ if (anAction->text() == "NONE")
+ aShapeType = TopAbs_SHAPE;
+ else
+ aShapeType = TopAbs::ShapeTypeFromString(anAction->text().toStdString().c_str());
+
+ myViewWindow->Displayer()->EraseAllPresentations();
+ aShapeItem->SetExplodeType(aShapeType);
+
+ //anItemBase->Parent()->Reset(); - TODO (update only modified sub-tree)
+ ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
+ aTreeModel->Reset();
+ aTreeModel->EmitLayoutChanged();
+ QApplication::restoreOverrideCursor();
}
// =======================================================================
QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
aFileName = QDir().toNativeSeparators (aFileName);
- if (!aFileName.isEmpty())
- onOpenFile(aFileName);
+ if (aFileName.isEmpty())
+ return;
+
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ onOpenFile(aFileName);
+ QApplication::restoreOverrideCursor();
}
// =======================================================================
-// function : onBREPView
+// function : onExportToBREP
// purpose :
// =======================================================================
-void ShapeView_Window::onBREPView()
+void ShapeView_Window::onExportToBREP()
{
- if (GetTemporaryDirectory().IsEmpty())
- return;
+ QString aFilter (tr ("Boundary representation file (*.brep *)"));
+ QString aSelectedFilter;
+ QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export shape to file"), QString(), aFilter, &aSelectedFilter);
QItemSelectionModel* aModel = myTreeView->selectionModel();
if (!aModel)
if (!anItem)
return;
- QString aFileName = anItem->GetFileName();
- QDir aDir;
- if (aFileName.isEmpty() || !aDir.exists (aFileName))
- {
- TCollection_AsciiString aFileNameIndiced = GetTemporaryDirectory() + TCollection_AsciiString ("\\") +
- getNextTmpName (anItem->TShapePointer());
- const TopoDS_Shape& aShape = anItem->GetItemShape();
- BRepTools::Write (aShape, aFileNameIndiced.ToCString());
- anItem->SetFileName (aFileNameIndiced.ToCString());
- aFileName = aFileNameIndiced.ToCString();
- }
- viewFile (aFileName);
-}
-
-// =======================================================================
-// function : onCloseAllBREPViews
-// purpose :
-// =======================================================================
-void ShapeView_Window::onCloseAllBREPViews()
-{
- removeBREPFiles();
-
- for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
- delete myBREPViews[aViewId];
-
- myBREPViews.clear();
-}
-
-// =======================================================================
-// function : onEditorDestroyed
-// purpose :
-// =======================================================================
-void ShapeView_Window::onEditorDestroyed(QObject* theObject)
-{
- QWidget* aWidget = dynamic_cast<QWidget*> (theObject);
-
- for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
- {
- if (myBREPViews[aViewId] == aWidget)
- myBREPViews.removeAll(aWidget);
- }
-}
-
-// =======================================================================
-// function : viewFile
-// purpose :
-// =======================================================================
-void ShapeView_Window::viewFile (const QString& theFileName)
-{
- QApplication::setOverrideCursor (Qt::WaitCursor);
- QString aFileText;
- QFile aFile (theFileName);
- if (aFile.open (QIODevice::ReadOnly | QIODevice::Text))
- {
- QTextStream aStream(&aFile);
- QString aLine = aStream.readLine();
- while (!aLine.isNull())
- {
- aLine = aStream.readLine();
- aFileText.append (aLine + QString ("\n"));
- }
- if (!aFileText.isEmpty())
- {
- QPlainTextEdit* anEditor = new QPlainTextEdit (0);
- anEditor->setAttribute (Qt::WA_DeleteOnClose, true);
- connect (anEditor, SIGNAL (destroyed(QObject*)), this, SLOT (onEditorDestroyed(QObject*)));
- anEditor->setPlainText (aFileText);
- anEditor->resize (DEFAULT_TEXT_VIEW_WIDTH, DEFAULT_TEXT_VIEW_HEIGHT);
- anEditor->move (DEFAULT_TEXT_VIEW_POSITION_X + myNextPosition, DEFAULT_TEXT_VIEW_POSITION_Y);
- myNextPosition += DEFAULT_TEXT_VIEW_DELTA;
- anEditor->show();
- myBREPViews.append (anEditor);
- }
- }
- QApplication::restoreOverrideCursor();
-}
-
-// =======================================================================
-// function : removeBREPFiles
-// purpose :
-// =======================================================================
-void ShapeView_Window::removeBREPFiles()
-{
- QDir aDir (GetTemporaryDirectory().ToCString());
-
- QStringList anEntries = aDir.entryList();
- QString aPrefix(viewBREPPrefix().ToCString());
- for (int anEntryId = 0, aSize = anEntries.size(); anEntryId < aSize; anEntryId++)
- {
- if (anEntries[anEntryId].contains (aPrefix))
- aDir.remove (anEntries[anEntryId]);
- }
-}
-
-// =======================================================================
-// function : getNextTmpName
-// purpose :
-// =======================================================================
-TCollection_AsciiString ShapeView_Window::getNextTmpName (const TCollection_AsciiString& thePointerInfo)
-{
- TCollection_AsciiString aTmpName(viewBREPPrefix());
- aTmpName += thePointerInfo;
- return aTmpName;
+ TCollection_AsciiString aFileNameIndiced = aFileName.toStdString().c_str();
+ const TopoDS_Shape& aShape = anItem->GetItemShape();
+ BRepTools::Write (aShape, aFileNameIndiced.ToCString());
+ anItem->SetFileName (aFileNameIndiced.ToCString());
+ aFileName = aFileNameIndiced.ToCString();
}
class View_Window;
+class ViewControl_PropertyView;
+
class QAction;
+class QDockWidget;
class QMainWindow;
class QWidget;
//! \param theParameters a parameters container
void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
- //! Provide container for actions available in inspector on general level
+ //! Provides container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
//! Returns current tree view
QTreeView* GetTreeView() const { return myTreeView; }
- //! Returns path to temporary directory
- TCollection_AsciiString GetTemporaryDirectory() const { return myParameters->GetTemporaryDirectory(); }
-
//! Removes all shapes in tree view model, remove all stored BREP files
Standard_EXPORT void RemoveAllShapes();
//! \param theParameters a parameters container
void Init (NCollection_List<Handle(Standard_Transient)>& theParameters);
- //! Read Shape from the file name, add Shape into tree view
+ //! Reads Shape from the file name, add Shape into tree view
//! \param theFileName BREP file name
void OpenFile (const TCollection_AsciiString& theFileName);
//! \param thePosition a clicked point
void onTreeViewContextMenuRequested (const QPoint& thePosition);
+ //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
+ //! check box is checked
+ //! \param theSelected a selected items
+ //! \param theDeselected a deselected items
+ void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
//! Updates visibility states by erase all in context
void onEraseAllPerformed();
- //! Exports shape to BREP file and view result file
- void onBREPDirectory();
+ //! Sets the shape item exploded
+ void onExplode();
//! Removes all shapes in tree view
void onClearView() { RemoveAllShapes(); }
- //! Load BREP file and updates tree model to have shape of the file
+ //! Loads BREP file and updates tree model to have shape of the file
void onLoadFile();
- //! View BREP files of selected items if exist
- void onBREPView();
-
- //! Remove BREP views, close views
- void onCloseAllBREPViews();
-
- //! Remove all BREP Viewse excepting active
- void onEditorDestroyed (QObject* theObject);
+ //! Views BREP files of selected items if exist
+ void onExportToBREP();
//! Convers file name to Ascii String and perform opeging file
//! \param theFileName a file name to be opened
void onOpenFile(const QString& theFileName) { OpenFile (TCollection_AsciiString (theFileName.toUtf8().data())); }
protected:
-
- //! Views file name content in a text editor. It creates new Qt free control with content.
- //! \param theFileName a file name
- void viewFile (const QString& theFileName);
-
- //! Removes all BREP files in tmp directory
- void removeBREPFiles();
-
//! Creates new action and connect it to the given slot
//! \param theText an action text
//! \param theSlot a listener method
QAction* createAction (const QString& theText, const char* theSlot);
- //! Key that uses to generate BREP file name
- //! \return string value
- static TCollection_AsciiString viewBREPPrefix() { return "ShapeView_Window"; }
-
- //! Returns newxt temporary name using BREPPrefix and pointer information
- //! \param thePointerInfo a pointer value
- //! \return string value
- TCollection_AsciiString getNextTmpName (const TCollection_AsciiString& thePointerInfo);
-
private:
QMainWindow* myMainWindow; //!< main control, parent for all ShapeView controls
+ QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
+ ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
+
View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
QTreeView* myTreeView; //!< tree view visualized shapes
- int myNextPosition; //!< delta of moving control of view BREP file
-
- QList<QWidget*> myBREPViews; //!< list of view BREP file controls
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
};
TInspector.qrc
TInspector_Communicator.cxx
TInspector_Communicator.hxx
+TInspector_OpenButton.cxx
+TInspector_OpenButton.hxx
+TInspector_OpenFileDialog.cxx
+TInspector_OpenFileDialog.hxx
+TInspector_OpenFileViewModel.cxx
+TInspector_OpenFileViewModel.hxx
TInspector_PluginParameters.cxx
TInspector_PluginParameters.hxx
TInspector_Preferences.cxx
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
- <file>icons/item_algo_folder.png</file>
- <file>icons/plugin_actions.png</file>
+ <file alias="folder_open.png">icons/folder_open.png</file>
+ <file alias="folder_import.png">icons/folder_import.png</file>
+ <file alias="plugin_actions.png">icons/plugin_actions.png</file>
</qresource>
</RCC>
const Standard_Boolean theAppend = Standard_False)
{ myWindow->Init (thePluginName, theParameters, theAppend); }
- //! UpdateContent for the TInspector window
+ //! Updates content for the TInspector window
void UpdateContent() { myWindow->UpdateContent(); }
- //! SetOpenButton for the TInspector window
+ //! Sets open button for the TInspector window
void SetOpenButton (QPushButton* theButton) { myWindow->SetOpenButton (theButton); }
- //! OpenFile in TInspector window
+ //! Opens file in TInspector window
void OpenFile (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theFileName)
{ myWindow->OpenFile (thePluginName, theFileName); }
//! \param thePluginName a name of the plugin
void Activate (const TCollection_AsciiString& thePluginName) { myWindow->ActivateTool (thePluginName); }
- //! Set item selected in the active plugin
+ //! Sets item selected in the active plugin
//! \param theItemName a containerr of name of items in plugin that should become selected
void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames) { myWindow->SetSelected (theItemNames); }
//! Sets objects to be selected in the plugin
//! \param theObjects an objects
- Standard_EXPORT void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects)
- { myWindow->SetSelected (theObjects); }
+ void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects) { myWindow->SetSelected (theObjects); }
//! Sets path to a directory for temporary plugin files
//! \param thePath a path
//! \return path
TCollection_AsciiString GetTemporaryDirectory() const { return myWindow->GetTemporaryDirectory(); }
- //! Change window visibility
+ //! Changes window visibility
//! \param theVisible boolean state
Standard_EXPORT virtual void SetVisible (const bool theVisible);
- //! Change window position
+ //! Changes window position
//! \param theX X pixel position of top left corner of the window
//! \param theY Y pixel position
Standard_EXPORT virtual void Move (const int theXPosition, const int theYPosition);
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/TInspector_OpenButton.hxx>
+
+#include <inspector/TInspector_Communicator.hxx>
+#include <inspector/TInspector_OpenFileDialog.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QDir>
+#include <QPushButton>
+#include <Standard_WarningsRestore.hxx>
+
+const int RECENT_FILES_CACHE_SIZE = 10;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspector_OpenButton::TInspector_OpenButton (QObject* theParent)
+ : QObject (theParent), myStartButton (0)
+{
+}
+
+// =======================================================================
+// function : StartButton
+// purpose :
+// =======================================================================
+QPushButton* TInspector_OpenButton::StartButton()
+{
+ if (!myStartButton)
+ {
+ myStartButton = new QPushButton();
+ myStartButton->setIcon (QIcon (":folder_open.png"));
+ connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
+ }
+ return myStartButton;
+}
+
+// =======================================================================
+// function : onStartButtonClicked
+// purpose :
+// =======================================================================
+void TInspector_OpenButton::onStartButtonClicked()
+{
+ QPushButton* aButton = (QPushButton*)sender();
+ TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
+ if (aPluginName.IsEmpty())
+ return;
+
+ QStringList aPluginRecentlyOpenedFiles;
+ if (myRecentlyOpenedFiles.contains(aPluginName))
+ {
+ QStringList aFileNames = myRecentlyOpenedFiles[aPluginName];
+ for (int i = 0; i < aFileNames.size(); i++)
+ {
+ QFileInfo aFileInfo (aFileNames[i]);
+ if (aFileInfo.exists() && aFileInfo.isFile())
+ aPluginRecentlyOpenedFiles.append(aFileInfo.absoluteFilePath());
+ }
+ }
+
+ QString aFileName = TInspector_OpenFileDialog::OpenFile (0, aPluginRecentlyOpenedFiles);
+ aFileName = QDir().toNativeSeparators (aFileName);
+ if (!aFileName.isEmpty()) {
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ TInspector_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
+
+ QFileInfo aFileInfo (aFileName);
+ if (!aPluginRecentlyOpenedFiles.contains (aFileInfo.absoluteFilePath()))
+ {
+ myRecentlyOpenedFiles[aPluginName].append (aFileInfo.absoluteFilePath());
+ for (int i = 0; i < myRecentlyOpenedFiles[aPluginName].size() - RECENT_FILES_CACHE_SIZE; i++)
+ myRecentlyOpenedFiles[aPluginName].removeFirst();
+ TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (aPluginName,
+ TInspector_OpenFileDialog::Communicator(), myRecentlyOpenedFiles[aPluginName]);
+
+ TInspector_OpenFileDialog::Communicator()->GetPluginParameters()->StorePreferences();
+ }
+
+ QApplication::restoreOverrideCursor();
+ }
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TInspectorEXE_OpenButton_H
+#define TInspectorEXE_OpenButton_H
+
+#include <TCollection_AsciiString.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QObject>
+#include <QMap>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+class QPushButton;
+
+//! \class TInspector_OpenButton
+//! Class that contains push button and the button processing. It obtains a file name from the default or current
+//! directory and gives the name into TInspector communicator
+//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
+class TInspector_OpenButton : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ Standard_EXPORT TInspector_OpenButton (QObject* theParent);
+
+ //! Destructor
+ virtual ~TInspector_OpenButton() {}
+
+ //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
+ Standard_EXPORT QPushButton* StartButton();
+
+ //! Sets the default directory of plugin.
+ void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+ const QStringList& theRecentlyOpenedFiles)
+ { myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles; }
+
+private slots:
+
+ //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
+ void onStartButtonClicked();
+
+private:
+
+ QPushButton* myStartButton; //!< processed button
+ //!< plugins recently opened files
+ QMap<TCollection_AsciiString, QStringList> myRecentlyOpenedFiles;
+};
+
+#endif
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/TInspector_OpenFileDialog.hxx>
+
+#include <inspector/TInspector_OpenButton.hxx>
+#include <inspector/TInspector_OpenFileViewModel.hxx>
+
+#include <inspector/TInspector_Communicator.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QCompleter>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileSystemModel>
+#include <QItemSelectionModel>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
+#include <QScrollBar>
+#include <QTableView>
+#include <QToolButton>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+const int FONT_POINT_SIZE = 18;
+const int ICON_SIZE = 40;
+
+const int OPEN_DIALOG_WIDTH = 550;
+const int OPEN_DIALOG_HEIGHT = 200;
+
+const int MARGIN_DIALOG = 4;
+const int SPACING_DIALOG = 2;
+
+const int RECENT_FILES_CACHE_SIZE = 10;
+
+TInspector_Communicator* MyCommunicator;
+
+// =======================================================================
+// function : changeMargins
+// purpose :
+// =======================================================================
+void changeMargins (QBoxLayout* theLayout)
+{
+ theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
+ theLayout->setSpacing (SPACING_DIALOG);
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspector_OpenFileDialog::TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
+: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
+{
+ setWindowTitle (tr ("Open File"));
+
+ QVBoxLayout* aDialogLay = new QVBoxLayout (this);
+ changeMargins (aDialogLay);
+
+ // Samples View
+ QGroupBox* aSamplesBox = new QGroupBox (this);
+ aSamplesBox->setTitle (tr ("Recent files"));
+ aDialogLay->addWidget (aSamplesBox);
+ QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
+ changeMargins (aSampleLay);
+ mySamplesView = createTableView (theRecentlyOpenedFiles);
+ aSampleLay->addWidget (mySamplesView);
+
+ // Select file
+ QGroupBox* aSelectFileBox = new QGroupBox (this);
+ aSelectFileBox->setTitle (tr ("Select file"));
+ aDialogLay->addWidget (aSelectFileBox);
+ QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
+ aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
+
+ mySelectedName = new QLineEdit (aSelectFileBox);
+ QCompleter* aCompleter = new QCompleter();
+ QFileSystemModel* aFileSystemModel = new QFileSystemModel;
+ aFileSystemModel->setRootPath (QDir::rootPath());
+ aCompleter->setModel (aFileSystemModel);
+ mySelectedName->setCompleter (aCompleter);
+ aSelectFileLay->addWidget (mySelectedName, 1, 0);
+
+ QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
+ aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
+ aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
+
+ connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
+ connect (mySelectedName, SIGNAL (returnPressed()), this, SLOT (onApplySelectClicked()));
+
+ resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+QString TInspector_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
+{
+ QString aFileName;
+ TInspector_OpenFileDialog* aDialog = new TInspector_OpenFileDialog (theParent, theRecentlyOpenedFiles);
+ if (aDialog->exec() == QDialog::Accepted)
+ aFileName = aDialog->GetFileName();
+
+ return aFileName;
+}
+
+// =======================================================================
+// function : Communicator
+// purpose :
+// =======================================================================
+TInspector_Communicator* TInspector_OpenFileDialog::Communicator()
+{
+ if (!MyCommunicator)
+ MyCommunicator = new TInspector_Communicator();
+ return MyCommunicator;
+}
+
+// =======================================================================
+// function : GetPluginRecentlyOpenedFiles
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+ TInspector_Communicator* theCommunicator,
+ QStringList& theFileNames)
+{
+ Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
+ TInspectorAPI_PreferencesDataMap aPreferencesItem;
+ aParameters->GetPreferences (thePluginName, aPreferencesItem);
+
+ for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (aPreferencesItem); anItemIt.More(); anItemIt.Next())
+ {
+ if (!anItemIt.Key().IsEqual("recently_opened_files"))
+ continue;
+ theFileNames = QString(anItemIt.Value().ToCString()).split(";", QString::SkipEmptyParts);
+ if (theFileNames.size() > RECENT_FILES_CACHE_SIZE)
+ for (int i = 0; i < theFileNames.size() - RECENT_FILES_CACHE_SIZE; i++)
+ theFileNames.removeFirst();
+ break;
+ }
+}
+
+// =======================================================================
+// function : SetPluginRecentlyOpenedFiles
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+ TInspector_Communicator* theCommunicator,
+ QStringList& theFileNames)
+{
+ Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
+
+ TInspectorAPI_PreferencesDataMap aPreferencesItem;
+ aParameters->GetPreferences (thePluginName, aPreferencesItem);
+ aPreferencesItem.Bind ("recently_opened_files", TCollection_AsciiString (theFileNames.join (";").toUtf8().data()));
+
+ aParameters->SetPreferences (thePluginName, aPreferencesItem);
+}
+
+// =======================================================================
+// function : onSampleSelectionChanged
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
+ if (!aSelectionModel)
+ return;
+ if (theSelected.isEmpty())
+ return;
+
+ QModelIndex anIndex = theSelected.first().indexes().first();
+ if (!anIndex.isValid())
+ return;
+
+ myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
+ accept();
+}
+
+// =======================================================================
+// function : onSelectClicked
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::onSelectClicked()
+{
+ QString anEnteredPath;
+ QString aDirName = mySelectedName->text();
+ if (!aDirName.isEmpty())
+ {
+ QDir aDir (aDirName);
+ if (aDir.exists())
+ anEnteredPath = aDirName;
+ }
+
+ QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
+
+ if (aFileName.isEmpty())
+ return; // do nothing, left the previous value
+
+
+ myFileName = aFileName;
+ accept();
+}
+
+// =======================================================================
+// function : onApplySelectClicked
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::onApplySelectClicked()
+{
+ QString aFileName = mySelectedName->text();
+
+ QFileInfo aFileInfo (aFileName);
+ if (!aFileInfo.exists() || !aFileInfo.isFile())
+ return;
+
+ myFileName = mySelectedName->text();
+ accept();
+}
+
+// =======================================================================
+// function : createTableView
+// purpose :
+// =======================================================================
+QTableView* TInspector_OpenFileDialog::createTableView (const QStringList& theFileNames)
+{
+ QTableView* aTableView = new QTableView (this);
+ aTableView->setFrameStyle (QFrame::NoFrame);
+ QPalette aPalette = aTableView->viewport()->palette();
+ QColor aWindowColor = aPalette.color (QPalette::Window);
+ aPalette.setBrush (QPalette::Base, aWindowColor);
+ aTableView->viewport()->setPalette (aPalette);
+
+ aTableView->horizontalHeader()->setVisible (false);
+ aTableView->verticalHeader()->setVisible (false);
+ aTableView->setGridStyle (Qt::NoPen);
+ aTableView->setModel (createModel (theFileNames));
+ aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
+ aPalette.color (QPalette::Highlight)));
+ aTableView->viewport()->setAttribute (Qt::WA_Hover);
+ int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
+ aTableView->setRowHeight (0, aCellHeight);
+ int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
+ aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ aTableView->setSelectionModel (aSelectionModel);
+
+ return aTableView;
+}
+
+// =======================================================================
+// function : createModel
+// purpose :
+// =======================================================================
+QAbstractItemModel* TInspector_OpenFileDialog::createModel (const QStringList& theFileNames)
+{
+ TInspector_OpenFileViewModel* aModel = new TInspector_OpenFileViewModel (this);
+ aModel->Init (theFileNames);
+ return aModel;
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TInspectorEXE_OpenFileDialog_H
+#define TInspectorEXE_OpenFileDialog_H
+
+#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
+
+#include <NCollection_DataMap.hxx>
+#include <NCollection_List.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QDialog>
+#include <QItemSelection>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+class TInspector_Communicator;
+
+class QAbstractItemModel;
+class QLineEdit;
+class QPushButton;
+class QTableView;
+class QToolButton;
+class QWidget;
+
+//! \class TInspector_OpenFileDialog
+//! Control that contains table view of samples and line to select a file name from other directory.
+//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
+//! the import becomes active. Click on the button will open selected file if it is possible
+class TInspector_OpenFileDialog : public QDialog
+{
+ Q_OBJECT
+private:
+
+ //! Constructor
+ Standard_EXPORT TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
+
+public:
+
+ //! Destructor
+ virtual ~TInspector_OpenFileDialog() Standard_OVERRIDE {}
+
+ //! Opens this file dialog using for samples view the given directory and try to open new file
+ //! \param theParent a parent for the new dialog
+ //! \param theDataDirName path to default samples directory
+ //! \returns a file name from the open file dialog
+ Standard_EXPORT static QString OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
+
+ //! Returns selection name from the dialog
+ QString GetFileName() const { return myFileName; }
+
+ //! Returns communicator, if this is the first call, create a communicator instance
+ Standard_EXPORT static TInspector_Communicator* Communicator();
+
+ //! Returns preferences: previous opened documents.
+ //! \param thePluginName name of the plugin
+ //! \param theCommunicator source of preferences
+ //! \param theFileNames [out] container of recently opened file names
+ Standard_EXPORT static void GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+ TInspector_Communicator* theCommunicator,
+ QStringList& theFileNames);
+
+ //! Sets preferences: previous opened documents.
+ //! \param thePluginName name of the plugin
+ //! \param theCommunicator source of preferences
+ //! \param theFileNames container of recently opened file names to be set into communicator preferences
+ Standard_EXPORT static void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+ TInspector_Communicator* theCommunicator,
+ QStringList& theFileNames);
+
+private slots:
+
+ //! Stores name of selected sample file
+ void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Opens file dialog to select a file name. Fills file name line, enable import button
+ void onSelectClicked();
+
+ //! Accepts open file dialog
+ void onApplySelectClicked();
+
+private:
+
+ //! Creates view of file names in samples directory
+ //! \param theFileNames a container of names
+ //! \return table view
+ QTableView* createTableView (const QStringList& theFileNames);
+
+ //! Creates view model and fills it by the file names
+ //! \param theFileNames a container of names
+ //! \return model
+ QAbstractItemModel* createModel (const QStringList& theFileNames);
+
+private:
+
+ QStringList myRecentlyOpenedFiles; //!< recently opened files
+ QString myFileName; //!< result file name
+ QTableView* mySamplesView; //!< view of sample file names
+ QLineEdit* mySelectedName; //!< alternative control to open file
+};
+
+#endif
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/TInspector_OpenFileViewModel.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFileInfo>
+#include <QIcon>
+#include <QPainter>
+#include <Standard_WarningsRestore.hxx>
+
+const int ICON_SIZE = 40;
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const
+{
+ // highlight cell
+ if (theOption.state & QStyle::State_MouseOver)
+ thePainter->fillRect (theOption.rect, myColor);
+
+ // action icon for all indices before the last one
+ QIcon anIcon (":folder_import.png");
+ QSize anIconSize (ICON_SIZE, ICON_SIZE);
+ int aDX = (theOption.rect.width() - anIconSize.width()) / 2;
+ int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
+ thePainter->drawPixmap (QRect (theOption.rect.left() + aDX,
+ theOption.rect.top() + aMargin,
+ anIconSize.width(),
+ anIconSize.height()),
+ anIcon.pixmap(anIconSize.width(), anIconSize.height()));
+ // default paint
+ QItemDelegate::paint (thePainter, theOption, theIndex);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TInspector_OpenFileViewModel::Init (const QStringList& theValues)
+{
+ myValues = theValues;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant TInspector_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ switch (theRole)
+ {
+ case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
+ case Qt::ToolTipRole: return myValues[theIndex.column()];
+ case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
+ default: break;
+ }
+ return QVariant();
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TInspectorEXE_OpenFileViewModel_H
+#define TInspectorEXE_OpenFileViewModel_H
+
+#include <Standard_Macro.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QItemDelegate>
+#include <Standard_WarningsRestore.hxx>
+
+class QObject;
+class QPainter;
+
+//! \class TInspectorEXE_OpenFileItemDelegate
+//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
+class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
+{
+
+public:
+
+ //! Constructor
+ TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
+ : QItemDelegate (theParent), myColor(theHighlightColor) {}
+
+ //! Destructor
+ virtual ~TInspectorEXE_OpenFileItemDelegate() {}
+
+ //! Draws an icon in the cell
+ //! \param thePainter a painter
+ //! \param theOption a paint options
+ //! \param theIndex a view index
+ virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+private:
+
+ QColor myColor; //!< highlight color
+};
+
+//! \class TInspector_OpenFileViewModel
+//! Table model that visualizes container of string values (file names)
+//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
+class TInspector_OpenFileViewModel : public QAbstractTableModel
+{
+
+public:
+
+ //! Constructor
+ TInspector_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
+
+ //! Destructor
+ virtual ~TInspector_OpenFileViewModel() {}
+
+ //! Store values
+ //! \param theValues a container of values to fill model
+ void Init (const QStringList& theValues);
+
+ //! Returns content of the model index for the given role, it is obtained from internal container of values
+ //! It returns value only for DisplayRole.
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns number of rows
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 1; }
+
+ //! Returns number of columns
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return myValues.size(); }
+
+private:
+
+ QStringList myValues; //!< file names
+};
+
+#endif
Standard_EXPORT TInspector_PluginParameters (TInspector_Window* theWindow);
//! Destructor
- virtual ~TInspector_PluginParameters() Standard_OVERRIDE {}
+ virtual ~TInspector_PluginParameters() {}
//! Stores the parameters for plugin
//! \param thePluginName a plugin name
const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
{ myPreferences->SetPreferences (thePluginName, theItem); }
- //! Store plugin preferences into a preferences file
+ //! Stores plugin preferences into a preferences file
virtual void StorePreferences() Standard_OVERRIDE { myPreferences->StorePreferences(); }
- //! Remove plugin preferences file
+ //! Removes plugin preferences file
void RemovePreferences() { myPreferences->RemovePreferences(); }
private:
void SetPreferences (const TCollection_AsciiString& thePluginName, const TInspectorAPI_PreferencesDataMap& theItem)
{ myLoadedPreferences.Bind(thePluginName, theItem); }
- //! Store plugin preferences into a preferences file
+ //! Stores plugin preferences into a preferences file
Standard_EXPORT void StorePreferences();
- //! Remove plugin preferences file
+ //! Removes plugin preferences file
Standard_EXPORT void RemovePreferences();
private:
//! Loads the directory preference file with filling internal container
void loadPreferences();
- //! clears all internal containers with information of already loaded file
+ //! Clears all internal containers with information of already loaded file
void reset() { myLoadedPreferences.Clear(); myIsLoadedPreferences = Standard_False; }
//! Reads plugin preferences and fill container
myActionsWidget = new QToolButton(aCentralWidget);
myActionsWidget->setPopupMode(QToolButton::InstantPopup);
- myActionsWidget->setIcon (QIcon (":/icons/plugin_actions.png"));
+ myActionsWidget->setIcon (QIcon (":plugin_actions.png"));
myActionsWidget->setIconSize (QSize (20, 20));
QMenu* anActionsMenu = new QMenu(myActionsWidget);
myActionsWidget->setMenu(anActionsMenu);
Standard_EXPORT TInspector_Window();
//! Destructor
- virtual ~TInspector_Window() Standard_OVERRIDE {}
+ virtual ~TInspector_Window() {}
//! Appends the plugin names into internal conainer
//! \param thePluginName a name of the plugin
//! \param thePluginName a name of the plugin
Standard_EXPORT void ActivateTool (const TCollection_AsciiString& thePluginName);
- //! Set item selected in the active plugin
+ //! Sets item selected in the active plugin
//! \param theItemNames a container of name of items in plugin that should become selected
Standard_EXPORT void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames);
//! Stores preferences (current state) of all plugins into a preferences file
Standard_EXPORT void OnStorePreferences();
- //! Remove preferences file
+ //! Removes preferences file
Standard_EXPORT void OnRemovePreferences();
protected slots:
//! Applies desktop preferences to window
void applyPreferences();
- //! Generate default temp directory by 'TEMP' or 'TMP' environment variables
+ //! Generates default temp directory by 'TEMP' or 'TMP' environment variables
//! \return generated path
TCollection_AsciiString defaultTemporaryDirectory() const;
TInspectorAPI_PluginParameters.cxx
TInspectorAPI_PluginParameters.hxx
TInspectorAPI_PreferencesDataMap.hxx
-TInspectorAPI_Version.hxx
#include <NCollection_List.hxx>
#include <Standard_Transient.hxx>
-#include <Standard_Version.hxx>
-#if OCC_VERSION_HEX > 0x060901
- #include <Standard_Handle.hxx>
-#endif
+#include <Standard_Handle.hxx>
#include <inspector/TInspectorAPI_PluginParameters.hxx>
//! The Communicator is an interface that should be implemented for a separate plugin
//! It will be placed in layout of the given parent. After the plugin is created, it is possible to
//! set container of parameters into plugin to provide the plugin's initialization by some external
//! objects(e.g. Interactive Context or OCAF Application). If the parameters are changed, it may be
-//! applyed in UpdateContent function. The communicator can change parameters in the following cases:
+//! applied in UpdateContent function. The communicator can change parameters in the following cases:
//! - the plugin removes own processed parameters (e.g. file names, that was opened by the plugin)
//! - the plugin sends some parameters to another plugin(by name) (e.g. shape to be analized)
//! (at the same time we should be careful here to do not change essential parameters of other plugins)
//! \param theParent a parent class
Standard_EXPORT virtual void SetParent (void* theParent) = 0;
- //! Provide container for actions available in inspector on general level
+ //! Provides container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
- Standard_EXPORT virtual void FillActionsMenu (void* theMenu) { (void)theMenu; }
+ virtual void FillActionsMenu (void* theMenu) { (void)theMenu; }
//! Returns plugin preferences, empty implementation by default
virtual void GetPreferences (TInspectorAPI_PreferencesDataMap&) {}
// commercial license or contractual agreement.
#include <inspector/TInspectorAPI_PluginParameters.hxx>
-#include <inspector/TInspectorAPI_Version.hxx>
-#if OCC_VERSION_HEX <= 0x060901
-IMPLEMENT_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
-#else
-IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
-#endif
// =======================================================================
// function : SetParameters
return;
anOrientationStr.Split (anOrientationStr.Length() - 1);
-#if TINSPECTORAPI_VERSION_HEX > 0x070200
TopAbs_Orientation anOrientation;
if (!TopAbs::ShapeOrientationFromString (anOrientationStr.ToCString(), anOrientation))
return;
theShape.Location (aLocation);
theShape.Orientation (anOrientation);
-#else
- (void)theValue; (void)theShape;
-#endif
}
#include <NCollection_DataMap.hxx>
#include <NCollection_List.hxx>
-#include <Standard_Version.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
-class TInspectorAPI_PluginParameters;
-DEFINE_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
-
//! The container of parameters for all possible plugins. It stores list of parameters for each plugin, even
//! it was not be loaded yet. There is a map of plugin name into plugin parameters.
//! The parameters may be:
Standard_EXPORT TInspectorAPI_PluginParameters() {}
//! Destructor
- Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() Standard_OVERRIDE {}
+ Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() {}
//! Stores the parameters for plugin
//! \param thePluginName a plugin name
Standard_EXPORT virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
const TInspectorAPI_PreferencesDataMap& theItem) = 0;
- //! Store plugin preferences into a preferences file
+ //! Stores plugin preferences into a preferences file
Standard_EXPORT virtual void StorePreferences() = 0;
//! Converts a Shape parameters excepting TShape into a string value
Standard_EXPORT static void ParametersToShape (const TCollection_AsciiString& theValue, TopoDS_Shape& theShape);
-#if OCC_VERSION_HEX <= 0x060901
- DEFINE_STANDARD_RTTI (TInspectorAPI_PluginParameters)
-#else
DEFINE_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
-#endif
private:
//! container of parameters
NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > myParameters;
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-/*======================================================================
-//
-// Purpose: Defines macros identifying current version of Inspector
-// The version is equal to current OCCT version and used to support compile compatibility
-// to previous OCCT versions interface.
-// To compile Inspector with earlier version of OCCT, change version variable here to needed OCCT version.
-//
-// TINSPECTORAPI_VERSION_MAJOR : (integer) number identifying major version
-// TINSPECTORAPI_VERSION_MINOR : (integer) number identifying minor version
-// TINSPECTORAPI_VERSION_MAINTENANCE : (integer) number identifying maintenance version
-// TINSPECTORAPI_VERSION_HEX : (hex) complete number as hex, two positions per each of major, minor, and patch number
-//
-//======================================================================*/
-
-#ifndef _TInspectorAPI_Version_HeaderFile
-#define _TInspectorAPI_Version_HeaderFile
-
-#include <Standard_Version.hxx>
-
-// Primary definitions
-#define TINSPECTORAPI_VERSION_MAJOR OCC_VERSION_MAJOR
-#define TINSPECTORAPI_VERSION_MINOR OCC_VERSION_MINOR
-#define TINSPECTORAPI_VERSION_MAINTENANCE 0//OCC_VERSION_MAINTENANCE
-
-// Derived: complete version as hex (0x0'major'0'minor'0'maintenance')
-#define TINSPECTORAPI_VERSION_HEX (TINSPECTORAPI_VERSION_MAJOR << 16 | TINSPECTORAPI_VERSION_MINOR << 8 | TINSPECTORAPI_VERSION_MAINTENANCE)
-
-#endif /* _TInspectorAPI_Version_HeaderFile */
-TKTInspector
\ No newline at end of file
+TKTInspector
+TKTInspectorAPI
+TKernel
+CSF_QT
\ No newline at end of file
TInspectorEXE.cxx
-TInspectorEXE_OpenFileDialog.cxx
-TInspectorEXE_OpenFileDialog.hxx
-TInspectorEXE_OpenFileViewModel.cxx
-TInspectorEXE_OpenFileViewModel.hxx
-TInspectorEXE.qrc
EXTERNLIB
+++ /dev/null
-TInspectorEXE
// commercial license or contractual agreement.
-#include <inspector/TInspectorEXE_OpenFileDialog.hxx>
+#include <inspector/TInspector_OpenFileDialog.hxx>
+#include <inspector/TInspector_OpenButton.hxx>
#include <inspector/TInspector_Communicator.hxx>
// purpose :
// =======================================================================
void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator,
- TInspectorEXE_OpenButton* theButtonControl)
+ TInspector_OpenButton* theButtonControl)
{
QStringList aRecentlyOpenedFiles;
- TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (theName, theCommunicator, aRecentlyOpenedFiles);
+ TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (theName, theCommunicator, aRecentlyOpenedFiles);
TCollection_AsciiString aFileName, anAdditionalFileName;
if (!aRecentlyOpenedFiles.isEmpty())
aFileName = TCollection_AsciiString (aRecentlyOpenedFiles.last().toUtf8().data());
NCollection_List<Handle(Standard_Transient)> aParameters;
// Create tool communicator
- TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator();
+ TInspector_Communicator* aCommunicator = TInspector_OpenFileDialog::Communicator();
if (!aCommunicator)
{
std::cout << "Communicator can not be created" << std::endl;
return 0;
}
- TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0);
+ TInspector_OpenButton* aButtonControl = new TInspector_OpenButton (0);
TCollection_AsciiString anActivatedPluginName;
if (aPlugins.empty())
{
+++ /dev/null
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource prefix="/">
- <file alias="folder_open.png">icons/folder_open.png</file>
- <file alias="folder_import.png">icons/folder_import.png</file>
- </qresource>
-</RCC>
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/TInspectorEXE_OpenFileDialog.hxx>
-#include <inspector/TInspectorEXE_OpenFileViewModel.hxx>
-
-#include <inspector/TInspector_Communicator.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QCompleter>
-#include <QDir>
-#include <QFileDialog>
-#include <QFileSystemModel>
-#include <QItemSelectionModel>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QLineEdit>
-#include <QScrollBar>
-#include <QTableView>
-#include <QToolButton>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-const int FONT_POINT_SIZE = 18;
-const int ICON_SIZE = 40;
-
-const int OPEN_DIALOG_WIDTH = 550;
-const int OPEN_DIALOG_HEIGHT = 200;
-
-const int MARGIN_DIALOG = 4;
-const int SPACING_DIALOG = 2;
-
-const int RECENT_FILES_CACHE_SIZE = 10;
-
-TInspector_Communicator* MyCommunicator;
-
-// =======================================================================
-// function : StartButton
-// purpose :
-// =======================================================================
-QPushButton* TInspectorEXE_OpenButton::StartButton()
-{
- if (!myStartButton)
- {
- myStartButton = new QPushButton();
- myStartButton->setIcon (QIcon (":folder_open.png"));
- connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
- }
- return myStartButton;
-}
-
-// =======================================================================
-// function : onStartButtonClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenButton::onStartButtonClicked()
-{
- QPushButton* aButton = (QPushButton*)sender();
- TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
- if (aPluginName.IsEmpty())
- return;
-
- QStringList aPluginRecentlyOpenedFiles;
- if (myRecentlyOpenedFiles.contains(aPluginName))
- {
- QStringList aFileNames = myRecentlyOpenedFiles[aPluginName];
- for (int i = 0; i < aFileNames.size(); i++)
- {
- QFileInfo aFileInfo (aFileNames[i]);
- if (aFileInfo.exists() && aFileInfo.isFile())
- aPluginRecentlyOpenedFiles.append(aFileInfo.absoluteFilePath());
- }
- }
-
- QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aPluginRecentlyOpenedFiles);
- aFileName = QDir().toNativeSeparators (aFileName);
- if (!aFileName.isEmpty()) {
- QApplication::setOverrideCursor (Qt::WaitCursor);
- TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
-
- QFileInfo aFileInfo (aFileName);
- if (!aPluginRecentlyOpenedFiles.contains (aFileInfo.absoluteFilePath()))
- {
- myRecentlyOpenedFiles[aPluginName].append (aFileInfo.absoluteFilePath());
- for (int i = 0; i < myRecentlyOpenedFiles[aPluginName].size() - RECENT_FILES_CACHE_SIZE; i++)
- myRecentlyOpenedFiles[aPluginName].removeFirst();
- TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (aPluginName,
- TInspectorEXE_OpenFileDialog::Communicator(), myRecentlyOpenedFiles[aPluginName]);
-
- TInspectorEXE_OpenFileDialog::Communicator()->GetPluginParameters()->StorePreferences();
- }
-
- QApplication::restoreOverrideCursor();
- }
-}
-
-// =======================================================================
-// function : changeMargins
-// purpose :
-// =======================================================================
-void changeMargins (QBoxLayout* theLayout)
-{
- theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
- theLayout->setSpacing (SPACING_DIALOG);
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
-: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
-{
- setWindowTitle (tr ("Open File"));
-
- QVBoxLayout* aDialogLay = new QVBoxLayout (this);
- changeMargins (aDialogLay);
-
- // Samples View
- QGroupBox* aSamplesBox = new QGroupBox (this);
- aSamplesBox->setTitle (tr ("Recent files"));
- aDialogLay->addWidget (aSamplesBox);
- QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
- changeMargins (aSampleLay);
- mySamplesView = createTableView (theRecentlyOpenedFiles);
- aSampleLay->addWidget (mySamplesView);
-
- // Select file
- QGroupBox* aSelectFileBox = new QGroupBox (this);
- aSelectFileBox->setTitle (tr ("Select file"));
- aDialogLay->addWidget (aSelectFileBox);
- QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
- aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
-
- mySelectedName = new QLineEdit (aSelectFileBox);
- QCompleter* aCompleter = new QCompleter();
- QFileSystemModel* aFileSystemModel = new QFileSystemModel;
- aFileSystemModel->setRootPath (QDir::rootPath());
- aCompleter->setModel (aFileSystemModel);
- mySelectedName->setCompleter (aCompleter);
- aSelectFileLay->addWidget (mySelectedName, 1, 0);
-
- QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
- aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
- aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
-
- connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
- connect (mySelectedName, SIGNAL (returnPressed()), this, SLOT (onApplySelectClicked()));
-
- resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
-}
-
-// =======================================================================
-// function : OpenFile
-// purpose :
-// =======================================================================
-QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
-{
- QString aFileName;
- TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog (theParent, theRecentlyOpenedFiles);
- if (aDialog->exec() == QDialog::Accepted)
- aFileName = aDialog->GetFileName();
-
- return aFileName;
-}
-
-// =======================================================================
-// function : Communicator
-// purpose :
-// =======================================================================
-TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
-{
- if (!MyCommunicator)
- MyCommunicator = new TInspector_Communicator();
- return MyCommunicator;
-}
-
-// =======================================================================
-// function : GetPluginRecentlyOpenedFiles
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
- TInspector_Communicator* theCommunicator,
- QStringList& theFileNames)
-{
- Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
- TInspectorAPI_PreferencesDataMap aPreferencesItem;
- aParameters->GetPreferences (thePluginName, aPreferencesItem);
-
- for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (aPreferencesItem); anItemIt.More(); anItemIt.Next())
- {
- if (!anItemIt.Key().IsEqual("recently_opened_files"))
- continue;
- theFileNames = QString(anItemIt.Value().ToCString()).split(";", QString::SkipEmptyParts);
- if (theFileNames.size() > RECENT_FILES_CACHE_SIZE)
- for (int i = 0; i < theFileNames.size() - RECENT_FILES_CACHE_SIZE; i++)
- theFileNames.removeFirst();
- break;
- }
-}
-
-// =======================================================================
-// function : SetPluginRecentlyOpenedFiles
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
- TInspector_Communicator* theCommunicator,
- QStringList& theFileNames)
-{
- Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
-
- TInspectorAPI_PreferencesDataMap aPreferencesItem;
- aParameters->GetPreferences (thePluginName, aPreferencesItem);
- aPreferencesItem.Bind ("recently_opened_files", TCollection_AsciiString (theFileNames.join (";").toUtf8().data()));
-
- aParameters->SetPreferences (thePluginName, aPreferencesItem);
-}
-
-// =======================================================================
-// function : onSampleSelectionChanged
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
- const QItemSelection&)
-{
- QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
- if (!aSelectionModel)
- return;
- if (theSelected.isEmpty())
- return;
-
- QModelIndex anIndex = theSelected.first().indexes().first();
- if (!anIndex.isValid())
- return;
-
- myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
- accept();
-}
-
-// =======================================================================
-// function : onSelectClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onSelectClicked()
-{
- QString anEnteredPath;
- QString aDirName = mySelectedName->text();
- if (!aDirName.isEmpty())
- {
- QDir aDir (aDirName);
- if (aDir.exists())
- anEnteredPath = aDirName;
- }
-
- QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
-
- if (aFileName.isEmpty())
- return; // do nothing, left the previous value
-
-
- myFileName = aFileName;
- accept();
-}
-
-// =======================================================================
-// function : onApplySelectClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
-{
- QString aFileName = mySelectedName->text();
-
- QFileInfo aFileInfo (aFileName);
- if (!aFileInfo.exists() || !aFileInfo.isFile())
- return;
-
- myFileName = mySelectedName->text();
- accept();
-}
-
-// =======================================================================
-// function : createTableView
-// purpose :
-// =======================================================================
-QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames)
-{
- QTableView* aTableView = new QTableView (this);
- aTableView->setFrameStyle (QFrame::NoFrame);
- QPalette aPalette = aTableView->viewport()->palette();
- QColor aWindowColor = aPalette.color (QPalette::Window);
- aPalette.setBrush (QPalette::Base, aWindowColor);
- aTableView->viewport()->setPalette (aPalette);
-
- aTableView->horizontalHeader()->setVisible (false);
- aTableView->verticalHeader()->setVisible (false);
- aTableView->setGridStyle (Qt::NoPen);
- aTableView->setModel (createModel (theFileNames));
- aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
- aPalette.color (QPalette::Highlight)));
- aTableView->viewport()->setAttribute (Qt::WA_Hover);
- int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
- aTableView->setRowHeight (0, aCellHeight);
- int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
- aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
- QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
- connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
- aTableView->setSelectionModel (aSelectionModel);
-
- return aTableView;
-}
-
-// =======================================================================
-// function : createModel
-// purpose :
-// =======================================================================
-QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames)
-{
- TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this);
- aModel->Init (theFileNames);
- return aModel;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TInspectorEXE_OpenFileDialog_H
-#define TInspectorEXE_OpenFileDialog_H
-
-#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
-
-#include <NCollection_DataMap.hxx>
-#include <NCollection_List.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QDialog>
-#include <QItemSelection>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-#include <map>
-
-class TInspector_Communicator;
-
-class QAbstractItemModel;
-class QLineEdit;
-class QPushButton;
-class QTableView;
-class QToolButton;
-class QWidget;
-
-//! \class TInspectorEXE_OpenButton
-//! Class that contains push button and the button processing. It obtains a file name from the default or current
-//! directory and gives the name into TInspector communicator
-//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
-class TInspectorEXE_OpenButton : public QObject
-{
- Q_OBJECT
-
-public:
-
- //! Constructor
- TInspectorEXE_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {}
-
- //! Destructor
- virtual ~TInspectorEXE_OpenButton() {}
-
- //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
- QPushButton* StartButton();
-
- //! Sets the default directory of plugin.
- void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
- const QStringList& theRecentlyOpenedFiles)
- { myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles; }
-
-private slots:
-
- //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
- void onStartButtonClicked();
-
-private:
-
- QPushButton* myStartButton; //!< processed button
- //!< plugins recently opened files
- QMap<TCollection_AsciiString, QStringList> myRecentlyOpenedFiles;
-};
-
-//! \class TInspectorEXE_OpenFileDialog
-//! Control that contains table view of samples and line to select a file name from other directory.
-//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
-//! the import becomes active. Click on the button will open selected file if it is possible
-class TInspectorEXE_OpenFileDialog : public QDialog
-{
- Q_OBJECT
-private:
-
- //! Constructor
- Standard_EXPORT TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
-
-public:
-
- //! Destructor
- virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {}
-
- //! Opens this file dialog using for samples view the given directory and try to open new file
- //! \param theParent a parent for the new dialog
- //! \param theDataDirName path to default samples directory
- //! \returns a file name from the open file dialog
- Standard_EXPORT static QString OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
-
- //! Returns selection name from the dialog
- QString GetFileName() const { return myFileName; }
-
- //! Returns communicator, if this is the first call, create a communicator instance
- Standard_EXPORT static TInspector_Communicator* Communicator();
-
- //! Returns preferences: previous opened documents.
- //! \param thePluginName name of the plugin
- //! \param theCommunicator source of preferences
- //! \param theFileNames [out] container of recently opened file names
- Standard_EXPORT static void GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
- TInspector_Communicator* theCommunicator,
- QStringList& theFileNames);
-
- //! Sets preferences: previous opened documents.
- //! \param thePluginName name of the plugin
- //! \param theCommunicator source of preferences
- //! \param theFileNames container of recently opened file names to be set into communicator preferences
- Standard_EXPORT static void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
- TInspector_Communicator* theCommunicator,
- QStringList& theFileNames);
-
-private slots:
-
- //! Stores name of selected sample file
- void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
- //! Open file dialog to select a file name. Fills file name line, enable import button
- void onSelectClicked();
-
- //! Accepts open file dialog
- void onApplySelectClicked();
-
-private:
-
- //! Creates view of file names in samples directory
- //! \param theFileNames a container of names
- //! \return table view
- QTableView* createTableView (const QStringList& theFileNames);
-
- //! Creates view model and fills it by the file names
- //! \param theFileNames a container of names
- //! \return model
- QAbstractItemModel* createModel (const QStringList& theFileNames);
-
-private:
-
- QStringList myRecentlyOpenedFiles; //!< recently opened files
- QString myFileName; //!< result file name
- QTableView* mySamplesView; //! <view of sample file names
- QLineEdit* mySelectedName; //!< alternative control to open file
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/TInspectorEXE_OpenFileViewModel.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFileInfo>
-#include <QIcon>
-#include <QPainter>
-#include <Standard_WarningsRestore.hxx>
-
-const int ICON_SIZE = 40;
-
-// =======================================================================
-// function : paint
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
- const QModelIndex& theIndex) const
-{
- // highlight cell
- if (theOption.state & QStyle::State_MouseOver)
- thePainter->fillRect (theOption.rect, myColor);
-
- // action icon for all indices before the last one
- QIcon anIcon (":folder_import.png");
- QSize anIconSize (ICON_SIZE, ICON_SIZE);
- int aDX = (theOption.rect.width() - anIconSize.width()) / 2;
- int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
- thePainter->drawPixmap (QRect (theOption.rect.left() + aDX,
- theOption.rect.top() + aMargin,
- anIconSize.width(),
- anIconSize.height()),
- anIcon.pixmap(anIconSize.width(), anIconSize.height()));
- // default paint
- QItemDelegate::paint (thePainter, theOption, theIndex);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
-{
- myValues = theValues;
-}
-
-// =======================================================================
-// function : data
-// purpose :
-// =======================================================================
-QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
-{
- switch (theRole)
- {
- case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
- case Qt::ToolTipRole: return myValues[theIndex.column()];
- case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
- default: break;
- }
- return QVariant();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TInspectorEXE_OpenFileViewModel_H
-#define TInspectorEXE_OpenFileViewModel_H
-
-#include <Standard_Macro.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QStringList>
-#include <QItemDelegate>
-#include <Standard_WarningsRestore.hxx>
-
-class QObject;
-class QPainter;
-
-//! \class TInspectorEXE_OpenFileItemDelegate
-//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
-class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
-{
-
-public:
-
- //! Constructor
- TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
- : QItemDelegate (theParent), myColor(theHighlightColor) {}
-
- //! Destructor
- virtual ~TInspectorEXE_OpenFileItemDelegate() {}
-
- //! Draw an icon in the cell
- //! \param thePainter a painter
- //! \param theOption a paint options
- //! \param theIndex a view index
- virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
- const QModelIndex& theIndex) const Standard_OVERRIDE;
-
-private:
-
- QColor myColor; //!< highlight color
-};
-
-//! \class TInspectorEXE_OpenFileViewModel
-//! Table model that visualizes container of string values (file names)
-//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
-class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
-{
-
-public:
-
- //! Constructor
- TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
-
- //! Destructor
- virtual ~TInspectorEXE_OpenFileViewModel() {}
-
- //! Store values
- //! \param theValues a container of values to fill model
- void Init (const QStringList& theValues);
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Returns number of rows
- //! \param theParent an index of the parent item
- //! \return an integer value
- virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 1; }
-
- //! Returns number of columns
- //! \param theParent an index of the parent item
- //! \return an integer value
- virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return myValues.size(); }
-
-private:
-
- QStringList myValues; //!< file names
-};
-
-#endif
TKTInspectorAPI
+TKernel
TKMath
TKBRep
TKGeomBase
TKG3d
TKService
TKTreeModel
+TKV3d
TKView
CSF_QT
TKG3d
TKernel
TKLCAF
-TKMath
\ No newline at end of file
+TKMath
+TKBRep
+TKTopAlgo
+TKPrim
+TKV3d
TKDCAF
TKTInspector
TKTInspectorAPI
+TKernel
TKService
TKV3d
TKViewerTest
+TKernel
+TKMath
+TKPrim
+TKTopAlgo
+TKTInspectorAPI
CSF_QT
\ No newline at end of file
TKService
TKOpenGl
TKV3d
+TKTInspectorAPI
CSF_QT
\ No newline at end of file
static TInspector_Communicator* MyCommunicator;
+// =======================================================================
+// function : Communicator
+// purpose : defines plugin library name by the command argument
+// =======================================================================
+TInspector_Communicator* ToolsDraw::Communicator()
+{
+ return MyCommunicator;
+}
+
// =======================================================================
// function : convertToPluginName
// purpose : defines plugin library name by the command argument
"\n\t\t: Plugins order will be the same as defined in arguments."
"\n\t\t: 'all' adds all available plugins in the order:"
"\n\t\t: DFBrowser, VInspector and ShapeView."
- "\n\t\t: If at the first call this option is not used, 'all' option is applyed;"
+ "\n\t\t: If at the first call this option is not used, 'all' option is applied;"
"\n\t\t: -activate activates the plugin in the tool view."
"\n\t\t: If at the first call this option is not used, the first plugin is activated;"
"\n\t\t: -shape initializes plugin/s by the shape object. If 'name' is empty, initializes all plugins;"
#include <Draw_Interpretor.hxx>
#include <Standard.hxx>
+class TInspector_Communicator;
+
//! \class ToolsDraw
//! \brief Registers DRAW commands to connect to TInspector tools
class ToolsDraw
//! \param theDI Draw interpretor
Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
- //! Add all tools command in the Draw_Interpretor
+ //! Adds all tools command in the Draw_Interpretor
//! \param theCommands
Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
+ //! Returns default communicator used in DRAW commands
+ Standard_EXPORT static TInspector_Communicator* Communicator();
+
private:
};
-TreeModel.hxx
TreeModel.qrc
TreeModel_ColumnType.hxx
TreeModel_ContextMenu.cxx
TreeModel_HeaderSection.hxx
TreeModel_ItemBase.cxx
TreeModel_ItemBase.hxx
+TreeModel_ItemProperties.cxx
+TreeModel_ItemProperties.hxx
TreeModel_ItemRole.hxx
+TreeModel_ItemStream.cxx
+TreeModel_ItemStream.hxx
TreeModel_ModelBase.cxx
TreeModel_ModelBase.hxx
TreeModel_Tools.cxx
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TREEMODEL_H
-#define TREEMODEL_H
-
-#ifdef __TreeModel_DLL
- #ifdef _WIN32
- #define TREEMODEL_EXPORT __declspec(dllexport)
- #else
- #define TREEMODEL_EXPORT
- #endif
-#else
- #ifdef _WIN32
- #define TREEMODEL_EXPORT __declspec(dllimport)
- #else
- #define TREEMODEL_EXPORT
- #endif
-#endif
-
-#endif
void onColumnVisibilityChanged();
private:
- QTreeView* myTreeView;
+ QTreeView* myTreeView; //!< current tree view
};
#endif
//! Destructor
~TreeModel_HeaderSection() {}
+ //! Returns whether the header section is not initialized with values.
+ //! The check is empty value of the name text
+ //! \return boolean value
+ bool IsEmpty() const { return myName.isEmpty(); }
+
//! Sets text value
//! \theName text value
void SetName (const QString& theName) { myName = theName; }
bool IsItalic() const { return myIsItalic; }
private:
- QString myName; //! text value
- int myWidth; //! section width
- bool myIsHidden; //! visibility
- bool myIsItalic; //! italic
+ QString myName; //!< text value
+ int myWidth; //!< section width
+ bool myIsHidden; //!< visibility
+ bool myIsItalic; //!< italic
};
#endif
// commercial license or contractual agreement.
#include <inspector/TreeModel_ItemBase.hxx>
-
+#include <inspector/TreeModel_ItemProperties.hxx>
#include <inspector/TreeModel_ItemRole.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
+#include <Standard_Dump.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
// purpose :
// =======================================================================
TreeModel_ItemBase::TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : m_bInitialized (false)
+ : m_iStreamChildren (0), m_bInitialized (false)
{
m_pParent = theParent;
m_iRow = theRow;
}
// =======================================================================
-// function : reset
+// function : Reset
// purpose :
// =======================================================================
void TreeModel_ItemBase::Reset()
anItem->Reset();
}
m_bInitialized = false;
+ if (!myProperties.IsNull())
+ {
+ myProperties->Reset();
+ }
myCachedValues.clear();
+ myStream.str ("");
}
// =======================================================================
// =======================================================================
void TreeModel_ItemBase::Reset (int theRole)
{
- if (!myCachedValues.contains (theRole))
+ if (!myCachedValues.contains (theRole))
return;
myCachedValues.remove (theRole);
TreeModel_ItemBasePtr anItem;
if (isToCreate) {
- anItem = createChild (theRow, theColumn);
+ if (theRow < m_iStreamChildren)
+ anItem = TreeModel_ItemStream::CreateItem (currentItem(), theRow, theColumn);
+ else
+ anItem = createChild (theRow - m_iStreamChildren, theColumn);
+
if (anItem)
m_ChildItems[aPos] = anItem;
}
if (myCachedValues.contains (theItemRole))
return myCachedValues[theItemRole];
- const_cast<TreeModel_ItemBase*>(this)->myCachedValues.insert (theItemRole,
- theItemRole == TreeModel_ItemRole_RowCountRole ? QVariant (initRowCount()) : initValue (theItemRole));
+ QVariant aValueToCache;
+ if (theItemRole == TreeModel_ItemRole_RowCountRole)
+ aValueToCache = initRowCount() + const_cast<TreeModel_ItemBase*>(this)->initStreamRowCount();
+ else
+ aValueToCache = initValue (theItemRole);
+ myCachedValues.insert (theItemRole, aValueToCache);
return myCachedValues.contains (theItemRole) ? myCachedValues[theItemRole] : QVariant();
}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TreeModel_ItemBase::Init()
+{
+ m_bInitialized = true;
+
+ initStream(myStream);
+ initStreamRowCount();
+}
+
+// =======================================================================
+// function : Object
+// purpose :
+// =======================================================================
+const Handle(Standard_Transient)& TreeModel_ItemBase::Object() const
+{
+ static Handle(Standard_Transient) aNullObject;
+ return aNullObject;
+}
+
+// =======================================================================
+// function : initStreamRowCount
+// purpose :
+// =======================================================================
+int TreeModel_ItemBase::initStreamRowCount()
+{
+ int aStreamChildrenCount = 0;
+ if (Column() == 0)
+ {
+ Standard_SStream aStream;
+ initStream (aStream);
+ if (!Standard_Dump::Text (aStream).IsEmpty())
+ {
+ if (!myProperties)
+ {
+ myProperties = new TreeModel_ItemProperties();
+ myProperties->SetItem (currentItem());
+ }
+ myProperties->Init();
+ aStreamChildrenCount = myProperties->Children().Extent();
+ }
+ }
+ m_iStreamChildren = aStreamChildrenCount;
+ return m_iStreamChildren;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant TreeModel_ItemBase::initValue (const int theItemRole) const
+{
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 1: { return Row(); }
+ }
+
+ return QVariant();
+}
#include <Standard.hxx>
#include <Standard_Macro.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_OStream.hxx>
+#include <Standard_SStream.hxx>
+
#include <inspector/TreeModel_ItemRole.hxx>
#include <Standard_WarningsDisable.hxx>
#include <Standard_WarningsRestore.hxx>
class TreeModel_ItemBase;
+class TreeModel_ItemProperties;
typedef QExplicitlySharedDataPointer<TreeModel_ItemBase> TreeModel_ItemBasePtr;
//! Sets the item internal initialized state to the true. If the item has internal values,
//! there should be initialized here.
- virtual void Init() { m_bInitialized = true; }
+ Standard_EXPORT virtual void Init();
+
+ //! Returns data object of the item.
+ //! \return object
+ Standard_EXPORT virtual const Handle(Standard_Transient)& Object() const;
//! Resets the item and the child items content. Sets the initialized state to false.
//! If the item has internal values, there should be reseted here.
//! \param theRole an item role
Standard_EXPORT virtual void Reset(int theRole);
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ const Standard_SStream& Stream() const { return myStream; }
+
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos,
+ Standard_Integer& theLastPos) const
+ { (void)theSStream; (void)theStartPos; (void)theLastPos; return false; }
+
//! Gets the parent of the item, or TreeModel_ItemBasePtr() if it has no parent.
//! \return pointer to the item
TreeModel_ItemBasePtr Parent() const { return m_pParent; };
//! Sets a custom value for the role in an internal cache
//! \param theValue a value
//! \param theRole a value role
- void SetCustomData(const QVariant theValue, int theRole) { myCachedValues.insert (theRole, theValue); }
+ void SetCustomData(const QVariant& theValue, int theRole) { myCachedValues.insert (theRole, theValue); }
//! Returns the data stored under the given role for the current item
//! \param theIndex the item model index
//! \return the row count
int rowCount() const { return cachedValue(TreeModel_ItemRole_RowCountRole).toInt(); }
+ //! Returns the item properties
+ const Handle(TreeModel_ItemProperties)& Properties() const { return myProperties; }
+
protected:
//! \param theParent the parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
Standard_EXPORT TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+ //! Initializes the current item. It creates a backup of the specific item information
+ virtual void initItem() const {}
+
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) = 0;
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn)
+ { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
//! Wraps the currrent item by shared pointer
//! \return the shared pointer to the current item
//! \return number of children. It should be reimplemented in child
virtual int initRowCount() const = 0;
- //! Return data value for the role. It should be reimplemented in child
+ //! \return number of children. It should be reimplemented in child
+ Standard_EXPORT int initStreamRowCount();
+
+ //! Returns data value for the role. It should be reimplemented in child
//! \param theItemRole a value role
//! \return the value
- virtual QVariant initValue (const int theItemRole) const = 0;
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const;
+
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ virtual void initStream (Standard_OStream& theOStream) const { (void)theOStream; }
+
+protected:
+ Handle(TreeModel_ItemProperties) myProperties; //!< the properties
+ int m_iStreamChildren; //!< the count of stream items
+ Standard_SStream myStream; //!< stream value
private:
typedef QHash< QPair<int, int>, TreeModel_ItemBasePtr > PositionToItemHash;
PositionToItemHash m_ChildItems; //!< the hash of item children
- QMap<int, QVariant> myCachedValues; //!< cached values, should be cleared by reset
+ mutable QMap<int, QVariant> myCachedValues; //!< cached values, should be cleared by reset
TreeModel_ItemBasePtr m_pParent; //!< the parent item
int m_iRow; //!< the item row position in the parent item
int m_iColumn; //!< the item column position in the parent item
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
+#include <inspector/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <gp_XYZ.hxx>
+#include <Standard_Dump.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient)
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::Init ()
+{
+ myRowValues.Clear();
+
+ const Standard_SStream& aStream = Item()->Stream();
+
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aValues;
+ TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream);
+ Standard_Dump::SplitJson (aStreamText, aValues);
+
+ TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(Item());
+ TCollection_AsciiString aKey;
+ Standard_DumpValue aKeyValue;
+ if (!aStreamParent)
+ {
+ const Handle(Standard_Transient)& anItemObject = Item()->Object();
+ aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name();
+ aKeyValue = Standard_DumpValue (aStreamText, 1);
+
+ myKey = aKey;
+ myStreamValue = aKeyValue;
+ }
+ else
+ {
+ TCollection_AsciiString aValue;
+ if (Item()->Parent())
+ {
+ const Handle(TreeModel_ItemProperties)& aParentProperties = Item()->Parent()->Properties();
+ if (aParentProperties)
+ aParentProperties->ChildStream (Item()->Row(), aKey, aKeyValue);
+ }
+ myKey = aKey;
+ myStreamValue = aKeyValue;
+
+ aValues.Clear();
+ Standard_Dump::SplitJson (myStreamValue.myValue, aValues);
+ }
+
+ for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++)
+ {
+ Standard_DumpValue aValue = aValues.FindFromIndex (anIndex);
+ if (Standard_Dump::HasChildKey (aValue.myValue))
+ myChildren.Add (aValues.FindKey (anIndex), aValue);
+ else
+ {
+ TreeModel_RowValue aRowValue (aValue.myStartPosition, aValues.FindKey (anIndex).ToCString(), aValue.myValue.ToCString());
+ myRowValues.Add (myRowValues.Size() + 1, aRowValue);
+ }
+ }
+ if (myRowValues.Size() == 1)
+ {
+ Quantity_Color aColor;
+ if (Convert_Tools::ConvertStreamToColor (aStream, aColor))
+ {
+ Standard_Real aRed, aGreen, aBlue;
+ aColor.Values (aRed, aGreen, aBlue, Quantity_TOC_RGB);
+
+ int aDelta = 255;
+ myRowValues.ChangeFromIndex (1).CustomValues.insert ((int)Qt::BackgroundRole, QColor((int)(aRed * aDelta),
+ (int)(aGreen * aDelta), (int)(aBlue * aDelta)));
+ }
+ }
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::Reset()
+{
+ myKey = "";
+ myStreamValue = Standard_DumpValue();
+
+ myChildren.Clear();
+ myRowValues.Clear();
+}
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+int TreeModel_ItemProperties::RowCount() const
+{
+ return RowValues().Size();
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn, int theRole) const
+{
+ if (theColumn == 1 && theRole == Qt::BackgroundRole)
+ {
+ const QMap<int, QVariant>& aCachedValues = RowValues().FindFromIndex (theRow + 1).CustomValues;
+ if (aCachedValues.contains ((int)theRole))
+ return aCachedValues[(int)theRole];
+ }
+
+ if (theRole == Qt::FontRole) // method name is in italic
+ {
+ if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
+ {
+ QFont aFont = qApp->font();
+ aFont.setItalic (true);
+ return aFont;
+ }
+ }
+ if (theRole == Qt::ForegroundRole)
+ {
+ if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
+ return QColor (Qt::darkGray).darker(150);
+ }
+
+ if (theRole == Qt::DisplayRole || theRole == Qt::ToolTipRole)
+ {
+ if (theColumn == 0) return RowValues().FindFromIndex (theRow + 1).Key;
+ else if (theColumn == 1) return RowValues().FindFromIndex (theRow + 1).Value;
+ }
+
+ return QVariant();
+}
+
+// =======================================================================
+// function : EditType
+// purpose :
+// =======================================================================
+ViewControl_EditType TreeModel_ItemProperties::EditType (const int, const int theColumn) const
+{
+ if (theColumn == 0)
+ return ViewControl_EditType_None;
+
+ return ViewControl_EditType_Line;
+}
+
+// =======================================================================
+// function : SetData
+// purpose :
+// =======================================================================
+bool TreeModel_ItemProperties::SetData (const int /*theRow*/, const int theColumn, const QVariant& /*theValue*/, int)
+{
+ if (theColumn == 0)
+ return false;
+ return false;
+}
+
+// =======================================================================
+// function : Presentations
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
+{
+ const Standard_SStream& aStream = Item()->Stream();
+ Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations);
+}
+
+// =======================================================================
+// function : TableFlags
+// purpose :
+// =======================================================================
+Qt::ItemFlags TreeModel_ItemProperties::TableFlags (const int, const int theColumn) const
+{
+ Qt::ItemFlags aFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+
+ if (theColumn == 1)
+ aFlags = aFlags | Qt::ItemIsEditable;
+
+ return aFlags;
+}
+
+// =======================================================================
+// function : ChildStream
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::ChildStream (const int theRowId,
+ TCollection_AsciiString& theKey,
+ Standard_DumpValue& theValue) const
+{
+ if (myChildren.Size() <= theRowId)
+ return;
+
+ theKey = myChildren.FindKey (theRowId + 1);
+ theValue = myChildren.FindFromIndex (theRowId + 1);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::initItem() const
+{
+ if (!Item())
+ return;
+ if (Item()->IsInitialized())
+ return;
+ Item()->Init();
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TreeModel_ItemProperties_H
+#define TreeModel_ItemProperties_H
+
+#include <Standard.hxx>
+#include <Standard_Dump.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+
+#include <NCollection_IndexedDataMap.hxx>
+#include <NCollection_IndexedMap.hxx>
+#include <NCollection_List.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
+#include <inspector/ViewControl_EditType.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class TreeModel_ItemProperties
+//! Class to manipulate properties of tree item. The properties are organized in table structure
+class TreeModel_ItemProperties : public Standard_Transient
+{
+ //! enum defined the dimension type
+ enum TreeModel_DimType
+ {
+ TreeModel_DimType_Rows, //!< defines number of rows
+ TreeModel_DimType_Columns //!< defines number of columns
+ };
+
+ //! container of values in a row of property table
+ struct TreeModel_RowValue
+ {
+ TreeModel_RowValue (const Standard_Integer theValueStartPosition, const QVariant& theKey, QVariant theValue)
+ : ValueStartPosition (theValueStartPosition), Key (theKey), Value (theValue) {}
+
+ Standard_Integer ValueStartPosition; //!< start position of the key
+ QVariant Key; //!< value in the first column
+ QVariant Value; //!< value in the second column
+ QMap<int, QVariant> CustomValues; //!< custom values, e.g. key is Background, value is a defined color
+ };
+
+public:
+ //! Constructor
+ TreeModel_ItemProperties() {}
+
+ //! Destructor
+ ~TreeModel_ItemProperties() {}
+
+ //! Sets the current item
+ void SetItem (const TreeModel_ItemBasePtr& theItem) { myItem = theItem; }
+
+ //! Returns the current item
+ TreeModel_ItemBasePtr Item() const { return myItem; }
+
+ //! Fills internal containers by item stream values
+ Standard_EXPORT void Init();
+
+ //! If the item has internal values, there should be reseted here.
+ Standard_EXPORT virtual void Reset();
+
+ //! Returns number of table rows
+ //! \return an integer value
+ Standard_EXPORT int RowCount() const;
+
+ //! Returns number of table columns
+ //! \return an integer value
+ int ColumnCount() const { return 2; }
+
+ //! Returns content of the model index for the given role, it is obtained from internal container of values
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \param theRole a view role
+ //! \return value interpreted depending on the given role
+ Standard_EXPORT QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const;
+
+ //! Returns type of edit control for the model index. By default, it is an empty control
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \return edit type
+ Standard_EXPORT ViewControl_EditType EditType (const int theRow, const int theColumn) const;
+
+ //! Sets content of the model index for the given role, it is applied to internal container of values
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \param theRole a view role
+ //! \return true if the value is changed
+ Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
+ int theRole = Qt::DisplayRole);
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \thePresentations [out] container of presentation handles to be visualized
+ Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
+
+ //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable.
+ //! Additional flag for the column 1 is Qt::ItemIsEditable.
+ //! \param theIndex a model index
+ //! \return flags
+ Standard_EXPORT virtual Qt::ItemFlags TableFlags (const int theRow, const int theColumn) const;
+
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ Standard_EXPORT void ChildStream (const int theRowId,
+ TCollection_AsciiString& theKey,
+ Standard_DumpValue& theValue) const;
+
+ //! Returns data object of the item.
+ //! \return object key
+ const TCollection_AsciiString& Key() const { return myKey; }
+
+ //! Returns stream value of the item.
+ //! \return value
+ const TCollection_AsciiString& StreamValue() const { return myStreamValue.myValue; }
+
+ //! Returns children stream values
+ //const NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& Values() const { initItem(); return myValues; }
+
+ //! Returns children stream values
+ const NCollection_IndexedDataMap<Standard_Integer, TreeModel_RowValue>& RowValues() const { initItem(); return myRowValues; }
+
+ //! Returns children stream values
+ const NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& Children() const { initItem(); return myChildren; }
+
+ DEFINE_STANDARD_RTTIEXT (TreeModel_ItemProperties, Standard_Transient)
+
+protected:
+ //! Initializes the current item. It creates a backup of the specific item information
+ Standard_EXPORT void initItem() const;
+
+private:
+ TreeModel_ItemBasePtr myItem; //!< current item
+
+ TCollection_AsciiString myKey; //!< the item key
+ Standard_DumpValue myStreamValue; //!< the stream value
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> myChildren; //!< the children
+ NCollection_IndexedDataMap<Standard_Integer, TreeModel_RowValue> myRowValues; //!< the values
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/TreeModel_ItemStream.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+
+#include <Standard_Dump.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TreeModel_ItemStream::TreeModel_ItemStream (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : TreeModel_ItemBase (theParent, theRow, theColumn)
+{
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::Init()
+{
+ TreeModel_ItemBase::Init();
+
+ int aStreamChildrenCount = 0;
+ if (Column() == 0)
+ {
+ if (!myProperties)
+ {
+ myProperties = new TreeModel_ItemProperties();
+ myProperties->SetItem (currentItem());
+ }
+ myProperties->Init();
+ aStreamChildrenCount = myProperties->Children().Extent();
+ }
+ m_iStreamChildren = aStreamChildrenCount;
+ initStream (myStream);
+}
+
+// =======================================================================
+// function : Rest
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::Reset()
+{
+ myStream.str ("");
+ TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant TreeModel_ItemStream::initValue (const int theItemRole) const
+{
+ QVariant aParentValue = TreeModel_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
+ if (Column() != 0)
+ return QVariant();
+
+ if (theItemRole == Qt::ForegroundRole)
+ return QColor (Qt::darkBlue);
+
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 0: return Properties() ? Properties()->Key().ToCString() : "";
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::initStream (Standard_OStream& theOStream) const
+{
+ if (!Properties())
+ return;
+
+ theOStream << Properties()->StreamValue();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<TreeModel_ItemStream*>(this)->Init();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr TreeModel_ItemStream::createChild (int theRow, int theColumn)
+{
+ return TreeModel_ItemStream::CreateItem (currentItem(), theRow, theColumn);
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TreeModel_ItemStream_H
+#define TreeModel_ItemStream_H
+
+#include <Standard.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
+
+class TreeModel_ItemProperties;
+class TreeModel_ItemStream;
+
+typedef QExplicitlySharedDataPointer<TreeModel_ItemStream> TreeModel_ItemStreamPtr;
+
+//! \class TreeModel_ItemStream
+//! Parent item, that corresponds to AIS_InteractiveContext
+//! Children of the item are:
+//! - "Property" item to show context attributes such as selection filters and drawer properties
+//! - presentation items to show all interactive elements displayed/erased in the context
+class TreeModel_ItemStream : public TreeModel_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static TreeModel_ItemStreamPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return TreeModel_ItemStreamPtr (new TreeModel_ItemStream (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~TreeModel_ItemStream() {}
+
+ //! Sets the item internal initialized state to the true. If the item has internal values,
+ //! there should be initialized here.
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets the item and the child items content. Sets the initialized state to false.
+ //! If the item has internal values, there should be reseted here.
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns number of displayed presentations
+ //! \return rows count
+ virtual int initRowCount() const Standard_OVERRIDE { initItem(); return 0; }
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const;
+
+ //! Initializes the current item. It creates a backup of the specific item information
+ //! Does nothing as context has been already set into item
+ Standard_EXPORT virtual void initItem() const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ Standard_EXPORT virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! \param theParent a parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
+ Standard_EXPORT TreeModel_ItemStream(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+};
+
+#endif
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/TreeModel_VisibilityState.hxx>
+#include <Standard_Transient.hxx>
+
#include <Standard_WarningsDisable.hxx>
#include <QIcon>
#include <Standard_WarningsRestore.hxx>
+const int COLUMN_NAME_WIDTH = 260;
+const int COLUMN_SIZE_WIDTH = 30;
+
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
-: QAbstractItemModel (theParent), m_pRootItem (0), m_pUseVisibilityColumn (false),
+: QAbstractItemModel (theParent), m_pUseVisibilityColumn (false),
myVisibilityState (0)
{
+ myVisibleIcon = QIcon (":/icons/item_visible.png");
+ myInvisibleIcon = QIcon (":/icons/item_invisible.png");
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::InitColumns()
+{
+ SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+ SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
+ SetHeaderItem (2, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
}
// =======================================================================
if (!myVisibilityState || !myVisibilityState->CanBeVisible (theIndex))
return QVariant();
- QVariant aValue = QIcon (myVisibilityState->IsVisible (theIndex) ? ":/icons/item_visible.png"
- : ":/icons/item_invisible.png");
+ QVariant aValue = myVisibilityState->IsVisible (theIndex) ? myVisibleIcon : myInvisibleIcon;
anItem->SetCustomData (aValue, theRole);
return aValue;
}
TreeModel_ItemBasePtr anItem = GetItemByIndex (theIndex);
- return anItem->data (theIndex, theRole);
+ QVariant anItemData = anItem->data (theIndex, theRole);
+
+ if (anItemData.isNull() && theRole == Qt::BackgroundRole && myHighlightedIndices.contains (theIndex))
+ anItemData = TreeModel_Tools::LightHighlightColor();
+
+ return anItemData;
}
// =======================================================================
else
aParentItem = GetItemByIndex (theParent);
+ if (!aParentItem)
+ return 0;
+
return aParentItem ? aParentItem->rowCount() : 0;
}
}
// =======================================================================
-// function : SingleSelected
+// function : SetHeaderItem
// purpose :
// =======================================================================
-QModelIndex TreeModel_ModelBase::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
- const Qt::Orientation theOrientation)
+void TreeModel_ModelBase::SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
+{
+ if (theSection.IsEmpty())
+ {
+ // remove section
+ myHeaderValues.remove (theColumnId);
+ myRootItems.remove (theColumnId);
+ }
+
+ myHeaderValues[theColumnId] = theSection;
+ createRoot (theColumnId);
+}
+
+// =======================================================================
+// function : Selected
+// purpose :
+// =======================================================================
+QModelIndexList TreeModel_ModelBase::Selected (const QModelIndexList& theIndices, const int theCellId,
+ const Qt::Orientation theOrientation)
{
- QModelIndexList aFirstColumnSelectedIndices;
+ QModelIndexList aSelected;
for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
{
QModelIndex anIndex = *anIndicesIt;
if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
(theOrientation == Qt::Vertical && anIndex.row() == theCellId))
- aFirstColumnSelectedIndices.append (anIndex);
+ aSelected.append (anIndex);
}
- return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
+ return aSelected;
+}
+
+// =======================================================================
+// function : SingleSelected
+// purpose :
+// =======================================================================
+QModelIndex TreeModel_ModelBase::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
+ const Qt::Orientation theOrientation)
+{
+ QModelIndexList aSelected = Selected (theIndices, theCellId, theOrientation);
+ return aSelected.size() == 1 ? aSelected.first() : QModelIndex();
+}
+
+// =======================================================================
+// function : SelectedItems
+// purpose :
+// =======================================================================
+QList<TreeModel_ItemBasePtr> TreeModel_ModelBase::SelectedItems (const QModelIndexList& theIndices)
+{
+ QList<TreeModel_ItemBasePtr> anItems;
+
+ for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
+ {
+ TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
+ if (!anItem || anItems.contains (anItem))
+ continue;
+ anItems.append (anItem);
+ }
+ return anItems;
+}
+
+// =======================================================================
+// function : createRoot
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::createRoot (const int theColumnId)
+{
+ myRootItems.insert (theColumnId, createRootItem (theColumnId));
}
// =======================================================================
#include <inspector/TreeModel_ItemBase.hxx>
#include <inspector/TreeModel_HeaderSection.hxx>
+#include <NCollection_List.hxx>
+
#include <Standard_WarningsDisable.hxx>
#include <QAbstractItemModel>
#include <QExplicitlySharedDataPointer>
//! Destructor
virtual ~TreeModel_ModelBase() {}
+ //! Creates model columns and root items.
+ //! Default columns are: [0] - Name, [1] - Visibility, [2] - Row
+ Standard_EXPORT virtual void InitColumns();
+
//! Returns the item shared pointer by the model index
//! if it is in the index internal pointer
//! @param theIndex a model index
//! Returns the model root item.
//! It is realized for OCAFBrowser
- virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const { (void)theColumn; return m_pRootItem; }
+ TreeModel_ItemBasePtr RootItem (const int theColumn) const { return myRootItems[theColumn]; }
//! Emits the layoutChanged signal from outside of this class
Standard_EXPORT void EmitLayoutChanged();
//! \param theState state
bool IsUseVisibilityColumn() const { return m_pUseVisibilityColumn; }
- //!< Fills visibility state checker
- //!< \param theController the checker interface
+ //! Fills visibility state checker
+ //! \param theController the checker interface
void SetVisibilityState (TreeModel_VisibilityState* theController) { myVisibilityState = theController; }
- //!< Returns visibility state checker
- //!< \return the checker interface
+ //! Returns visibility state checker
+ //! \return the checker interface
TreeModel_VisibilityState* GetVisibilityState () const { return myVisibilityState; }
+ //! Returns true if the tree view model contains highlighted items. This highlight is set manually.
+ bool HasHighlighted() { return !myHighlightedIndices.isEmpty(); }
+
+ //! Sets items of the indices highlighted in the model.
+ //! \param theIndices a list of tree model indices
+ void SetHighlighted (const QModelIndexList& theIndices = QModelIndexList()) { myHighlightedIndices = theIndices; }
+
//! Returns the index of the item in the model specified by the given row, column and parent index.
//! Saves an internal pointer at the createIndex. This pointer is a shared pointer to the class,
//! that realizes a base item interface. If the parent is invalid, a root item is used, otherwise a new item
//! \return header section values container
TreeModel_HeaderSection GetHeaderItem (const int theColumnId) const { return myHeaderValues[theColumnId]; }
- //! Set header properties item.
+ //! Sets header properties item.
//! \param theColumnId a column index
//! \param theSection a section value
- void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
- { myHeaderValues[theColumnId] = theSection; createRootItem (theColumnId); }
+ Standard_EXPORT void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
//! Returns count of columns in the model
//! \param theParent an index of the parent item
//! \return integer value
static int ColumnVisibilityWidth() { return 20; }
+ //! Returns selected items in the cell of given orientation.
+ //! \param theIndices a container of selected indices
+ //! \param theCellId column index if orientation is horizontal, row index otherwise
+ //! \param theOrientation an orientation to apply the cell index
+ //! \return model indices from the list
+ Standard_EXPORT static QModelIndexList Selected (const QModelIndexList& theIndices, const int theCellId,
+ const Qt::Orientation theOrientation = Qt::Horizontal);
+
//! Returns single selected item in the cell of given orientation. If the orientation is Horizontal,
//! in the cell id colum, one row should be selected.
//! \param theIndices a container of selected indices
Standard_EXPORT static QModelIndex SingleSelected (const QModelIndexList& theIndices, const int theCellId,
const Qt::Orientation theOrientation = Qt::Horizontal);
+ //! Returns selected tree model items for indices.
+ //! \param theIndices a container of selected indices
+ //! \return model items from the list
+ Standard_EXPORT static QList<TreeModel_ItemBasePtr> SelectedItems (const QModelIndexList& theIndices);
+
protected:
//! Creates root item
//! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId) = 0;
+ virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) = 0;
//! Converts the item shared pointer to void* type
//! \param theItem
//! \return an item pointer
Standard_EXPORT static void* getIndexValue (const TreeModel_ItemBasePtr& theItem);
+private:
+ //! Creates root item
+ //! \param theColumnId index of a column
+ Standard_EXPORT void createRoot (const int theColumnId);
+
protected:
- TreeModel_ItemBasePtr m_pRootItem; //!< the model root item. It should be created in the
+ QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
QMap<int, TreeModel_HeaderSection> myHeaderValues; //!< header values
//!< model subclass. The model is fulfilled by this item content
bool m_pUseVisibilityColumn; //!< the state whether column=0 is reserved for Visibility state
TreeModel_VisibilityState* myVisibilityState; //!< the interface of item visibility
+ QIcon myVisibleIcon; //!< icon of visible state
+ QIcon myInvisibleIcon; //!< icon of invisible state
+
+ QModelIndexList myHighlightedIndices; //!< tree model indices that should be visualized as highlighted
};
#endif
TreeModel_ModelBase* aModel = dynamic_cast<TreeModel_ModelBase*> (theTreeView->model());
aModel->SetHeaderItem (TreeModel_ColumnType_Visibility,
TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
-
- TreeModel_VisibilityState* aVisibilityState = aModel->GetVisibilityState ();
-
- aModel->SetUseVisibilityColumn (true);
- if (theActive && aVisibilityState)
- QObject::connect (theTreeView, SIGNAL (clicked (const QModelIndex&)),
- aVisibilityState, SLOT (OnClicked(const QModelIndex&)));
+ aModel->SetUseVisibilityColumn (theActive);
}
// =======================================================================
return aLength < theText.length() ? theText.mid (0, aLength) + theTail : theText;
}
+
+// =======================================================================
+// function : LightHighlightColor
+// purpose :
+// =======================================================================
+QColor TreeModel_Tools::LightHighlightColor()
+{
+ QWidget aWidget;
+ QPalette aPalette = aWidget.palette();
+ return aPalette.highlight().color().lighter();
+}
+
+// =======================================================================
+// function : SetExpandedTo
+// purpose :
+// =======================================================================
+void TreeModel_Tools::SetExpandedTo (QTreeView* theTreeView, const QModelIndex& theIndex)
+{
+ QAbstractItemModel* aModel = theTreeView->model();
+
+ QModelIndex aParent = aModel->parent (theIndex);
+ while (aParent.isValid())
+ {
+ theTreeView->setExpanded (aParent, true);
+ aParent = aModel->parent (aParent);
+ }
+}
+
+// =======================================================================
+// function : setExpanded
+// purpose :
+// =======================================================================
+void TreeModel_Tools::SetExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
+ int& theLevels)
+{
+ bool isToExpand = theLevels == -1 || theLevels > 0;
+ if (!isToExpand)
+ return;
+
+ theTreeView->setExpanded (theIndex, isExpanded);
+ if (theLevels != -1)
+ theLevels--;
+
+ QAbstractItemModel* aModel = theTreeView->model();
+ for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
+ {
+ int aLevels = theLevels;
+ SetExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
+ }
+}
#include <Standard_WarningsDisable.hxx>
#include <QApplication>
#include <QByteArray>
+#include <QColor>
#include <QMap>
+#include <QModelIndex>
#include <QString>
#include <QStyle>
#include <Standard_WarningsRestore.hxx>
//! Returns header margin, defined in style settings of application
//! \return integer value
- Standard_EXPORT static int HeaderSectionMargin() { return qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); }
+ static int HeaderSectionMargin() { return qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); }
- //! Save state of three view in a container in form: key, value. It saves:
- //! - visibiblity of columns,
+ //! Saves state of tree view in a container in form: key, value. It saves:
+ //! - visibility of columns,
//! - columns width
//! \param theTreeView a view instance
//! \param theItems [out] properties
//! \param thePrefix peference item prefix
Standard_EXPORT static void SaveState (QTreeView* theTreeView, QMap<QString, QString>& theItems,
const QString& thePrefix = QString());
- //! Restore state of three view by a container
+
+ //! Restores state of tree view by a container
//! \param theTreeView a view instance
//! \param theKey property key
//! \param theValue property value
//! \param thePrefix peference item prefix
- //! \return boolean value whether the property is applyed to the tree view
+ //! \return boolean value whether the property is applied to the tree view
Standard_EXPORT static bool RestoreState (QTreeView* theTreeView, const QString& theKey, const QString& theValue,
const QString& thePrefix = QString());
//! \param theWidth width value, if -1, default value is used
//! \param theTail symbols added to the end of the cut string
Standard_EXPORT static QString CutString (const QString& theText, const int theWidth = -1, const QString& theTail = "...");
+
+ //! Returns light highlight color
+ //! \returns Qt color
+ Standard_EXPORT static QColor LightHighlightColor();
+
+ //! Makes the view expanded from the root till the index
+ Standard_EXPORT static void SetExpandedTo (QTreeView* theTreeView, const QModelIndex& theIndex);
+
+ //! Expands items in tree view staring from the index recursive in given number of levels
+ //! \param theTreeView an OCAF tree view
+ //! \param theParentIndex an index which children should be expanded
+ //! \param isExpanded a boolean state if the item should be expanded or collapsed
+ //! \param theLevels a number of levels to be expanded, or -1 for all levels
+ Standard_EXPORT static void SetExpanded (QTreeView* theTreeView,
+ const QModelIndex& theIndex,
+ const bool isExpanded,
+ int& theLevels);
+
};
#endif
// function : OnClicked
// purpose :
// =======================================================================
-void TreeModel_VisibilityState::OnClicked (const QModelIndex& theIndex)
+bool TreeModel_VisibilityState::processClicked (const QModelIndex& theIndex)
{
if (theIndex.column() != TreeModel_ColumnType_Visibility)
- return;
+ return false;
if (!CanBeVisible (theIndex))
- return;
+ return false;
SetVisible (theIndex, !IsVisible (theIndex), true);
- emit itemClicked (theIndex);
+ return true;
}
#ifndef TreeModel_VisibilityState_H
#define TreeModel_VisibilityState_H
-#include <inspector/TreeModel.hxx>
#include <inspector/TreeModel_ModelBase.hxx>
#include <inspector/TreeModel_ColumnType.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
-#include <Standard_WarningsDisable.hxx>
-#include <QObject>
-#include <QString>
-#include <Standard_WarningsRestore.hxx>
-
//! \class TreeModel_VisibilityState
//! \brief Interface that provides connection between model and visualization control to:
//! - know whether the model item is visible
//! - change visibility of the model item
-class TREEMODEL_EXPORT TreeModel_VisibilityState : public QObject
+class TreeModel_VisibilityState
{
- Q_OBJECT
public:
//! Constructor
TreeModel_VisibilityState (TreeModel_ModelBase* theModel) : myModel (theModel) {}
//! \return boolean value
virtual bool IsVisible (const QModelIndex& theIndex) const = 0;
-public slots:
+protected:
//! Processes the mouse clicked on the index.
//! It changes the item visibility if model allows to change it.
//! \theIndex tree model index
- void OnClicked (const QModelIndex& theIndex);
-
-signals:
- //! Signal after OnClicked is performed
- //! \theIndex tree model index
- void itemClicked (const QModelIndex& theIndex);
+ //! \return true if click is processed
+ Standard_EXPORT bool processClicked (const QModelIndex& theIndex);
protected:
//! tree view model
TreeModel_ModelBase* getModel() const { return myModel; }
private:
- TreeModel_ModelBase* myModel; //! tree view model
+ TreeModel_ModelBase* myModel; //!< tree view model
};
#endif
VInspector.qrc
+VInspectorAPI_CallBack.cxx
+VInspectorAPI_CallBack.hxx
VInspector_CallBack.cxx
VInspector_CallBack.hxx
VInspector_CallBackMode.hxx
VInspector_ItemBase.hxx
VInspector_ItemContext.cxx
VInspector_ItemContext.hxx
-VInspector_ItemFolderObject.cxx
-VInspector_ItemFolderObject.hxx
-VInspector_ItemEntityOwner.cxx
-VInspector_ItemEntityOwner.hxx
VInspector_ItemHistoryElement.cxx
VInspector_ItemHistoryElement.hxx
VInspector_ItemHistoryRoot.cxx
VInspector_ItemHistoryTypeInfo.hxx
VInspector_ItemPresentableObject.cxx
VInspector_ItemPresentableObject.hxx
-VInspector_ItemSelection.cxx
-VInspector_ItemSelection.hxx
-VInspector_ItemSelectMgrFilter.cxx
-VInspector_ItemSelectMgrFilter.hxx
-VInspector_ItemSensitiveEntity.cxx
-VInspector_ItemSensitiveEntity.hxx
-VInspector_SelectionType.hxx
VInspector_ToolActionType.hxx
VInspector_ToolBar.cxx
VInspector_ToolBar.hxx
VInspector_ViewModelHistory.hxx
VInspector_Window.cxx
VInspector_Window.hxx
-VInspectorAPI_CallBack.cxx
-VInspectorAPI_CallBack.hxx
#include <inspector/VInspectorAPI_CallBack.hxx>
-#if OCC_VERSION_HEX <= 0x060901
-IMPLEMENT_STANDARD_HANDLE(VInspectorAPI_CallBack, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
-#else
-IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
-#endif
// =======================================================================
// function : Constructor
#include <Standard.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Version.hxx>
#include <Standard_Transient.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TopoDS_Shape.hxx>
-#if OCC_VERSION_HEX > 0x060901
class AIS_InteractiveObject;
-#else
-#include <AIS_InteractiveObject.hxx>
-#endif
class SelectMgr_EntityOwner;
-DEFINE_STANDARD_HANDLE(VInspectorAPI_CallBack, Standard_Transient)
-
//! \class VInspectorAPI_CallBack
//! API of AIS_InteractiveContext methods to provide information about the actions
class VInspectorAPI_CallBack : public Standard_Transient
//! Processing method of context
virtual void ShiftSelect() = 0;
-#if OCC_VERSION_HEX <= 0x060901
- DEFINE_STANDARD_RTTI(VInspectorAPI_CallBack)
-#else
DEFINE_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
-#endif
};
#endif
#include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <Standard_Version.hxx>
#include <inspector/VInspector_CallBackMode.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModelHistory.hxx>
-#if OCC_VERSION_HEX <= 0x060901
-IMPLEMENT_STANDARD_HANDLE(VInspector_CallBack, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
-#else
-IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
-#endif
// =======================================================================
// function : Activate
// =======================================================================
void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode)
{
- QList<QVariant> anInfo = VInspector_Tools::GetInfo (thePrs);
+ if (!myHistoryModel)
+ return;
+
+ QList<QVariant> anInfo;
+ if (!thePrs.IsNull())
+ anInfo = VInspector_Tools::GetInfo (thePrs);
+ else
+ {
+ anInfo.append ("Activate");
+ anInfo.append ("");
+ anInfo.append ("");
+ }
anInfo[0] = QString ("%1: %2").arg (anInfo[0].toString()).arg (theMode);
myHistoryModel->AddElement (VInspector_CallBackMode_Activate, anInfo);
}
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues.append (""); // Name
aValues.append (""); // Pointer
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs);
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues);
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues.append (""); // Name
- aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer
+ aValues.append (Standard_Dump::GetPointerInfo (theOwner, true).ToCString()); // Pointer
aValues.append (""); // Shape type
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
// =======================================================================
void VInspector_CallBack::ClearSelected()
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues);
}
// =======================================================================
void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetHighlightInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues);
// =======================================================================
void VInspector_CallBack::Select()
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetSelectedInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues);
// =======================================================================
void VInspector_CallBack::ShiftSelect()
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetSelectedInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues);
class AIS_InteractiveObject;
class SelectMgr_EntityOwner;
-DEFINE_STANDARD_HANDLE(VInspector_CallBack, VInspectorAPI_CallBack)
-
//! \class VInspector_CallBack
//! Updates inspector state on actions in context
class VInspector_CallBack : public VInspectorAPI_CallBack
VInspector_CallBack() : VInspectorAPI_CallBack() {}
//! Destructor
- virtual ~VInspector_CallBack() Standard_OVERRIDE {}
+ virtual ~VInspector_CallBack() {}
//! Appends displayed presentation into history model
//! \param thePrs the presentation
virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
//! Appends redisplayed presentation into history model
//! \param thePrs the presentation
virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
//! Appends removed presentation into history model
//! \param thePrs the presentation
virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
//! Appends loaded presentation into history model
//! \param thePrs the presentation
virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about modes activation
//! \param thePrs the presentation
//! Appends information about modes deactivation
//! \param thePrs the presentation
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about modes deactivation
//! \param thePrs the presentation
//! \param theMode the selection mode
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
- { (void)theMode; myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+ { (void)theMode;
+ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about selection change
//! \param theShape the selected shape
//! Appends information about selection clear
//! \param thePrs the selected presentation
virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about moving to point
//! \param theXPix a pixels on horizontal
//! Appends information about setting selection
//! \param thePrs the selected presentation
virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about select
Standard_EXPORT virtual void Select() Standard_OVERRIDE;
//! Sets context, where actions happen
//! \param theContext a context instance
void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
-#if OCC_VERSION_HEX <= 0x060901
- DEFINE_STANDARD_RTTI(VInspector_CallBack)
-#else
DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
-#endif
//! Returns string information of call back mode
//! \param theMode type of AIS action
Standard_EXPORT VInspector_Communicator();
//! Destructor
- virtual ~VInspector_Communicator() Standard_OVERRIDE {}
+ virtual ~VInspector_Communicator() {}
//! Provides the container with a parent where this container should be inserted.
//! If Qt implementation, it should be QWidget with QLayout set inside
//! Provide container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
- Standard_EXPORT virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
+ virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
//! Returns plugin preferences, empty implementation by default
//! \param theItem container of preference elements
#include <inspector/VInspector_ItemBase.hxx>
#include <inspector/VInspector_ItemContext.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemBase::Reset()
+{
+ myPresentationShape = TopoDS_Shape();
+ TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemBase::initValue (const int theItemRole) const
+{
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 3: return Standard_Dump::GetPointerInfo (Object(), true).ToCString();
+ }
+
+ return QVariant();
+}
+
// =======================================================================
// function : GetContext
// purpose :
return myContext;
}
+
+// =======================================================================
+// function : GetContext
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_ItemBase::GetPresentationShape() const
+{
+ if (Column() != TreeModel_ColumnType_Name)
+ return TopoDS_Shape();
+
+ initItem();
+ return myPresentationShape;
+}
#include <AIS_InteractiveContext.hxx>
#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ItemBase.hxx>
class VInspector_ItemBase;
{
public:
//! Resets cached values
- virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Sets the context
//! \param theLabel an object where the child items structure is found
//! \return a context
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \thePresentations [out] container of presentation handles to be visualized
+ virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
+ { (void)thePresentations; }
+
+ //! Returns transform persistent of the item or NULL
+ Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
+
+ //! Returns shape of the item parameters
+ //! \return generated shape of the item parameters
+ Standard_EXPORT virtual TopoDS_Shape GetPresentationShape() const;
+
+ //! Rebuild presentation shape if the item use it
+ //! \return generated shape of the item parameters
+ void UpdatePresentationShape() { myPresentationShape = buildPresentationShape(); }
+
protected:
- //! Initialize the current item. It creates a backup of the specific item information
- virtual void initItem() const {}
+ //! Build presentation shape
+ //! \return generated shape of the item parameters
+ virtual TopoDS_Shape buildPresentationShape() { return TopoDS_Shape(); }
protected:
//! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theParent a parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
VInspector_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: TreeModel_ItemBase (theParent, theRow, theColumn), myContext (0) {}
protected:
Handle(AIS_InteractiveContext) myContext; //!< the current context
+ TopoDS_Shape myPresentationShape; //!< item presentation shape
+ Handle(Graphic3d_TransformPers) myTransformPersistence; //!< item cached persistent
};
#endif
\ No newline at end of file
#include <inspector/VInspector_ItemContext.hxx>
+#include <AIS.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
-//#define DEBUG_FREE_OWNERS
-
// =======================================================================
// function : initRowCount
// purpose :
if (Column() != 0)
return 0;
- int aNbProperties = 1; // item to visualize Filters/Drawer information of context
-
- int aNbPresentations = 0;
- Handle(AIS_InteractiveContext) aContext = GetContext();
+ Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (Object());
if (aContext.IsNull())
return 0;
AIS_ListOfInteractive aListOfIO;
aContext->DisplayedObjects (aListOfIO);
aContext->ErasedObjects(aListOfIO);
- aNbPresentations = aListOfIO.Extent();
-
- // owners without Presentation
-#ifdef DEBUG_FREE_OWNERS
- int aRows = 0;
- // only local context is processed: TODO for global context
- NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
- aContext->MainSelector()->ActiveOwners(anActiveOwners);
-
- Handle(SelectMgr_EntityOwner) anOwner;
- for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt(anActiveOwners); anOwnersIt.More(); anOwnersIt.Next())
+ int aNbPresentations = 0;
+ for (AIS_ListIteratorOfListOfInteractive aListOfIOIt (aListOfIO); aListOfIOIt.More(); aListOfIOIt.Next())
{
- anOwner = anOwnersIt.Value();
- if (anOwner.IsNull())
- continue;
- Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
- if (anAISObj.IsNull())
- aRows++;
+ if (aListOfIOIt.Value()->Parent())
+ continue; // child presentation
+ aNbPresentations++;
}
- // owners in Global Context
- NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
- aContext->MainSelector()->ActiveOwners(anActiveOwners);
- if (aRows > 0)
- aNbPresentations += aRows;
- NCollection_List<Handle(SelectMgr_EntityOwner)> anEmptySelectableOwners;
- NCollection_List<Handle(SelectMgr_EntityOwner)> anOwners =
- VInspector_Tools::ActiveOwners (aContext, anEmptySelectableOwners);
- if (anEmptySelectableOwners.Size() > 0)
- aNbPresentations += 1;
-#endif
- return aNbProperties + aNbPresentations;
+
+ return aNbPresentations;
}
// =======================================================================
// =======================================================================
QVariant VInspector_ItemContext::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
- if (GetContext().IsNull())
+ Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (Object());
+ if (aContext.IsNull())
return Column() == 0 ? "Empty context" : "";
switch (Column())
{
- case 0: return GetContext()->DynamicType()->Name();
- case 1: return rowCount();
+ case 0: return aContext->DynamicType()->Name();
case 4:
{
Handle(AIS_InteractiveObject) anEmptyIO;
- int aSelectedCount = VInspector_Tools::SelectedOwners (GetContext(), anEmptyIO, false);
+ int aSelectedCount = VInspector_Tools::SelectedOwners (aContext, anEmptyIO, false);
return aSelectedCount > 0 ? QString::number (aSelectedCount) : "";
}
- case 6: return GetContext()->DeviationCoefficient();
+ case 6: return aContext->DeviationCoefficient();
default:
break;
}
return QVariant();
}
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::Init()
+{
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (aContext.IsNull())
+ return;
+
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::Reset()
+{
+ VInspector_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemContext*>(this)->Init();
+}
+
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemContext::createChild (int theRow, int theColumn)
{
- if (theRow == 0)
- return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
+ return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
}
+
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::initStream (Standard_OStream& theOStream) const
+{
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (aContext.IsNull())
+ return;
+
+ aContext->DumpJson (theOStream);
+}
+
{ return VInspector_ItemContextPtr (new VInspector_ItemContext (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~VInspector_ItemContext() Standard_OVERRIDE {};
+ virtual ~VInspector_ItemContext() {}
+
+ //! Returns data object of the item.
+ //! \return object
+ virtual const Handle(Standard_Transient)& Object() const { initItem(); return myContext; }
//! Returns number of displayed presentations
//! \return rows count
//! \return the value
Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
protected:
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE {}
+ //! Initializes the current item. It creates a backup of the specific item information
+ //! Does nothing as context has been already set into item
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
protected:
private:
//! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
+ //! \param theParent a parent item
+ //! \param theRow the item row position in the parent item
+ //! \param theColumn the item column position in the parent item
VInspector_ItemContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
};
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QItemSelectionModel>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemEntityOwner::initValue(int theItemRole) const
-{
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- Handle(SelectMgr_EntityOwner) anOwner = getEntityOwner();
- if (anOwner.IsNull())
- return QVariant();
-
- switch (Column())
- {
- case 0: return anOwner->DynamicType()->Name();
- case 2: return VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
- case 3:
- {
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
- if (BROwnr.IsNull())
- return QVariant();
-
- const TopoDS_Shape& aShape = BROwnr->Shape();
- if (aShape.IsNull())
- return QVariant();
-
- return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
- }
- case 17:
- case 18:
- case 19:
- {
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
- if (BROwnr.IsNull())
- return QVariant();
-
- const TopoDS_Shape& aShape = BROwnr->Shape();
- if (aShape.IsNull())
- return QVariant();
-
- return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
- : Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
- : /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
- }
- default: break;
- }
- break;
- }
- case Qt::BackgroundRole:
- case Qt::ForegroundRole:
- {
- if (Column() == 2)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
- if (!aContext.IsNull())
- {
- if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
- return (theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white);
- }
- }
- VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
- if (aParentItem)
- return aParentItem->data(QModelIndex(), theItemRole);
- break;
- }
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemEntityOwner::Init()
-{
- Handle(SelectMgr_EntityOwner) anOwner;
-
- VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
- if (aParentItem)
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aParentItem->GetSensitiveEntity();
- anOwner = anEntity->BaseSensitive()->OwnerId();
- }
- else
- {
- VInspector_ItemPresentableObjectPtr aPOItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- if (aPOItem)
- {
- Handle(AIS_InteractiveObject) anIO = aPOItem->GetInteractiveObject();
-
- int aRowId = Row();
- int aCurrentIndex = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
- {
- const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
- for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
-#else
- for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next())
- {
- const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next())
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
-#endif
- const Handle(Select3D_SensitiveEntity)& aBase = anEntity->BaseSensitive();
- if (!aBase.IsNull())
- {
- if (aRowId == aCurrentIndex)
- anOwner = aBase->OwnerId();
- aCurrentIndex++;
- }
- }
- }
- }
- }
- myOwner = anOwner;
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemEntityOwner::Reset()
-{
- VInspector_ItemBase::Reset();
- SetContext (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemEntityOwner::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemEntityOwner*>(this)->Init();
-}
-
-// =======================================================================
-// function : getEntityOwner
-// purpose :
-// =======================================================================
-Handle(SelectMgr_EntityOwner) VInspector_ItemEntityOwner::getEntityOwner() const
-{
- initItem();
- return myOwner;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemEntityOwner_H
-#define VInspector_ItemEntityOwner_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemEntityOwner;
-typedef QExplicitlySharedDataPointer<VInspector_ItemEntityOwner> VInspector_ItemEntityOwnerPtr;
-
-//! \class VInspector_ItemPresentableObject
-//! Item for selection entity owner. The parent is sensitive entity item, there are no children
-class VInspector_ItemEntityOwner : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemEntityOwnerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemEntityOwnerPtr (new VInspector_ItemEntityOwner (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemEntityOwner() Standard_OVERRIDE {};
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns the current entity owner
- Handle(SelectMgr_EntityOwner) EntityOwner() const { return myOwner; }
-
-protected:
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE{ return 0; }
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
- { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemEntityOwner(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- //! Returns the current entity owner. Initializes the item if it was not initialized yet
- Handle(SelectMgr_EntityOwner) getEntityOwner() const;
-
-private:
-
- Handle(SelectMgr_EntityOwner) myOwner; //!< the current entity owner
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemFolderObject.hxx>
-
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
-{
- if (Column() == 0 && (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole))
- {
- if (parentItemIsContext()) return "Properties";
- else if (Row() == 0) return "Filters";
- else return QVariant();
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemFolderObject::initRowCount() const
-{
- return parentItemIsContext() ? 1 : (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int theColumn)
-{
- if (parentItemIsContext())
- return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemFolderObject::Init()
-{
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemFolderObject::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemFolderObject::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemFolderObject*> (this)->Init();
-}
-
-// =======================================================================
-// function : parentItemIsContext
-// purpose :
-// =======================================================================
-bool VInspector_ItemFolderObject::parentItemIsContext() const
-{
- return itemDynamicCast<VInspector_ItemContext> (Parent());
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemFolderObject_H
-#define VInspector_ItemFolderObject_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <AIS_InteractiveObject.hxx>
-#include <NCollection_List.hxx>
-#include <TCollection_AsciiString.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemFolderObject;
-typedef QExplicitlySharedDataPointer<VInspector_ItemFolderObject> VInspector_ItemFolderObjectPtr;
-
-//! \class VInspector_ItemFolderObject
-//! Item presents additional level of information in the tree model.
-//! Parent is item context, children are either folder item or Selection filter item.
-class VInspector_ItemFolderObject : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemFolderObjectPtr CreateItem (TreeModel_ItemBasePtr theParent,
- const int theRow, const int theColumn)
- { return VInspector_ItemFolderObjectPtr (new VInspector_ItemFolderObject (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemFolderObject() Standard_OVERRIDE {};
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
- //! Returns whether the parent item is context item
- //! \returns bolean value
- bool parentItemIsContext() const;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemFolderObject (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase (theParent, theRow, theColumn) {}
-
-};
-
-#endif
// =======================================================================
QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return getName();
- case 1: return QVariant();
- case 2: return GetPointerInfo();
- case 3: return GetShapeTypeInfo();
+ case 2: return QVariant();
+ case 3: return GetPointerInfo();
+ case 4: return GetShapeTypeInfo();
default: break;
}
return QVariant();
{ return VInspector_ItemHistoryElementPtr (new VInspector_ItemHistoryElement (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~VInspector_ItemHistoryElement() Standard_OVERRIDE {};
+ virtual ~VInspector_ItemHistoryElement() {}
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
VInspector_ItemHistoryElement(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (const int theChildRowIndex)
{
int anInfoMapIndex = theChildRowIndex + myFirstIndex;
+
+ bool aReversed = true;
+ if (aReversed)
+ anInfoMapIndex = (myInfoMap.size() - myFirstIndex) - 1 - anInfoMapIndex;
+
return myInfoMap[anInfoMapIndex];
}
// =======================================================================
QVariant VInspector_ItemHistoryRoot::initValue (const int theRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return "History";
- case 1: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
+ case 2: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
default:
break;
}
{ return VInspector_ItemHistoryRootPtr (new VInspector_ItemHistoryRoot (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~VInspector_ItemHistoryRoot() Standard_OVERRIDE {};
+ virtual ~VInspector_ItemHistoryRoot() {}
//! Sets maximum count of history elements in internal container.
//! \param theSize a size value
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
private:
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ if (aTypeInfo.myElements.size() < rowCount())
+ return QString();
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
return anElements.size() > 1 ? anElements[1].toString() : QString();
}
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ if ( aTypeInfo.myElements.size() < rowCount())
+ return QString();
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
return anElements.size() > 3 ? anElements[3].toString() : QString();
}
// =======================================================================
QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ int aRowCount = rowCount();
+ if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount)
+ return QVariant();
+
QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
int anInfoSize = anElements.size();
switch (Column())
{
case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode);
- case 1: return rowCount();
- case 2: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
- case 3: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
- case 4: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
- case 5: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
+ case 3: return rowCount();
+ case 4: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
+ case 5: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
+ case 6: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
+ case 7: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
default: break;
}
return QVariant();
{ return VInspector_ItemHistoryTypePtr (new VInspector_ItemHistoryType (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~VInspector_ItemHistoryType() Standard_OVERRIDE {};
+ virtual ~VInspector_ItemHistoryType() {}
//! Returns the pointer info of the first child item, initialize item if it has not been initialized yet.
Standard_EXPORT QString PointerInfo() const;
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
VInspector_ItemHistoryType(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
#include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <AIS.hxx>
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelection.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
#include <NCollection_List.hxx>
#include <Prs3d.hxx>
#include <Prs3d_Drawer.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <SelectBasics_EntityOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
-#include <Standard_Version.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QColor>
// =======================================================================
QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
{
- if (Column() == 20 && theItemRole == Qt::BackgroundRole) {
- Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
- if (!anIO.IsNull() && anIO->HasColor())
- {
- Quantity_Color aColor;
- anIO->Color(aColor);
- return QColor ((int)(aColor.Red()*255.), (int)(aColor.Green()*255.), (int)(aColor.Blue()*255.));
- }
- }
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (anIO->DynamicType()->Name());
}
- case 1:
- return rowCount();
- case 2:
- {
- if (!aNullIO)
- return VInspector_Tools::GetPointerInfo (anIO, true).ToCString();
- break;
- }
- case 3:
- {
- Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
- if (!aShapeIO.IsNull())
- {
- const TopoDS_Shape& aShape = aShapeIO->Shape();
- if (!aShape.IsNull())
- return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
- }
- break;
- }
case 4:
{
int aNbSelected = VInspector_Tools::SelectedOwners (GetContext(), anIO, false);
return aNbSelected > 0 ? QString::number (aNbSelected) : "";
}
- case 5:
- {
- TColStd_ListOfInteger aModes;
- Handle(AIS_InteractiveContext) aContext = GetContext();
- aContext->ActivatedModes(anIO, aModes);
- TCollection_AsciiString aModesInfo;
- for (TColStd_ListIteratorOfListOfInteger itr (aModes); itr.More(); itr.Next())
- {
- if (!aModesInfo.IsEmpty())
- aModesInfo += ", ";
- aModesInfo += VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType(itr.Value()));
- }
- return aModesInfo.ToCString();
- }
- break;
case 6:
{
double aDeviationCoefficient = 0;
}
return QString::number(aDeviationCoefficient);
}
- case 7:
- {
- double aShapeDeflection = 0;
- Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
- if (!aShapeIO.IsNull())
- {
- const TopoDS_Shape& aShape = aShapeIO->Shape();
- if (!aShape.IsNull())
- aShapeDeflection = Prs3d::GetDeflection(aShape, anIO->Attributes());
- }
- return QString::number (aShapeDeflection);
- }
case 8:
{
double aDeviationCoefficient = 0;
bool anIsAutoTriangulation = aNullIO ? false : anIO->Attributes()->IsAutoTriangulation();
return anIsAutoTriangulation ? QString ("true") : QString ("false");
}
- case 17:
- case 18:
- case 19:
- {
- Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
- if (aShapeIO.IsNull())
- return QVariant();
- const TopoDS_Shape& aShape = aShapeIO->Shape();
- if (aShape.IsNull())
- return QVariant();
-
- return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
- : Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
- : /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
- }
default: break;
}
}
// =======================================================================
int VInspector_ItemPresentableObject::initRowCount() const
{
- Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
-#if OCC_VERSION_HEX < 0x070201
- int aRows = 0;
- if (anIO.IsNull())
- return aRows;
- // iteration through sensitive privitives
- for (anIO->Init(); anIO->More(); anIO->Next())
- aRows++;
- return aRows;
-#else
- return !anIO.IsNull()
- ? anIO->Selections().Size()
- : 0;
-#endif
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemPresentableObject::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemSelection::CreateItem(currentItem(), theRow, theColumn);
+ return 0;
}
// =======================================================================
AIS_ListOfInteractive aListOfIO;
GetContext()->DisplayedObjects (aListOfIO); // the presentation is in displayed objects of Context
GetContext()->ErasedObjects (aListOfIO); // the presentation is in erased objects of Context
- int aDeltaIndex = 1; // properties item
+
+ std::vector<Handle(AIS_InteractiveObject)> aListOfIOSorted;
+ aListOfIOSorted.reserve (aListOfIO.Size());
+ for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next())
+ {
+ aListOfIOSorted.push_back (anIOIt.Value());
+ }
+ std::sort (aListOfIOSorted.begin(), aListOfIOSorted.end());
+
int aCurrentIndex = 0;
- for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next(), aCurrentIndex++)
+ for (std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIOIt = aListOfIOSorted.begin(); anIOIt != aListOfIOSorted.end(); anIOIt++, aCurrentIndex++)
{
- if (aCurrentIndex != aRowId - aDeltaIndex)
+ if (aCurrentIndex != aRowId)
continue;
- anIO = anIOIt.Value();
+ anIO = *anIOIt;
break;
}
}
setInteractiveObject (anIO);
+ myTransformPersistence = !anIO.IsNull() ? anIO->TransformPersistence() : NULL;
+ UpdatePresentationShape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
SetContext (NULL);
setInteractiveObject (NULL);
+ myTransformPersistence = NULL;
}
// =======================================================================
}
// =======================================================================
-// function : GetInteractiveObject
+// function : buildPresentationShape
// purpose :
// =======================================================================
-Handle(AIS_InteractiveObject) VInspector_ItemPresentableObject::GetInteractiveObject() const
+TopoDS_Shape VInspector_ItemPresentableObject::buildPresentationShape()
{
- initItem();
- return myIO;
+ Handle(AIS_InteractiveObject) aPrs = myIO;
+ if (aPrs.IsNull())
+ return TopoDS_Shape();
+
+ Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs);
+ if (!aShapePrs.IsNull())
+ return aShapePrs->Shape();
+
+ return TopoDS_Shape();
}
// =======================================================================
// =======================================================================
QString VInspector_ItemPresentableObject::PointerInfo() const
{
- return VInspector_Tools::GetPointerInfo (GetInteractiveObject(), true).ToCString();
+ return Standard_Dump::GetPointerInfo (GetInteractiveObject(), true).ToCString();
}
// =======================================================================
-// function : GetSelectedPresentations
+// function : Presentations
// purpose :
// =======================================================================
-NCollection_List<Handle(AIS_InteractiveObject)> VInspector_ItemPresentableObject::GetSelectedPresentations
- (QItemSelectionModel* theSelectionModel)
+void VInspector_ItemPresentableObject::Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
- NCollection_List<Handle(AIS_InteractiveObject)> aResultList;
- if (!theSelectionModel)
- return aResultList;
-
- QList<TreeModel_ItemBasePtr> anItems;
-
- QModelIndexList anIndices = theSelectionModel->selectedIndexes();
- for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
- {
- TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
- if (!anItem || anItems.contains (anItem))
- continue;
- anItems.append (anItem);
- }
+ if (Column() != 0)
+ return;
- QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
- for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
- {
- TreeModel_ItemBasePtr anItem = *anItemIt;
- VInspector_ItemPresentableObjectPtr aPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(anItem);
- if (!aPrsItem)
- continue;
- Handle(AIS_InteractiveObject) aPresentation = aPrsItem->GetInteractiveObject();
- if (aSelectedIds.contains ((size_t)aPresentation.operator->()))
- continue;
- aSelectedIds.append ((size_t)aPresentation.operator->());
- if (!aPresentation.IsNull())
- aResultList.Append (aPresentation);
- }
- return aResultList;
+ thePresentations.Append (GetInteractiveObject());
+}
+
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void VInspector_ItemPresentableObject::initStream (Standard_OStream& theOStream) const
+{
+ Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
+ if (anIO.IsNull())
+ return;
+
+ anIO->DumpJson (theOStream);
}
+
static VInspector_ItemPresentableObjectPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemPresentableObjectPtr (new VInspector_ItemPresentableObject (theParent, theRow, theColumn)); }
//! Destructor
- virtual ~VInspector_ItemPresentableObject() Standard_OVERRIDE {};
+ virtual ~VInspector_ItemPresentableObject() {}
+
+ //! Returns data object of the item.
+ //! \return object
+ virtual const Handle(Standard_Transient)& Object() const { initItem(); return myIO; }
//! Returns the current interactive object, init item if it was not initialized yet
//! \return interactive object
- Standard_EXPORT Handle(AIS_InteractiveObject) GetInteractiveObject() const;
+ Handle(AIS_InteractiveObject) GetInteractiveObject() const { return Handle(AIS_InteractiveObject)::DownCast (Object()); }
//! Returns pointer information for the current interactive object, init item if it was not initialized yet
//! \return string value
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
- //! Returns presentations, which items are selected in tree view
- //! \param theSelectionModel a selection model
- //! \return container of presentations
- Standard_EXPORT static NCollection_List<Handle(AIS_InteractiveObject)> GetSelectedPresentations
- (QItemSelectionModel* theSelectionModel);
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \thePresentations [out] container of presentation handles to be visualized
+ Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
protected:
//! \return the value
virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+ //! Returns stream value of the item to fulfill property panel.
+ //! \return stream value or dummy
+ Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
-private:
+protected:
+ //! Build presentation shape
+ //! \return generated shape of the item parameters
+ virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
//! Set interactive object into the current field
//! \param theIO a presentation
private:
//! Constructor
- //! param theParent a parent item
+ //! \param theParent a parent item
VInspector_ItemPresentableObject(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <SelectMgr_AndFilter.hxx>
-#include <SelectMgr_OrFilter.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QIcon>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrFilter::initValue (int theItemRole) const
-{
- if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
- {
- Handle(SelectMgr_Filter) aFilter = GetFilter();
- switch (Column())
- {
- case 0: return theItemRole == Qt::ToolTipRole ? QVariant ("")
- : QVariant (aFilter->DynamicType()->Name());
- case 1: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
- case 2: return VInspector_Tools::GetPointerInfo (aFilter, true).ToCString();
- default: break;
- }
- }
- if (Column() == 0 && theItemRole == Qt::DecorationRole)
- {
- Handle(SelectMgr_Filter) aFilter = GetFilter();
- if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_AndFilter))) return QIcon (":/icons/treeview_and.png");
- if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_OrFilter))) return QIcon (":/icons/treeview_or.png");
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrFilter::initRowCount() const
-{
- Handle(SelectMgr_Filter) aFilter = GetFilter();
- if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_CompositionFilter)))
- {
- Handle(SelectMgr_CompositionFilter) aCompositionFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aFilter);
- return aCompositionFilter->StoredFilters().Size();
- }
- return 0;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrFilter::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemSelectMgrFilter::CreateItem(currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrFilter::Init()
-{
- Handle(AIS_InteractiveContext) aContext = GetContext();
-
- Handle(SelectMgr_Filter) aFilter;
-
- Handle(SelectMgr_CompositionFilter) aParentCompositeFilter;
- VInspector_ItemSelectMgrFilterPtr aParentSelectMgrItem = itemDynamicCast<VInspector_ItemSelectMgrFilter> (Parent());
- if (aParentSelectMgrItem)
- aParentCompositeFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aParentSelectMgrItem->GetFilter());
-
- int aRowId = Row();
- const SelectMgr_ListOfFilter& aFilters = !aParentCompositeFilter.IsNull() ? aParentCompositeFilter->StoredFilters()
- : aContext->Filters();
- int aCurrentIndex = 0;
- for (SelectMgr_ListOfFilter::Iterator aFiltersIt (aFilters); aFiltersIt.More(); aFiltersIt.Next(), aCurrentIndex++)
- {
- if (aCurrentIndex != aRowId)
- continue;
- aFilter = aFiltersIt.Value();
- break;
- }
- setFilter (aFilter);
- TreeModel_ItemBase::Init(); // to use getFilter() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrFilter::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setFilter (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrFilter::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrFilter*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetInteractiveObject
-// purpose :
-// =======================================================================
-Handle(SelectMgr_Filter) VInspector_ItemSelectMgrFilter::GetFilter() const
-{
- initItem();
- return myFilter;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelectMgrFilter_H
-#define VInspector_ItemSelectMgrFilter_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <SelectMgr_Filter.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemSelectMgrFilter;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrFilter> VInspector_ItemSelectMgrFilterPtr;
-
-//! \class VInspector_ItemSelectMgrFilter
-//! Item presents information about SelectMgr_Filter.
-//! Parent is item folder, children are sub filter if the filter is a composition filter.
-class VInspector_ItemSelectMgrFilter : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrFilterPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrFilterPtr (new VInspector_ItemSelectMgrFilter (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemSelectMgrFilter() Standard_OVERRIDE {};
-
- //! Returns the current filter, init item if it was not initialized yet
- //! \return filter object
- Standard_EXPORT Handle(SelectMgr_Filter) GetFilter() const;
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
- //! Set filter into the current item
- //! \param theFilter a filter
- void setFilter (Handle(SelectMgr_Filter) theFilter) { myFilter = theFilter; }
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelectMgrFilter (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase (theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(SelectMgr_Filter) myFilter; //!< the current filter
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemSelection.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : getSelection
-// purpose :
-// =======================================================================
-Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
-{
- initItem();
- return mySelection;
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelection::initRowCount() const
-{
- Handle(SelectMgr_Selection) aSelection = getSelection();
-#if OCC_VERSION_HEX < 0x070201
- int aRows = 0;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
- aRows++;
- return aRows;
-#else
- return aSelection->Entities().Size();
-#endif
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelection::initValue (int theItemRole) const
-{
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return getSelection()->DynamicType()->Name();
- case 1: return rowCount();
- case 3:
- {
- if (theItemRole == Qt::ToolTipRole)
- return "Mode";
- else
- {
- VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- return VInspector_Tools::SelectionModeToName(getSelection()->Mode(), aParentItem->GetInteractiveObject()).ToCString();
- }
- }
- case 4:
- {
- if (theItemRole == Qt::ToolTipRole)
- return "SelectMgr_StateOfSelection";
- else {
- int aNbSelected = 0;
- SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
- if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
-#if OCC_VERSION_HEX < 0x070201
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
- {
- const Handle(SelectMgr_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
-#else
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
- {
- const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
-#endif
- if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
- aNbSelected++;
- }
- }
- return aNbSelected > 0 ? QString::number (aNbSelected) : "";
- }
- }
- case 9:
- {
- SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
- return VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
- }
- case 10: return QString::number (getSelection()->Sensitivity());
- case 11:
- return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
- getSelection()->UpdateStatus()).ToCString();
- case 12:
- return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
- getSelection()->BVHUpdateStatus()).ToCString();
- default:
- break;
- }
- break;
- }
- case Qt::ForegroundRole:
- {
- SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
- return QVariant (aState == SelectMgr_SOS_Activated ? QColor (Qt::black) : QColor (Qt::darkGray));
- }
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelection::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelection::Init()
-{
- VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
-
- Handle(AIS_InteractiveObject) anIO = aParentItem->GetInteractiveObject();
-
- int aRowId = Row();
- int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
-#else
- for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
-#endif
- {
- if (aCurrentId != aRowId)
- continue;
-#if OCC_VERSION_HEX < 0x070201
- mySelection = anIO->CurrentSelection();
-#else
- mySelection = aSelIter.Value();
-#endif
- break;
- }
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelection::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
-
- mySelection = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelection::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelection*>(this)->Init();
- // an empty method to don't initialize the main label, as it was not cleared in Reset()
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelection_H
-#define VInspector_ItemSelection_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <SelectMgr_Selection.hxx>
-
-class VInspector_ItemSelection;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelection> VInspector_ItemSelectionPtr;
-
-//! \class VInspector_ItemSelection
-//! Item about SelectMgr_Selection.
-//! Parent is presentable object item, children are sensitive entity items
-class VInspector_ItemSelection : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectionPtr CreateItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectionPtr (new VInspector_ItemSelection (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelection() {};
-
- //! \return current selection value
- Standard_EXPORT Handle(SelectMgr_Selection) getSelection() const;
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
- //! Initializes the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Initializes number of children
- //! \return integer value
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- Handle(SelectMgr_Selection) mySelection; //!< the current selection
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TopoDS_Shape.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelection.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : GetSensitiveEntity
-// purpose :
-// =======================================================================
-Handle(SelectMgr_SensitiveEntity) VInspector_ItemSensitiveEntity::GetSensitiveEntity() const
-{
- initItem();
- return myEntity;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
-{
- Handle(SelectMgr_SensitiveEntity) aBase = GetSensitiveEntity();
- Handle(SelectMgr_EntityOwner) anOwner = aBase->BaseSensitive()->OwnerId();
-
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return myEntity->DynamicType()->Name();
- case 2: return VInspector_Tools::GetPointerInfo (GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
- case 3:
- {
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
- if (BROwnr.IsNull())
- return QVariant();
-
- const TopoDS_Shape& aShape = BROwnr->Shape();
- if (aShape.IsNull())
- return QVariant();
-
- return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
- }
- case 13: return
-#if OCC_VERSION_HEX <= 0x060901
- ("none");
-#else
- myEntity->IsActiveForSelection() ? QString ("true") : QString ("false");
-#endif
- case 14: return QString::number (GetSensitiveEntity()->BaseSensitive()->SensitivityFactor());
- case 15: return QString::number (GetSensitiveEntity()->BaseSensitive()->NbSubElements());
- case 16:
- {
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
- if (BROwnr.IsNull())
- return QVariant();
- return anOwner->Priority();
- }
- default:
- break;
- }
- break;
- }
- case Qt::BackgroundRole:
- case Qt::ForegroundRole:
- {
- if (Column() == 2)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
- if (!aContext.IsNull())
- {
- if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
- return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
- }
- }
- VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
- if (aParentItem)
- return aParentItem->data(QModelIndex(), theItemRole);
- break;
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSensitiveEntity::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemEntityOwner::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSensitiveEntity::Init()
-{
- VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
-
- Handle(SelectMgr_Selection) aSelection = aParentItem->getSelection();
-
- int aRowId = Row();
- int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
-#else
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++)
-#endif
- {
- if (aCurrentId != aRowId)
- continue;
-#if OCC_VERSION_HEX < 0x070201
- myEntity = aSelection->Sensitive();
-#else
- myEntity = aSelEntIter.Value();
-#endif
- break;
- }
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSensitiveEntity::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
- myEntity = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSensitiveEntity::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSensitiveEntity*>(this)->Init();
-}
-
-// =======================================================================
-// function : getEntityOwner
-// purpose :
-// =======================================================================
-Handle(SelectMgr_EntityOwner) VInspector_ItemSensitiveEntity::getEntityOwner() const
-{
- initItem();
-
- Handle(SelectMgr_EntityOwner) anOwner;
- const Handle(Select3D_SensitiveEntity)& aBase = myEntity->BaseSensitive();
- if (aBase.IsNull())
- return anOwner;
- return aBase->OwnerId();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSensitiveEntity_H
-#define VInspector_ItemSensitiveEntity_H
-
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class SelectMgr_EntityOwner;
-class VInspector_ItemSensitiveEntity;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemSensitiveEntity> VInspector_ItemSensitiveEntityPtr;
-
-//! \class VInspector_ItemSensitiveEntity
-//! The item shows information about SelectMgr_EntityOwner.
-//! The parent is item selection, children are item entity owners
-class VInspector_ItemSensitiveEntity : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSensitiveEntityPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSensitiveEntityPtr (new VInspector_ItemSensitiveEntity (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSensitiveEntity() Standard_OVERRIDE {};
-
- //! \return the current sensitive entity
- Standard_EXPORT Handle(SelectMgr_SensitiveEntity) GetSensitiveEntity() const;
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE { return !GetSensitiveEntity()->BaseSensitive().IsNull() ? 1 : 0; }
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
- //! Returns owner of the current sensitive entity
- //! \return owner
- Handle(SelectMgr_EntityOwner) getEntityOwner() const;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- Handle(SelectMgr_SensitiveEntity) myEntity; //!< the current entity owner
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_SelectionType_H
-#define VInspector_SelectionType_H
-
-//! Type of SelectMgr enumeration types
-enum VInspector_SelectionType
-{
- VInspector_SelectionType_TypeOfUpdate, //!< Values of SelectMgr_TypeOfUpdate
- VInspector_SelectionType_StateOfSelection, //!< Values of SelectMgr_StateOfSelection
- VInspector_SelectionType_TypeOfBVHUpdate //!< Values of SelectMgr_TypeOfBVHUpdate
-};
-
-#endif
-
\ No newline at end of file
enum VInspector_ToolActionType
{
VInspector_ToolActionType_NoneId, //!< No action activated
- VInspector_ToolActionType_UpdateId, //!< Update content of tree view (content of AIS_InteractiveContext)
- VInspector_ToolActionType_SelectPresentationsId, //!< Selects presentation in context by selection in tree view
- VInspector_ToolActionType_SelectOwnersId //!< Selects owners in context by selection in tree view
+ VInspector_ToolActionType_UpdateId //!< Update content of tree view (content of AIS_InteractiveContext)
};
#endif
myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
- myActionsMap[VInspector_ToolActionType_SelectPresentationsId] = new QPushButton (theParent);
- myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setText ("Select Presentations");
- myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setCheckable (true);
-
- myActionsMap[VInspector_ToolActionType_SelectOwnersId] = new QPushButton (theParent);
- myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setText ("Select Owners");
- myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setCheckable (true);
-
myMainWindow = new QWidget (theParent);
QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
break;
}
- if (anId == VInspector_ToolActionType_SelectPresentationsId && myActionsMap[VInspector_ToolActionType_SelectOwnersId]->isChecked())
- myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setChecked(false);
- else if (anId == VInspector_ToolActionType_SelectOwnersId && myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->isChecked())
- myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setChecked(false);
-
if (anId != -1)
emit actionClicked (anId);
}
Standard_EXPORT VInspector_ToolBar (QWidget* theParent);
//! Destructor
- virtual ~VInspector_ToolBar() Standard_OVERRIDE {}
+ virtual ~VInspector_ToolBar() {}
//! Returns main control
QWidget* GetControl() const { return myMainWindow; }
#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_TableModelValues.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/Convert_Tools.hxx>
+
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_Selection.hxx>
#include <AIS_Shape.hxx>
-#include <AIS_Trihedron.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
-#include <gp_Trsf.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <Graphic3d_IndexBuffer.hxx>
+#include <Graphic3d_Buffer.hxx>
+#include <Graphic3d_BoundBuffer.hxx>
+
#include <SelectMgr_StateOfSelection.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
#include <SelectMgr_TypeOfBVHUpdate.hxx>
-#include <Standard_Version.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
+#include <TopoDS_Compound.hxx>
+
#include <sstream>
// =======================================================================
return aSStream.str().c_str();
}
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- std::ostringstream aPtrStr;
- aPtrStr << thePointer.operator->();
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend("0x");
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
// =======================================================================
// function : SelectedOwners
// purpose :
if (theShapeInfoOnly && BROwnr.IsNull())
continue;
- Standard_Transient* anOwnerPtr = anOwner.operator->();
+ Standard_Transient* anOwnerPtr = anOwner.get();
if (aSelectedIds.contains ((size_t)anOwnerPtr))
continue;
aSelectedIds.append ((size_t)anOwnerPtr);
- anObjects.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+ anObjects.append (Standard_Dump::GetPointerInfo (anOwnerPtr, true).ToCString());
}
return anObjects.size();
}
// purpose :
// =======================================================================
bool VInspector_Tools::IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
- const Handle(SelectMgr_EntityOwner)& theOwner)
+ const Handle(SelectBasics_EntityOwner)& theOwner)
{
bool anIsSelected = false;
- Handle(SelectMgr_EntityOwner) anOwner = theOwner;
for (theContext->InitSelected(); theContext->MoreSelected() && !anIsSelected; theContext->NextSelected())
- anIsSelected = theContext->SelectedOwner() == anOwner;
+ anIsSelected = theContext->SelectedOwner() == theOwner;
return anIsSelected;
}
// function : ContextOwners
// purpose :
// =======================================================================
-NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ContextOwners (
+NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ContextOwners (
const Handle(AIS_InteractiveContext)& theContext)
{
- NCollection_List<Handle(SelectMgr_EntityOwner)> aResultOwners;
+ NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
if (theContext.IsNull())
return aResultOwners;
Handle(AIS_InteractiveObject) anIO = aIt.Value();
if (anIO.IsNull())
continue;
-#if OCC_VERSION_HEX < 0x070201
- for (anIO->Init(); anIO->More(); anIO->Next())
- {
- Handle(SelectMgr_Selection) aSelection = anIO->CurrentSelection();
- if (aSelection.IsNull())
- continue;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
-#else
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next())
{
Handle(SelectMgr_Selection) aSelection = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
-#endif
if (anEntity.IsNull())
continue;
- const Handle(Select3D_SensitiveEntity)& aBase = anEntity->BaseSensitive();
- Handle(SelectMgr_EntityOwner) anOwner = aBase->OwnerId();
- Standard_Transient* anOwnerPtr = anOwner.operator->();
+ const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
+ Handle(SelectBasics_EntityOwner) anOwner = aBase->OwnerId();
+ Standard_Transient* anOwnerPtr = anOwner.get();
if (aSelectedIds.contains ((size_t)anOwnerPtr))
continue;
aSelectedIds.append ((size_t)anOwnerPtr);
// function : ActiveOwners
// purpose :
// =======================================================================
-NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ActiveOwners (
+NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ActiveOwners (
const Handle(AIS_InteractiveContext)& theContext,
- NCollection_List<Handle(SelectMgr_EntityOwner)>& theEmptySelectableOwners)
+ NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners)
{
- NCollection_List<Handle(SelectMgr_EntityOwner)> aResultOwners;
+ NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
// only local context is processed: TODO for global context
Handle(AIS_InteractiveContext) aContext = theContext;
if (aContext.IsNull())
return aResultOwners;
- NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
// OCCT BUG:1 - equal pointer owners are appears in the list
-#if OCC_VERSION_HEX > 0x060901
aContext->MainSelector()->ActiveOwners (anActiveOwners);
-#else
- anActiveOwners = aContext->MainSelector()->ActiveOwners();
-#endif
QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
- for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
+ Handle(SelectMgr_EntityOwner) anOwner;
+ for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
- const Handle(SelectMgr_EntityOwner)& anOwner = anOwnersIt.Value();
+ anOwner = anOwnersIt.Value();
if (anOwner.IsNull())
continue;
- Standard_Transient* anOwnerPtr = anOwner.operator->();
+ Standard_Transient* anOwnerPtr = anOwner.get();
if (aSelectedIds.contains ((size_t)anOwnerPtr))
continue;
aSelectedIds.append ((size_t)anOwnerPtr);
// purpose :
// =======================================================================
void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
- const NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners)
+ const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners)
{
// TODO: the next two rows are to be removed later
theContext->UnhilightSelected(false);
theContext->UnhilightSelected(Standard_False);
- for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt(theOwners);
+ for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(theOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
Handle(SelectMgr_EntityOwner) anOwner = anOwnersIt.Value();
{
QList<QVariant> anInfo;
anInfo.append (theObject->DynamicType()->Name());
- anInfo.append (VInspector_Tools::GetPointerInfo (theObject, true).ToCString());
+ anInfo.append (Standard_Dump::GetPointerInfo (theObject, true).ToCString());
Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (theObject);
if (aShapeIO.IsNull())
Handle(SelectMgr_EntityOwner) anOwner = theContext->DetectedOwner();
if (anOwner.IsNull())
continue;
- Standard_Transient* anOwnerPtr = anOwner.operator->();
+ Standard_Transient* anOwnerPtr = anOwner.get();
if (aSelectedIds.contains ((size_t)anOwnerPtr))
continue;
aSelectedIds.append ((size_t)anOwnerPtr);
aSelectedPointers.append (anIOInfo[1].toString());
aSelectedTypes.append (anIOInfo[2].toString());
}
- aSelectedOwners.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+ aSelectedOwners.append (Standard_Dump::GetPointerInfo (anOwnerPtr, true).ToCString());
}
aValues.append (aSelectedNames.join (", "));
aValues.append (aSelectedPointers.join (", "));
Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
if (anOwner.IsNull())
continue;
- Standard_Transient* anOwnerPtr = anOwner.operator->();
+ Standard_Transient* anOwnerPtr = anOwner.get();
if (aSelectedIds.contains ((size_t)anOwnerPtr))
continue;
aSelectedIds.append ((size_t)anOwnerPtr);
aSelectedPointers.append (anIOInfo[1].toString());
aSelectedTypes.append (anIOInfo[2].toString());
}
- aSelectedOwners.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+ aSelectedOwners.append (Standard_Dump::GetPointerInfo (anOwnerPtr, true).ToCString());
}
aValues.append (aSelectedNames.join (", "));
aValues.append (aSelectedPointers.join (", "));
return aSelectedInfo.size() > 2 ? aSelectedInfo[1].toString() : QString();
}
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::ToName (const VInspector_SelectionType theType, const int theValue)
-{
- switch (theType)
- {
- case VInspector_SelectionType_TypeOfUpdate:
- {
- switch (theValue)
- {
- case SelectMgr_TOU_Full: return "Full";
- case SelectMgr_TOU_Partial: return "Partial";
- case SelectMgr_TOU_None: return "None";
- default: break;
- }
- }
- break;
- case VInspector_SelectionType_StateOfSelection:
- {
- switch (theValue)
- {
- case SelectMgr_SOS_Any: return "Any";
- case SelectMgr_SOS_Unknown: return "Unknown";
- case SelectMgr_SOS_Activated: return "Activated";
- case SelectMgr_SOS_Deactivated: return "Deactivated";
- default: break;
- }
- }
- break;
- case VInspector_SelectionType_TypeOfBVHUpdate:
- {
- switch (theValue)
- {
- case SelectMgr_TBU_Add: return "Add";
- case SelectMgr_TBU_Remove: return "Remove";
- case SelectMgr_TBU_Renew: return "Renew";
- case SelectMgr_TBU_Invalidate: return "Invalidate";
- case SelectMgr_TBU_None: return "None";
- default: break;
- }
- }
- default: break;
- }
- return "";
-}
-
-// =======================================================================
-// function : SelectionModeToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation)
+namespace
{
- // types are obtained by comment of SelectMgr_Selection class;
- Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (thePresentation);
- if (!aShapePresentation.IsNull())
- return VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType (theMode)).ToCString();
- else
+ static Standard_CString VInspector_Table_PrintDisplayActionType[5] =
{
- Handle(AIS_Trihedron) aTrihedronPresentation = Handle(AIS_Trihedron)::DownCast (thePresentation);
- if (!aTrihedronPresentation.IsNull())
- {
- switch (theMode)
- {
- case 0: return "Trihedron";
- case 1: return "Trihedron Origin";
- case 2: return "Trihedron Axes";
- case 3: return "Trihedron Planes";
- default: break;
- }
- }
- }
- return TCollection_AsciiString (theMode);
+ "None", "Display", "Redisplay", "Erase", "Remove"
+ };
}
-// =======================================================================
-// function : OrientationToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::OrientationToName (const TopAbs_Orientation& theOrientation)
+//=======================================================================
+//function : DisplayActionTypeToString
+//purpose :
+//=======================================================================
+Standard_CString VInspector_Tools::DisplayActionTypeToString (View_DisplayActionType theType)
{
- Standard_SStream aSStream;
- TopAbs::Print(theOrientation, aSStream);
- return aSStream.str().c_str();
+ return VInspector_Table_PrintDisplayActionType[theType];
}
-// =======================================================================
-// function : LocationToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::LocationToName (const TopLoc_Location& theLocation)
+//=======================================================================
+//function : DisplayActionTypeFromString
+//purpose :
+//=======================================================================
+Standard_Boolean VInspector_Tools::DisplayActionTypeFromString (Standard_CString theTypeString,
+ View_DisplayActionType& theType)
{
- gp_Trsf aTrsf = theLocation.Transformation();
-
- TCollection_AsciiString aValues;
- for (int aRowId = 1; aRowId <= 3; aRowId++)
+ const TCollection_AsciiString aName (theTypeString);
+ for (Standard_Integer aTypeIter = 0; aTypeIter <= View_DisplayActionType_RemoveId; ++aTypeIter)
{
- for (int aColId = 1; aColId <= 4; aColId++) {
- aValues += TCollection_AsciiString (aTrsf.Value(aRowId, aColId));
- if (aColId != 4)
- aValues += ",";
+ Standard_CString aTypeName = VInspector_Table_PrintDisplayActionType[aTypeIter];
+ if (aName == aTypeName)
+ {
+ theType = View_DisplayActionType (aTypeIter);
+ return Standard_True;
}
- if (aRowId != 3)
- aValues += " ";
}
- return aValues;
-}
-
-// =======================================================================
-// function : ReadShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_Tools::ReadShape (const TCollection_AsciiString& theFileName)
-{
- TopoDS_Shape aShape;
-
- BRep_Builder aBuilder;
- BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
-
- return aShape;
+ return Standard_False;
}
#define VInspector_Tools_H
#include <AIS_InteractiveContext.hxx>
+#include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
+#include <Graphic3d_Buffer.hxx>
+#include <Graphic3d_Mat4.hxx>
+#include <Graphic3d_Mat4d.hxx>
+#include <Select3D_BndBox3d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <inspector/VInspector_CallBackMode.hxx>
-#include <inspector/VInspector_SelectionType.hxx>
+#include <inspector/View_DisplayActionType.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QList>
#include <QVariant>
#include <Standard_WarningsRestore.hxx>
+class ViewControl_TableModelValues;
+
+class Graphic3d_IndexBuffer;
+class Graphic3d_Buffer;
+class Graphic3d_BoundBuffer;
+
//! \class VInspector_Tools
//! The class that gives auxiliary methods for Visualization elements manipulation
class VInspector_Tools
//! \return text value
Standard_EXPORT static TCollection_AsciiString GetShapeTypeInfo (const TopAbs_ShapeEnum& theType);
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo);
-
//! Returns number of selected owners for presentation
//! \param theContext an interactive context
//! \param theObject a presentation
//! \param theOwner a selectable owner
//! \return boolean value
Standard_EXPORT static bool IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
- const Handle(SelectMgr_EntityOwner)& theOwner);
+ const Handle(SelectBasics_EntityOwner)& theOwner);
//! Returns all owners present in the context
//! \param theContext an interactive context
//! \return container of owners
- Standard_EXPORT static NCollection_List<Handle(SelectMgr_EntityOwner)> ContextOwners (
+ Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ContextOwners (
const Handle(AIS_InteractiveContext)& theContext);
//! Returns active owners in main selector of context
//! \param theContext an interactive context
//! \param theEmptySelectableOwners container of owners with NULL presentation or not displayed presentation
//! \return container of owners
- Standard_EXPORT static NCollection_List<Handle(SelectMgr_EntityOwner)> ActiveOwners (
+ Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ActiveOwners (
const Handle(AIS_InteractiveContext)& theContext,
- NCollection_List<Handle(SelectMgr_EntityOwner)>& theEmptySelectableOwners);
+ NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners);
//! Unhighlight selected, set selected the owners
//! \param theContext an interactive context
//! \param theOwners a container of owners
Standard_EXPORT static void AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
- const NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners);
+ const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
//! Unhighlight selected, set selected presentations
//! \param theContext an interactive context
//! Returns the first pointer of selection in the context
Standard_EXPORT static QString GetSelectedInfoPointers (const Handle(AIS_InteractiveContext)& theContext);
- //! Returns string information of call back mode
- //! \param theMode type of selection
- //! \param theValue a value in selection enumeration
- //! \return information text
- Standard_EXPORT static TCollection_AsciiString ToName (const VInspector_SelectionType theType, const int theValue);
-
- //! Returns selection information
- //! \param theMode a selection mode
- //! \param thePresentation a presentation
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation);
-
- //! Returns text of orientation
- //! \param theOrientation an orientation value
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString OrientationToName (const TopAbs_Orientation& theOrientation);
-
- //! Returns text of orientation
- //! \param theLocation a location value
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString LocationToName (const TopLoc_Location& theLocation);
-
- //! Read Shape using BREP reader
- //! \param theFileName a file name
- //! \return shape or NULL
- Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+ //! Returns the string name for a given type.
+ //! @param theType action type
+ //! @return string identifier from the display action type
+ Standard_EXPORT static Standard_CString DisplayActionTypeToString (View_DisplayActionType theType);
+
+ //! Returns the enumeration type from the given string identifier (using case-insensitive comparison).
+ //! @param theTypeString string identifier
+ //! @return string identifier from the display action type
+ static View_DisplayActionType DisplayActionTypeFromString (Standard_CString theTypeString)
+ {
+ View_DisplayActionType aType = View_DisplayActionType_NoneId;
+ DisplayActionTypeFromString (theTypeString, aType);
+ return aType;
+ }
+
+ //! Determines the enumeration type from the given string identifier (using case-insensitive comparison).
+ //! @param theTypeString string identifier
+ //! @param theType detected action type
+ //! @return TRUE if string identifier is known
+ Standard_EXPORT static Standard_Boolean DisplayActionTypeFromString (Standard_CString theTypeString,
+ View_DisplayActionType& theType);
};
#endif
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QItemSelectionModel>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
-const int COLUMN_NAME_WIDTH = 260;
-const int COLUMN_SIZE_WIDTH = 30;
const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
// =======================================================================
// function : Constructor
VInspector_ViewModel::VInspector_ViewModel (QObject* theParent)
: TreeModel_ModelBase (theParent)
{
- SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
- SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
- SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (3, TreeModel_HeaderSection ("ShapeType", COLUMN_SHAPE_TYPE_WIDTH)); // ItemPresentableObject, ItemSelection
- SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); // ItemContext, ItemPresentableObject, ItemSelection
- SetHeaderItem (5, TreeModel_HeaderSection ("ActivatedModes", -1)); // ItemPresentableObject
- SetHeaderItem (6, TreeModel_HeaderSection ("DeviationCoefficient", -1, true)); // ItemContext, ItemPresentableObject
- SetHeaderItem (7, TreeModel_HeaderSection ("Deflection", -1, true)); // ItemPresentableObject
- SetHeaderItem (8, TreeModel_HeaderSection ("IsAutoTriangulation", -1, true)); // ItemPresentableObject
-
- SetHeaderItem (9, TreeModel_HeaderSection ("SelectionState", -1)); // ItemSelection
- SetHeaderItem (10, TreeModel_HeaderSection ("Sensitivity", -1, true)); // ItemSelection
- SetHeaderItem (11, TreeModel_HeaderSection ("UpdateStatus", -1, true)); // ItemSelection
- SetHeaderItem (12, TreeModel_HeaderSection ("BVHUpdateStatus", -1, true)); // ItemSelection
-
- SetHeaderItem (13, TreeModel_HeaderSection ("IsActiveForSelection", -1, true)); // ItemSensitiveEntity
- SetHeaderItem (14, TreeModel_HeaderSection ("SensitivityFactor", -1, true)); // ItemSensitiveEntity
- SetHeaderItem (15, TreeModel_HeaderSection ("NbSubElements", -1, true)); // ItemSensitiveEntity
- SetHeaderItem (16, TreeModel_HeaderSection ("Priority", -1, true)); // ItemSensitiveEntity
-
- SetHeaderItem (17, TreeModel_HeaderSection ("TShape", COLUMN_POINTER_WIDTH, true)); // ItemEntityOwner
- SetHeaderItem (18, TreeModel_HeaderSection ("Orientation", -1, true)); // ItemEntityOwner
- SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
-
- SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void VInspector_ViewModel::InitColumns()
+{
+ TreeModel_ModelBase::InitColumns();
+
+ SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+ SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
}
// =======================================================================
// function : createRootItem
// purpose :
// =======================================================================
-void VInspector_ViewModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr VInspector_ViewModel::createRootItem (const int theColumnId)
{
- myRootItems.insert (theColumnId, VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
- if (theColumnId == 0)
- m_pRootItem = myRootItems[0];
+ return VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
}
// =======================================================================
// fill root item by the application
for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
itemDynamicCast<VInspector_ItemContext>(myRootItems[aColId])->SetContext (theContext);
- EmitLayoutChanged();
+
+ UpdateTreeModel();
}
// =======================================================================
// function : FindPointers
// purpose :
// =======================================================================
-QModelIndexList VInspector_ViewModel::FindPointers (const QStringList& thePointers)
+void VInspector_ViewModel::FindPointers (const QStringList& thePointers,
+ const QModelIndex& theParent,
+ QModelIndexList& theFoundIndices)
{
- QModelIndexList anIndices;
- QModelIndex aParentIndex = index (0, 0);
+ (void)thePointers;
+ (void)theParent;
+ (void)theFoundIndices;
+ // should be used after Object of items is improved, as it takes a lot of time on BVH item
+ /*
+ if (thePointers.isEmpty())
+ return;
+
+ QModelIndex aParentIndex = theParent.isValid() ? theParent : index (0, 0);
TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // context item
for (int aRowId = 0, aCount = aParentItem->rowCount(); aRowId < aCount; aRowId++)
{
QModelIndex anIndex = index (aRowId, 0, aParentIndex);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- VInspector_ItemPresentableObjectPtr anItemPrs = itemDynamicCast<VInspector_ItemPresentableObject>(anItemBase);
- if (!anItemPrs)
+ VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItemBase);
+ if (!aVItem)
continue;
- if (thePointers.contains (anItemPrs->PointerInfo()))
- anIndices.append (anIndex);
- }
- return anIndices;
+ const Handle(Standard_Transient)& anObject = aVItem->Object();
+ TCollection_AsciiString aPointerInfo = Standard_Dump::GetPointerInfo (anObject);
+ if (thePointers.contains (aPointerInfo.ToCString()))
+ theFoundIndices.append (anIndex);
+
+ FindPointers (thePointers, anIndex, theFoundIndices);
+ }*/
}
// =======================================================================
return QModelIndex();
}
-// =======================================================================
-// function : GetSelectedOwners
-// purpose :
-// =======================================================================
-void VInspector_ViewModel::GetSelectedOwners (QItemSelectionModel* theSelectionModel,
- NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners)
-{
- if (!theSelectionModel)
- return;
- QList<TreeModel_ItemBasePtr> anItems;
-
- QModelIndexList anIndices = theSelectionModel->selectedIndexes();
- for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
- {
- TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
- if (!anItem || anItems.contains (anItem))
- continue;
- anItems.append (anItem);
- }
-
- QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
- for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
- {
- TreeModel_ItemBasePtr anItem = *anItemIt;
- Handle(SelectMgr_EntityOwner) anEntityOwner;
- if (VInspector_ItemEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemEntityOwner>(anItem))
- {
- anEntityOwner = anOwnerItem->EntityOwner();
- }
- else if (VInspector_ItemSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(anItem))
- {
- anEntityOwner = aSensItem->GetSensitiveEntity()->BaseSensitive()->OwnerId();
- }
- if (anEntityOwner.IsNull())
- continue;
- if (aSelectedIds.contains ((size_t)anEntityOwner.operator->()))
- continue;
- aSelectedIds.append ((size_t)anEntityOwner.operator->());
- if (!anEntityOwner.IsNull())
- theOwners.Append (anEntityOwner);
- }
-}
-
// =======================================================================
// function : UpdateTreeModel
// purpose :
#include <AIS_InteractiveContext.hxx>
#include <NCollection_List.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <SelectBasics_EntityOwner.hxx>
#include <Standard.hxx>
#include <inspector/TreeModel_ModelBase.hxx>
#include <inspector/VInspector_ItemBase.hxx>
Standard_EXPORT VInspector_ViewModel (QObject* theParent);
//! Destructor
- virtual ~VInspector_ViewModel() Standard_OVERRIDE {};
+ virtual ~VInspector_ViewModel() {}
+
+ //! Creates model columns and root items.
+ Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
//! Initialize the model by the given context
//! \param theContext viewer context
//! Returns tree view indices for the given pointers of presentable object
//! \param thePointers a list of presentation pointers
- //! \return container of indices
- Standard_EXPORT QModelIndexList FindPointers (const QStringList& thePointers);
+ //! \param theParent an index of the parent item
+ //! \param [out] container of indices
+ Standard_EXPORT void FindPointers (const QStringList& thePointers,
+ const QModelIndex& theParent,
+ QModelIndexList& theFoundIndices);
//! Returns tree model index of the presentation item in the tree view.
//! \param thePresentation a presentation
//! \return model index if the value is found or Null model index
Standard_EXPORT QModelIndex FindIndex (const Handle(AIS_InteractiveObject)& thePresentation) const;
- //! Returns root item by column
- //! \param theColumn an index of the column
- //! \return root item instance
- virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
- { return myRootItems[theColumn]; }
-
- //! Returns select owners for tree view selected items
- //! \param theSelectionModel a selection model
- //! \param theOwners an output list of owners
- Standard_EXPORT static void GetSelectedOwners (QItemSelectionModel* theSelectionModel,
- NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners);
-
//! Updates tree model
Standard_EXPORT void UpdateTreeModel();
protected:
-
//! Creates root item
//! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
-
-private:
+ Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
- QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
};
#endif
// purpose :
// =======================================================================
VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
-: TreeModel_ModelBase (theParent)
+: TreeModel_ModelBase (theParent), myHistoryTypesMaxAmount (theHistoryTypesMaxAmount)
{
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void VInspector_ViewModelHistory::InitColumns()
+{
+ TreeModel_ModelBase::InitColumns();
+
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
- SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
- SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (3, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
- SetHeaderItem (4, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
- SetHeaderItem (5, TreeModel_HeaderSection ("Selected/Highlighted", -1));
+ SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item
+ SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
+ SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+ SetHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
+ SetHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
+ SetHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1));
for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
{
VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot> (myRootItems[aColumnId]);
- aRootItem->SetHistoryTypesMaxAmount (theHistoryTypesMaxAmount);
+ aRootItem->SetHistoryTypesMaxAmount (myHistoryTypesMaxAmount);
}
}
-
// =======================================================================
// function : createRootItem
// purpose :
// =======================================================================
-void VInspector_ViewModelHistory::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr VInspector_ViewModelHistory::createRootItem (const int theColumnId)
{
- myRootItems.insert (theColumnId, VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
- if (theColumnId == 0)
- m_pRootItem = myRootItems[0];
+ return VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
}
// =======================================================================
Standard_EXPORT VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount = 50);
//! Destructor
- virtual ~VInspector_ViewModelHistory() Standard_OVERRIDE {};
+ virtual ~VInspector_ViewModelHistory() {}
+
+ //! Creates model columns and root items.
+ Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
//! Append new element under the root item
Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
//! \param container of strings
Standard_EXPORT QStringList GetSelectedPointers (const QModelIndex& theIndex);
- //! Returns root item by column
- //! \param theColumn an index of the column
- //! \return root item instance
- virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE { return myRootItems[theColumn]; }
-
protected:
//! Creates root item
//! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+ Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
private:
-
- QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
+ int myHistoryTypesMaxAmount; //!< maximum types in history
};
#endif
#include <inspector/VInspector_Window.hxx>
#include <AIS_Shape.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+
+#include <inspector/Convert_Tools.hxx>
#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/ViewControl_MessageDialog.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
#include <inspector/ViewControl_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_CallBack.hxx>
#include <inspector/VInspector_Communicator.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_ViewModelHistory.hxx>
+#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_TreeView.hxx>
+#include <inspector/View_Displayer.hxx>
+#include <inspector/View_DisplayPreview.hxx>
+#include <inspector/View_PreviewParameters.hxx>
#include <inspector/View_Widget.hxx>
#include <inspector/View_Window.hxx>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
+const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH = 300;
+const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT = 1000;
+
const int VINSPECTOR_DEFAULT_WIDTH = 1250;
const int VINSPECTOR_DEFAULT_HEIGHT = 800;
VInspector_Window::VInspector_Window()
: myParent (0), myExportToShapeViewDialog (0), myViewWindow (0)
{
+ myDisplayer = new View_Displayer();
+
myMainWindow = new QMainWindow (0);
QWidget* aCentralWidget = new QWidget (myMainWindow);
myTreeView->header()->setStretchLastSection (true);
myTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView);
+ aTreeModel->InitColumns();
myTreeView->setModel (aTreeModel);
// hide Visibility column
TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
myTreeView->setSelectionModel (aSelModel);
connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
aParentLay->addWidget(myTreeView, 1, 0);
aParentLay->setRowStretch (1, 1);
myMainWindow->setCentralWidget (aCentralWidget);
+ // property view
+ myPropertyView = new ViewControl_PropertyView (myMainWindow,
+ QSize(VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH, VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT));
+ myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
+ myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
+ myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
+ myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
+ myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
+ connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool)));
+
myHistoryView = new ViewControl_TreeView (myMainWindow);
myHistoryView->setSelectionBehavior (QAbstractItemView::SelectRows);
((ViewControl_TreeView*)myHistoryView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH,
myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
+ aHistoryModel->InitColumns();
myHistoryView->setModel (aHistoryModel);
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHistoryModel);
this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
anItem = aHistoryModel->GetHeaderItem (0);
- TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
// hide Visibility column
+ TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
anItem = aHistoryModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
anItem.SetIsHidden (true);
aHistoryModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
}
anItems.clear();
- TreeModel_Tools::SaveState (myHistoryView, anItems, "history_view_");
+ View_PreviewParameters::SaveState (displayer()->DisplayPreview()->GetPreviewParameters(), anItems, "preview_parameters_");
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+
+ anItems.clear();
+ TreeModel_Tools::SaveState (myTreeView, anItems);
+ for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+ {
+ theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+ }
+
+ anItems.clear();
+ ViewControl_PropertyView::SaveState (myPropertyView, anItems, "property_view_parameters_");
+ for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+ theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+
+ if (myViewWindow)
+ {
+ anItems.clear();
+ View_Window::SaveState(myViewWindow, anItems);
+ for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+ theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+ }
}
// =======================================================================
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
{
- if (anItemIt.Key().IsEqual ("geometry"))
- myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
- else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+ TCollection_AsciiString anItemKey = anItemIt.Key();
+ TCollection_AsciiString anItemValue = anItemIt.Value();
+ if (anItemKey.IsEqual ("geometry"))
+ myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemValue.ToCString()));
+ else if (TreeModel_Tools::RestoreState (myTreeView, anItemKey.ToCString(), anItemValue.ToCString()))
continue;
- else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(),
+ else if (TreeModel_Tools::RestoreState (myHistoryView, anItemKey.ToCString(), anItemValue.ToCString(),
"history_view_"))
continue;
+ else if (View_PreviewParameters::RestoreState (displayer()->DisplayPreview()->GetPreviewParameters(), anItemKey.ToCString(),
+ anItemValue.ToCString(), "preview_parameters_"))
+ continue;
+ else if (ViewControl_PropertyView::RestoreState (myPropertyView, anItemKey.ToCString(),
+ anItemValue.ToCString(), "property_view_parameters_"))
+ continue;
+ else if (myViewWindow && View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+ continue;
}
}
myTreeView->scrollTo (aPresentationIndex);
}
}
+
+ if (!myCallBack.IsNull())
+ {
+ VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
+ (myHistoryView->model());
+ aHistoryModel->Reset();
+ aHistoryModel->EmitLayoutChanged();
+ }
+}
+
+// =======================================================================
+// function : SelectedPresentations
+// purpose :
+// =======================================================================
+NCollection_List<Handle(AIS_InteractiveObject)> VInspector_Window::SelectedPresentations (QItemSelectionModel* theModel)
+{
+ NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations;
+
+ QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (theModel->selectedIndexes());
+
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ NCollection_List<Handle(Standard_Transient)> anItemPresentations;
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt)
+ {
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
+ if (!aVItem)
+ continue;
+
+ anItemPresentations.Clear();
+ aVItem->Presentations (anItemPresentations);
+
+ for (NCollection_List<Handle(Standard_Transient)>::Iterator anIt (anItemPresentations); anIt.More(); anIt.Next())
+ {
+ Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (anIt.Value());
+ if (aSelectedIds.contains ((size_t)aPresentation.get()))
+ continue;
+ aSelectedIds.append ((size_t)aPresentation.get());
+ if (!aPresentation.IsNull())
+ aSelectedPresentations.Append (aPresentation);
+ }
+ }
+ return aSelectedPresentations;
+}
+
+// =======================================================================
+// function : SelectedShapes
+// purpose :
+// =======================================================================
+void VInspector_Window::SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations)
+{
+ QModelIndexList theIndices = myTreeView->selectionModel()->selectedIndexes();
+
+ QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (theIndices);
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt)
+ {
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
+ if (!aVItem /*|| aVItem->Row() == 0*/)
+ continue;
+
+ TopoDS_Shape aShape = aVItem->GetPresentationShape();
+ if (aShape.IsNull())
+ continue;
+
+ theSelPresentations.Append (new Convert_TransientShape (aShape));
+ }
}
// =======================================================================
// =======================================================================
bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
{
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aViewModel)
+ return Standard_False;
+
Handle(AIS_InteractiveContext) aContext;
Handle(VInspector_CallBack) aCallBack;
+ Standard_Boolean isModelUpdated = Standard_False;
for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next())
{
if (aCallBack.IsNull())
aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
}
- if (aContext.IsNull())
- return false;
- VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (aViewModel && aViewModel->GetContext() == aContext)
- UpdateTreeModel();
+ if (aViewModel->GetContext() != aContext)
+ SetContext(aContext);
else
- SetContext (aContext);
+ isModelUpdated = Standard_True;
if (!aCallBack.IsNull() && aCallBack != myCallBack)
{
myCallBack->SetContext(aContext);
myCallBack->SetHistoryModel(aHistoryModel);
}
+
+ if (isModelUpdated)
+ UpdateTreeModel();
+
return true;
}
// =======================================================================
void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theContext)
{
+ if (theContext.IsNull())
+ return;
+
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
aViewModel->SetContext (theContext);
myTreeView->setExpanded (aViewModel->index (0, 0), true);
if (!myCallBack.IsNull())
myCallBack->SetContext (theContext);
+
+ if (myDisplayer)
+ myDisplayer->SetContext (theContext);
}
// =======================================================================
isModelUpdated = true;
}
- TopoDS_Shape aShape = VInspector_Tools::ReadShape (theFileName);
+ TopoDS_Shape aShape = Convert_Tools::ReadShape (theFileName);
if (aShape.IsNull())
return isModelUpdated;
Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape);
- aContext->Display (aPresentation, false);
- aContext->Load (aPresentation, -1/*selection mode*/);
+ View_Displayer* aDisplayer = myViewWindow->Displayer();
+ aDisplayer->DisplayPresentation (aPresentation);
aContext->UpdateCurrentViewer();
UpdateTreeModel();
{
QMenu* aMenu = new QMenu (GetMainWindow());
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this));
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Show"), SLOT (onShow()), GetMainWindow(), this));
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Hide"), SLOT (onHide()), GetMainWindow(), this));
+ aMenu->addSeparator();
+
+ QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ if (anItemBase)
+ {
+ if (itemDynamicCast<VInspector_ItemContext> (anItemBase))
+ {
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to MessageView"), SLOT (onExportToMessageView()), GetMainWindow(), this));
+ aMenu->addSeparator();
+ }
+ }
+
+ aMenu->addSeparator();
+ for (int aTypeId = (int)View_DisplayActionType_DisplayId; aTypeId <= (int)View_DisplayActionType_RemoveId; aTypeId++)
+ {
+ aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((View_DisplayActionType) aTypeId),
+ SLOT (onDisplayActionTypeClicked()), GetMainWindow(), this));
+ }
+ aMenu->addSeparator();
+
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand"), SLOT (onExpand()), GetMainWindow(), this));
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand All"), SLOT (onExpandAll()), GetMainWindow(), this));
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Collapse All"), SLOT (onCollapseAll()), GetMainWindow(), this));
+
+ aMenu->addSeparator();
+ aMenu->addAction (ViewControl_Tools::CreateAction ("Test AddChild", SLOT (OnTestAddChild()), GetMainWindow(), this));
+
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec(aPoint);
}
UpdateTreeModel();
break;
}
- case VInspector_ToolActionType_SelectPresentationsId:
- {
- bool isChecked = myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked();
- NCollection_List<Handle(AIS_InteractiveObject)> aPresentationsForViewer;
- if (isChecked)
- aPresentationsForViewer = VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
- Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
- VInspector_Tools::AddOrRemovePresentations(aContext, aPresentationsForViewer);
- UpdateTreeModel();
- break;
- }
- case VInspector_ToolActionType_SelectOwnersId:
- {
- NCollection_List<Handle(SelectMgr_EntityOwner)> anOwnersForViewer;
- if (myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked())
- VInspector_ViewModel::GetSelectedOwners(myTreeView->selectionModel(), anOwnersForViewer);
- VInspector_Tools::AddOrRemoveSelectedShapes(aViewModel->GetContext(), anOwnersForViewer);
- UpdateTreeModel();
- break;
- }
default:
break;
}
}
// =======================================================================
-// function : onSelectionChanged
+// function : onPropertyPanelShown
// purpose :
// =======================================================================
-void VInspector_Window::onSelectionChanged (const QItemSelection&,
- const QItemSelection&)
+void VInspector_Window::onPropertyPanelShown (bool isToggled)
{
- QApplication::setOverrideCursor (Qt::WaitCursor);
+ if (!isToggled)
+ return;
- if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectPresentationsId)->isChecked())
- onToolBarActionClicked(VInspector_ToolActionType_SelectPresentationsId);
- else if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectOwnersId)->isChecked())
- onToolBarActionClicked(VInspector_ToolActionType_SelectOwnersId);
+ myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+}
- QApplication::restoreOverrideCursor();
+// =======================================================================
+// function : onTreeViewSelectionChanged
+// purpose :
+// =======================================================================
+void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&,
+ const QItemSelection&)
+{
+ if (myPropertyPanelWidget->toggleViewAction()->isChecked())
+ myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+
+ NCollection_List<Handle(Standard_Transient)> aSelPresentations;
+
+ QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes();
+ for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+ {
+ QModelIndex anIndex = *aSelIt;
+ if (anIndex.column() != 0)
+ continue;
+
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ if (!anItemBase)
+ continue;
+
+ const Handle(TreeModel_ItemProperties)& anItemProperties = anItemBase->Properties();
+ if (anItemProperties)
+ {
+ anItemProperties->Presentations (aSelPresentations);
+ }
+ }
+
+ SelectedShapes (aSelPresentations);
+ displayer()->DisplayPreview()->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations, myViewWindow->ViewWidget()->DisplayMode());
}
// =======================================================================
QModelIndexList aSelectedIndices = theSelected.indexes();
QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first());
-
- VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aTreeModel)
- return;
-
- QModelIndexList anIndices = aTreeModel->FindPointers (aPointers);
- QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
- aSelectionModel->clear();
- for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
- {
- QModelIndex anIndex = anIndices[anIndicesId];
- myTreeView->setExpanded (aTreeModel->parent (anIndex), true);
- aSelectionModel->select (anIndex, QItemSelectionModel::Select);
- }
+ selectTreeViewItems (aPointers);
}
// =======================================================================
// =======================================================================
void VInspector_Window::onExportToShapeView()
{
- NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
- VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
- if (aSelectedPresentations.Extent() <= 0)
- return;
+ NCollection_List<Handle(Standard_Transient)> aSelectedShapes;
+ SelectedShapes (aSelectedShapes);
TCollection_AsciiString aPluginName ("TKShapeView");
NCollection_List<Handle(Standard_Transient)> aParameters;
anItemNames = myParameters->GetSelectedNames (aPluginName);
QStringList anExportedPointers;
- for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt (aSelectedPresentations); anIOIt.More(); anIOIt.Next())
+ if (aSelectedShapes.Extent() > 0)
{
- Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (anIOIt.Value());
- if (aShapePresentation.IsNull())
- continue;
+ for (NCollection_List<Handle(Standard_Transient)>::Iterator aShapeIt (aSelectedShapes); aShapeIt.More(); aShapeIt.Next())
+ {
+ Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (aShapeIt.Value());
+ if (aShapePtr.IsNull())
+ continue;
- const TopoDS_Shape& aShape = aShapePresentation->Shape();
- if (aShape.IsNull())
+ const TopoDS_Shape& aShape = aShapePtr->Shape();
+ if (aShape.IsNull())
+ continue;
+ aParameters.Append (aShape.TShape());
+ anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
+ anExportedPointers.append (Standard_Dump::GetPointerInfo (aShape.TShape(), true).ToCString());
+ }
+ }
+
+ // search for objects to be exported
+ QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (myTreeView->selectionModel()->selectedIndexes());
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt)
+ {
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
+ if (!aVItem)
+ continue;
+
+ const Handle(Standard_Transient)& anObject = aVItem->Object();
+ if (anObject.IsNull())
continue;
- aParameters.Append (aShape.TShape());
- anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
- anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
+
+ aParameters.Append (anObject);
+ anItemNames.Append (anObject->DynamicType()->Name());
+ anExportedPointers.append (Standard_Dump::GetPointerInfo (anObject, true).ToCString());
}
- if (anExportedPointers.empty())
+
+ if (anExportedPointers.isEmpty())
return;
TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
- QString aMessage = QString ("TShape %1 is sent to %2.")
+ QString aMessage = QString ("Objects %1 are sent to %2.")
.arg (anExportedPointers.join(", "))
.arg (aPluginShortName.ToCString());
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
}
// =======================================================================
-// function : onShow
+// function : onDisplayActionTypeClicked
// purpose :
// =======================================================================
-void VInspector_Window::onShow()
+void VInspector_Window::onDisplayActionTypeClicked()
{
- displaySelectedPresentations (true);
+ QAction* anAction = (QAction*)sender();
+
+ displaySelectedPresentations (VInspector_Tools::DisplayActionTypeFromString (anAction->text().toStdString().c_str()));
}
// =======================================================================
-// function : onHide
+// function : onExpand
// purpose :
// =======================================================================
-void VInspector_Window::onHide()
+void VInspector_Window::onExpand()
{
- displaySelectedPresentations (false);
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = 2;
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onExpandAll
+// purpose :
+// =======================================================================
+void VInspector_Window::onExpandAll()
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = -1;
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onCollapseAll
+// purpose :
+// =======================================================================
+void VInspector_Window::onCollapseAll()
+{
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = -1;
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+ }
+}
+
+// =======================================================================
+// function : UpdateTreeModel
+// purpose :
+// =======================================================================
+void VInspector_Window::OnTestAddChild()
+{
+ Handle(AIS_Shape) aPresentation = new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt()));
+
+ aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt (10., 10., 10.))));
+ aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(20., 10., 10.))));
+ aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(30., 10., 10.))));
+
+ displayer()->DisplayPresentation (aPresentation);
+
+ UpdateTreeModel();
}
// =======================================================================
// function : displaySelectedPresentations
// purpose :
// =======================================================================
-void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
+
+void VInspector_Window::displaySelectedPresentations (const View_DisplayActionType theType)
{
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (!aViewModel)
if (aContext.IsNull())
return;
- NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
- VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
- if (aSelectedPresentations.Extent() <= 0)
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ if (!aSelectionModel)
+ return;
+
+ NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations = SelectedPresentations (aSelectionModel);
+ // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
+ // Erased to Displayed container or back
+ aSelectionModel->clear();
+
+
+ if (aSelectedPresentations.Extent() == 0)
return;
for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt(aSelectedPresentations); anIOIt.More(); anIOIt.Next())
{
Handle(AIS_InteractiveObject) aPresentation = anIOIt.Value();
- if (theToDisplay)
+ switch (theType)
{
- aContext->Display(aPresentation, false);
- aContext->Load(aPresentation, -1);
+ case View_DisplayActionType_DisplayId:
+ {
+ aContext->Display(aPresentation, false);
+ aContext->Load(aPresentation, -1);
+ }
+ break;
+
+ case View_DisplayActionType_RedisplayId: aContext->Redisplay (aPresentation, false); break;
+ case View_DisplayActionType_EraseId: aContext->Erase (aPresentation, false); break;
+ case View_DisplayActionType_RemoveId: aContext->Remove (aPresentation, false); break;
+ default: break;
}
- else
- aContext->Erase(aPresentation, false);
}
aContext->UpdateCurrentViewer();
- // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
- // Erased to Displayed container or back
+ UpdateTreeModel();
+}
+
+// =======================================================================
+// function : highlightTreeViewItems
+// purpose :
+// =======================================================================
+void VInspector_Window::highlightTreeViewItems (const QStringList& thePointers)
+{
+ VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aTreeModel)
+ return;
+
+ QModelIndexList anIndices;
+ aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
+ for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+ {
+ QModelIndex anIndex = anIndices[anIndicesId];
+ TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
+ }
+ aTreeModel->SetHighlighted (anIndices);
+
+ if (!anIndices.isEmpty())
+ myTreeView->scrollTo (anIndices.last());
+}
+
+// =======================================================================
+// function : selectTreeViewItems
+// purpose :
+// =======================================================================
+void VInspector_Window::selectTreeViewItems (const QStringList& thePointers)
+{
+ VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aTreeModel)
+ return;
+
+ QModelIndexList anIndices;
+ aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
aSelectionModel->clear();
-
- UpdateTreeModel();
+ for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+ {
+ QModelIndex anIndex = anIndices[anIndicesId];
+ TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
+ aSelectionModel->select (anIndex, QItemSelectionModel::Select);
+ }
}
// =======================================================================
// =======================================================================
Handle(AIS_InteractiveContext) VInspector_Window::createView()
{
- myViewWindow = new View_Window (0);
- myViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
+ // create two view windows
+ Handle(AIS_InteractiveContext) aContext = View_Viewer::CreateStandardViewer();
+
+ myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true);
+ myViewWindow->ViewWidget()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
myViewWindow->show();
- return myViewWindow->GetView()->GetViewer()->GetContext();
+ return aContext;
+}
+
+// =======================================================================
+// function : displayer
+// purpose :
+// =======================================================================
+View_Displayer* VInspector_Window::displayer()
+{
+ if (myViewWindow)
+ return myViewWindow->Displayer();
+
+ return myDisplayer;
}
#include <AIS_InteractiveContext.hxx>
#include <NCollection_List.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <SelectBasics_EntityOwner.hxx>
#include <Standard.hxx>
#include <inspector/TInspectorAPI_PluginParameters.hxx>
#include <inspector/VInspector_CallBack.hxx>
+#include <inspector/View_DisplayActionType.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QObject>
#include <Standard_WarningsRestore.hxx>
class ViewControl_MessageDialog;
+class ViewControl_PropertyView;
class VInspector_ToolBar;
+
+class View_Displayer;
class View_Window;
class QAbstractItemModel;
class QAction;
-class QMainWindow;
+class QDockWidget;
class QTreeView;
class QWidget;
Standard_EXPORT VInspector_Window();
//! Destructor
- virtual ~VInspector_Window() Standard_OVERRIDE {}
+ virtual ~VInspector_Window() {}
//! Provides the container with a parent where this container should be inserted.
//! If Qt implementation, it should be QWidget with QLayout set inside
//! Returns main control
QWidget* GetMainWindow() const { return myMainWindow; }
+ //! Returns presentations of selected items in tree model
+ //! \param theModel selection model
+ //! \return container of presentations
+ NCollection_List<Handle(AIS_InteractiveObject)> SelectedPresentations (QItemSelectionModel* theModel);
+
+ //! Returns selected shapes
+ //! \param [out] container of shapes
+ void SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations);
+
private:
//! Fills controls of the plugin by parameters:
//! \param theActionId an action identifier in tool bar
void onToolBarActionClicked (const int theActionId);
+ //! Display content of selected tree view item if isToggled is true
+ //! \param isToggled true if the property dock widget is shown
+ void onPropertyPanelShown (bool isToggled);
+
//! Synchronization selection between history and tree view. Selection by history view
//! \param theSelected a selected items
//! \param theDeselected a deselected items
//! check box is checked
//! \param theSelected a selected items
//! \param theDeselected a deselected items
- void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+ void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
//! Exports the first selected shape into ShapeViewer plugin.
void onExportToShapeView();
- //! Shows selected presentation if it is not shown yet
- void onShow();
+ //! Apply activated display action
+ void onDisplayActionTypeClicked();
+
+ //! Expand two next levels for all selected item
+ void onExpand();
+
+ //! Expand all levels for all selected items
+ void onExpandAll();
+
+ //! Collapse all levels for all selected items
+ void onCollapseAll();
- //! Erase selected presentation if it is shown
- void onHide();
+ //! Creates a tree of inherited presentable objects
+ void OnTestAddChild();
private:
//! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
//! still belongs to the current context until Remove is called.
- //! \param theToDisplay if true, presentation is displayed otherwise erased
- void displaySelectedPresentations (const bool theToDisplay);
+ //! \param theType display action type
+ void displaySelectedPresentations (const View_DisplayActionType theType);
+
+ //! Set items of the pointers highlighted in tree view
+ //! \param theType display action type
+ void highlightTreeViewItems (const QStringList& thePointers);
+
+ //! Set items of the pointers selected in tree view
+ //! \param theType display action type
+ void selectTreeViewItems (const QStringList& thePointers);
+
+ //! Returns displayer where the presentations/preview should be shown/erased
+ //! If default view is created, it returns displayer of this view
+ Standard_EXPORT View_Displayer* displayer();
//! Creates an istance of 3D view to initialize context.
//! \return a context of created view.
QMainWindow* myMainWindow; //!< main control
VInspector_ToolBar* myToolBar; //!< tool bar actions
+
+ QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
+ ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
+
QTreeView* myTreeView; //!< tree view of AIS content
QTreeView* myHistoryView; //!< history of AIS context calls
Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
+
+ View_Displayer* myDisplayer; //!< class to display presentations/preview if myMainWindow is not used
};
#endif
View.qrc
View_ContextType.hxx
+View_DisplayActionType.hxx
View_Displayer.cxx
View_Displayer.hxx
+View_DisplayPreview.cxx
+View_DisplayPreview.hxx
View_PresentationType.hxx
+View_PreviewParameters.cxx
+View_PreviewParameters.hxx
View_ToolActionType.hxx
View_ToolBar.cxx
View_ToolBar.hxx
View_ToolButton.hxx
-View_Tools.cxx
-View_Tools.hxx
View_ViewActionType.hxx
View_Viewer.cxx
View_Viewer.hxx
<file>icons/cursor_zoom.png</file>
<file>icons/keep_view_off.png</file>
<file>icons/keep_view_on.png</file>
+ <file>icons/trihedron.png</file>
<file>icons/view_clear.png</file>
<file>icons/view_dm_shading.png</file>
<file>icons/view_dm_wireframe.png</file>
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef View_DisplayActionType_H
+#define View_DisplayActionType_H
+
+//! \enum View_DisplayActionType
+enum View_DisplayActionType
+{
+ View_DisplayActionType_NoneId, //!< No action activated
+ View_DisplayActionType_DisplayId, //!< Display action
+ View_DisplayActionType_RedisplayId, //!< Redisplay action
+ View_DisplayActionType_EraseId, //!< Erase action
+ View_DisplayActionType_RemoveId //!< Remove action
+};
+
+#endif
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/View_DisplayPreview.hxx>
+#include <inspector/View_PreviewParameters.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+
+#include <Geom_Axis2Placement.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <TopoDS_Compound.hxx>
+
+static void enableGlobalClipping (const Handle(AIS_InteractiveObject)& theObject, const bool theIsEnable)
+{
+ if (theIsEnable)
+ {
+ theObject->SetClipPlanes (Handle(Graphic3d_SequenceOfHClipPlane)());
+ }
+ else
+ {
+ Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane();
+ aPlanes->SetOverrideGlobal (Standard_True);
+ theObject->SetClipPlanes (aPlanes);
+ }
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_DisplayPreview::View_DisplayPreview()
+{
+ myPreviewParameters = new View_PreviewParameters();
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theContext)
+{
+ if (myContext == theContext)
+ return;
+
+ // remove all preview presentations from the previous context, display it in the new
+
+ myContext = theContext;
+ if (!theContext.IsNull())
+ myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer());
+}
+
+// =======================================================================
+// function : UpdatePreview
+// purpose :
+// =======================================================================
+void View_DisplayPreview::UpdatePreview (const View_DisplayActionType,
+ const NCollection_List<Handle(Standard_Transient)>& thePresentations,
+ int theDisplayMode)
+{
+ if (myContext.IsNull())
+ return;
+
+ // clear previous previews
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIterator (myPreviewReadyPresentations); anIterator.More(); anIterator.Next())
+ {
+ if (!anIterator.Value()->GetContext().IsNull())
+ anIterator.Value()->GetContext()->Remove (anIterator.Value(), Standard_True);
+ }
+ myPreviewReadyPresentations.Clear();
+
+ if (thePresentations.IsEmpty())
+ {
+ if (!myPreviewPresentation.IsNull() && !myPreviewPresentation->GetContext().IsNull())
+ myPreviewPresentation->GetContext()->Remove (myPreviewPresentation, Standard_True);
+ myPreviewPresentation = NULL;
+
+ return;
+ }
+
+ // display parameter previews
+ BRep_Builder aBuilder;
+ TopoDS_Compound aCompound;
+ aBuilder.MakeCompound (aCompound);
+ for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator (thePresentations); anIterator.More(); anIterator.Next())
+ {
+ if (Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (anIterator.Value()))
+ {
+ aBuilder.Add (aCompound, aShapePtr->Shape());
+ }
+ Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (anIterator.Value());
+ if (!aPrs.IsNull() && aPrs->GetContext().IsNull()/*is not displayed in another context*/)
+ {
+ myContext->Display (aPrs, theDisplayMode, -1/*does not participate in selection*/, Standard_True);
+ enableGlobalClipping(aPrs, false);
+ myPreviewReadyPresentations.Append (aPrs);
+ }
+ }
+
+ if (myPreviewPresentation.IsNull())
+ {
+ myPreviewPresentation = new AIS_Shape (aCompound);
+ Quantity_Color aColor(Quantity_NOC_TOMATO);
+ myPreviewPresentation->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
+ myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
+
+ myContext->Display (myPreviewPresentation, theDisplayMode, -1/*does not participate in selection*/, Standard_True);
+ enableGlobalClipping(myPreviewPresentation, false);
+ }
+ else
+ {
+ Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
+ if (!myPreviewPresentation->GetContext().IsNull())
+ {
+ myPreviewPresentation->GetContext()->Redisplay (myPreviewPresentation, Standard_True);
+ }
+ }
+}
+
+// =======================================================================
+// function : SetDisplayMode
+// purpose :
+// =======================================================================
+void View_DisplayPreview::SetDisplayMode (const int theDisplayMode, const bool theToUpdateViewer)
+{
+ if (myContext.IsNull())
+ return;
+
+ if (!myPreviewPresentation.IsNull())
+ {
+ if (myContext == myPreviewPresentation->GetContext())
+ myContext->SetDisplayMode (myPreviewPresentation, theDisplayMode, Standard_False);
+ }
+
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator aPreviewIt (myPreviewReadyPresentations); aPreviewIt.More(); aPreviewIt.Next())
+ {
+ if (myContext == aPreviewIt.Value()->GetContext())
+ myContext->SetDisplayMode (aPreviewIt.Value(), theDisplayMode, Standard_False);
+ }
+
+ if (theToUpdateViewer)
+ myContext->UpdateCurrentViewer();
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef View_DisplayPreview_H
+#define View_DisplayPreview_H
+
+#include <inspector/View_DisplayActionType.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+
+class AIS_InteractiveObject;
+class View_PreviewParameters;
+
+//! \class View_DisplayPreview
+//! \brief It is responsible for communication with AIS Interactive Context to:
+//! - display/erase presentations;
+//! - change display mode of visualized presentations (Shaded or WireFrame mode)
+//!
+//! It contains containers of visualized presentations to obtain presentations relating only to this displayer.
+//! Displayer is connected to AIS Interactive Context
+class View_DisplayPreview
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT View_DisplayPreview();
+
+ //! Destructor
+ virtual ~View_DisplayPreview() {}
+
+ //! Stores the current context where the presentations will be displayed/erased.
+ //! Erases previuously displayd presentations if there were some displayed
+ //! \param theContext a context instance
+ Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Returns preview parameters
+ View_PreviewParameters* GetPreviewParameters() const { return myPreviewParameters; }
+
+ //! Updates visibility of the presentations for the display type
+ Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType,
+ const NCollection_List<Handle(Standard_Transient)>& thePresentations,
+ int theDisplayMode);
+
+ //! Sets display mode for all displayed presentations
+ Standard_EXPORT void SetDisplayMode (const int theDisplayMode,
+ const bool theToUpdateViewer = true);
+
+ //! Returns true if preview presentation is shown
+ Standard_Boolean HasPreview() const { return !myPreviewPresentation.IsNull(); }
+
+private:
+
+ //! Returns the current context
+ const Handle(AIS_InteractiveContext)& GetContext() const { return myContext; }
+
+private:
+
+ Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
+
+ View_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation
+ Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
+ NCollection_List<Handle(AIS_InteractiveObject)> myPreviewReadyPresentations; //!< presentation of preview for a selected object
+};
+
+#endif
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Trihedron.hxx>
+#include <Geom_Axis2Placement.hxx>
#include <Prs3d_PointAspect.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
+
+#include <inspector/View_DisplayPreview.hxx>
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
View_Displayer::View_Displayer()
: myIsKeepPresentations (false), myFitAllActive (false), myDisplayMode (-1)
{
+ myDisplayPreview = new View_DisplayPreview();
}
// =======================================================================
aPresentationsIt.More(); aPresentationsIt.Next())
DisplayPresentation (aPresentationsIt.Value(), aType, false);
}
+ myDisplayPreview->SetContext (theContext);
UpdateViewer();
}
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
GetContext()->SetDisplayMode (aDisplayedIt.Value(), theDisplayMode, Standard_False);
+ myDisplayPreview->SetDisplayMode (theDisplayMode, Standard_False);
+
if (theToUpdateViewer)
UpdateViewer();
}
UpdateViewer();
}
+// =======================================================================
+// function : DisplayDefaultTrihedron
+// purpose :
+// =======================================================================
+void View_Displayer::DisplayDefaultTrihedron (const Standard_Boolean toDisplay, const bool theToUpdateViewer)
+{
+ const Handle(AIS_Trihedron)& aTrihedron = defaultTrihedron (toDisplay);
+ if (aTrihedron.IsNull())
+ return;
+
+ if (toDisplay)
+ GetContext()->Display (aTrihedron, theToUpdateViewer);
+ else
+ GetContext()->Erase (aTrihedron, theToUpdateViewer);
+}
+
// =======================================================================
// function : SetVisible
// purpose :
return !aPresentation.IsNull();
}
+// =======================================================================
+// function : UpdatePreview
+// purpose :
+// =======================================================================
+void View_Displayer::UpdatePreview (const View_DisplayActionType theType,
+ const NCollection_List<Handle(Standard_Transient)>& thePresentations)
+{
+ myDisplayPreview->UpdatePreview (theType, thePresentations, myDisplayMode);
+ if (!myIsKeepPresentations || myFitAllActive)
+ fitAllView();
+}
+
// =======================================================================
// function : UpdateViewer
// purpose :
// =======================================================================
Handle(Standard_Transient) View_Displayer::CreatePresentation (const TopoDS_Shape& theShape)
{
- Handle(AIS_Shape) aShape = new AIS_Shape (theShape);
-
- aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
-
- return aShape;
+ return new AIS_Shape (theShape);
}
// =======================================================================
aView->FitAll();
aView->Redraw();
}
-}
\ No newline at end of file
+}
+
+// =======================================================================
+// function : defaultTrihedron
+// purpose :
+// =======================================================================
+const Handle(AIS_Trihedron)& View_Displayer::defaultTrihedron (const bool toCreate)
+{
+ if (myDefaultTrihedron.IsNull() && toCreate)
+ {
+ myDefaultTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY()));
+ myDefaultTrihedron->SetSize (1);
+ }
+ return myDefaultTrihedron;
+}
#include <NCollection_Shared.hxx>
#include <TopoDS_Shape.hxx>
#include <Quantity_Color.hxx>
+
#include <inspector/View_PresentationType.hxx>
+#include <inspector/View_DisplayActionType.hxx>
+class AIS_Trihedron;
class V3d_View;
+class View_DisplayPreview;
//! \class View_Displayer
//! \brief It is responsible for communication with AIS Interactive Context to:
//! Destructor
virtual ~View_Displayer() {}
+ //! Returns preview display instance
+ View_DisplayPreview* DisplayPreview() const { return myDisplayPreview; }
+
//! Stores the current context where the presentations will be displayed/erased.
//! Erases previuously displayd presentations if there were some displayed
//! \param theContext a context instance
//! \param theToKeepPresentation boolean state
void KeepPresentations (const bool theToKeepPresentations) { myIsKeepPresentations = theToKeepPresentations; }
+ //! Returns true if fit Fit All should be peformed automatically by each Display
+ bool IsFitAllActive() const { return myFitAllActive; }
+
//! Stores flag whether the FitAll shoud be done automatically for each display
//! \param theFitAllActive boolean value
void SetFitAllActive (const bool theFitAllActive) { myFitAllActive = theFitAllActive; }
+ //! Returns current display mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
+ int DisplayMode() const { return myDisplayMode; }
+
//! Stores display mode and changes display mode of displayed presentations
//! \param theDisplayMode a mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
//! \param theType presentation type
Standard_EXPORT void ErasePresentations (const View_PresentationType theType = View_PresentationType_Main,
const bool theToUpdateViewer = true);
- //! Erase presentation from viewer
+ //! Erases presentation from viewer
//! \param thePresentation a presentation, it will be casted to AIS_InteractiveObject
//! \param theType presentation type
//! \param isToUpdateView boolean state if viewer should be updated
const View_PresentationType theType = View_PresentationType_Main,
const bool theToUpdateViewer = true);
+ //! Displays presentation of default trihedron, create it by the first call
+ //! \param toDisplay flag to display presentation if true, or erase it
+ //! \param isToUpdateView boolean state if viewer should be updated
+ Standard_EXPORT void DisplayDefaultTrihedron (const Standard_Boolean toDisplay, const bool theToUpdateViewer);
+
//! Sets shape visible/invisible
//! \theShape shape instance
//! \theState visibility state
Standard_EXPORT bool IsVisible (const TopoDS_Shape& theShape,
const View_PresentationType theType = View_PresentationType_Main) const;
+ //! Updates visibility of the presentations for the display type
+ Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType,
+ const NCollection_List<Handle(Standard_Transient)>& thePresentations);
+
//! Calls UpdateCurrentViewer of context
Standard_EXPORT void UpdateViewer();
//! Returns 3d view
Handle(V3d_View) GetView() const;
- //! Fit all view
+ //! Fits all view
void fitAllView();
+ //! Returns default trihedron, create it if flag allows
+ //! \param toCreate boolean state if trihedron should be created if it is NULL
+ const Handle(AIS_Trihedron)& defaultTrihedron (const bool toCreate);
+
private:
+ View_DisplayPreview* myDisplayPreview; //!< class for preview display
+
Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
+ Handle(AIS_Trihedron) myDefaultTrihedron; //!< NULL presentation until the first display
+
NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive>> myDisplayed; //!< visualized presentations
NCollection_DataMap<View_PresentationType, Quantity_Color> myColorAttributes; //!< color properties of presentations
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/View_PreviewParameters.hxx>
+
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_PreviewParameters::View_PreviewParameters()
+{
+ myDrawer = new Prs3d_Drawer();
+
+ Quantity_Color aColor(Quantity_NOC_TOMATO);
+
+ // point parameters
+ myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
+
+ // shading parameters
+ Graphic3d_MaterialAspect aShadingMaterial;
+ aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+
+ myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
+ myDrawer->ShadingAspect()->SetColor (aColor);
+ myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial);
+
+ // common parameters
+ myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef View_PreviewParameters_H
+#define View_PreviewParameters_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <Prs3d_Drawer.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QMap>
+#include <QString>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class View_PreviewParameters
+//! Container of View tool bar actions
+class View_PreviewParameters
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT View_PreviewParameters ();
+
+ //! Destructor
+ virtual ~View_PreviewParameters() {}
+
+ //! Returns main control
+ const Handle(Prs3d_Drawer)& GetDrawer() const { return myDrawer; }
+
+ //! Saves state of preview parameters in a container in form: key, value. It saves:
+ //! - visibility of columns,
+ //! - columns width
+ //! \param theTreeView a view instance
+ //! \param theItems [out] properties
+ //! \param thePrefix peference item prefix
+ static void SaveState (View_PreviewParameters* theParameters,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix = QString())
+ { (void)theParameters; (void)theItems; (void)thePrefix; }
+
+ //! Restores state of preview parameters by a container
+ //! \param theTreeView a view instance
+ //! \param theKey property key
+ //! \param theValue property value
+ //! \param thePrefix peference item prefix
+ //! \return boolean value whether the property is applied to the tree view
+ static bool RestoreState (View_PreviewParameters* theParameters,
+ const QString& theKey, const QString& theValue,
+ const QString& thePrefix = QString())
+ { (void)theParameters; (void)theKey; (void)theValue; (void)thePrefix; return false; }
+
+private:
+
+ Handle(Prs3d_Drawer) myDrawer; //!< attributes for preview presentation
+};
+
+#endif
{
View_ToolActionType_KeepViewId, //!< Do not clear previously shown presentations
View_ToolActionType_KeepViewOffId, //!< Do show only for new displayed presentation
- View_ToolActionType_ClearViewId //!< Erase all displayed presentations
+ View_ToolActionType_ClearViewId, //!< Erase all displayed presentations
+ View_ToolActionType_Trihedron //!< Display/Erase trihedron presentation
};
#endif
// purpose :
// =======================================================================
View_ToolBar::View_ToolBar (QWidget* theParent, const bool isUseKeepView)
-: QObject (theParent)
+: QObject (theParent), myDefaultContextType (-1)
{
myMainWindow = new QWidget (theParent);
myViewContexts[View_ContextType_Own] = Handle(AIS_InteractiveContext)();
myViewContexts[View_ContextType_External] = Handle(AIS_InteractiveContext)();
+ myActionsMap[View_ToolActionType_Trihedron] = new QToolButton (theParent);
+ myActionsMap[View_ToolActionType_Trihedron]->setIcon (QIcon (":/icons/trihedron.png"));
+ myActionsMap[View_ToolActionType_Trihedron]->setToolTip (tr ("Trihedron display"));
+ myActionsMap[View_ToolActionType_Trihedron]->setCheckable (true);
+ myActionsMap[View_ToolActionType_Trihedron]->setChecked (false);
+
if (isUseKeepView)
{
myActionsMap[View_ToolActionType_KeepViewId] = new QToolButton (theParent);
myActionsMap[View_ToolActionType_KeepViewOffId]->setToolTip (tr ("Keep View Off: clear previously shown presentation"));
myActionsMap[View_ToolActionType_KeepViewOffId]->setCheckable (true);
myActionsMap[View_ToolActionType_KeepViewOffId]->setChecked (true);
- }
- myActionsMap[View_ToolActionType_ClearViewId] = new QToolButton (theParent);
- myActionsMap[View_ToolActionType_ClearViewId]->setIcon (QIcon (":/icons/view_clear.png"));
- myActionsMap[View_ToolActionType_ClearViewId]->setText (tr ( "Clear View"));
- myActionsMap[View_ToolActionType_ClearViewId]->setToolTip (tr ("Remove all visualized presentations from view context"));
+ myActionsMap[View_ToolActionType_ClearViewId] = new QToolButton (theParent);
+ myActionsMap[View_ToolActionType_ClearViewId]->setIcon (QIcon (":/icons/view_clear.png"));
+ myActionsMap[View_ToolActionType_ClearViewId]->setText (tr ( "Clear View"));
+ myActionsMap[View_ToolActionType_ClearViewId]->setToolTip (tr ("Remove all visualized presentations from view context"));
+ }
for (QMap<View_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin(),
anActionsLast = myActionsMap.end(); anActionsIt != anActionsLast; anActionsIt++)
aLay->addStretch (1);
}
-TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- std::ostringstream aPtrStr;
- aPtrStr << thePointer.operator->();
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend("0x");
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
// =======================================================================
// function : SetContext
// purpose :
QString aViewContextName = myViewContextNames[theType];
if (!theContext.IsNull())
aViewContextName = QString ("%1 : [%2]").arg (myViewContextNames[theType])
- .arg (getPointerInfo (theContext, true).ToCString());
+ .arg (Standard_Dump::GetPointerInfo (theContext, true).ToCString());
// there are only "Own" and "None" items
if (!theContext.IsNull() && theType == View_ContextType_External && myViewSelector->count() == 2)
myViewSelector->insertItem (View_ContextType_External, aViewContextName);
else
myViewSelector->setItemText (theType, aViewContextName);
+
+ if (myDefaultContextType >= 0 && myViewSelector->count() > myDefaultContextType)
+ {
+ // using default type during the first setting the external context
+ myViewSelector->setCurrentIndex (myDefaultContextType);
+ myDefaultContextType = -1;
+ }
}
// =======================================================================
-// function : getCurrentContextType
+// function : CurrentContextType
// purpose :
// =======================================================================
-View_ContextType View_ToolBar::GetCurrentContextType() const
+View_ContextType View_ToolBar::CurrentContextType() const
{
return (View_ContextType)myViewSelector->currentIndex();
}
// =======================================================================
-// function : GetCurrentContext
+// function : SetCurrentContext
+// purpose :
+// =======================================================================
+void View_ToolBar::SetCurrentContextType (View_ContextType theType)
+{
+ myViewSelector->setCurrentIndex ((int)theType);
+ emit contextChanged();
+}
+
+// =======================================================================
+// function : CurrentContext
// purpose :
// =======================================================================
-Handle(AIS_InteractiveContext) View_ToolBar::GetCurrentContext() const
+Handle(AIS_InteractiveContext) View_ToolBar::CurrentContext() const
{
View_ContextType aCurrentType = (View_ContextType)myViewSelector->currentIndex();
return myViewContexts[aCurrentType];
return myActionsMap.contains (anActionId) ? myActionsMap[anActionId]->isChecked() : false;
}
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_ToolBar::SaveState (View_ToolBar* theToolBar,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix)
+{
+ theItems[thePrefix + "context_type"] = QString::number (theToolBar->CurrentContextType());
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool View_ToolBar::RestoreState (View_ToolBar* theToolBar,
+ const QString& theKey, const QString& theValue,
+ const QString& thePrefix)
+{
+ if (theKey == thePrefix + "context_type")
+ {
+ theToolBar->SetDefaultContextType ((View_ContextType)theValue.toInt());
+ }
+ else
+ return false;
+
+ return true;
+}
+
// =======================================================================
// function : onActionClicked
// purpose :
Standard_EXPORT View_ToolBar (QWidget* theParent, const bool isUseKeepView = true);
//! Destructor
- virtual ~View_ToolBar() Standard_OVERRIDE {}
+ virtual ~View_ToolBar() {}
//! \returns parent widget of actions
QWidget* GetControl() const { return myMainWindow; }
- //! Append context for the given type
+ //! Appends context for the given type
//! \param theType a context type
//! \param theContext a context
Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
//! \returns type of active item of context selector
- Standard_EXPORT View_ContextType GetCurrentContextType() const;
+ Standard_EXPORT View_ContextType CurrentContextType() const;
+
+ //! Sets current context type
+ //! \param theType a context type
+ Standard_EXPORT void SetCurrentContextType (View_ContextType theType);
+
+ //! Sets default context type
+ //! \param theType a context type
+ void SetDefaultContextType (const View_ContextType theType) { myDefaultContextType = (int)theType; }
//! \returns an active context of context selector
- Standard_EXPORT Handle(AIS_InteractiveContext) GetCurrentContext() const;
+ Standard_EXPORT Handle(AIS_InteractiveContext) CurrentContext() const;
//! \returns whether the action is checked(toggled). Acceptable only if the action is checkable.
Standard_EXPORT bool IsActionChecked (const int theActionId) const;
+ //! Saves state of tool bar actions
+ //! \param theToolBar a view instance
+ //! \param theItems [out] properties
+ //! \param thePrefix peference item prefix
+ Standard_EXPORT static void SaveState (View_ToolBar* theToolBar,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix = QString());
+ //! Restores state of tool bar actions
+ //! \param theToolBar a view instance
+ //! \param theKey property key
+ //! \param theValue property value
+ //! \param thePrefix peference item prefix
+ //! \return boolean value whether the property is applied to the tree view
+ Standard_EXPORT static bool RestoreState (View_ToolBar* theToolBar,
+ const QString& theKey, const QString& theValue,
+ const QString& thePrefix = QString());
+
signals:
//! Signal about click on action of View_ToolActionType enumeration
QWidget* myMainWindow; //!< tool bar parent widget
QComboBox* myViewSelector; //!< container of possible contexts
+ int myDefaultContextType; //!< type of context read from preferences
QMap<View_ToolActionType, QToolButton*> myActionsMap; //!< tool actions
QMap<View_ContextType, Handle(AIS_InteractiveContext)> myViewContexts; //!< contexts
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/View_Tools.hxx>
-#include <inspector/View_Viewer.hxx>
-#include <inspector/View_Widget.hxx>
-#include <inspector/View_Window.hxx>
-
-#include <V3d_View.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAction>
-#include <QObject>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : CreateAction
-// purpose :
-// =======================================================================
-QAction* View_Tools::CreateAction (const QString& theText, const char* theSlot, QObject* theParent, QObject* theContext)
-{
- QAction* anAction = new QAction (theText, theParent);
- QObject::connect (anAction, SIGNAL (triggered (bool)), theContext, theSlot);
- return anAction;
-}
-
-// =======================================================================
-// function : SaveState
-// purpose :
-// =======================================================================
-void View_Tools::SaveState (View_Window* theView, QMap<QString, QString>& theItems,
- const QString& thePrefix)
-{
- QStringList aCameraDirection;
- Standard_Real aVX, aVY, aVZ;
- theView->GetView()->GetViewer()->GetView()->Proj (aVX, aVY, aVZ);
- aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
-
- theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
-}
-
-// =======================================================================
-// function : RestoreState
-// purpose :
-// =======================================================================
-bool View_Tools::RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
- const QString& thePrefix)
-{
- if (theKey == thePrefix + "view_camera_direction")
- {
- QStringList aValues = theValue.split (",");
- if (aValues.size() == 3)
- {
- Standard_Real aVX = aValues.at (0).toDouble();
- Standard_Real aVY = aValues.at (1).toDouble();
- Standard_Real aVZ = aValues.at (2).toDouble();
-
- theView->GetView()->SetInitProj (aVX, aVY, aVZ);
- }
- }
- else
- return false;
- return true;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef View_Tools_H
-#define View_Tools_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QMap>
-#include <QString>
-#include <Standard_WarningsRestore.hxx>
-
-class View_Window;
-
-class QAction;
-class QObject;
-
-//! \class View_Tools
-//! \brief The tool that gives auxiliary methods for qt elements manipulation
-class View_Tools
-{
-public:
-
- //! Creates an action with the given text connected to the slot
- //! \param theText an action text value
- //! \param theSlot a listener of triggered signal of the new action
- //! \param theParent a parent object
- //! \param theContext listener of the action toggle
- //! \return a new action
- Standard_EXPORT static QAction* CreateAction (const QString& theText, const char* theSlot,
- QObject* theParent, QObject* theContext);
-
- //! Save state of three view in a container in form: key, value. It saves:
- //! - visibiblity of columns,
- //! - columns width
- //! \param theTreeView a view instance
- //! \param theItems [out] properties
- //! \param thePrefix peference item prefix
- Standard_EXPORT static void SaveState (View_Window* theView, QMap<QString, QString>& theItems,
- const QString& thePrefix = QString());
- //! Restore state of three view by a container
- //! \param theTreeView a view instance
- //! \param theKey property key
- //! \param theValue property value
- //! \param thePrefix peference item prefix
- //! \return boolean value whether the property is applyed to the tree view
- Standard_EXPORT static bool RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
- const QString& thePrefix = QString());
-};
-
-#endif
#include <OpenGl_GraphicDriver.hxx>
#include <Standard_ExtString.hxx>
-#include <Standard_Version.hxx>
// =======================================================================
// function : CreateView
}
// =======================================================================
-// function : InitStandardViewer
+// function : InitViewer
// purpose :
// =======================================================================
-void View_Viewer::InitStandardViewer()
+void View_Viewer::InitViewer (const Handle(AIS_InteractiveContext)& theContext)
+{
+ myContext = theContext;
+ myViewer = myContext->CurrentViewer();
+}
+
+// =======================================================================
+// function : CreateStandardViewer
+// purpose :
+// =======================================================================
+Handle(AIS_InteractiveContext) View_Viewer::CreateStandardViewer()
{
Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
static Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection);
-#if OCC_VERSION_HEX > 0x060901
- myViewer = new V3d_Viewer (aGraphicDriver);
-#else
- TCollection_AsciiString a3DName ("Visu3D");
- myViewer = new V3d_Viewer (aGraphicDriver, a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30,
- V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_False);
-#endif
+ Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
+ aViewer->SetDefaultLights();
+ aViewer->SetLightOn();
+ aViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
- myViewer->SetDefaultLights();
- myViewer->SetLightOn();
- myViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
+ Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (aViewer);
+ aContext->UpdateCurrentViewer();
- myContext = new AIS_InteractiveContext (myViewer);
- myContext->UpdateCurrentViewer();
+ return aContext;
}
//! Creates OCC components on the window
//! \param theWindowHandle an id of the application window
- Standard_EXPORT void InitStandardViewer();
+ Standard_EXPORT void InitViewer (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Creates OCC components on the window
+ //! \param theWindowHandle an id of the application window
+ Standard_EXPORT static Handle(AIS_InteractiveContext) CreateStandardViewer();
//! Returns an OCC viewer
const Handle(V3d_Viewer)& GetViewer() { return myViewer; }
#include <inspector/View_Widget.hxx>
-#include <AIS_Trihedron.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Graphic3d_GraphicDriver.hxx>
-#include <Standard_Version.hxx>
#include <inspector/View_ToolButton.hxx>
#include <inspector/View_ViewActionType.hxx>
// function : Constructor
// purpose :
// =======================================================================
-View_Widget::View_Widget (QWidget* theParent, const bool isFitAllActive)
+View_Widget::View_Widget (QWidget* theParent,
+ const Handle(AIS_InteractiveContext)& theContext,
+ const bool isFitAllActive)
: QWidget (theParent), myCurrentMode (View_CurrentAction3d_Nothing), myFirst (true), myDefaultWidth (-1),
myDefaultHeight (-1), myViewIsEnabled (true), myXmin (0), myYmin (0), myXmax (0), myYmax (0), myDragButtonDownX (0),
myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0),
myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
{
myViewer = new View_Viewer (View_Viewer::DefaultColor());
- myViewer->InitStandardViewer();
-
- myViewer->GetContext()->Display(new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())), Standard_True);
+ if (!theContext.IsNull())
+ myViewer->InitViewer (theContext);
+ else
+ {
+ myViewer->InitViewer (myViewer->CreateStandardViewer());
+ }
setAttribute (Qt::WA_PaintOnScreen);
setAttribute (Qt::WA_NoSystemBackground);
#ifdef _WIN32
Aspect_Handle aWindowHandle = (Aspect_Handle)winId();
Handle(Aspect_Window) aWnd = new WNT_Window (aWindowHandle);
-#if OCC_VERSION_HEX <= 0x060901
- myViewer->GetView()->SetZClippingDepth (0.5);
- myViewer->GetView()->SetZClippingWidth (0.5);
-#endif
#elif defined (__APPLE__) && !defined (MACOSX_USE_GLX)
NSView* aViewHandle = (NSView*)winId();
Handle(Aspect_Window) aWnd = new Cocoa_Window (aViewHandle);
}
// =======================================================================
-// function : GetDisplayMode
+// function : DisplayMode
// purpose :
// =======================================================================
-int View_Widget::GetDisplayMode() const
+int View_Widget::DisplayMode() const
{
return myViewActions[View_ViewActionType_DisplayModeId]->isChecked() ? AIS_Shaded : AIS_WireFrame;
}
+// =======================================================================
+// function : SetDisplayMode
+// purpose :
+// =======================================================================
+void View_Widget::SetDisplayMode (const int theMode)
+{
+ myViewActions[View_ViewActionType_DisplayModeId]->setChecked ( theMode ? AIS_Shaded : AIS_WireFrame);
+}
+
// =======================================================================
// function : paintEvent
// purpose :
myViewer->GetView()->SetBackgroundColor (theIsEnabled ? View_Viewer::DefaultColor()
: View_Viewer::DisabledColor());
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
- GetViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
+ ViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_Widget::SaveState (View_Widget* theWidget,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix)
+{
+ theItems[thePrefix + "fitall"] = theWidget->ViewAction (View_ViewActionType_FitAllId)->isChecked();
+ theItems[thePrefix + "dispmode"] = QString::number (theWidget->DisplayMode());
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool View_Widget::RestoreState (View_Widget* theWidget,
+ const QString& theKey, const QString& theValue,
+ const QString& thePrefix)
+{
+ if (theKey == thePrefix + "fitall")
+ {
+ theWidget->SetActionChecked (View_ViewActionType_FitAllId, theValue.toInt() > 0);
+ }
+ else if (theKey == thePrefix + "dispmode")
+ {
+ theWidget->SetDisplayMode (theValue.toInt());
+ }
+ else
+ return false;
+
+ return true;
}
// =======================================================================
if (!myViewActions.empty())
return;
- myFitAllAction = new View_ToolButton (this); //!< action for automatic fit all
+ myFitAllAction = new View_ToolButton (this); // action for automatic fit all
connect (myFitAllAction, SIGNAL (checkedStateChanged(bool)), this, SLOT (onCheckedStateChanged(bool)));
createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
- myFitAllAction->setDefaultAction (GetViewAction (View_ViewActionType_FitAllId));
+ myFitAllAction->setDefaultAction (ViewAction (View_ViewActionType_FitAllId));
createAction (View_ViewActionType_FitAreaId, ":/icons/view_fitarea.png", tr ("Fit Area"), SLOT (OnFitArea()), true);
createAction (View_ViewActionType_ZoomId, ":/icons/view_zoom.png", tr ("Zoom"), SLOT (OnZoom()), true);
}
}
activateCursor (myCurrentMode);
+ emit leftButtonDown(thePoint.x(), thePoint.y());
}
// =======================================================================
myDragMultiButtonDownX = 0;
myDragMultiButtonDownY = 0;
- activateCursor (myCurrentMode);
emit selectionChanged();
+ emit leftButtonUp(thePoint.x(), thePoint.y());
}
// =======================================================================
else
processMoveEvent (thePoint.x(), thePoint.y());
}
+ emit moveTo (thePoint.x(), thePoint.y());
}
// =======================================================================
//! Enumeration defines drag mode
enum View_DragMode
{
- View_DragMode_ButtonDown, // theState == -1 button down
- View_DragMode_ButtonMove, // theState == 0 move
- View_DragMode_ButtonUp // theState == 1 button up
+ View_DragMode_ButtonDown, //!< theState == -1 button down
+ View_DragMode_ButtonMove, //!< theState == 0 move
+ View_DragMode_ButtonUp //< theState == 1 button up
};
public:
//! Constructor
- Standard_EXPORT View_Widget (QWidget* theParent, const bool isFitAllActive);
+ Standard_EXPORT View_Widget (QWidget* theParent,
+ const Handle(AIS_InteractiveContext)& theContext,
+ const bool isFitAllActive);
//! Destructor
virtual ~View_Widget() {}
//! Returns an action for the given action type
//! \param theActionId an action index
- QAction* GetViewAction (const View_ViewActionType theActionId) const { return myViewActions[theActionId]; };
+ QAction* ViewAction (const View_ViewActionType theActionId) const { return myViewActions[theActionId]; };
//! Retuns an action widget if exist. Implemented for fit all widget.
//! \param theActionId an action index
QWidget* GetWidget (const View_ViewActionType theActionId) const { return theActionId == View_ViewActionType_FitAllId ? myFitAllAction : 0; };
//! \returns 0 - AIS_WireFrame, 1 - AIS_Shaded
- Standard_EXPORT int GetDisplayMode() const;
+ Standard_EXPORT int DisplayMode() const;
- //! Enable/disable view and tool bar actions depending on the parameter
+ //! Sets display mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
+ Standard_EXPORT void SetDisplayMode (const int theMode);
+
+ //! Sets enable/disable view and tool bar actions depending on the parameter
//! \param theIsEnabled boolean value
Standard_EXPORT void SetEnabledView (const bool theIsEnabled);
- //!< widget for fit all, processed double click to perform action automatically
+ //! Returns true if action is checked. It processes fit all action only.
+ //! \param theIsEnabled boolean value
+ bool IsActionChecked (const View_ViewActionType theActionId)
+ { return theActionId == View_ViewActionType_FitAllId && myFitAllAction->isChecked(); }
+
+ //! Sets checked fit all action. Double click on fit all action set the action checked automatically
//! \param theIsEnabled boolean value
- bool IsActionChecked (const View_ViewActionType theActionId) { if (theActionId == View_ViewActionType_FitAllId) return myFitAllAction->isChecked(); }
+ void SetActionChecked (const View_ViewActionType theActionId, const bool isChecked)
+ { if (theActionId == View_ViewActionType_FitAllId) myFitAllAction->setChecked(isChecked); }
- //!< Setx initial camera position
+ //! Sets initial camera position
//! \param theVx direction on Ox
//! \param theVy direction on Oy
//! \param theVz direction on Oz
void SetInitProj (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
{ myHasInitProj = Standard_True; myInitVx = theVx; myInitVy = theVy; myInitVz = theVz; }
- //! Get paint engine for the OpenGL viewer. Avoid default execution of Qt Widget.
+ //! Returns paint engine for the OpenGL viewer. Avoid default execution of Qt Widget.
virtual QPaintEngine* paintEngine() const Standard_OVERRIDE { return 0; }
- //! Recommended size for view. If default size exists, it returns the default size
+ //! Return the recommended size for view. If default size exists, it returns the default size
Standard_EXPORT virtual QSize sizeHint() const Standard_OVERRIDE;
+ //! Saves state of widget actions
+ //! \param theParameters a view instance
+ //! \param theItems [out] properties
+ //! \param thePrefix peference item prefix
+ Standard_EXPORT static void SaveState (View_Widget* theWidget,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix = QString());
+
+ //! Restores state of widget actions
+ //! \param theParameters a view instance
+ //! \param theKey property key
+ //! \param theValue property value
+ //! \param thePrefix peference item prefix
+ //! \return boolean value whether the property is applied to the tree view
+ Standard_EXPORT static bool RestoreState (View_Widget* theWidget,
+ const QString& theKey, const QString& theValue,
+ const QString& thePrefix = QString());
+
signals:
//! Sends a signal about selection change if the left mouse button is pressed and current action does not process it
void selectionChanged();
+ //! Sends a signal about moving to the point in the view
+ //! \param theX X mouse position in pixels
+ //! \param theY Y mouse position in pixels
+ void moveTo (const int theX, const int theY);
+
+ //! Sends a signal about up the left mouse button down
+ //! \param theX X mouse position in pixels
+ //! \param theY Y mouse position in pixels
+ void leftButtonDown (const int theX, const int theY);
+
+ //! Sends a signal about up the left mouse button up
+ //! \param theX X mouse position in pixels
+ //! \param theY Y mouse position in pixels
+ void leftButtonUp (const int theX, const int theY);
+
//! Sends a signal about display mode change
void displayModeClicked();
protected:
- //! Avoid Qt standard execution of this method, redraw V3d view
+ //! Avoids Qt standard execution of this method, redraw V3d view
//! \param an event
virtual void paintEvent (QPaintEvent* theEvent) Standard_OVERRIDE;
- //! Avoid Qt standard execution of this method, do mustBeResized for V3d view, Init view if it is the first call
+ //! Avoids Qt standard execution of this method, do mustBeResized for V3d view, Init view if it is the first call
//! \param an event
virtual void resizeEvent (QResizeEvent* theEvent) Standard_OVERRIDE;
#include <inspector/View_Window.hxx>
-#include <inspector/TInspectorAPI_Version.hxx>
-
#include <inspector/View_Displayer.hxx>
+#include <inspector/View_DisplayPreview.hxx>
+#include <inspector/View_PreviewParameters.hxx>
#include <inspector/View_ToolBar.hxx>
-#include <inspector/View_Tools.hxx>
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
// function : Constructor
// purpose :
// =======================================================================
-View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bool isFitAllActive)
+View_Window::View_Window (QWidget* theParent,
+ const Handle(AIS_InteractiveContext)& theContext,
+ const bool isUseKeepView, const bool isFitAllActive)
: QWidget (theParent)
{
QGridLayout* aViewLayout = new QGridLayout (this);
aViewLayout->setContentsMargins (0, 0, 0, 0);
aViewLayout->setSpacing (DEFAULT_SPACING);
- myView = new View_Widget (this, isFitAllActive);
+ myView = new View_Widget (this, theContext, isFitAllActive);
myViewToolBar = new View_ToolBar (this, isUseKeepView);
aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
myActionsToolBar->addWidget (myView-> GetWidget (View_ViewActionType_FitAllId));
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
- myActionsToolBar->addAction (myView->GetViewAction ((View_ViewActionType)anActionId));
+ myActionsToolBar->addAction (myView->ViewAction ((View_ViewActionType)anActionId));
aViewLayout->addWidget (myActionsToolBar, 1, 0);
aViewLayout->addWidget (myView, 1, 1);
// =======================================================================
void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_InteractiveContext)& theContext)
{
- GetViewToolBar()->SetContext (View_ContextType_External, theContext);
+ ViewToolBar()->SetContext (View_ContextType_External, theContext);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_Window::SaveState (View_Window* theView, QMap<QString, QString>& theItems,
+ const QString& thePrefix)
+{
+ QStringList aCameraDirection;
+ Standard_Real aVX, aVY, aVZ;
+ Handle(V3d_View) aView = theView->ViewWidget()->GetViewer()->GetView();
+ if (aView.IsNull())
+ return;
+
+ aView->Proj (aVX, aVY, aVZ);
+ aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
+
+ theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
+
+ View_PreviewParameters::SaveState (theView->Displayer()->DisplayPreview()->GetPreviewParameters(), theItems, "preview_parameters_");
+ View_ToolBar::SaveState (theView->ViewToolBar(), theItems, "view_toolbar_");
+ View_Widget::SaveState (theView->ViewWidget(), theItems, "view_widget_");
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool View_Window::RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
+ const QString& thePrefix)
+{
+ if (theKey == thePrefix + "view_camera_direction")
+ {
+ QStringList aValues = theValue.split (",");
+ if (aValues.size() == 3)
+ {
+ Standard_Real aVX = aValues.at (0).toDouble();
+ Standard_Real aVY = aValues.at (1).toDouble();
+ Standard_Real aVZ = aValues.at (2).toDouble();
+
+ theView->ViewWidget()->SetInitProj (aVX, aVY, aVZ);
+ }
+ return true;
+ }
+ else if (View_PreviewParameters::RestoreState (theView->Displayer()->DisplayPreview()->GetPreviewParameters(),
+ theKey, theValue, "preview_parameters_"))
+ {
+ return true;
+ }
+ else if (View_ToolBar::RestoreState (theView->ViewToolBar(), theKey, theValue, "view_toolbar_"))
+ {
+ return true;
+ }
+ else if (View_Widget::RestoreState (theView->ViewWidget(), theKey, theValue, "view_widget_"))
+ {
+ // display mode is restored
+ View_Displayer* aDisplayer = theView->Displayer();
+ if (theView->ViewWidget()->DisplayMode() != aDisplayer->DisplayMode())
+ aDisplayer->SetDisplayMode (theView->ViewWidget()->DisplayMode());
+
+ bool toFitAll = theView->ViewWidget()->IsActionChecked (View_ViewActionType_FitAllId);
+ if (toFitAll != aDisplayer->IsFitAllActive())
+ aDisplayer->SetFitAllActive (toFitAll);
+
+ return true;
+ }
+
+ return false;
}
// =======================================================================
// =======================================================================
void View_Window::onViewSelectorActivated()
{
- View_ContextType aType = myViewToolBar->GetCurrentContextType();
+ View_ContextType aType = myViewToolBar->CurrentContextType();
bool isViewEnabled = aType == View_ContextType_Own;
myView->SetEnabledView (isViewEnabled);
- Handle(AIS_InteractiveContext) aContext = myViewToolBar->GetCurrentContext();
+ Handle(AIS_InteractiveContext) aContext = myViewToolBar->CurrentContext();
myDisplayer->EraseAllPresentations (true);
emit eraseAllPerformed();
{
switch (theActionId)
{
+ case View_ToolActionType_Trihedron:
+ {
+ myDisplayer->DisplayDefaultTrihedron (myViewToolBar->IsActionChecked (theActionId), Standard_True);
+ break;
+ }
case View_ToolActionType_KeepViewId:
{
myDisplayer->KeepPresentations (myViewToolBar->IsActionChecked (theActionId));
// =======================================================================
void View_Window::onViewContextMenuRequested (const QPoint& thePosition)
{
-#if TINSPECTORAPI_VERSION_HEX > 0x070200
QMenu* aMenu = new QMenu (this);
QMenu* anOrientationSubMenu = aMenu->addMenu ("Set View Orientation");
for (int i = 0; i < (int)V3d_XnegYnegZneg; i++)
{
V3d_TypeOfOrientation anOrientationType = (V3d_TypeOfOrientation)i;
- anOrientationSubMenu->addAction (View_Tools::CreateAction (V3d::TypeOfOrientationToString (anOrientationType),
- SLOT (onSetOrientation()), this, this));
+
+ QAction* anAction = new QAction (V3d::TypeOfOrientationToString (anOrientationType), this);
+ QObject::connect (anAction, SIGNAL (triggered (bool)), this, SLOT (onSetOrientation()));
+
+ anOrientationSubMenu->addAction (anAction);
}
aMenu->addMenu (anOrientationSubMenu);
QPoint aPoint = myView->mapToGlobal (thePosition);
aMenu->exec (aPoint);
-#else
- (void)thePosition;
-#endif
}
// =======================================================================
// =======================================================================
void View_Window::onSetOrientation()
{
-#if TINSPECTORAPI_VERSION_HEX > 0x070200
QAction* anAction = (QAction*)(sender());
TCollection_AsciiString anOrientationStr (anAction->text().toStdString().c_str());
aView->SetProj (anOrientationType);
aView->FitAll();
aView->Redraw();
-#endif
}
// =======================================================================
// =======================================================================
void View_Window::onDisplayModeChanged()
{
- int aDisplayMode = myView->GetDisplayMode();
+ int aDisplayMode = myView->DisplayMode();
for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator
anIterator(myDisplayer->GetDisplayed()); anIterator.More(); anIterator.Next())
myDisplayer->SetDisplayMode (aDisplayMode, anIterator.Key(), false);
public:
//! Constructor
- Standard_EXPORT View_Window (QWidget* theParent, const bool isUseKeepView = true, const bool isFitAllActive = true);
+ Standard_EXPORT View_Window (QWidget* theParent,
+ const Handle(AIS_InteractiveContext)& theContext = Handle(AIS_InteractiveContext)(),
+ const bool isUseKeepView = true, const bool isFitAllActive = true);
//! Destructor
virtual ~View_Window() {}
//! Returns view displayer
- View_Displayer* GetDisplayer() const { return myDisplayer; }
+ View_Displayer* Displayer() const { return myDisplayer; }
//! Returns view widget
- View_Widget* GetView() const { return myView; }
+ View_Widget* ViewWidget() const { return myView; }
//! Returns actions tool bar
- QToolBar* GetActionsToolBar() const { return myActionsToolBar; }
+ QToolBar* ActionsToolBar() const { return myActionsToolBar; }
//! Returns window tool bar
- View_ToolBar* GetViewToolBar() const { return myViewToolBar; }
+ View_ToolBar* ViewToolBar() const { return myViewToolBar; }
//! Sets a new context for context type
//! \param theType a type of context, will be selected in the tool bar combo box
//! \param theContext an AIS context
Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
+ //! Saves state of view window in a container in form: key, value. It saves:
+ //! - visibility of columns,
+ //! - columns width
+ //! \param theTreeView a view instance
+ //! \param theItems [out] properties
+ //! \param thePrefix peference item prefix
+ Standard_EXPORT static void SaveState (View_Window* theView, QMap<QString, QString>& theItems,
+ const QString& thePrefix = QString());
+
+ //! Restores state of view window by a container
+ //! \param theTreeView a view instance
+ //! \param theKey property key
+ //! \param theValue property value
+ //! \param thePrefix peference item prefix
+ //! \return boolean value whether the property is applied to the tree view
+ Standard_EXPORT static bool RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
+ const QString& thePrefix = QString());
+
signals:
//! Signals about calling erasing all presentations in context
void eraseAllPerformed();
+ViewControl_EditType.hxx
ViewControl_MessageDialog.cxx
ViewControl_MessageDialog.hxx
+ViewControl_PropertyView.cxx
+ViewControl_PropertyView.hxx
+ViewControl_Table.cxx
+ViewControl_Table.hxx
+ViewControl_TableModel.cxx
+ViewControl_TableModel.hxx
+ViewControl_TableModelValues.cxx
+ViewControl_TableModelValues.hxx
ViewControl_Tools.cxx
ViewControl_Tools.hxx
-ViewControl_TreeView.hxx
\ No newline at end of file
+ViewControl_TreeView.hxx
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ViewControl_EditType_H
+#define ViewControl_EditType_H
+
+//! Type of context used in a tool library
+enum ViewControl_EditType
+{
+ ViewControl_EditType_None, //!< View widget is null
+ ViewControl_EditType_Bool, //!< check box widget
+ ViewControl_EditType_Double, //!< line edit widget used double validator
+ ViewControl_EditType_Line, //!< line edit widget
+ ViewControl_EditType_Spin, //!< spin box widget
+ ViewControl_EditType_DoAction //!< control to perform the row action
+};
+
+#endif
void onCancelClicked();
private:
- //! Change state of the dialog to message tool tip. Only information control will be shown in the dialog
+ //! Changes state of the dialog to message tool tip. Only information control will be shown in the dialog
void setToolTipInfoMode();
private:
- bool myDoNotShowItAgain; //! state if the dialog should not be shown again, the latest result is used as answer
- bool myPreviousAnswer; //! the previous cached result of the dialog
+ bool myDoNotShowItAgain; //!< state if the dialog should not be shown again, the latest result is used as answer
+ bool myPreviousAnswer; //!< the previous cached result of the dialog
- QString myInformation; //! the information text
- QString myQuestion; //! the question text
+ QString myInformation; //!< the information text
+ QString myQuestion; //!< the question text
- QLabel* myInformationLabel; //! message control
- QCheckBox* myDoNotShowCheckBox; //! choice whether the dialog will be shown again
- QPushButton* myOkButton; //! accept button
- QPushButton* myCancelButton; //! reject button
+ QLabel* myInformationLabel; //!< message control
+ QCheckBox* myDoNotShowCheckBox; //!< choice whether the dialog will be shown again
+ QPushButton* myOkButton; //!< accept button
+ QPushButton* myCancelButton; //!< reject button
};
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/ViewControl_PropertyView.hxx>
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
+#include <inspector/ViewControl_TableModelValues.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QHeaderView>
+#include <QStackedWidget>
+#include <QScrollArea>
+#include <QTableView>
+#include <QVBoxLayout>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+//! Class that uses parameter size as recommended size for the widget.
+//! If the control is placed in a dock widget of the main window, it will not be resized on free size by resizing the main window.
+class ViewControl_PredefinedSizeWidget : public QWidget
+{
+public:
+ //! Constructor
+ ViewControl_PredefinedSizeWidget (QWidget* theParent, const QSize& theSize) : QWidget (theParent) { SetPredefinedSize (theSize); }
+
+ //! Destructor
+ virtual ~ViewControl_PredefinedSizeWidget() {}
+
+ //! Sets default size of control, that is used by the first control show
+ //! \param theDefaultWidth the width value
+ //! \param theDefaultHeight the height value
+ void SetPredefinedSize (const QSize& theSize) { myDefaultSize = theSize;}
+
+ //! Returns predefined size if both values are positive, otherwise parent size hint
+ virtual QSize sizeHint() const Standard_OVERRIDE { return myDefaultSize.isValid() ? myDefaultSize : QWidget::sizeHint(); }
+
+private:
+ QSize myDefaultSize; //!< default size, empty size if it should not be used
+};
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ViewControl_PropertyView::ViewControl_PropertyView (QWidget* theParent, const QSize& thePredefinedSize)
+: QObject (theParent), myOwnSelectionChangeBlocked (false)
+{
+ myMainWidget = new ViewControl_PredefinedSizeWidget (theParent, QSize (1, 100));
+ if (!thePredefinedSize.isEmpty())
+ ((ViewControl_PredefinedSizeWidget*)myMainWidget)->SetPredefinedSize (thePredefinedSize);
+
+ QVBoxLayout* aLayout = new QVBoxLayout (myMainWidget);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+
+ QScrollArea* anArea = new QScrollArea (myMainWidget);
+
+ myAttributesStack = new QStackedWidget (myMainWidget);
+ anArea->setWidget (myAttributesStack);
+ anArea->setWidgetResizable( true );
+ aLayout->addWidget (anArea);
+
+ myEmptyWidget = new QWidget (myAttributesStack);
+ myAttributesStack->addWidget (myEmptyWidget);
+
+ myTableWidget = new QWidget (myAttributesStack);
+ myTableWidgetLayout = new QVBoxLayout (myTableWidget);
+ myTableWidgetLayout->setContentsMargins (0, 0, 0, 0);
+ myAttributesStack->addWidget (myTableWidget);
+
+ myAttributesStack->setCurrentWidget (myEmptyWidget);
+
+ // create table
+ ViewControl_Table* aTable = new ViewControl_Table (myMainWidget);
+ ViewControl_TableModel* aModel = new ViewControl_TableModel(aTable->TableView());
+ aTable->SetModel (aModel);
+
+ connect (aTable->TableView()->selectionModel(),
+ SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT(onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+ connect (aModel, SIGNAL (dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)),
+ this, SIGNAL (propertyViewDataChanged()));
+
+ myTableWidgetLayout->addWidget (aTable->GetControl());
+ myTable = aTable;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::Init (ViewControl_TableModelValues* theTableValues)
+{
+ ViewControl_Table* aTable = Table();
+ if (theTableValues)
+ {
+ aTable->Init (theTableValues);
+ ViewControl_Tools::SetDefaultHeaderSections (aTable->TableView(), Qt::Horizontal);
+ }
+ aTable->SetActive (theTableValues != 0);
+
+ if (theTableValues)
+ myAttributesStack->setCurrentWidget (myTableWidget);
+ else
+ myAttributesStack->setCurrentWidget (myEmptyWidget);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::Init (QWidget*)
+{
+}
+
+// =======================================================================
+// function : ClearActiveTablesSelection
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::ClearActiveTablesSelection()
+{
+ bool aWasBlocked = myOwnSelectionChangeBlocked;
+ myOwnSelectionChangeBlocked = true;
+
+ QList<ViewControl_Table*> aTables;
+ ViewControl_Table* aTable = Table();
+ if (aTable->IsActive())
+ aTable->TableView()->selectionModel()->clearSelection();
+
+ myOwnSelectionChangeBlocked = aWasBlocked;
+}
+
+// =======================================================================
+// function : Clear
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::Clear()
+{
+ ViewControl_Table* aTable = Table();
+ if (aTable->IsActive())
+ {
+ ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (aTable->TableView()->model());
+ aModel->SetModelValues (0);
+
+ aTable->SetActive (true);
+ }
+ myAttributesStack->setCurrentWidget (myEmptyWidget);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::SaveState (ViewControl_PropertyView* thePropertyView,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix)
+{
+ ViewControl_Table* aTable = thePropertyView->Table();
+ int aColumnWidth = aTable->TableView()->columnWidth (0);
+ theItems[thePrefix + "column_width_0"] = QString::number (aColumnWidth);
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool ViewControl_PropertyView::RestoreState (ViewControl_PropertyView* thePropertyView,
+ const QString& theKey,
+ const QString& theValue,
+ const QString& thePrefix)
+{
+ if (theKey == thePrefix + "column_width_0")
+ {
+ bool isOk;
+ int aWidth = theValue.toInt (&isOk);
+ if (isOk)
+ thePropertyView->Table()->TableView()->horizontalHeader()->setDefaultSectionSize (aWidth);
+ }
+ else
+ return false;
+ return true;
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::onTableSelectionChanged (const QItemSelection&, const QItemSelection&)
+{
+ if (myOwnSelectionChangeBlocked)
+ return;
+
+ emit propertyViewSelectionChanged();
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TreeModel_PropertyView_H
+#define TreeModel_PropertyView_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <inspector/ViewControl_Table.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QObject>
+#include <QList>
+#include <Standard_WarningsRestore.hxx>
+
+class QAbstractTableModel;
+class QStackedWidget;
+class QWidget;
+class QVBoxLayout;
+
+class ViewControl_TableModelValues;
+
+//! \class ViewControl_PropertyView
+//! \brief View widget where several tables are visualized in vertical layout.
+class ViewControl_PropertyView : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT ViewControl_PropertyView (QWidget* theParent, const QSize& thePredefinedSize = QSize());
+
+ //! Destructor
+ virtual ~ViewControl_PropertyView() {}
+
+ //! Fills the view content with values. Number of visible tables is size of container,
+ //! Each element of container is values of the corresponded table
+ //! \param theTableValues values
+ Standard_EXPORT void Init (ViewControl_TableModelValues* theTableValues);
+
+ //! Fills the view content with the parameter custom widget.
+ //! \param theWidget control
+ Standard_EXPORT void Init (QWidget* theWidget);
+
+ //! Clears layout of the view and tables models.
+ Standard_EXPORT void Clear();
+
+ //! \return the text edit control
+ QWidget* GetControl() const { return myMainWidget; }
+
+ //! Returns container an active table or NULL
+ ViewControl_Table* Table() { return myTable; }
+
+ //! Clears selection in active tables
+ Standard_EXPORT void ClearActiveTablesSelection();
+
+ //! Saves state of property view in a container in form: key, value. It saves:
+ //! - visibility of columns,
+ //! - columns width
+ //! \param theTreeView a view instance
+ //! \param theItems [out] properties
+ //! \param thePrefix peference item prefix
+ Standard_EXPORT static void SaveState (ViewControl_PropertyView* theParameters,
+ QMap<QString, QString>& theItems,
+ const QString& thePrefix = QString());
+
+ //! Restores state of property view by a container
+ //! \param theTreeView a view instance
+ //! \param theKey property key
+ //! \param theValue property value
+ //! \param thePrefix peference item prefix
+ //! \return boolean value whether the property is applied to the tree view
+ Standard_EXPORT static bool RestoreState (ViewControl_PropertyView* theParameters,
+ const QString& theKey, const QString& theValue,
+ const QString& thePrefix = QString());
+
+signals:
+ //! Signal about selection change in property view table
+ void propertyViewSelectionChanged();
+
+ //! Signal about data change in property view table
+ void propertyViewDataChanged();
+
+protected slots:
+ //! Emits signal about selection is changed
+ //! \param theSelected container of selected table cells
+ //! \param theDeselected container of selected table cells
+ void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+private:
+ bool myOwnSelectionChangeBlocked; //!< blocking emit of selection changed signal
+
+ QWidget* myMainWidget; //!< parent of all controls
+
+ QStackedWidget* myAttributesStack; //!< container of already created panes
+ QWidget* myEmptyWidget; //!< an empty widget when nothing is selected in tree view
+
+ QWidget* myTableWidget; //!< widget of tables in vertical layout
+ QVBoxLayout* myTableWidgetLayout; //!< main view layout where tables or custom widgets are presented
+ ViewControl_Table* myTable; //!< table view, shown only first tables filled in Init method
+ QWidget* myCustomWidget; //!< custom view widget
+};
+#endif
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
+#include <inspector/TreeModel_Tools.hxx>
+
+#include <Standard_Dump.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAction>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QTableView>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ViewControl_Table::ViewControl_Table (QWidget* theParent)
+: QObject (theParent), myIsUseProperty (false)
+{
+ myMainWidget = new QWidget (theParent);
+ QGridLayout* aLayout = new QGridLayout (myMainWidget);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+
+ myTableView = new QTableView (myMainWidget);
+ myTableView->setVerticalScrollMode (QAbstractItemView::ScrollPerPixel);
+
+ QHeaderView* aVHeader = myTableView->verticalHeader();
+ int aDefCellSize = aVHeader->minimumSectionSize();
+ aVHeader->setDefaultSectionSize (aDefCellSize);
+
+ connect (myTableView->horizontalHeader(), SIGNAL (sectionResized (int, int, int)),
+ this, SLOT(onHeaderResized (int, int, int)));
+
+ aLayout->addWidget (myTableView);
+}
+
+// =======================================================================
+// function : SetModel
+// purpose :
+// =======================================================================
+void ViewControl_Table::SetModel (QAbstractTableModel* theModel)
+{
+ myTableView->setModel (theModel);
+
+ myTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel(theModel);
+ myTableView->setSelectionModel (aSelectionModel);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ViewControl_Table::Init (ViewControl_TableModelValues* theModelValues)
+{
+ myTableView->selectionModel()->clearSelection();
+
+ ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (myTableView->model());
+ aModel->SetModelValues (theModelValues);
+
+ myTableView->horizontalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Horizontal));
+
+ myTableView->verticalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Vertical));
+ int aSectionSize;
+ if (theModelValues->DefaultSectionSize (Qt::Vertical, aSectionSize) )
+ {
+ myTableView->verticalHeader()->setDefaultSectionSize (aSectionSize);
+ }
+ else
+ myTableView->verticalHeader()->setDefaultSectionSize (myTableView->verticalHeader()->minimumSectionSize());
+
+ aModel->EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : SelectedIndices
+// purpose :
+// =======================================================================
+void ViewControl_Table::SelectedIndices (QMap<int, QList<int>>& theSelectedIndices) const
+{
+ QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes();
+
+ int aRow, aColumn;
+ for (QModelIndexList::const_iterator anIt = aSelected.begin(); anIt != aSelected.end(); anIt++)
+ {
+ QModelIndex anIndex = *anIt;
+ aRow = anIndex.row();
+ aColumn = anIndex.column();
+ if (!theSelectedIndices.contains (aRow))
+ theSelectedIndices.insert (aRow, QList<int>());
+ theSelectedIndices[aRow].append (aColumn);
+ }
+}
+
+// =======================================================================
+// function : SeparatorData
+// purpose :
+// =======================================================================
+QString ViewControl_Table::SeparatorData()
+{
+ return ViewControl_Tools::TableSeparator();
+}
+
+// =======================================================================
+// function : SelectedPointers
+// purpose :
+// =======================================================================
+void ViewControl_Table::SelectedPointers (QStringList& thePointers) const
+{
+ QMap<int, QList<int>> aSelectedIndices;
+ SelectedIndices (aSelectedIndices);
+
+ ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(TableView()->model());
+ ViewControl_TableModelValues* aTableValues = aTableModel->ModelValues();
+
+ for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+ {
+ int aRowId = aSelIt.key();
+ QList<int> aColIds = aSelIt.value();
+ for (int aColId = 0; aColId < aColIds.size(); aColId++)
+ {
+ int aSelectedColId = aColIds[aColId];
+ if (aSelectedColId != 1)
+ continue;
+
+ QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString();
+ if (aData.contains (Standard_Dump::GetPointerPrefix().ToCString()))
+ thePointers.append (aData);
+ }
+ }
+}
+
+// =======================================================================
+// function : onHeaderResized
+// purpose :
+// =======================================================================
+void ViewControl_Table::onHeaderResized (int theSectionId, int, int)
+{
+ if (theSectionId != 0)
+ return;
+
+ myTableView->horizontalHeader()->setDefaultSectionSize (myTableView->columnWidth (theSectionId));
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ViewControl_Table_H
+#define ViewControl_Table_H
+
+#include <NCollection_List.hxx>
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Transient.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QItemSelection>
+#include <QObject>
+#include <QTableView>
+#include <Standard_WarningsRestore.hxx>
+
+class ViewControl_TableModelValues;
+
+class QAbstractTableModel;
+class QContextMenuEvent;
+class QWidget;
+
+//! \class ViewControl_Table
+//! \brief View to display table values with possibility to change table columns
+//! if the table has 1D dimension and Horizontal orientation
+class ViewControl_Table : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT ViewControl_Table (QWidget* theParent);
+
+ //! Destructor
+ virtual ~ViewControl_Table() {}
+
+ //! Sets model into table view, init selection model by the given model, connect to selection change
+ //! \param theModel table values model
+ void SetModel (QAbstractTableModel* theModel);
+
+ //! Fills table view and table size control by the model
+ //! \param theModel values model
+ Standard_EXPORT void Init (ViewControl_TableModelValues* theModelValues);
+
+ //! true if the table is used in property view and visible
+ bool IsActive() const { return myIsActive; }
+
+ //! Sets the table active and show the table
+ //! \param theState boolean value
+ void SetActive (const bool theState) { myIsActive = theState; TableView()->setVisible (theState); }
+
+ //! \return the text edit control
+ QWidget* GetControl() const { return myMainWidget; }
+
+ //! \return the table view
+ QTableView* TableView() const { return myTableView; }
+
+ //! Retuns model indices of the selected cells in table view
+ //! \param theSelectedIndices [out] a container of indices: row to list of columns
+ Standard_EXPORT void SelectedIndices (QMap<int, QList<int>>& aSelectedIndices) const;
+
+ //! Returns pointers from selected cells
+ Standard_EXPORT void SelectedPointers (QStringList& thePointers) const;
+
+ //! Returns text of separation row in table
+ //! \return string value
+ Standard_EXPORT static QString SeparatorData();
+
+protected slots:
+ void onHeaderResized (int theSectionId, int, int);
+
+private:
+ bool myIsActive; //!< true if the table is used in property view and visible
+
+ QWidget* myMainWidget; //!< parent of all controls
+ bool myIsUseProperty; //!< boolean value whether the property control should be shown/hidden
+ QTableView* myTableView; //!< table view
+};
+#endif
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/ViewControl_TableModel.hxx>
+
+// =======================================================================
+// function : SetModelValues
+// purpose :
+// =======================================================================
+void ViewControl_TableModel::SetModelValues (ViewControl_TableModelValues* theModelValues)
+{
+ if (myModelValues)
+ delete myModelValues;
+
+ myModelValues = theModelValues;
+}
+
+// =======================================================================
+// function : columnCount
+// purpose :
+// =======================================================================
+int ViewControl_TableModel::columnCount(const QModelIndex& theParent) const
+{
+ if (!myModelValues)
+ return 0;
+
+ return myModelValues->ColumnCount (theParent);
+}
+
+// =======================================================================
+// function : rowCount
+// purpose :
+// =======================================================================
+int ViewControl_TableModel::rowCount(const QModelIndex& theParent ) const
+{
+ if (!myModelValues)
+ return 0;
+
+ return myModelValues->RowCount (theParent);
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant ViewControl_TableModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ if (!myModelValues)
+ return QVariant();
+
+ int aRow = theIndex.row(), aColumn = theIndex.column();
+ return myModelValues->Data (aRow, aColumn, theRole);
+}
+
+// =======================================================================
+// function : setData
+// purpose :
+// =======================================================================
+bool ViewControl_TableModel::setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole)
+{
+ if (!myModelValues)
+ return false;
+
+ int aRow = theIndex.row(), aColumn = theIndex.column();
+ bool aResult = myModelValues->SetData (aRow, aColumn, theValue, theRole);
+
+ emit dataChanged (theIndex, theIndex);
+
+ return aResult;
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ViewControl_TableModel_H
+#define ViewControl_TableModel_H
+
+#include <Standard.hxx>
+
+#include <inspector/ViewControl_TableModelValues.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+#include <vector>
+
+//! \class ViewControl_TableModel
+//! \brief This is an extension of table model to visualize a container of values
+//! It is possible to:
+//! - set orientation to interpretate the values.
+//! - set table view header values.
+//! Items of the view are enabled and selectable.
+class ViewControl_TableModel : public QAbstractTableModel
+{
+public:
+
+ //! Constructor
+ ViewControl_TableModel (QObject* theParent = 0) : myModelValues (0) { (void)theParent; }
+
+ //! Destructor
+ virtual ~ViewControl_TableModel() {}
+
+ //! Returns instance of interface for access totable values
+ //! \return interface or NULL
+ ViewControl_TableModelValues* ModelValues() const { return myModelValues; }
+
+ //! Sets interface to table values
+ //! \theModelValues instance of values
+ Standard_EXPORT void SetModelValues (ViewControl_TableModelValues* theModelValues);
+
+ //! Emits the layoutChanged signal from outside of this class
+ void EmitLayoutChanged() { emit layoutChanged(); }
+
+ //! Returns number of columns, depending on orientation: myColumnCount or size of values container
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns content of the model index for the given role, it is obtained from internal container of values
+ //! It returns value only for DisplayRole.
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Sets the new value of passed role to tree cell.
+ //! \param[in] index refers to item in tree.
+ //! \param[in] value the new value.
+ //! \param[in] role the role of value.
+ Standard_EXPORT virtual bool setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole) Standard_OVERRIDE;
+
+ //! Returns content of the model index for the given role, it is obtainer from internal container of header values
+ //! It returns value only for DisplayRole.
+ //! \param theSection an index of value in the container
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ virtual QVariant headerData (int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const Standard_OVERRIDE
+ { return myModelValues ? myModelValues->HeaderData (theSection, theOrientation, theRole) : QVariant(); }
+
+ //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
+ //! \param theIndex a model index
+ //! \return flags
+ Qt::ItemFlags flags (const QModelIndex& theIndex) const
+ { return myModelValues ? myModelValues->Flags (theIndex) : Qt::NoItemFlags; }
+
+private:
+ ViewControl_TableModelValues* myModelValues; //!< interface to table values
+};
+
+#endif
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/ViewControl_TableModelValues.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : ColumnCount
+// purpose :
+// =======================================================================
+
+int ViewControl_TableModelValues::ColumnCount (const QModelIndex&) const
+{
+ if (!Properties().IsNull())
+ return Properties()->ColumnCount();
+
+ return 0;
+}
+
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+
+int ViewControl_TableModelValues::RowCount (const QModelIndex&) const
+{
+ return !Properties().IsNull() ? Properties()->RowCount() : 0;
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+
+QVariant ViewControl_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const
+{
+ if (!Properties().IsNull())
+ {
+ QVariant aValue = Properties()->Data (theRow, theColumn, theRole);
+ if (aValue.isValid())
+ return aValue;
+ }
+
+ if (theRole == Qt::TextAlignmentRole) // for multi-lines text, align it to the top
+ return Qt::AlignTop;
+
+ if ((theRole == Qt::FontRole || theRole == Qt::ForegroundRole) && isItalicHeader (theRow, theColumn))
+ {
+ if (theRole == Qt::FontRole)
+ {
+ QFont aFont = qApp->font();
+ aFont.setItalic (true);
+ return aFont;
+ }
+ else
+ return QColor (Qt::darkGray).darker (150);
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : SetData
+// purpose :
+// =======================================================================
+
+bool ViewControl_TableModelValues::SetData (const int theRow, const int theColumn, const QVariant& theValue, int)
+{
+ if (!Properties().IsNull())
+ return Properties()->SetData (theRow, theColumn, theValue);
+
+ return false;
+}
+
+// =======================================================================
+// function : HeaderData
+// purpose :
+// =======================================================================
+
+QVariant ViewControl_TableModelValues::HeaderData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+ if (theRole == Qt::DisplayRole)
+ return myHeaderValues.contains (theOrientation) ? myHeaderValues[theOrientation][theSection].GetName()
+ : QString::number (theSection + 1);
+ else if (theRole == Qt::ForegroundRole)
+ return QColor (Qt::darkGray);
+
+ return QVariant();
+}
+
+// =======================================================================
+// function : EditType
+// purpose :
+// =======================================================================
+ViewControl_EditType ViewControl_TableModelValues::EditType (const int theRow, const int theColumn) const
+{
+ if (!Properties().IsNull())
+ {
+ return Properties()->EditType (theRow, theColumn);
+ }
+ return ViewControl_EditType_None;
+}
+
+// =======================================================================
+// function : isItalicHeader
+// purpose :
+// =======================================================================
+Qt::ItemFlags ViewControl_TableModelValues::Flags (const QModelIndex& theIndex) const
+{
+ if (!Properties().IsNull())
+ {
+ return Properties()->TableFlags (theIndex.row(), theIndex.column());
+ }
+ return theIndex.isValid() ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags;
+}
+
+// =======================================================================
+// function : isItalicHeader
+// purpose :
+// =======================================================================
+bool ViewControl_TableModelValues::isItalicHeader (const int theRow, const int theColumn) const
+{
+ Qt::Orientation anOrientation = myOrientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical;
+ int aCell = anOrientation == Qt::Horizontal ? theColumn : theRow;
+
+ return HeaderItem (anOrientation, aCell).IsItalic();
+}
--- /dev/null
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ViewControl_TableModelValues_H
+#define ViewControl_TableModelValues_H
+
+#include <Standard.hxx>
+
+#include <inspector/TreeModel_HeaderSection.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/ViewControl_EditType.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class ViewControl_TableModelValues
+//! \brief This is an interace for ViewControl_TableModel to give real values of the model
+//! It should be filled or redefined.
+class ViewControl_TableModelValues
+{
+public:
+
+ //! Constructor
+ ViewControl_TableModelValues (const Qt::Orientation& theOrientation = Qt::Vertical) { SetOrientation (theOrientation); }
+
+ //! Destructor
+ virtual ~ViewControl_TableModelValues() {}
+
+ //! Returns item table properties builder
+ Handle(TreeModel_ItemProperties) Properties() const { return myProperties; }
+
+ //! Sets item table properties builder
+ void SetProperties (const Handle(TreeModel_ItemProperties)& theProperties) { myProperties = theProperties; }
+
+ //! Sets direction of the values applying, whether it should be placed by rows or by columns
+ //! \param theOrientation if horizontal, the values are applied by rows, otherwise by columns
+ void SetOrientation (const Qt::Orientation& theOrientation) { myOrientation = theOrientation; }
+
+ //! Fills the model header values for orientation.
+ //! \param theValues a container of header text values
+ //! \param theOrientation an orientation of header
+ void SetHeaderValues (const QList<TreeModel_HeaderSection>& theValues, const Qt::Orientation theOrientation)
+ { myHeaderValues.insert (theOrientation, theValues); }
+
+ //! Returns whether the column is hidden by default
+ //! \param theColumnId a column index
+ //! \return header section values container
+ TreeModel_HeaderSection HeaderItem (const Qt::Orientation theOrientation, const int theColumnId) const
+ { return myHeaderValues.contains(theOrientation) ? myHeaderValues[theOrientation][theColumnId] : TreeModel_HeaderSection(); }
+
+ //! Stores information about table view header visibility
+ //! \param theOrientation an orientation of header
+ //! \param theVisibility if true, header is visible
+ void SetHeaderVisible (const Qt::Orientation theOrientation, const bool theVisibility)
+ { myVisibleHeader.insert (theOrientation, theVisibility); }
+
+ //! Stores information about table view header visibility
+ //! \param theOrientation an orientation of header
+ //! \param theVisibility if true, header is visible
+ bool IsHeaderVisible (const Qt::Orientation theOrientation) const
+ { return myVisibleHeader.contains(theOrientation) ? myVisibleHeader[theOrientation] : true; }
+
+ //! Get default section size if defined
+ //! \param theOrientation an orientation of header
+ //! \param theVisibility if true, header is visible
+ bool DefaultSectionSize (const Qt::Orientation theOrientation, int& theSectionSize)
+ {
+ theSectionSize = myDefaultSectionSize.contains (theOrientation) ? myDefaultSectionSize[theOrientation] : -1;
+ return myDefaultSectionSize.contains (theOrientation);
+ }
+
+ //! Set default section size if defined
+ //! \param theOrientation an orientation of header
+ //! \param theVisibility if true, header is visible
+ void SetDefaultSectionSize (const Qt::Orientation theOrientation, const int& theSectionSize)
+ { myDefaultSectionSize.insert(theOrientation, theSectionSize); }
+
+ //! Returns number of columns, size of header values
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const;
+
+ //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int RowCount (const QModelIndex& theParent = QModelIndex()) const;
+
+ //! Returns content of the model index for the given role, it is obtained from internal container of values
+ //! It returns value only for DisplayRole.
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const;
+
+ //! Sets content of the model index for the given role, it is applied to internal container of values
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \param theRole a view role
+ //! \return true if the value is changed
+ Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
+ int theRole = Qt::DisplayRole);
+
+ //! Returns content of the model index for the given role, it is obtainer from internal container of header values
+ //! It returns value only for DisplayRole.
+ //! \param theSection an index of value in the container
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant HeaderData (int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const;
+
+ //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
+ //! \param theIndex a model index
+ //! \return flags
+ Standard_EXPORT virtual Qt::ItemFlags Flags (const QModelIndex& theIndex) const;
+
+ //! Returns type of edit control for the model index. By default, it is an empty control
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \return edit type
+ Standard_EXPORT virtual ViewControl_EditType EditType (const int theRow, const int theColumn) const;
+
+ //! Returns default color for editable cell
+ //! \return color value
+ static QColor EditCellColor() { return QColor (Qt::darkBlue); }
+
+protected:
+ //! Returns true if the header item is italic of the parameter index
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \param boolean value
+ bool isItalicHeader (const int theRow, const int theColumn) const;
+
+protected:
+
+ Qt::Orientation myOrientation; //!< orientation how the values should fill the current table view
+ QMap<Qt::Orientation, QList<TreeModel_HeaderSection> > myHeaderValues; //!< table header values
+ QMap<Qt::Orientation, bool> myVisibleHeader; //!< table header visibility
+ QMap<Qt::Orientation, int> myDefaultSectionSize; //!< table section default size
+
+ Handle(TreeModel_ItemProperties) myProperties; //!< item properties
+};
+
+#endif
#include <inspector/ViewControl_Tools.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
+#include <inspector/TreeModel_ModelBase.hxx>
+
#include <Standard_WarningsDisable.hxx>
#include <QAction>
+#include <QHeaderView>
#include <QObject>
#include <QPalette>
+#include <QTableView>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
aPalette.setColor (QPalette::All, QPalette::Foreground, Qt::white);
theControl->setPalette (aPalette);
}
+
+// =======================================================================
+// function : SetDefaultHeaderSections
+// purpose :
+// =======================================================================
+void ViewControl_Tools::SetDefaultHeaderSections(QTableView* theTableView, const Qt::Orientation theOrientation)
+{
+ ViewControl_TableModel * aTableModel = dynamic_cast<ViewControl_TableModel*> (theTableView->model());
+ ViewControl_TableModelValues* aModelValues = aTableModel->ModelValues();
+ if (!aModelValues)
+ return;
+
+ int aSectionSize;
+ if (aModelValues->DefaultSectionSize (Qt::Horizontal, aSectionSize) )
+ theTableView->horizontalHeader()->setDefaultSectionSize (aSectionSize);
+ else {
+ bool isStretchLastSection = true;
+ for (int aColumnId = 0, aNbColumns = aTableModel->columnCount(); aColumnId < aNbColumns; aColumnId++)
+ {
+ TreeModel_HeaderSection aSection = aModelValues->HeaderItem (theOrientation, aColumnId);
+ if (aSection.IsEmpty())
+ continue;
+
+ int aColumnWidth = aSection.GetWidth();
+ if (aColumnWidth > 0)
+ {
+ theTableView->setColumnWidth (aColumnId, aColumnWidth);
+ if (aColumnId == aNbColumns - 1)
+ isStretchLastSection = false;
+ }
+ theTableView->setColumnHidden (aColumnId, aSection.IsHidden());
+ }
+ if (isStretchLastSection != theTableView->horizontalHeader()->stretchLastSection())
+ theTableView->horizontalHeader()->setStretchLastSection (isStretchLastSection);
+ }
+}
+
+// =======================================================================
+// function : CreateTableModelValues
+// purpose :
+// =======================================================================
+ViewControl_TableModelValues* ViewControl_Tools::CreateTableModelValues (QItemSelectionModel* theSelectionModel)
+{
+ ViewControl_TableModelValues* aTableValues = 0;
+
+ QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (theSelectionModel->selectedIndexes(), 0);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ if (!anItemBase)
+ return aTableValues;
+
+ const Handle(TreeModel_ItemProperties)& anItemProperties = anItemBase->Properties();
+ if (anItemProperties.IsNull())
+ return aTableValues;
+
+ aTableValues = new ViewControl_TableModelValues();
+ aTableValues->SetProperties (anItemProperties);
+ return aTableValues;
+}
#include <Standard.hxx>
#include <Standard_Macro.hxx>
+#include <TCollection_AsciiString.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QString>
#include <Standard_WarningsRestore.hxx>
+class ViewControl_TableModelValues;
+
class QAction;
+class QItemSelectionModel;
class QObject;
+class QTableView;
class QWidget;
//! \class ViewControl_Tools
class ViewControl_Tools
{
public:
+ //! Returns text of separation row in table
+ //! \return string value
+ static QString TableSeparator() { return "---------------------------"; }
//! Creates an action with the given text connected to the slot
//! \param theText an action text value
//! \param theControl a widget to be modified
Standard_EXPORT static void SetWhiteBackground (QWidget* theControl);
+ //! Fills tree view by default sections parameters obtained in view's table model
+ //! \param theTableView table view instance
+ //! \param theOrientation header orientation
+ Standard_EXPORT static void SetDefaultHeaderSections (QTableView* theTableView, const Qt::Orientation theOrientation);
+
+ //! Create table of values on the current selection
+ //! It is created if the selection contains only one item and it has a property item
+ Standard_EXPORT static ViewControl_TableModelValues* CreateTableModelValues (QItemSelectionModel* theSelectionModel);
+
};
#endif
virtual QSize sizeHint() const Standard_OVERRIDE { return myDefaultSize.isValid() ? myDefaultSize : QTreeView::sizeHint(); }
private:
- QSize myDefaultSize; //! default size, empty isze if it should not be used
+ QSize myDefaultSize; //!< default size, empty size if it should not be used
};
#endif