Compare commits
3 Commits
V7_8_1
...
CR0_SHI_we
Author | SHA1 | Date | |
---|---|---|---|
|
466e3259dd | ||
|
116dc5bbf5 | ||
|
03f3900b2d |
@@ -4079,13 +4079,26 @@ void OpenGl_Context::ApplyModelWorldMatrix()
|
||||
// =======================================================================
|
||||
void OpenGl_Context::ApplyWorldViewMatrix()
|
||||
{
|
||||
if (myShaderManager->ModelWorldState().ModelWorldMatrix() != THE_IDENTITY_MATRIX)
|
||||
/*if (myShaderManager->ModelWorldState().ModelWorldMatrix() != THE_IDENTITY_MATRIX)
|
||||
{
|
||||
myShaderManager->UpdateModelWorldStateTo (THE_IDENTITY_MATRIX);
|
||||
}
|
||||
if (myShaderManager->WorldViewState().WorldViewMatrix() != WorldViewState.Current())
|
||||
{
|
||||
myShaderManager->UpdateWorldViewStateTo (WorldViewState.Current());
|
||||
}*/
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (core11 != NULL)
|
||||
{
|
||||
core11->glMatrixMode (GL_MODELVIEW);
|
||||
core11->glLoadMatrixf (WorldViewState.Current());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!myShaderManager->IsEmpty())
|
||||
{
|
||||
myShaderManager->UpdateModelWorldStateTo (THE_IDENTITY_MATRIX);
|
||||
myShaderManager->UpdateWorldViewStateTo (WorldViewState.Current());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -895,6 +895,18 @@ public: //! @name methods to alter or retrieve current state
|
||||
//! Bind default Vertex Array Object
|
||||
Standard_EXPORT void BindDefaultVao();
|
||||
|
||||
//! Active Frame Buffer Object.
|
||||
const Handle(OpenGl_FrameBuffer)& ActiveFrameBuffer() const
|
||||
{
|
||||
return myActiveFbo;
|
||||
}
|
||||
|
||||
//! Setup Active Frame Buffer Object.
|
||||
Standard_EXPORT void SetActiveFrameBuffer (const Handle(OpenGl_FrameBuffer)& theFbo)
|
||||
{
|
||||
myActiveFbo = theFbo;
|
||||
}
|
||||
|
||||
//! Default Frame Buffer Object.
|
||||
const Handle(OpenGl_FrameBuffer)& DefaultFrameBuffer() const
|
||||
{
|
||||
@@ -1132,6 +1144,7 @@ private: //! @name fields tracking current state
|
||||
//!< currently active sampler objects
|
||||
Standard_Integer myActiveMockTextures; //!< currently active mock sampler objects
|
||||
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
|
||||
Handle(OpenGl_FrameBuffer) myActiveFbo; //!< active Frame Buffer Object
|
||||
Handle(OpenGl_LineAttributes) myHatchStyles; //!< resource holding predefined hatch styles patterns
|
||||
Handle(OpenGl_Texture) myTextureRgbaBlack;//!< mock black texture returning (0, 0, 0, 0)
|
||||
Handle(OpenGl_Texture) myTextureRgbaWhite;//!< mock white texture returning (1, 1, 1, 1)
|
||||
|
@@ -692,6 +692,8 @@ void OpenGl_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theGlCtx)
|
||||
{
|
||||
theGlCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, myGlFBufferId);
|
||||
theGlCtx->SetFrameBufferSRGB (true);
|
||||
|
||||
theGlCtx->SetActiveFrameBuffer (this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
54
tools/Convert/Convert_Tools.cxx
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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;
|
||||
}
|
54
tools/Convert/Convert_Tools.hxx
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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
|
51
tools/Convert/Convert_TransientShape.hxx
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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
|
3
tools/Convert/FILES
Normal file
@@ -0,0 +1,3 @@
|
||||
Convert_Tools.cxx
|
||||
Convert_Tools.hxx
|
||||
Convert_TransientShape.hxx
|
@@ -80,7 +80,7 @@ void DFBrowser_AttributePaneStack::SetPaneMode (const DFBrowser_AttributePaneTyp
|
||||
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());
|
||||
@@ -103,7 +103,7 @@ void DFBrowser_AttributePaneStack::SetCurrentItem (const QModelIndex& theIndex)
|
||||
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());
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
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
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
//! \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); }
|
||||
|
||||
|
@@ -38,14 +38,14 @@ public:
|
||||
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);
|
||||
|
@@ -33,9 +33,9 @@ public:
|
||||
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
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#include <QObject>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
//#define USE_DUMPJSON
|
||||
|
||||
// =======================================================================
|
||||
// function : hasAttribute
|
||||
// purpose :
|
||||
@@ -147,6 +149,24 @@ QVariant DFBrowser_Item::initValue (const int theItemRole) const
|
||||
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 :
|
||||
|
@@ -38,14 +38,14 @@ class DFBrowser_Item : public DFBrowser_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 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;
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
//! 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;
|
||||
@@ -69,21 +69,25 @@ protected:
|
||||
//! \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
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
{ 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
|
||||
@@ -67,7 +67,7 @@ protected:
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
//! param theParent a parent item
|
||||
//! \param theParent a parent item
|
||||
DFBrowser_ItemApplication(TreeModel_ItemBasePtr theParent) : DFBrowser_ItemBase(theParent, 0, 0) {}
|
||||
|
||||
private:
|
||||
|
@@ -113,7 +113,7 @@ QVariant DFBrowser_ItemBase::initValue (const int theItemRole) const
|
||||
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);
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
//! \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
|
||||
@@ -84,15 +84,15 @@ protected:
|
||||
//! \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:
|
||||
|
@@ -32,14 +32,14 @@ class DFBrowser_ItemDocument : public DFBrowser_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 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
|
||||
@@ -65,10 +65,10 @@ public:
|
||||
|
||||
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:
|
||||
@@ -82,7 +82,7 @@ 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) {}
|
||||
|
||||
|
@@ -53,7 +53,9 @@ DFBrowser_Module::DFBrowser_Module()
|
||||
// =======================================================================
|
||||
void DFBrowser_Module::CreateViewModel (void* theParent)
|
||||
{
|
||||
myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
|
||||
myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent);
|
||||
myOCAFViewModel->InitColumns();
|
||||
myOCAFViewModel->SetModule (this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -152,7 +154,7 @@ DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Handle(TDF_A
|
||||
// function : GetAttributePane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (const Standard_CString& theAttributeName)
|
||||
DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Standard_CString theAttributeName)
|
||||
{
|
||||
DFBrowserPane_AttributePaneAPI* aPane = 0;
|
||||
|
||||
@@ -197,7 +199,7 @@ QVariant DFBrowser_Module::GetAttributeInfo (Handle(TDF_Attribute) theAttribute,
|
||||
// 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;
|
||||
@@ -222,7 +224,7 @@ QVariant DFBrowser_Module::GetAttributeInfo (const Standard_CString& theAttribut
|
||||
// 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
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
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);
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
//! \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
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
//! \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); }
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
//! 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
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
//! \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:
|
||||
|
||||
@@ -139,7 +139,7 @@ protected:
|
||||
//! 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:
|
||||
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#include <BinLDrivers.hxx>
|
||||
#include <BinXCAFDrivers.hxx>
|
||||
#include <PCDM_ReadWriter.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <StdDrivers.hxx>
|
||||
#include <StdLDrivers.hxx>
|
||||
#include <STEPCAFControl_Reader.hxx>
|
||||
@@ -48,7 +47,6 @@ namespace DFBrowser_OpenApplication
|
||||
return anApplication;
|
||||
}
|
||||
|
||||
#if OCC_VERSION_HEX > 0x060901
|
||||
// Load static variables for STEPCAF (ssv; 16.08.2012)
|
||||
STEPCAFControl_Controller::Init();
|
||||
|
||||
@@ -74,7 +72,6 @@ namespace DFBrowser_OpenApplication
|
||||
PCDM_ReaderStatus aStatus = anApplication->Open (theFileName, aDocument);
|
||||
if (aStatus != PCDM_RS_OK)
|
||||
return Handle(TDocStd_Application)();
|
||||
#endif
|
||||
return anApplication;
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
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
|
||||
|
@@ -41,7 +41,7 @@ public:
|
||||
Standard_EXPORT DFBrowser_PropertyPanel (QWidget* theParent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_PropertyPanel() Standard_OVERRIDE {}
|
||||
virtual ~DFBrowser_PropertyPanel() {}
|
||||
|
||||
//! Returns main control
|
||||
QWidget* GetControl() const { return myMainWindow; }
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
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
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
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
|
||||
@@ -66,10 +66,10 @@ public:
|
||||
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(); }
|
||||
@@ -87,15 +87,17 @@ private slots:
|
||||
|
||||
//! 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
|
||||
|
@@ -49,7 +49,7 @@ public:
|
||||
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 ": "; }
|
||||
@@ -87,7 +87,6 @@ public:
|
||||
//! 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.
|
||||
@@ -96,10 +95,10 @@ public:
|
||||
|
||||
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; }
|
||||
|
||||
|
@@ -41,7 +41,7 @@ public:
|
||||
Standard_EXPORT DFBrowser_SearchView (QWidget* theParent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_SearchView() Standard_OVERRIDE {}
|
||||
virtual ~DFBrowser_SearchView() {}
|
||||
|
||||
//! Returns search parent control
|
||||
QWidget* GetControl() const { return myMainWindow; }
|
||||
|
@@ -34,7 +34,7 @@ public:
|
||||
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
|
||||
|
@@ -48,10 +48,10 @@ public:
|
||||
//! 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:
|
||||
@@ -73,7 +73,7 @@ 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
|
||||
|
@@ -54,7 +54,7 @@ public:
|
||||
Standard_EXPORT DFBrowser_TreeLevelLine (QWidget* theParent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_TreeLevelLine() Standard_OVERRIDE {}
|
||||
virtual ~DFBrowser_TreeLevelLine() {}
|
||||
|
||||
//! Clears history of selected items
|
||||
Standard_EXPORT void ClearHistory();
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
//! 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
|
||||
|
@@ -59,14 +59,17 @@ QVariant DFBrowser_TreeLevelLineModel::data (const QModelIndex& theIndex, int th
|
||||
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
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public:
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_TreeLevelLineModel() {}
|
||||
|
||||
//!
|
||||
//! Resets the cached values
|
||||
void Reset() { myLevelItems.clear(); }
|
||||
|
||||
//! Inits the model by the index
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
//! 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
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
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
|
||||
|
@@ -42,12 +42,12 @@ public:
|
||||
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
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
//! \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,
|
||||
|
@@ -92,6 +92,9 @@ QVariant DFBrowser_TreeLevelViewModel::data (const QModelIndex& theIndex, int th
|
||||
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);
|
||||
|
@@ -37,9 +37,9 @@ public:
|
||||
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
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
//! 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;
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
//! 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
|
||||
|
@@ -38,12 +38,27 @@ const int COLUMN_NAME_WIDTH = 300;
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -51,9 +66,9 @@ DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module*
|
||||
// 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());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -62,7 +77,7 @@ void DFBrowser_TreeModel::createRootItem (const int)
|
||||
// =======================================================================
|
||||
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();
|
||||
@@ -74,7 +89,7 @@ void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplicatio
|
||||
// =======================================================================
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -179,7 +194,7 @@ QModelIndex DFBrowser_TreeModel::FindIndexByPath (const QStringList& theLabelEnt
|
||||
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)
|
||||
|
@@ -45,14 +45,20 @@ class DFBrowser_TreeModel : public TreeModel_ModelBase
|
||||
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;
|
||||
@@ -98,7 +104,7 @@ public:
|
||||
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:
|
||||
|
||||
|
@@ -47,10 +47,9 @@
|
||||
#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>
|
||||
@@ -102,6 +101,8 @@ const int DFBROWSER_DEFAULT_POSITION_Y = 60;
|
||||
const int DEFAULT_PROPERTY_PANEL_HEIGHT = 200;
|
||||
const int DEFAULT_BROWSER_HEIGHT = 800;
|
||||
|
||||
//#define USE_DUMPJSON
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
@@ -161,12 +162,24 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
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);
|
||||
@@ -181,20 +194,26 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
|
||||
// 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_sRGB), 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);
|
||||
|
||||
@@ -254,7 +273,7 @@ void DFBrowser_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem
|
||||
|
||||
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());
|
||||
@@ -278,7 +297,7 @@ void DFBrowser_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& t
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -420,6 +439,11 @@ void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>&
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (anApplication.IsNull() && CDF_Session::Exists())
|
||||
anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
|
||||
}
|
||||
|
||||
myModule = new DFBrowser_Module();
|
||||
myModule->CreateViewModel (myMainWindow);
|
||||
@@ -659,7 +683,7 @@ void DFBrowser_Window::onExpand()
|
||||
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();
|
||||
}
|
||||
@@ -677,7 +701,7 @@ void DFBrowser_Window::onExpandAll()
|
||||
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();
|
||||
}
|
||||
@@ -692,7 +716,7 @@ void DFBrowser_Window::onCollapseAll()
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,6 +729,12 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
|
||||
{
|
||||
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();
|
||||
@@ -716,7 +746,7 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
|
||||
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);
|
||||
@@ -765,7 +795,7 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
|
||||
{
|
||||
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();
|
||||
@@ -793,7 +823,7 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
|
||||
|
||||
// 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
|
||||
@@ -894,7 +924,7 @@ void DFBrowser_Window::onLevelSelected (const QModelIndex& theIndex)
|
||||
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);
|
||||
}
|
||||
@@ -988,26 +1018,3 @@ void DFBrowser_Window::findPresentations (const QModelIndexList& theIndices, AIS
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -39,12 +39,14 @@ class DFBrowser_Thread;
|
||||
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;
|
||||
|
||||
@@ -62,7 +64,7 @@ public:
|
||||
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
|
||||
@@ -72,7 +74,7 @@ public:
|
||||
//! \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);
|
||||
|
||||
@@ -125,13 +127,13 @@ private slots:
|
||||
//! \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
|
||||
@@ -206,13 +208,6 @@ protected:
|
||||
//! \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
|
||||
@@ -220,7 +215,9 @@ private:
|
||||
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
|
||||
|
@@ -140,7 +140,7 @@ void DFBrowserPane_AttributePane::GetShortAttributeInfo (const Handle(TDF_Attrib
|
||||
// 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)
|
||||
|
@@ -74,7 +74,7 @@ public:
|
||||
//! \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
|
||||
|
@@ -126,8 +126,7 @@
|
||||
// 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())
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
//! 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
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
//! 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
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
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
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#ifndef DFBrowserPane_HelperExport_H
|
||||
#define DFBrowserPane_HelperExport_H
|
||||
|
||||
#include <inspector/DFBrowserPane.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
@@ -29,7 +28,7 @@
|
||||
//! 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:
|
||||
@@ -55,7 +54,7 @@ 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:
|
||||
|
||||
|
@@ -41,6 +41,7 @@ DFBrowserPane_TDataStdTreeNode::DFBrowserPane_TDataStdTreeNode()
|
||||
: 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));
|
||||
}
|
||||
@@ -99,15 +100,14 @@ void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttri
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@@ -119,7 +119,7 @@ void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttri
|
||||
anAttributeNodeItem->setCurrentAttribute (true);
|
||||
}
|
||||
}
|
||||
aModel->EmitLayoutChanged();
|
||||
myModel->EmitLayoutChanged();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <Standard.hxx>
|
||||
|
||||
class QAbstractItemModel;
|
||||
class DFBrowserPane_TDataStdTreeNodeModel;
|
||||
class QTreeView;
|
||||
|
||||
//! \class DFBrowserPane_TDataStdTreeNode
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
QAbstractItemModel* myModel;
|
||||
DFBrowserPane_TDataStdTreeNodeModel* myModel;
|
||||
QTreeView* myTreeNodeView;
|
||||
};
|
||||
|
||||
|
@@ -39,15 +39,15 @@ class DFBrowserPane_TDataStdTreeNodeItem : 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 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
|
||||
@@ -90,13 +90,13 @@ protected:
|
||||
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
|
||||
|
@@ -29,16 +29,24 @@
|
||||
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);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -47,7 +55,7 @@ void DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int 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();
|
||||
|
@@ -38,7 +38,10 @@ public:
|
||||
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
|
||||
@@ -59,7 +62,7 @@ public:
|
||||
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:
|
||||
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include <TDocStd_Owner.hxx>
|
||||
#include <TDF_Delta.hxx>
|
||||
#include <TDF_ListIteratorOfDeltaList.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QGridLayout>
|
||||
@@ -56,7 +55,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
|
||||
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 = "---------------------------";
|
||||
@@ -100,7 +99,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
|
||||
|
||||
// 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()
|
||||
@@ -119,9 +118,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
|
||||
<< "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());
|
||||
}
|
||||
|
@@ -154,7 +154,7 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
|
||||
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())
|
||||
@@ -162,7 +162,7 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
|
||||
|
||||
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);
|
||||
@@ -171,7 +171,7 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
|
||||
|
||||
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);
|
||||
@@ -227,14 +227,14 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
|
||||
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
|
||||
<< "";
|
||||
@@ -382,7 +382,7 @@ void DFBrowserPane_TNamingNamedShape::GetSelectionParameters (QItemSelectionMode
|
||||
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());
|
||||
@@ -467,7 +467,7 @@ TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes()
|
||||
QModelIndex anIndex = *anIt;
|
||||
if (!myHelperExport.HasShape (anIndex))
|
||||
continue;
|
||||
aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
|
||||
aBuilder.Add (aComp, myHelperExport.Shape (anIndex));
|
||||
aHasShapes = true;
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes()
|
||||
QModelIndex anIndex = *anIt;
|
||||
if (!myHelperExport.HasShape (anIndex))
|
||||
continue;
|
||||
aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
|
||||
aBuilder.Add (aComp, myHelperExport.Shape (anIndex));
|
||||
aHasShapes = true;
|
||||
}
|
||||
if (aHasShapes)
|
||||
|
@@ -124,7 +124,7 @@ void DFBrowserPane_TNamingNaming::GetValues (const Handle(TDF_Attribute)& theAtt
|
||||
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() : "");
|
||||
|
@@ -80,7 +80,7 @@ void DFBrowserPane_TNamingUsedShapes::GetValues (const Handle(TDF_Attribute)& th
|
||||
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" << "";
|
||||
@@ -89,7 +89,7 @@ void DFBrowserPane_TNamingUsedShapes::GetValues (const Handle(TDF_Attribute)& th
|
||||
{
|
||||
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 << "" << "";
|
||||
|
@@ -63,7 +63,7 @@ void DFBrowserPane_TPrsStdAISPresentation::GetValues (const Handle(TDF_Attribute
|
||||
<< "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()
|
||||
|
@@ -35,7 +35,7 @@ void DFBrowserPane_TPrsStdAISViewer::GetValues (const Handle(TDF_Attribute)& the
|
||||
|
||||
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();
|
||||
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#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>
|
||||
@@ -70,30 +69,6 @@ TCollection_AsciiString DFBrowserPane_Tools::GetEntry (const TDF_Label& theLabel
|
||||
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 :
|
||||
|
@@ -48,13 +48,6 @@ public:
|
||||
//! \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
|
||||
|
@@ -1,4 +1,3 @@
|
||||
DFBrowserPane.hxx
|
||||
DFBrowserPane.qrc
|
||||
DFBrowserPane_AttributePane.cxx
|
||||
DFBrowserPane_AttributePane.hxx
|
||||
|
@@ -52,7 +52,7 @@ DFBrowserPaneXDE_AttributeCommonPane::DFBrowserPaneXDE_AttributeCommonPane (DFBr
|
||||
// function : ProcessAttribute
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (const Standard_CString& theAttributeType)
|
||||
bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (Standard_CString theAttributeType)
|
||||
{
|
||||
if (AttributeTypes.empty())
|
||||
{
|
||||
|
@@ -46,7 +46,7 @@ public:
|
||||
//! 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
|
||||
|
@@ -34,17 +34,13 @@
|
||||
#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>
|
||||
@@ -71,7 +67,7 @@ DFBrowserPaneXDE_AttributePaneCreator::DFBrowserPaneXDE_AttributePaneCreator(
|
||||
// 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))
|
||||
@@ -91,7 +87,7 @@ DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAtt
|
||||
// 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())
|
||||
@@ -106,20 +102,16 @@ DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDE
|
||||
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())
|
||||
|
@@ -43,14 +43,14 @@ public:
|
||||
//! \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:
|
||||
|
||||
|
@@ -17,13 +17,10 @@
|
||||
|
||||
#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
|
||||
@@ -50,13 +47,11 @@ void DFBrowserPaneXDE_XCAFDocDatum::GetValues (const Handle(TDF_Attribute)& theA
|
||||
<< "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
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -116,7 +116,7 @@ void DFBrowserPaneXDE_XCAFDocShapeMapTool::GetValues (const Handle(TDF_Attribute
|
||||
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
|
||||
|
@@ -42,11 +42,8 @@
|
||||
#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>
|
||||
@@ -247,7 +244,6 @@ TCollection_AsciiString DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (Handle(TDF_A
|
||||
else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
|
||||
type = "DatumToler Link";
|
||||
}
|
||||
#if OCC_VERSION_HEX > 0x060901
|
||||
else if ( att->ID() == XCAFDoc::DimensionRefFirstGUID() ) {
|
||||
type = "Dimension Link First";
|
||||
}
|
||||
@@ -257,7 +253,6 @@ TCollection_AsciiString DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (Handle(TDF_A
|
||||
else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ){
|
||||
type = "GeomTolerance Link";
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return TCollection_AsciiString();
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
ShapeView.qrc
|
||||
ShapeView_Communicator.cxx
|
||||
ShapeView_Communicator.hxx
|
||||
ShapeView_ItemBase.hxx
|
||||
ShapeView_ItemRoot.cxx
|
||||
ShapeView_ItemRoot.hxx
|
||||
ShapeView_ItemShape.cxx
|
||||
|
@@ -29,7 +29,7 @@ public:
|
||||
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
|
||||
@@ -41,9 +41,9 @@ public:
|
||||
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
|
||||
|
@@ -1,48 +0,0 @@
|
||||
// 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
|
@@ -18,10 +18,10 @@
|
||||
#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++)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#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>
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef QExplicitlySharedDataPointer<ShapeView_ItemRoot> ShapeView_ItemRootPtr;
|
||||
//! 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:
|
||||
|
||||
@@ -37,7 +37,7 @@ 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
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
|
||||
//! 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;
|
||||
@@ -69,9 +69,9 @@ protected:
|
||||
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:
|
||||
|
||||
|
@@ -15,21 +15,17 @@
|
||||
|
||||
#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>
|
||||
@@ -37,166 +33,32 @@
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : ToString
|
||||
// function : Shape
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString ToString (const Standard_Boolean& theValue)
|
||||
TopoDS_Shape ShapeView_ItemShape::Shape (const int theRowId) const
|
||||
{
|
||||
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
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString ToName (const GeomAbs_Shape& theType)
|
||||
{
|
||||
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
|
||||
{
|
||||
aValues.append (ToString (aCurve->IsPeriodic()));
|
||||
anInfo.append ("IsPeriodic");
|
||||
}
|
||||
theValue = aValues.join (" / ");
|
||||
theInfo = QString ("%1:\n%2").arg (anInfo.join (" / ")).arg (aValues.join ("\n"));
|
||||
break;
|
||||
TopExp::MapShapes(myShape, myExplodeType, aThis->myChildShapes);
|
||||
}
|
||||
else
|
||||
{
|
||||
TopoDS_Iterator aSubShapeIt (myShape);
|
||||
for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
|
||||
{
|
||||
aThis->myChildShapes.Add (aSubShapeIt.Value());
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -205,6 +67,10 @@ TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
|
||||
// =======================================================================
|
||||
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();
|
||||
@@ -214,58 +80,7 @@ QVariant ShapeView_ItemShape::initValue(const int theRole) const
|
||||
|
||||
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();
|
||||
@@ -282,11 +97,33 @@ int ShapeView_ItemShape::initRowCount() const
|
||||
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 :
|
||||
@@ -304,7 +141,9 @@ void ShapeView_ItemShape::Init()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -317,30 +156,6 @@ TopoDS_Shape ShapeView_ItemShape::getShape() const
|
||||
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 :
|
||||
@@ -348,8 +163,10 @@ TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standa
|
||||
void ShapeView_ItemShape::Reset()
|
||||
{
|
||||
myFileName = QString();
|
||||
myChildShapes.Clear();
|
||||
myShape = TopoDS_Shape();
|
||||
|
||||
ShapeView_ItemBase::Reset();
|
||||
TreeModel_ItemBase::Reset();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -362,4 +179,3 @@ void ShapeView_ItemShape::initItem() const
|
||||
return;
|
||||
const_cast<ShapeView_ItemShape*>(this)->Init();
|
||||
}
|
||||
|
||||
|
@@ -16,9 +16,13 @@
|
||||
#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>
|
||||
@@ -32,19 +36,26 @@ typedef QExplicitlySharedDataPointer<ShapeView_ItemShape> ShapeView_ItemShapePtr
|
||||
//! \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; }
|
||||
@@ -52,7 +63,7 @@ public:
|
||||
//! 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
|
||||
@@ -62,17 +73,13 @@ public:
|
||||
//! \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;
|
||||
@@ -80,9 +87,13 @@ public:
|
||||
//! \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.
|
||||
@@ -99,22 +110,19 @@ protected:
|
||||
//! \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
|
||||
|
@@ -135,9 +135,9 @@ private:
|
||||
|
||||
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
|
||||
|
@@ -28,7 +28,7 @@
|
||||
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
|
||||
{
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
//! 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
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
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
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
//! Destructor
|
||||
virtual ~ShapeView_OpenFileViewModel() {}
|
||||
|
||||
//! Store values
|
||||
//! Stores values
|
||||
//! \param theValues a container of values to fill model
|
||||
void Init (const QStringList& theValues);
|
||||
|
||||
|
@@ -14,20 +14,34 @@
|
||||
// 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();
|
||||
|
||||
BRep_Builder aBuilder;
|
||||
BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
|
||||
return aShape;
|
||||
if (!theExplodeTypes.Contains (aShapeType))
|
||||
theExplodeTypes.Append(aShapeType);
|
||||
|
||||
if (theExplodeTypes.Extent() == TopAbs_SHAPE + 1) // all types are collected, stop
|
||||
return Standard_True;
|
||||
|
||||
TopoDS_Iterator aSubShapeIt (theShape);
|
||||
for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
|
||||
{
|
||||
if (IsPossibleToExplode (aSubShapeIt.Value(), theExplodeTypes))
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
@@ -18,20 +18,34 @@
|
||||
|
||||
#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
|
||||
|
@@ -19,14 +19,6 @@
|
||||
#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 :
|
||||
@@ -34,40 +26,15 @@ const int COLUMN_LOCATION_WIDTH = 120;
|
||||
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);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#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>
|
||||
@@ -38,21 +38,15 @@ public:
|
||||
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
|
||||
@@ -61,10 +55,8 @@ public:
|
||||
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
|
||||
|
@@ -17,13 +17,23 @@
|
||||
|
||||
#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;
|
||||
|
||||
@@ -35,10 +45,10 @@ bool ShapeView_VisibilityState::SetVisible (const QModelIndex& theIndex, const b
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// 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)
|
||||
|
@@ -28,8 +28,9 @@ class TreeModel_ModelBase;
|
||||
|
||||
//! \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),
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
//! 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
|
||||
@@ -60,17 +61,28 @@ public:
|
||||
|
||||
//! 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
|
||||
|
@@ -19,15 +19,17 @@
|
||||
#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>
|
||||
@@ -83,7 +85,7 @@ const int SHAPEVIEW_DEFAULT_VIEW_HEIGHT = 1000;
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
ShapeView_Window::ShapeView_Window (QWidget* theParent)
|
||||
: QObject (theParent), myNextPosition (0)
|
||||
: QObject (theParent)
|
||||
{
|
||||
myMainWindow = new QMainWindow (theParent);
|
||||
|
||||
@@ -95,28 +97,48 @@ ShapeView_Window::ShapeView_Window (QWidget* 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);
|
||||
}
|
||||
@@ -127,7 +149,6 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
|
||||
// =======================================================================
|
||||
ShapeView_Window::~ShapeView_Window()
|
||||
{
|
||||
onCloseAllBREPViews();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -171,7 +192,7 @@ void ShapeView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem
|
||||
|
||||
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());
|
||||
}
|
||||
@@ -194,7 +215,7 @@ void ShapeView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& t
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +323,7 @@ void ShapeView_Window::Init (NCollection_List<Handle(Standard_Transient)>& thePa
|
||||
// =======================================================================
|
||||
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);
|
||||
}
|
||||
@@ -315,8 +336,6 @@ void ShapeView_Window::RemoveAllShapes()
|
||||
{
|
||||
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
|
||||
aModel->RemoveAllShapes();
|
||||
|
||||
onCloseAllBREPViews();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -351,16 +370,52 @@ void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition
|
||||
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 :
|
||||
@@ -376,17 +431,43 @@ void ShapeView_Window::onEraseAllPerformed()
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// 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();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -399,18 +480,23 @@ void ShapeView_Window::onLoadFile()
|
||||
|
||||
QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
|
||||
aFileName = QDir().toNativeSeparators (aFileName);
|
||||
if (!aFileName.isEmpty())
|
||||
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)
|
||||
@@ -429,107 +515,9 @@ void ShapeView_Window::onBREPView()
|
||||
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();
|
||||
}
|
||||
|
@@ -33,7 +33,10 @@
|
||||
|
||||
class View_Window;
|
||||
|
||||
class ViewControl_PropertyView;
|
||||
|
||||
class QAction;
|
||||
class QDockWidget;
|
||||
class QMainWindow;
|
||||
class QWidget;
|
||||
|
||||
@@ -59,7 +62,7 @@ public:
|
||||
//! \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);
|
||||
|
||||
@@ -80,9 +83,6 @@ public:
|
||||
//! 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();
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
//! \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);
|
||||
|
||||
@@ -108,64 +108,47 @@ protected slots:
|
||||
//! \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
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
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
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<!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>
|
||||
|
@@ -64,13 +64,13 @@ public:
|
||||
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); }
|
||||
|
||||
@@ -78,14 +78,13 @@ public:
|
||||
//! \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
|
||||
@@ -95,11 +94,11 @@ public:
|
||||
//! \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);
|
||||
|
96
tools/TInspector/TInspector_OpenButton.cxx
Normal file
@@ -0,0 +1,96 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
65
tools/TInspector/TInspector_OpenButton.hxx
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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
|
@@ -13,8 +13,10 @@
|
||||
// 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_OpenFileDialog.hxx>
|
||||
|
||||
#include <inspector/TInspector_OpenButton.hxx>
|
||||
#include <inspector/TInspector_OpenFileViewModel.hxx>
|
||||
|
||||
#include <inspector/TInspector_Communicator.hxx>
|
||||
|
||||
@@ -51,66 +53,6 @@ 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 :
|
||||
@@ -125,7 +67,7 @@ void changeMargins (QBoxLayout* theLayout)
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
|
||||
TInspector_OpenFileDialog::TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
|
||||
: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
|
||||
{
|
||||
setWindowTitle (tr ("Open File"));
|
||||
@@ -171,10 +113,10 @@ TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent,
|
||||
// function : OpenFile
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
|
||||
QString TInspector_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
|
||||
{
|
||||
QString aFileName;
|
||||
TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog (theParent, theRecentlyOpenedFiles);
|
||||
TInspector_OpenFileDialog* aDialog = new TInspector_OpenFileDialog (theParent, theRecentlyOpenedFiles);
|
||||
if (aDialog->exec() == QDialog::Accepted)
|
||||
aFileName = aDialog->GetFileName();
|
||||
|
||||
@@ -185,7 +127,7 @@ QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QStrin
|
||||
// function : Communicator
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
|
||||
TInspector_Communicator* TInspector_OpenFileDialog::Communicator()
|
||||
{
|
||||
if (!MyCommunicator)
|
||||
MyCommunicator = new TInspector_Communicator();
|
||||
@@ -196,7 +138,7 @@ TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
|
||||
// function : GetPluginRecentlyOpenedFiles
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
void TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
TInspector_Communicator* theCommunicator,
|
||||
QStringList& theFileNames)
|
||||
{
|
||||
@@ -220,7 +162,7 @@ void TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollecti
|
||||
// function : SetPluginRecentlyOpenedFiles
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
void TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
TInspector_Communicator* theCommunicator,
|
||||
QStringList& theFileNames)
|
||||
{
|
||||
@@ -237,7 +179,7 @@ void TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollecti
|
||||
// function : onSampleSelectionChanged
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
|
||||
void TInspector_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
|
||||
const QItemSelection&)
|
||||
{
|
||||
QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
|
||||
@@ -258,7 +200,7 @@ void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelectio
|
||||
// function : onSelectClicked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileDialog::onSelectClicked()
|
||||
void TInspector_OpenFileDialog::onSelectClicked()
|
||||
{
|
||||
QString anEnteredPath;
|
||||
QString aDirName = mySelectedName->text();
|
||||
@@ -283,7 +225,7 @@ void TInspectorEXE_OpenFileDialog::onSelectClicked()
|
||||
// function : onApplySelectClicked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
|
||||
void TInspector_OpenFileDialog::onApplySelectClicked()
|
||||
{
|
||||
QString aFileName = mySelectedName->text();
|
||||
|
||||
@@ -299,7 +241,7 @@ void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
|
||||
// function : createTableView
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames)
|
||||
QTableView* TInspector_OpenFileDialog::createTableView (const QStringList& theFileNames)
|
||||
{
|
||||
QTableView* aTableView = new QTableView (this);
|
||||
aTableView->setFrameStyle (QFrame::NoFrame);
|
||||
@@ -331,9 +273,9 @@ QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& th
|
||||
// function : createModel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames)
|
||||
QAbstractItemModel* TInspector_OpenFileDialog::createModel (const QStringList& theFileNames)
|
||||
{
|
||||
TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this);
|
||||
TInspector_OpenFileViewModel* aModel = new TInspector_OpenFileViewModel (this);
|
||||
aModel->Init (theFileNames);
|
||||
return aModel;
|
||||
}
|
@@ -28,8 +28,6 @@
|
||||
#include <QStringList>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
#include <map>
|
||||
|
||||
class TInspector_Communicator;
|
||||
|
||||
class QAbstractItemModel;
|
||||
@@ -39,58 +37,22 @@ 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
|
||||
//! \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 TInspectorEXE_OpenFileDialog : public QDialog
|
||||
class TInspector_OpenFileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
|
||||
Standard_EXPORT TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
|
||||
|
||||
public:
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {}
|
||||
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
|
||||
@@ -125,7 +87,7 @@ 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
|
||||
//! Opens file dialog to select a file name. Fills file name line, enable import button
|
||||
void onSelectClicked();
|
||||
|
||||
//! Accepts open file dialog
|
||||
@@ -147,7 +109,7 @@ private:
|
||||
|
||||
QStringList myRecentlyOpenedFiles; //!< recently opened files
|
||||
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
|
||||
};
|
||||
|
@@ -13,7 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspectorEXE_OpenFileViewModel.hxx>
|
||||
#include <inspector/TInspector_OpenFileViewModel.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QApplication>
|
||||
@@ -53,7 +53,7 @@ void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QSty
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
|
||||
void TInspector_OpenFileViewModel::Init (const QStringList& theValues)
|
||||
{
|
||||
myValues = theValues;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
|
||||
// function : data
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
|
||||
QVariant TInspector_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
|
||||
{
|
||||
switch (theRole)
|
||||
{
|
@@ -41,7 +41,7 @@ public:
|
||||
//! Destructor
|
||||
virtual ~TInspectorEXE_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
|
||||
@@ -53,19 +53,19 @@ private:
|
||||
QColor myColor; //!< highlight color
|
||||
};
|
||||
|
||||
//! \class TInspectorEXE_OpenFileViewModel
|
||||
//! \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 TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
|
||||
class TInspector_OpenFileViewModel : public QAbstractTableModel
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
|
||||
TInspector_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspectorEXE_OpenFileViewModel() {}
|
||||
virtual ~TInspector_OpenFileViewModel() {}
|
||||
|
||||
//! Store values
|
||||
//! \param theValues a container of values to fill model
|
@@ -35,7 +35,7 @@ public:
|
||||
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
|
||||
@@ -62,10 +62,10 @@ public:
|
||||
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:
|
||||
|
@@ -57,17 +57,17 @@ public:
|
||||
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
|
||||
|
@@ -83,7 +83,7 @@ TInspector_Window::TInspector_Window()
|
||||
|
||||
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);
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
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
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
//! \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);
|
||||
|
||||
@@ -149,7 +149,7 @@ public slots:
|
||||
//! 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:
|
||||
@@ -180,7 +180,7 @@ protected:
|
||||
//! 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;
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 615 B |