mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0031362: Inspectors - MessageView plugin for message alerts
- append new MessageView plugin to display content of Message_Report; - correct DumpJson of TDataStd array attributes to print Lower/Upper values; - correct remove level of Message_Report to store stop time during removing all levels; - append DumpJson for TFunction, TPrsStd attributes; - correct DumpJson of XCAFDoc tools due to simplify performance of it; - move AttributeInfo functionality from XDEDRAW into a static public method of XCAFDoc to call it outside; - remove obsolete pane classes in DFBrowser plugin, now we may use DumpJSon panel to visualize this content of attributes; - add new property panel in DFBrowser (synchronized with the same in other plugins); - add button to switch ON DumpJson in DFBrowser(OFF by default, for better performance), also there is a context menu item in tree view; - rename in DFBrowser "Property Panel" into "Property Panel (custom)"; - implement ViewControl_ColorSeletor and setting color in TreeModel_ItemProperties. Use only for light in VInspector now; - implement setting false for all created AIS_Shape presentation to don't modify source TopoDS_Shape; - remove not use VInspector_CallBack. It's possible using Message_Report/MessageView to track commands way; - remove History panel in VInspector as not used, MessageView will be better solution for this; - implement item and actions in VInspector for setting Lights in the view.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
VInspector.qrc
|
||||
VInspectorAPI_CallBack.cxx
|
||||
VInspectorAPI_CallBack.hxx
|
||||
VInspector_CallBack.cxx
|
||||
VInspector_CallBack.hxx
|
||||
VInspector_CallBackMode.hxx
|
||||
VInspector_Communicator.cxx
|
||||
VInspector_Communicator.hxx
|
||||
VInspector_ItemBase.cxx
|
||||
@@ -12,13 +7,8 @@ VInspector_ItemContext.cxx
|
||||
VInspector_ItemContext.hxx
|
||||
VInspector_ItemContextProperties.cxx
|
||||
VInspector_ItemContextProperties.hxx
|
||||
VInspector_ItemHistoryElement.cxx
|
||||
VInspector_ItemHistoryElement.hxx
|
||||
VInspector_ItemHistoryRoot.cxx
|
||||
VInspector_ItemHistoryRoot.hxx
|
||||
VInspector_ItemHistoryType.cxx
|
||||
VInspector_ItemHistoryType.hxx
|
||||
VInspector_ItemHistoryTypeInfo.hxx
|
||||
VInspector_ItemGraphic3dCLight.cxx
|
||||
VInspector_ItemGraphic3dCLight.hxx
|
||||
VInspector_ItemPresentableObject.cxx
|
||||
VInspector_ItemPresentableObject.hxx
|
||||
VInspector_ItemSelectMgrViewerSelector.cxx
|
||||
@@ -32,7 +22,5 @@ VInspector_Tools.cxx
|
||||
VInspector_Tools.hxx
|
||||
VInspector_ViewModel.cxx
|
||||
VInspector_ViewModel.hxx
|
||||
VInspector_ViewModelHistory.cxx
|
||||
VInspector_ViewModelHistory.hxx
|
||||
VInspector_Window.cxx
|
||||
VInspector_Window.hxx
|
||||
|
@@ -1,26 +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.
|
||||
|
||||
#include <inspector/VInspectorAPI_CallBack.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
VInspectorAPI_CallBack::VInspectorAPI_CallBack()
|
||||
{
|
||||
}
|
@@ -1,95 +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 VInspectorAPI_CallBack_H
|
||||
#define VInspectorAPI_CallBack_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
class AIS_InteractiveObject;
|
||||
class SelectMgr_EntityOwner;
|
||||
|
||||
//! \class VInspectorAPI_CallBack
|
||||
//! API of AIS_InteractiveContext methods to provide information about the actions
|
||||
class VInspectorAPI_CallBack : public Standard_Transient
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT VInspectorAPI_CallBack();
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspectorAPI_CallBack() {}
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Display(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Redisplay(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Remove(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Load(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void ActivatedModes (Handle(AIS_InteractiveObject) thePrs, TColStd_ListOfInteger& theList) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Activate(Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Deactivate(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Deactivate(Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void ClearSelected() = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void ClearSelected(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void MoveTo (const Standard_Integer theXPix, const Standard_Integer theYPix) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void SetSelected(Handle(AIS_InteractiveObject) thePrs) = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void Select() = 0;
|
||||
|
||||
//! Processing method of context
|
||||
virtual void ShiftSelect() = 0;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,175 +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.
|
||||
|
||||
#include <inspector/VInspector_CallBack.hxx>
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
|
||||
#include <inspector/VInspector_CallBackMode.hxx>
|
||||
#include <inspector/VInspector_Tools.hxx>
|
||||
#include <inspector/VInspector_ViewModelHistory.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
|
||||
|
||||
// =======================================================================
|
||||
// function : Activate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode)
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
|
||||
QList<QVariant> anInfo;
|
||||
if (!thePrs.IsNull())
|
||||
anInfo = VInspector_Tools::GetInfo (thePrs);
|
||||
else
|
||||
{
|
||||
anInfo.append ("Activate");
|
||||
anInfo.append ("");
|
||||
anInfo.append ("");
|
||||
}
|
||||
anInfo[0] = QString ("%1: %2").arg (anInfo[0].toString()).arg (theMode);
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_Activate, anInfo);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddOrRemoveSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues;
|
||||
aValues.append (""); // Name
|
||||
aValues.append (""); // Pointer
|
||||
aValues.append (VInspector_Tools::GetShapeTypeInfo (theShape.ShapeType()).ToCString()); // Shape Type
|
||||
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelectedShape, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddOrRemoveSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs)
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs);
|
||||
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddOrRemoveSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner)
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues;
|
||||
aValues.append (""); // Name
|
||||
aValues.append (Standard_Dump::GetPointerInfo (theOwner, true).ToCString()); // Pointer
|
||||
aValues.append (""); // Shape type
|
||||
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
|
||||
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelectedOwner, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ClearSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::ClearSelected()
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues;
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : MoveTo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/)
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues;
|
||||
aValues = VInspector_Tools::GetHighlightInfo (myContext);
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Select
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::Select()
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues;
|
||||
aValues = VInspector_Tools::GetSelectedInfo (myContext);
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ShiftSelect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_CallBack::ShiftSelect()
|
||||
{
|
||||
if (!myHistoryModel)
|
||||
return;
|
||||
QList<QVariant> aValues;
|
||||
aValues = VInspector_Tools::GetSelectedInfo (myContext);
|
||||
myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString VInspector_CallBack::GetInfo (const VInspector_CallBackMode& theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case VInspector_CallBackMode_None: return "None";
|
||||
case VInspector_CallBackMode_Display: return "Display";
|
||||
case VInspector_CallBackMode_Redisplay: return "Redisplay";
|
||||
case VInspector_CallBackMode_Remove: return "Remove";
|
||||
case VInspector_CallBackMode_Load: return "Load";
|
||||
case VInspector_CallBackMode_ActivatedModes: return "ActivatedModes";
|
||||
case VInspector_CallBackMode_Activate: return "Activate";
|
||||
case VInspector_CallBackMode_Deactivate: return "Deactivate";
|
||||
case VInspector_CallBackMode_AddOrRemoveSelectedShape: return "AddOrRemoveSelectedShape";
|
||||
case VInspector_CallBackMode_AddOrRemoveSelected: return "AddOrRemoveSelected";
|
||||
case VInspector_CallBackMode_AddOrRemoveSelectedOwner: return "AddOrRemoveSelectedOwner";
|
||||
case VInspector_CallBackMode_ClearSelected: return "ClearSelected";
|
||||
case VInspector_CallBackMode_MoveTo: return "MoveTo";
|
||||
case VInspector_CallBackMode_SetSelected: return "SetSelected";
|
||||
case VInspector_CallBackMode_Select: return "Select";
|
||||
case VInspector_CallBackMode_ShiftSelect: return "ShiftSelect";
|
||||
default: break;
|
||||
}
|
||||
return QString();
|
||||
}
|
@@ -1,140 +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 VInspector_CallBack_H
|
||||
#define VInspector_CallBack_H
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <inspector/VInspectorAPI_CallBack.hxx>
|
||||
#include <inspector/VInspector_CallBackMode.hxx>
|
||||
#include <inspector/VInspector_ViewModelHistory.hxx>
|
||||
#include <inspector/VInspector_Tools.hxx>
|
||||
|
||||
class AIS_InteractiveObject;
|
||||
class SelectMgr_EntityOwner;
|
||||
|
||||
//! \class VInspector_CallBack
|
||||
//! Updates inspector state on actions in context
|
||||
class VInspector_CallBack : public VInspectorAPI_CallBack
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
VInspector_CallBack() : VInspectorAPI_CallBack() {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspector_CallBack() {}
|
||||
|
||||
//! Appends displayed presentation into history model
|
||||
//! \param thePrs the presentation
|
||||
virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends redisplayed presentation into history model
|
||||
//! \param thePrs the presentation
|
||||
virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends removed presentation into history model
|
||||
//! \param thePrs the presentation
|
||||
virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends loaded presentation into history model
|
||||
//! \param thePrs the presentation
|
||||
virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends information about modes activation
|
||||
//! \param thePrs the presentation
|
||||
//! \param theModes the selection modes
|
||||
virtual void ActivatedModes (Handle(AIS_InteractiveObject) thePrs, TColStd_ListOfInteger& theModes) Standard_OVERRIDE
|
||||
{ (void)thePrs; (void)theModes; }
|
||||
|
||||
//! Appends information about mode activation
|
||||
//! \param thePrs the presentation
|
||||
//! \param theModes the selection mode
|
||||
Standard_EXPORT virtual void Activate (Handle(AIS_InteractiveObject) thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about modes deactivation
|
||||
//! \param thePrs the presentation
|
||||
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends information about modes deactivation
|
||||
//! \param thePrs the presentation
|
||||
//! \param theMode the selection mode
|
||||
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
|
||||
{ (void)theMode;
|
||||
if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends information about selection change
|
||||
//! \param theShape the selected shape
|
||||
Standard_EXPORT virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about selection change
|
||||
//! \param thePrs the selected presentation
|
||||
Standard_EXPORT virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about selection change
|
||||
//! \param theOwner the selected owner
|
||||
Standard_EXPORT virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about selection clear
|
||||
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about selection clear
|
||||
//! \param thePrs the selected presentation
|
||||
virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends information about moving to point
|
||||
//! \param theXPix a pixels on horizontal
|
||||
//! \param theYPix a pixels on vertical
|
||||
Standard_EXPORT virtual void MoveTo (const Standard_Integer theXPix, const Standard_Integer theYPix) Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about setting selection
|
||||
//! \param thePrs the selected presentation
|
||||
virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
|
||||
{ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
|
||||
|
||||
//! Appends information about select
|
||||
Standard_EXPORT virtual void Select() Standard_OVERRIDE;
|
||||
|
||||
//! Appends information about shift select
|
||||
Standard_EXPORT virtual void ShiftSelect() Standard_OVERRIDE;
|
||||
|
||||
//! Sets history model, it will be filled by actions in context
|
||||
//! \param theHistoryModel the view model
|
||||
void SetHistoryModel (VInspector_ViewModelHistory* theHistoryModel) { myHistoryModel = theHistoryModel; }
|
||||
|
||||
//! Sets context, where actions happen
|
||||
//! \param theContext a context instance
|
||||
void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
|
||||
DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
|
||||
|
||||
//! Returns string information of call back mode
|
||||
//! \param theMode type of AIS action
|
||||
//! \return information text
|
||||
static QString GetInfo (const VInspector_CallBackMode& theMode);
|
||||
|
||||
private:
|
||||
VInspector_ViewModelHistory* myHistoryModel; //!< the current history model, fulfilled by context actions
|
||||
Handle(AIS_InteractiveContext) myContext; //!< the listened context
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,40 +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 VInspector_CallBackMode_H
|
||||
#define VInspector_CallBackMode_H
|
||||
|
||||
//! History context modes corresponding to actions in AIS_InteractiveContext
|
||||
enum VInspector_CallBackMode
|
||||
{
|
||||
VInspector_CallBackMode_None, //!< undefined
|
||||
VInspector_CallBackMode_Display, //!< Display
|
||||
VInspector_CallBackMode_Redisplay, //!< Redisplay
|
||||
VInspector_CallBackMode_Remove, //!< Remove
|
||||
VInspector_CallBackMode_Load, //!< Load
|
||||
VInspector_CallBackMode_ActivatedModes, //!< ActivatedModes
|
||||
VInspector_CallBackMode_Activate, //!< Activate
|
||||
VInspector_CallBackMode_Deactivate, //!< Deactivate
|
||||
VInspector_CallBackMode_AddOrRemoveSelectedShape, //!< AddOrRemoveSelectedShape for TopoDS_Shape
|
||||
VInspector_CallBackMode_AddOrRemoveSelected, //!< AddOrRemoveSelectedShape for Presentation
|
||||
VInspector_CallBackMode_AddOrRemoveSelectedOwner, //!< AddOrRemoveSelectedShape for Owner
|
||||
VInspector_CallBackMode_ClearSelected, //!< ClearSelected
|
||||
VInspector_CallBackMode_MoveTo, //!< MoveTo
|
||||
VInspector_CallBackMode_SetSelected, //!< SetSelected
|
||||
VInspector_CallBackMode_Select, //!< Select
|
||||
VInspector_CallBackMode_ShiftSelect //!< ShiftSelect
|
||||
};
|
||||
|
||||
#endif
|
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <inspector/VInspector_Communicator.hxx>
|
||||
|
||||
#include <inspector/VInspector_CallBack.hxx>
|
||||
#include <inspector/VInspector_Window.hxx>
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
|
@@ -43,7 +43,7 @@ QVariant VInspector_ItemBase::initValue (const int theItemRole) const
|
||||
case 3: return Standard_Dump::GetPointerInfo (Object(), true).ToCString();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return TreeModel_ItemBase::initValue (theItemRole);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -51,11 +51,6 @@ public:
|
||||
//! \return the value
|
||||
Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns presentation of the attribute to be visualized in the view
|
||||
//! \thePresentations [out] container of presentation handles to be visualized
|
||||
virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
{ (void)thePresentations; }
|
||||
|
||||
//! Returns transform persistent of the item or NULL
|
||||
Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
|
||||
|
||||
|
@@ -16,9 +16,13 @@
|
||||
#include <inspector/VInspector_ItemContextProperties.hxx>
|
||||
|
||||
#include <inspector/VInspector_ItemContext.hxx>
|
||||
#include <inspector/VInspector_ItemGraphic3dCLight.hxx>
|
||||
#include <inspector/VInspector_ItemV3dViewer.hxx>
|
||||
#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
|
||||
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : initValue
|
||||
// purpose :
|
||||
@@ -41,7 +45,24 @@ QVariant VInspector_ItemContextProperties::initValue (int theItemRole) const
|
||||
// =======================================================================
|
||||
int VInspector_ItemContextProperties::initRowCount() const
|
||||
{
|
||||
return 2; // V3d_Viewer, SelectMgr_ViewerSelector
|
||||
int aLightsCount = 0;
|
||||
|
||||
VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(Parent());
|
||||
if (aParentContextItem)
|
||||
{
|
||||
Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
|
||||
Handle(V3d_Viewer) aViewer = aContext->CurrentViewer();
|
||||
if (!aViewer.IsNull())
|
||||
{
|
||||
if (!aViewer->ActiveViews().IsEmpty())
|
||||
{
|
||||
Handle(V3d_View) aView = aViewer->ActiveViews().First();
|
||||
if (!aView.IsNull())
|
||||
aLightsCount = aView->ActiveLights().Extent();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 2 + aLightsCount; // V3d_Viewer, SelectMgr_ViewerSelector
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -52,8 +73,12 @@ TreeModel_ItemBasePtr VInspector_ItemContextProperties::createChild (int theRow,
|
||||
{
|
||||
if (theRow == 0)
|
||||
return VInspector_ItemV3dViewer::CreateItem (currentItem(), theRow, theColumn);
|
||||
|
||||
return VInspector_ItemSelectMgrViewerSelector::CreateItem (currentItem(), theRow, theColumn);
|
||||
else if (theRow == 1)
|
||||
return VInspector_ItemSelectMgrViewerSelector::CreateItem (currentItem(), theRow, theColumn);
|
||||
else // lights
|
||||
{
|
||||
return VInspector_ItemGraphic3dCLight::CreateItem (currentItem(), theRow, theColumn);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
234
tools/VInspector/VInspector_ItemGraphic3dCLight.cxx
Normal file
234
tools/VInspector/VInspector_ItemGraphic3dCLight.cxx
Normal file
@@ -0,0 +1,234 @@
|
||||
// Created on: 2021-04-27
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2021 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/VInspector_ItemGraphic3dCLight.hxx>
|
||||
|
||||
#include <AIS.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <inspector/VInspector_ItemContext.hxx>
|
||||
#include <inspector/VInspector_ItemContextProperties.hxx>
|
||||
#include <inspector/TreeModel_ItemProperties.hxx>
|
||||
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : initRowCount
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
int VInspector_ItemGraphic3dCLight::initRowCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant VInspector_ItemGraphic3dCLight::initValue (const int theItemRole) const
|
||||
{
|
||||
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
if (theItemRole == Qt::ForegroundRole)
|
||||
{
|
||||
if (GetLight().IsNull())
|
||||
return QVariant();
|
||||
|
||||
if (!GetLight()->IsEnabled())
|
||||
return QColor(Qt::darkGray);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
|
||||
return QVariant();
|
||||
|
||||
if (GetLight().IsNull())
|
||||
return Column() == 0 ? "Empty light" : "";
|
||||
|
||||
if (Column() != 0)
|
||||
return QVariant();
|
||||
|
||||
switch (GetLight()->Type())
|
||||
{
|
||||
case Graphic3d_TOLS_AMBIENT: return "Ambient light";
|
||||
case Graphic3d_TOLS_DIRECTIONAL: return "Directional light";
|
||||
case Graphic3d_TOLS_POSITIONAL: return "Positional light";
|
||||
case Graphic3d_TOLS_SPOT: return "Spot light";
|
||||
default: break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemGraphic3dCLight::Init()
|
||||
{
|
||||
VInspector_ItemContextPropertiesPtr aParentItem = itemDynamicCast<VInspector_ItemContextProperties>(Parent());
|
||||
Handle(Graphic3d_CLight) aLight;
|
||||
if (aParentItem)
|
||||
{
|
||||
VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
|
||||
if (aParentContextItem)
|
||||
{
|
||||
Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
|
||||
Handle(V3d_Viewer) aViewer = aContext->CurrentViewer();
|
||||
if (!aViewer.IsNull())
|
||||
{
|
||||
int aLightId = Row() - 2 /*in parent*/;
|
||||
int aCurrentId = 0;
|
||||
for (V3d_ListOfLightIterator aLightsIt (aViewer->ActiveLightIterator()); aLightsIt.More(); aLightsIt.Next(), aCurrentId++)
|
||||
{
|
||||
if (aCurrentId != aLightId)
|
||||
continue;
|
||||
aLight = aLightsIt.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myLight = aLight;
|
||||
TreeModel_ItemBase::Init();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Reset
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemGraphic3dCLight::Reset()
|
||||
{
|
||||
VInspector_ItemBase::Reset();
|
||||
|
||||
myLight = NULL;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemGraphic3dCLight::StoreItemProperties (const int theRow, const int theColumn, const QVariant& theValue)
|
||||
{
|
||||
if (myLight.IsNull())
|
||||
return;
|
||||
|
||||
const Handle(TreeModel_ItemProperties)& aProperties = Properties();
|
||||
if (theRow == -1 && theColumn == -1) // processing sub-item value
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
aStream << theValue.toString().toStdString().c_str();
|
||||
|
||||
int aStartPos = 1;
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColor.InitFromJson (aStream, aStartPos))
|
||||
{
|
||||
myLight->SetColor (aColor.GetRGB());
|
||||
return;
|
||||
}
|
||||
|
||||
// "Direction"
|
||||
gp_Dir aDir;
|
||||
if (aDir.InitFromJson (aStream, aStartPos))
|
||||
{
|
||||
myLight->SetDirection (aDir);
|
||||
return;
|
||||
}
|
||||
|
||||
// "Position"
|
||||
gp_Pnt aPnt;
|
||||
if (aPnt.InitFromJson (aStream, aStartPos))
|
||||
{
|
||||
myLight->SetPosition (aPnt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QString aPropertyName = aProperties->Data(theRow, 0).toString();
|
||||
QVariant aPropertyValue = aProperties->Data(theRow, 1);
|
||||
if (aPropertyName == "Position")
|
||||
{
|
||||
}
|
||||
else if (aPropertyName == "Intensity")
|
||||
{
|
||||
myLight->SetIntensity ((Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
else if (aPropertyName == "ConstAttenuation")
|
||||
{
|
||||
myLight->SetAttenuation ((Standard_ShortReal)aPropertyValue.toReal(),
|
||||
(Standard_ShortReal)aProperties->Data(theRow + 1, 1).toReal());
|
||||
}
|
||||
else if (aPropertyName == "LinearAttenuation")
|
||||
{
|
||||
myLight->SetAttenuation ((Standard_ShortReal)aProperties->Data(theRow - 1, 1).toReal(),
|
||||
(Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
else if (aPropertyName == "Angle")
|
||||
{
|
||||
myLight->SetAngle ((Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
else if (aPropertyName == "Concentration")
|
||||
{
|
||||
myLight->SetConcentration ((Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
else if (aPropertyName == "Range")
|
||||
{
|
||||
myLight->SetRange ((Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
else if (aPropertyName == "Smoothness")
|
||||
{
|
||||
if (myLight->Type() == Graphic3d_TOLS_DIRECTIONAL)
|
||||
{
|
||||
myLight->SetSmoothAngle ((Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
else
|
||||
{
|
||||
myLight->SetSmoothRadius ((Standard_ShortReal)aPropertyValue.toReal());
|
||||
}
|
||||
}
|
||||
else if (aPropertyName == "IsHeadlight")
|
||||
{
|
||||
myLight->SetHeadlight (aPropertyValue.toInt() == 1);
|
||||
}
|
||||
else if (aPropertyName == "IsEnabled")
|
||||
{
|
||||
myLight->SetEnabled (aPropertyValue.toInt() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemGraphic3dCLight::initItem() const
|
||||
{
|
||||
if (IsInitialized())
|
||||
return;
|
||||
const_cast<VInspector_ItemGraphic3dCLight*>(this)->Init();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemGraphic3dCLight::initStream (Standard_OStream& theOStream) const
|
||||
{
|
||||
Handle(Graphic3d_CLight) aLight = GetLight();
|
||||
if (aLight.IsNull())
|
||||
return;
|
||||
|
||||
aLight->DumpJson (theOStream);
|
||||
}
|
88
tools/VInspector/VInspector_ItemGraphic3dCLight.hxx
Normal file
88
tools/VInspector/VInspector_ItemGraphic3dCLight.hxx
Normal file
@@ -0,0 +1,88 @@
|
||||
// Created on: 2021-04-27
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2021 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef VInspector_ItemGraphic3dCLight_H
|
||||
#define VInspector_ItemGraphic3dCLight_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <inspector/VInspector_ItemBase.hxx>
|
||||
|
||||
#include <Graphic3d_CLight.hxx>
|
||||
|
||||
class VInspector_ItemGraphic3dCLight;
|
||||
typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dCLight> VInspector_ItemGraphic3dCLightPtr;
|
||||
|
||||
//! \class VInspector_ItemGraphic3dCLight
|
||||
//! Parent item is context properties, that corresponds to AIS_InteractiveContext
|
||||
class VInspector_ItemGraphic3dCLight : public VInspector_ItemBase
|
||||
{
|
||||
public:
|
||||
|
||||
//! Creates an item wrapped by a shared pointer
|
||||
static VInspector_ItemGraphic3dCLightPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return VInspector_ItemGraphic3dCLightPtr (new VInspector_ItemGraphic3dCLight (theParent, theRow, theColumn)); }
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspector_ItemGraphic3dCLight() Standard_OVERRIDE {};
|
||||
|
||||
//! Inits the item, fills internal containers
|
||||
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
|
||||
|
||||
//! Resets cached values
|
||||
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
|
||||
|
||||
//! Returns data object of the item.
|
||||
//! \return object
|
||||
virtual const Handle(Standard_Transient)& Object() const { initItem(); return myLight; }
|
||||
|
||||
//! Returns the current light, init item if it was not initialized yet
|
||||
//! \return interactive object
|
||||
Handle(Graphic3d_CLight) GetLight() const { return Handle(Graphic3d_CLight)::DownCast (Object()); }
|
||||
|
||||
//! Updates item by the item properties value
|
||||
virtual void StoreItemProperties (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
//! Initializes the current item. It is empty because Reset() is also empty.
|
||||
virtual void initItem() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns number of displayed presentations
|
||||
//! \return rows count
|
||||
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns item information for the given role. Fills internal container if it was not filled yet
|
||||
//! \param theItemRole a value role
|
||||
//! \return the value
|
||||
Standard_EXPORT 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;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
//! param theParent a parent item
|
||||
//! \param theRow the item row positition in the parent item
|
||||
//! \param theColumn the item column positition in the parent item
|
||||
VInspector_ItemGraphic3dCLight(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: VInspector_ItemBase(theParent, theRow, theColumn) {}
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Graphic3d_CLight) myLight; //!< the current light
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,110 +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.
|
||||
|
||||
#include <inspector/VInspector_ItemHistoryElement.hxx>
|
||||
|
||||
#include <inspector/VInspector_ItemHistoryRoot.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryType.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryElement.hxx>
|
||||
#include <inspector/VInspector_Tools.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : data
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
|
||||
{
|
||||
QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
|
||||
return QVariant();
|
||||
|
||||
switch (Column())
|
||||
{
|
||||
case 0: return getName();
|
||||
case 2: return QVariant();
|
||||
case 3: return GetPointerInfo();
|
||||
case 4: return GetShapeTypeInfo();
|
||||
default: break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemHistoryElement::Init()
|
||||
{
|
||||
VInspector_ItemHistoryTypePtr aParentItem = itemDynamicCast<VInspector_ItemHistoryType>(Parent());
|
||||
VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(aParentItem->Parent());
|
||||
|
||||
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aRootItem->GetTypeInfo (aParentItem->Row());
|
||||
QList<QList<QVariant>> anElements = aTypeInfo.myElements;
|
||||
|
||||
int aRowId = Row();
|
||||
QList<QVariant> anInfo = anElements.at(aRowId);
|
||||
int anInfoSize = anInfo.size();
|
||||
|
||||
myName = anInfoSize > 0 ? anInfo[0].toString() : QString ("Element: %1").arg (aRowId);
|
||||
myPointerInfo = anInfoSize > 1 ? anInfo[1].toString() : QString();
|
||||
myShapeTypeInfo = anInfoSize > 2 ? anInfo[2].toString() : QString();
|
||||
|
||||
TreeModel_ItemBase::Init();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemHistoryElement::initItem() const
|
||||
{
|
||||
if (IsInitialized())
|
||||
return;
|
||||
const_cast<VInspector_ItemHistoryElement*>(this)->Init();
|
||||
// an empty method to don't initialize the main label, as it was not cleared in Reset()
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : getName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString VInspector_ItemHistoryElement::getName() const
|
||||
{
|
||||
initItem();
|
||||
return myName;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetPointerInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString VInspector_ItemHistoryElement::GetPointerInfo() const
|
||||
{
|
||||
initItem();
|
||||
return myPointerInfo;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetShapeTypeInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString VInspector_ItemHistoryElement::GetShapeTypeInfo() const
|
||||
{
|
||||
initItem();
|
||||
return myShapeTypeInfo;
|
||||
}
|
@@ -1,92 +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 VInspector_ItemHistoryElement_H
|
||||
#define VInspector_ItemHistoryElement_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <inspector/VInspector_ItemBase.hxx>
|
||||
|
||||
class VInspector_ItemHistoryElement;
|
||||
typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryElement> VInspector_ItemHistoryElementPtr;
|
||||
|
||||
//! \class VInspector_ItemHistoryElement
|
||||
//! Item shows name, pointer and shape type values of item history type information
|
||||
//! Parent is item history type, there are no children.
|
||||
class VInspector_ItemHistoryElement : public VInspector_ItemBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Creates an item wrapped by a shared pointer
|
||||
static VInspector_ItemHistoryElementPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return VInspector_ItemHistoryElementPtr (new VInspector_ItemHistoryElement (theParent, theRow, theColumn)); }
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspector_ItemHistoryElement() {}
|
||||
|
||||
//! Inits the item, fills internal containers
|
||||
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
|
||||
|
||||
//! Resets cached values
|
||||
virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
|
||||
|
||||
//! Returns pointer string value
|
||||
QString PointerInfo() const { return myPointerInfo; }
|
||||
|
||||
//! \return number of children.
|
||||
virtual int initRowCount() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
//! Returns item information for the given role. Fills internal container if it was not filled yet
|
||||
//! \param theItemRole a value role
|
||||
//! \return the value
|
||||
Standard_EXPORT virtual QVariant initValue(const int theItemRole) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Initialize 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.
|
||||
//! \param theRow the child row position
|
||||
//! \param theColumn the child column position
|
||||
//! \return the created item
|
||||
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
|
||||
{ (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
|
||||
|
||||
//! Returns the item text value, initialize item if it has not been initialized yet
|
||||
QString getName() const;
|
||||
|
||||
//! Returns the item pointer value, initialize item if it has not been initialized yet
|
||||
QString GetPointerInfo() const;
|
||||
|
||||
//! Returns the shape type text value, initialize item if it has not been initialized yet
|
||||
QString GetShapeTypeInfo() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
//! \param theParent a parent item
|
||||
VInspector_ItemHistoryElement(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: VInspector_ItemBase(theParent, theRow, theColumn) {}
|
||||
|
||||
private:
|
||||
|
||||
QString myName; //!< cached text value
|
||||
QString myPointerInfo; //!< cached pointer text value
|
||||
QString myShapeTypeInfo; //!<cached shape type text value
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,106 +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.
|
||||
|
||||
#include <inspector/VInspector_ItemHistoryRoot.hxx>
|
||||
|
||||
#include <inspector/VInspector_ItemHistoryType.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
VInspector_ItemHistoryRoot::VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent,
|
||||
const int theRow, const int theColumn)
|
||||
: VInspector_ItemBase (theParent, theRow, theColumn), myFirstIndex (0), myLastIndex (0), myInfoMaxSize (10)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddElement
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemHistoryRoot::AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
|
||||
{
|
||||
if (!myLastIndex)
|
||||
{
|
||||
myInfoMap[myLastIndex] = VInspector_ItemHistoryTypeInfo(theMode, theInfo);
|
||||
myLastIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myInfoMap[myLastIndex].myMode == theMode)
|
||||
myInfoMap[myLastIndex].AddElement(theInfo);
|
||||
else
|
||||
{
|
||||
myLastIndex++;
|
||||
myInfoMap[myLastIndex] = VInspector_ItemHistoryTypeInfo(theMode, theInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// clear cache
|
||||
if (myInfoMap.size() >= myInfoMaxSize)
|
||||
{
|
||||
myInfoMap.remove (myFirstIndex);
|
||||
myFirstIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetTypeInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (const int theChildRowIndex)
|
||||
{
|
||||
int anInfoMapIndex = theChildRowIndex + myFirstIndex;
|
||||
|
||||
bool aReversed = true;
|
||||
if (aReversed)
|
||||
anInfoMapIndex = (myInfoMap.size() - myFirstIndex) - 1 - anInfoMapIndex;
|
||||
|
||||
return myInfoMap[anInfoMapIndex];
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant VInspector_ItemHistoryRoot::initValue (const int theRole) const
|
||||
{
|
||||
QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
|
||||
return QVariant();
|
||||
|
||||
switch (Column())
|
||||
{
|
||||
case 0: return "History";
|
||||
case 2: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createChild
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr VInspector_ItemHistoryRoot::createChild (int theRow, int theColumn)
|
||||
{
|
||||
return VInspector_ItemHistoryType::CreateItem (currentItem(), theRow, theColumn);
|
||||
}
|
||||
|
@@ -1,86 +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 VInspector_ItemHistoryRoot_H
|
||||
#define VInspector_ItemHistoryRoot_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <inspector/VInspector_ItemBase.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryTypeInfo.hxx>
|
||||
#include <inspector/VInspector_CallBackMode.hxx>
|
||||
|
||||
class VInspector_ItemHistoryRoot;
|
||||
typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryRoot> VInspector_ItemHistoryRootPtr;
|
||||
|
||||
//! \class VInspector_ItemHistoryRoot
|
||||
//! Item in history tree model. Has container of VInspector_ItemHistoryTypeInfo. Each element is a child item.
|
||||
//! Parent item is NULL, children are ItemHistoryType items
|
||||
class VInspector_ItemHistoryRoot : public VInspector_ItemBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Creates an item wrapped by a shared pointer
|
||||
static VInspector_ItemHistoryRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return VInspector_ItemHistoryRootPtr (new VInspector_ItemHistoryRoot (theParent, theRow, theColumn)); }
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspector_ItemHistoryRoot() {}
|
||||
|
||||
//! Sets maximum count of history elements in internal container.
|
||||
//! \param theSize a size value
|
||||
void SetHistoryTypesMaxAmount (const int theSize) { myInfoMaxSize = theSize; }
|
||||
|
||||
//! Appends new history element into internal container. If the container already has maximum number
|
||||
//! of values, the first container is removed.
|
||||
//! \param theMode a type of the element
|
||||
//! \param theInfo a history information element
|
||||
Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
|
||||
|
||||
//! Returns history item information for the child item
|
||||
//! \param theChildRowIndex a child index
|
||||
Standard_EXPORT const VInspector_ItemHistoryTypeInfo& GetTypeInfo (const int theChildRowIndex);
|
||||
|
||||
protected:
|
||||
|
||||
//! Return data value for the role. It should be reimplemented in child
|
||||
//! \param theRole a value role
|
||||
//! \return the value
|
||||
virtual QVariant initValue(const int theRole) const;
|
||||
|
||||
//! \return number of children. It should be reimplemented in child
|
||||
virtual int initRowCount() const Standard_OVERRIDE { return myInfoMap.size(); }
|
||||
|
||||
//! Creates a child item in the given position.
|
||||
//! \param theRow the child row position
|
||||
//! \param theColumn the child column position
|
||||
//! \return the created item
|
||||
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
//! \param theParent a parent item
|
||||
VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
|
||||
|
||||
private:
|
||||
|
||||
QMap<int, VInspector_ItemHistoryTypeInfo> myInfoMap; //!< container of whole callback info, bounded by maximum size value
|
||||
int myFirstIndex; //!< the first index in the information map, the first index is incremented if max value of container is achieved
|
||||
int myLastIndex; //!< the last index in the information map, is incremented when new element is added
|
||||
int myInfoMaxSize; //!< maximum number of elements in information map
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,121 +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.
|
||||
|
||||
#include <inspector/VInspector_ItemHistoryType.hxx>
|
||||
|
||||
#include <inspector/VInspector_CallBack.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryRoot.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryElement.hxx>
|
||||
#include <inspector/VInspector_Tools.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : PointerInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString VInspector_ItemHistoryType::PointerInfo() const
|
||||
{
|
||||
if (rowCount() <= 0)
|
||||
return QString();
|
||||
|
||||
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
|
||||
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
|
||||
if (aTypeInfo.myElements.size() < rowCount())
|
||||
return QString();
|
||||
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
|
||||
return anElements.size() > 1 ? anElements[1].toString() : QString();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : PointerInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString VInspector_ItemHistoryType::OwnerInfo() const
|
||||
{
|
||||
if (rowCount() <= 0)
|
||||
return QString();
|
||||
|
||||
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
|
||||
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
|
||||
if ( aTypeInfo.myElements.size() < rowCount())
|
||||
return QString();
|
||||
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
|
||||
return anElements.size() > 3 ? anElements[3].toString() : QString();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : data
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
|
||||
{
|
||||
QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
|
||||
return QVariant();
|
||||
|
||||
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
|
||||
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
|
||||
int aRowCount = rowCount();
|
||||
if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount)
|
||||
return QVariant();
|
||||
|
||||
QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
|
||||
int anInfoSize = anElements.size();
|
||||
switch (Column())
|
||||
{
|
||||
case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode);
|
||||
case 3: return rowCount();
|
||||
case 4: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
|
||||
case 5: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
|
||||
case 6: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
|
||||
case 7: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
|
||||
default: break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : rowCount
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
int VInspector_ItemHistoryType::initRowCount() const
|
||||
{
|
||||
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
|
||||
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
|
||||
return aTypeInfo.myElements.size();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createChild
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr VInspector_ItemHistoryType::createChild (int theRow, int theColumn)
|
||||
{
|
||||
return VInspector_ItemHistoryElement::CreateItem (currentItem(), theRow, theColumn);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ItemHistoryType::initItem() const
|
||||
{
|
||||
if (IsInitialized())
|
||||
return;
|
||||
const_cast<VInspector_ItemHistoryType*>(this)->Init();
|
||||
// an empty method to don't initialize the main label, as it was not cleared in Reset()
|
||||
}
|
@@ -1,76 +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 VInspector_ItemHistoryType_H
|
||||
#define VInspector_ItemHistoryType_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <inspector/VInspector_ItemBase.hxx>
|
||||
|
||||
class VInspector_ItemHistoryType;
|
||||
typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryType> VInspector_ItemHistoryTypePtr;
|
||||
|
||||
//! \class VInspector_ItemHistoryType
|
||||
//! Item to show history type. Also it shows the element information of the first sub-item
|
||||
//! Parent is item history root item, children are item history elements
|
||||
class VInspector_ItemHistoryType : public VInspector_ItemBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Creates an item wrapped by a shared pointer
|
||||
static VInspector_ItemHistoryTypePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return VInspector_ItemHistoryTypePtr (new VInspector_ItemHistoryType (theParent, theRow, theColumn)); }
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspector_ItemHistoryType() {}
|
||||
|
||||
//! Returns the pointer info of the first child item, initialize item if it has not been initialized yet.
|
||||
Standard_EXPORT QString PointerInfo() const;
|
||||
|
||||
//! Returns the owner info of the first child item, initialize item if it has not been initialized yet.
|
||||
Standard_EXPORT QString OwnerInfo() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Return data value for the role.
|
||||
//! \param theRole a value role
|
||||
//! \return the value
|
||||
virtual QVariant initValue(const int theRole) const;
|
||||
|
||||
//! \return number of children.
|
||||
virtual int initRowCount() const Standard_OVERRIDE;
|
||||
|
||||
//! Initialize the current item. It is empty because Reset() is also empty.
|
||||
virtual void initItem() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a child item in the given position.
|
||||
//! \param theRow the child row position
|
||||
//! \param theColumn the child column position
|
||||
//! \return the created item
|
||||
virtual TreeModel_ItemBasePtr createChild(int theRow, int theColumn) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
//! \param theParent a parent item
|
||||
VInspector_ItemHistoryType(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: VInspector_ItemBase(theParent, theRow, theColumn) {}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,41 +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 VInspector_ItemHistoryTypeInfo_H
|
||||
#define VInspector_ItemHistoryTypeInfo_H
|
||||
|
||||
#include <inspector/VInspector_CallBackMode.hxx>
|
||||
|
||||
//! \class VInspector_ItemHistoryTypeInfo
|
||||
//! History info for a type item. It contains container of information for the element
|
||||
struct VInspector_ItemHistoryTypeInfo
|
||||
{
|
||||
|
||||
//! Constructor
|
||||
VInspector_ItemHistoryTypeInfo() : myMode(VInspector_CallBackMode_None) {}
|
||||
|
||||
//! Destructor
|
||||
VInspector_ItemHistoryTypeInfo (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
|
||||
: myMode(theMode) { AddElement(theInfo); }
|
||||
|
||||
//! Append new element
|
||||
//! \param theInfo an information element
|
||||
void AddElement (const QList<QVariant>& theInfo) { myElements.append (theInfo); }
|
||||
|
||||
VInspector_CallBackMode myMode; //!< history element mode
|
||||
QList<QList<QVariant>> myElements; //!< container of elements information
|
||||
};
|
||||
|
||||
#endif
|
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
//! Returns presentation of the attribute to be visualized in the view
|
||||
//! \thePresentations [out] container of presentation handles to be visualized
|
||||
Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
|
||||
Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <inspector/VInspector_CallBackMode.hxx>
|
||||
#include <inspector/View_DisplayActionType.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ItemBase.hxx>
|
||||
|
@@ -43,8 +43,8 @@ void VInspector_ViewModel::InitColumns()
|
||||
{
|
||||
TreeModel_ModelBase::InitColumns();
|
||||
|
||||
SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
|
||||
SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
|
||||
setHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
|
||||
setHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -1,130 +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.
|
||||
|
||||
#include <inspector/VInspector_ViewModelHistory.hxx>
|
||||
|
||||
#include <inspector/VInspector_ItemHistoryElement.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryRoot.hxx>
|
||||
#include <inspector/VInspector_ItemHistoryType.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QStringList>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
const int COLUMN_NAME_WIDTH = 230;
|
||||
const int COLUMN_SIZE_WIDTH = 30;
|
||||
const int COLUMN_POINTER_WIDTH = 70;
|
||||
const int COLUMN_SHAPE_TYPE_WIDTH = 75;
|
||||
const int COLUMN_AIS_NAME_WIDTH = 75;
|
||||
const int COLUMN_SELECTED_WIDTH = 75;
|
||||
|
||||
const int COLUMN_5_WIDTH = 120;
|
||||
const int COLUMN_6_WIDTH = 65;
|
||||
const int COLUMN_7_WIDTH = 70;
|
||||
|
||||
const int HISTORY_AIS_NAME_COLUMN_WIDTH = 140;
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
|
||||
: TreeModel_ModelBase (theParent), myHistoryTypesMaxAmount (theHistoryTypesMaxAmount)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitColumns
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ViewModelHistory::InitColumns()
|
||||
{
|
||||
TreeModel_ModelBase::InitColumns();
|
||||
|
||||
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
|
||||
SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item
|
||||
SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
|
||||
SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
|
||||
SetHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
|
||||
SetHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
|
||||
SetHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1));
|
||||
|
||||
for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
|
||||
{
|
||||
VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot> (myRootItems[aColumnId]);
|
||||
aRootItem->SetHistoryTypesMaxAmount (myHistoryTypesMaxAmount);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createRootItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr VInspector_ViewModelHistory::createRootItem (const int theColumnId)
|
||||
{
|
||||
return VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddElement
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_ViewModelHistory::AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
|
||||
{
|
||||
// fill root item by the application
|
||||
for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
|
||||
{
|
||||
VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(myRootItems[aColId]);
|
||||
aRootItem->AddElement(theMode, theInfo);
|
||||
}
|
||||
Reset();
|
||||
EmitLayoutChanged();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetSelectedPointers
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QStringList VInspector_ViewModelHistory::GetSelectedPointers (const QModelIndex& theIndex)
|
||||
{
|
||||
QStringList aPointers;
|
||||
TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (theIndex);
|
||||
if (!anItem)
|
||||
return aPointers;
|
||||
|
||||
VInspector_ItemHistoryTypePtr aHistoryItem = itemDynamicCast<VInspector_ItemHistoryType>(anItem);
|
||||
if (aHistoryItem)
|
||||
{
|
||||
QString aPointerInfo = aHistoryItem->PointerInfo();
|
||||
QString anOwnerInfo = aHistoryItem->OwnerInfo();
|
||||
|
||||
if (!aPointerInfo.isEmpty())
|
||||
aPointers.append (aPointerInfo);
|
||||
if (!anOwnerInfo.isEmpty())
|
||||
aPointers.append (anOwnerInfo.split (", "));
|
||||
}
|
||||
else
|
||||
{
|
||||
VInspector_ItemHistoryElementPtr anElementItem = itemDynamicCast<VInspector_ItemHistoryElement>(anItem);
|
||||
if (anElementItem)
|
||||
{
|
||||
QString aPointerInfo = anElementItem->PointerInfo();
|
||||
if (!aPointerInfo.isEmpty())
|
||||
aPointers.append (aPointerInfo);
|
||||
}
|
||||
}
|
||||
return aPointers;
|
||||
}
|
@@ -1,67 +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 VInspector_ViewModelHistory_H
|
||||
#define VInspector_ViewModelHistory_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <inspector/VInspector_ItemBase.hxx>
|
||||
#include <inspector/VInspector_CallBackMode.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
|
||||
//! \class VInspector_ViewModelHistory
|
||||
//! The class that visualizes methods called in AIS interactive context.
|
||||
class VInspector_ViewModelHistory : public TreeModel_ModelBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount = 50);
|
||||
|
||||
//! Destructor
|
||||
virtual ~VInspector_ViewModelHistory() {}
|
||||
|
||||
//! Creates model columns and root items.
|
||||
Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
|
||||
|
||||
//! Append new element under the root item
|
||||
Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
|
||||
|
||||
//! Returns container of pointer information for selected presentation or owner item
|
||||
//! \param theIndex an index of tree view model
|
||||
//! \param container of strings
|
||||
Standard_EXPORT QStringList GetSelectedPointers (const QModelIndex& theIndex);
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates root item
|
||||
//! \param theColumnId index of a column
|
||||
Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
int myHistoryTypesMaxAmount; //!< maximum types in history
|
||||
};
|
||||
|
||||
#endif
|
@@ -33,13 +33,13 @@
|
||||
#include <inspector/VInspector_ToolBar.hxx>
|
||||
#include <inspector/VInspector_Tools.hxx>
|
||||
#include <inspector/VInspector_ViewModel.hxx>
|
||||
#include <inspector/VInspector_CallBack.hxx>
|
||||
#include <inspector/VInspector_Communicator.hxx>
|
||||
#include <inspector/VInspector_ItemContext.hxx>
|
||||
#include <inspector/VInspector_ItemContextProperties.hxx>
|
||||
#include <inspector/VInspector_ItemGraphic3dCLight.hxx>
|
||||
#include <inspector/VInspector_ToolBar.hxx>
|
||||
#include <inspector/VInspector_Tools.hxx>
|
||||
#include <inspector/VInspector_ViewModel.hxx>
|
||||
#include <inspector/VInspector_ViewModelHistory.hxx>
|
||||
|
||||
#include <inspector/ViewControl_PropertyView.hxx>
|
||||
#include <inspector/ViewControl_TreeView.hxx>
|
||||
@@ -77,9 +77,6 @@ const int VINSPECTOR_DEFAULT_POSITION_Y = 60;
|
||||
const int VINSPECTOR_DEFAULT_VIEW_WIDTH = 400;
|
||||
const int VINSPECTOR_DEFAULT_VIEW_HEIGHT = 1000;
|
||||
|
||||
const int VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH = 400;
|
||||
const int VINSPECTOR_DEFAULT_HISTORY_VIEW_HEIGHT = 50;
|
||||
|
||||
const int VINSPECTOR_DEFAULT_VIEW_POSITION_X = 200 + 900 + 100; // TINSPECTOR_DEFAULT_POSITION_X + TINSPECTOR_DEFAULT_WIDTH + 100
|
||||
const int VINSPECTOR_DEFAULT_VIEW_POSITION_Y = 60; // TINSPECTOR_DEFAULT_POSITION_Y + 50
|
||||
|
||||
@@ -114,9 +111,8 @@ VInspector_Window::VInspector_Window()
|
||||
aTreeModel->InitColumns();
|
||||
myTreeView->setModel (aTreeModel);
|
||||
// hide Visibility column
|
||||
TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
|
||||
anItem.SetIsHidden (true);
|
||||
aTreeModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
|
||||
TreeModel_HeaderSection* anItem = aTreeModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility);
|
||||
anItem->SetIsHidden (true);
|
||||
|
||||
connect (myTreeView, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
this, SLOT (onTreeViewContextMenuRequested(const QPoint&)));
|
||||
@@ -141,40 +137,6 @@ VInspector_Window::VInspector_Window()
|
||||
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
|
||||
connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool)));
|
||||
|
||||
myHistoryView = new ViewControl_TreeView (myMainWindow);
|
||||
myHistoryView->setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||
((ViewControl_TreeView*)myHistoryView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH,
|
||||
VINSPECTOR_DEFAULT_HISTORY_VIEW_HEIGHT));
|
||||
myHistoryView->setContextMenuPolicy (Qt::CustomContextMenu);
|
||||
myHistoryView->header()->setStretchLastSection (true);
|
||||
new TreeModel_ContextMenu (myHistoryView);
|
||||
|
||||
myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||
VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
|
||||
aHistoryModel->InitColumns();
|
||||
myHistoryView->setModel (aHistoryModel);
|
||||
|
||||
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHistoryModel);
|
||||
myHistoryView->setSelectionModel (aSelectionModel);
|
||||
connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
|
||||
|
||||
anItem = aHistoryModel->GetHeaderItem (0);
|
||||
// hide Visibility column
|
||||
TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
|
||||
anItem = aHistoryModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
|
||||
anItem.SetIsHidden (true);
|
||||
aHistoryModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
|
||||
|
||||
QModelIndex aParentIndex = myHistoryView->model()->index (0, 0);
|
||||
myHistoryView->setExpanded (aParentIndex, true);
|
||||
|
||||
QDockWidget* aHistoryDockWidget = new QDockWidget (tr ("HistoryView"), myMainWindow);
|
||||
aHistoryDockWidget->setObjectName (aHistoryDockWidget->windowTitle());
|
||||
aHistoryDockWidget->setTitleBarWidget (new QWidget(myMainWindow));
|
||||
aHistoryDockWidget->setWidget (myHistoryView);
|
||||
myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aHistoryDockWidget);
|
||||
|
||||
myMainWindow->resize (450, 800);
|
||||
myMainWindow->move (60, 20);
|
||||
|
||||
@@ -263,7 +225,6 @@ void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
|
||||
if (theItem.IsEmpty())
|
||||
{
|
||||
TreeModel_Tools::SetDefaultHeaderSections (myTreeView);
|
||||
TreeModel_Tools::SetDefaultHeaderSections (myHistoryView);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,9 +236,6 @@ void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
|
||||
myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemValue.ToCString()));
|
||||
else if (TreeModel_Tools::RestoreState (myTreeView, anItemKey.ToCString(), anItemValue.ToCString()))
|
||||
continue;
|
||||
else if (TreeModel_Tools::RestoreState (myHistoryView, anItemKey.ToCString(), anItemValue.ToCString(),
|
||||
"history_view_"))
|
||||
continue;
|
||||
else if (View_PreviewParameters::RestoreState (displayer()->DisplayPreview()->GetPreviewParameters(), anItemKey.ToCString(),
|
||||
anItemValue.ToCString(), "preview_parameters_"))
|
||||
continue;
|
||||
@@ -334,14 +292,6 @@ void VInspector_Window::UpdateContent()
|
||||
myTreeView->scrollTo (aPresentationIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!myCallBack.IsNull())
|
||||
{
|
||||
VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
|
||||
(myHistoryView->model());
|
||||
aHistoryModel->Reset();
|
||||
aHistoryModel->EmitLayoutChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -417,7 +367,6 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
|
||||
return Standard_False;
|
||||
|
||||
Handle(AIS_InteractiveContext) aContext;
|
||||
Handle(VInspector_CallBack) aCallBack;
|
||||
Standard_Boolean isModelUpdated = Standard_False;
|
||||
|
||||
for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next())
|
||||
@@ -426,23 +375,12 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
|
||||
if (aContext.IsNull())
|
||||
aContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
|
||||
|
||||
if (aCallBack.IsNull())
|
||||
aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
|
||||
}
|
||||
if (aViewModel->GetContext() != aContext)
|
||||
SetContext(aContext);
|
||||
else
|
||||
isModelUpdated = Standard_True;
|
||||
|
||||
if (!aCallBack.IsNull() && aCallBack != myCallBack)
|
||||
{
|
||||
myCallBack = aCallBack;
|
||||
VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
|
||||
(myHistoryView->model());
|
||||
myCallBack->SetContext(aContext);
|
||||
myCallBack->SetHistoryModel(aHistoryModel);
|
||||
}
|
||||
|
||||
if (isModelUpdated)
|
||||
UpdateTreeModel();
|
||||
|
||||
@@ -462,9 +400,6 @@ void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theCon
|
||||
aViewModel->SetContext (theContext);
|
||||
myTreeView->setExpanded (aViewModel->index (0, 0), true);
|
||||
|
||||
if (!myCallBack.IsNull())
|
||||
myCallBack->SetContext (theContext);
|
||||
|
||||
if (myDisplayer)
|
||||
myDisplayer->SetContext (theContext);
|
||||
}
|
||||
@@ -485,6 +420,14 @@ bool VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
|
||||
{
|
||||
aContext = createView();
|
||||
SetContext (aContext);
|
||||
|
||||
const Handle(V3d_Viewer) aViewer = aViewModel->GetContext()->CurrentViewer();
|
||||
if (!aViewer.IsNull())
|
||||
{
|
||||
addLight (Graphic3d_TOLS_POSITIONAL, aViewer);
|
||||
addLight (Graphic3d_TOLS_SPOT, aViewer);
|
||||
}
|
||||
|
||||
isModelUpdated = true;
|
||||
}
|
||||
|
||||
@@ -493,6 +436,8 @@ bool VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
|
||||
return isModelUpdated;
|
||||
|
||||
Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape);
|
||||
aPresentation->Attributes()->SetAutoTriangulation (Standard_False);
|
||||
|
||||
View_Displayer* aDisplayer = myViewWindow->Displayer();
|
||||
aDisplayer->DisplayPresentation (aPresentation);
|
||||
aContext->UpdateCurrentViewer();
|
||||
@@ -516,10 +461,28 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
|
||||
if (anItemBase)
|
||||
{
|
||||
if (itemDynamicCast<VInspector_ItemContext> (anItemBase))
|
||||
if (itemDynamicCast<VInspector_ItemContextProperties> (anItemBase))
|
||||
{
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to MessageView"), SLOT (onExportToMessageView()), GetMainWindow(), this));
|
||||
aMenu->addSeparator();
|
||||
QMenu* anExplodeMenu = aMenu->addMenu ("Add Light");
|
||||
|
||||
anExplodeMenu->addAction (ViewControl_Tools::CreateAction ("Ambient", SLOT (onAddLight()), myMainWindow, this));
|
||||
anExplodeMenu->addAction (ViewControl_Tools::CreateAction ("Directional", SLOT (onAddLight()), myMainWindow, this));
|
||||
anExplodeMenu->addAction (ViewControl_Tools::CreateAction ("Positional", SLOT (onAddLight()), myMainWindow, this));
|
||||
anExplodeMenu->addAction (ViewControl_Tools::CreateAction ("Spot", SLOT (onAddLight()), myMainWindow, this));
|
||||
}
|
||||
|
||||
if (itemDynamicCast<VInspector_ItemGraphic3dCLight> (anItemBase))
|
||||
{
|
||||
aMenu->addSeparator();
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction ("Remove Light", SLOT (onRemoveLight()), myMainWindow, this));
|
||||
VInspector_ItemGraphic3dCLightPtr anItemLight = itemDynamicCast<VInspector_ItemGraphic3dCLight> (anItemBase);
|
||||
if (!anItemLight->GetLight().IsNull())
|
||||
{
|
||||
bool isOn = anItemLight->GetLight()->IsEnabled();
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction (isOn ? "OFF Light" : "ON Light", SLOT (onOnOffLight()),
|
||||
myMainWindow, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,9 +498,6 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand All"), SLOT (onExpandAll()), GetMainWindow(), this));
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Collapse All"), SLOT (onCollapseAll()), GetMainWindow(), this));
|
||||
|
||||
aMenu->addSeparator();
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction ("Test AddChild", SLOT (OnTestAddChild()), GetMainWindow(), this));
|
||||
|
||||
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
|
||||
aMenu->exec(aPoint);
|
||||
}
|
||||
@@ -606,25 +566,6 @@ void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&,
|
||||
displayer()->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onHistoryViewSelectionChanged
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& theSelected,
|
||||
const QItemSelection&)
|
||||
{
|
||||
VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*> (myHistoryView->model());
|
||||
if (!aHistoryModel)
|
||||
return;
|
||||
|
||||
if (theSelected.size() == 0)
|
||||
return;
|
||||
|
||||
QModelIndexList aSelectedIndices = theSelected.indexes();
|
||||
QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first());
|
||||
selectTreeViewItems (aPointers);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onExportToShapeView
|
||||
// purpose :
|
||||
@@ -636,12 +577,7 @@ void VInspector_Window::onExportToShapeView()
|
||||
|
||||
TCollection_AsciiString aPluginName ("TKShapeView");
|
||||
NCollection_List<Handle(Standard_Transient)> aParameters;
|
||||
if (myParameters->FindParameters (aPluginName))
|
||||
aParameters = myParameters->Parameters (aPluginName);
|
||||
|
||||
NCollection_List<TCollection_AsciiString> anItemNames;
|
||||
if (myParameters->FindSelectedNames (aPluginName))
|
||||
anItemNames = myParameters->GetSelectedNames (aPluginName);
|
||||
|
||||
QStringList anExportedPointers;
|
||||
if (aSelectedShapes.Extent() > 0)
|
||||
@@ -661,24 +597,6 @@ void VInspector_Window::onExportToShapeView()
|
||||
}
|
||||
}
|
||||
|
||||
// search for objects to be exported
|
||||
QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (myTreeView->selectionModel()->selectedIndexes());
|
||||
for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt)
|
||||
{
|
||||
TreeModel_ItemBasePtr anItem = *anItemIt;
|
||||
VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
|
||||
if (!aVItem)
|
||||
continue;
|
||||
|
||||
const Handle(Standard_Transient)& anObject = aVItem->Object();
|
||||
if (anObject.IsNull())
|
||||
continue;
|
||||
|
||||
aParameters.Append (anObject);
|
||||
anItemNames.Append (anObject->DynamicType()->Name());
|
||||
anExportedPointers.append (Standard_Dump::GetPointerInfo (anObject, true).ToCString());
|
||||
}
|
||||
|
||||
if (anExportedPointers.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -698,6 +616,97 @@ void VInspector_Window::onExportToShapeView()
|
||||
myParameters->SetParameters (aPluginName, aParameters, myExportToShapeViewDialog->IsAccepted());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onAddLight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_Window::onAddLight()
|
||||
{
|
||||
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
|
||||
if (!aViewModel)
|
||||
return;
|
||||
const Handle(V3d_Viewer) aViewer = aViewModel->GetContext()->CurrentViewer();
|
||||
if (aViewer.IsNull())
|
||||
return;
|
||||
|
||||
QAction* anAction = (QAction*)sender();
|
||||
QString aText = anAction->text();
|
||||
|
||||
Graphic3d_TypeOfLightSource aLightSourceType = Graphic3d_TOLS_AMBIENT;
|
||||
|
||||
if (aText == "Ambient") { aLightSourceType = Graphic3d_TOLS_AMBIENT; }
|
||||
else if (aText == "Directional") { aLightSourceType = Graphic3d_TOLS_DIRECTIONAL; }
|
||||
else if (aText == "Positional") { aLightSourceType = Graphic3d_TOLS_POSITIONAL; }
|
||||
else if (aText == "Spot") { aLightSourceType = Graphic3d_TOLS_SPOT; }
|
||||
else { return; }
|
||||
|
||||
addLight(aLightSourceType, aViewer);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onRemoveLight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_Window::onRemoveLight()
|
||||
{
|
||||
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
|
||||
const Handle(V3d_Viewer) aViewer = aViewModel ? aViewModel->GetContext()->CurrentViewer() : NULL;
|
||||
if (aViewer.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
|
||||
VInspector_ItemGraphic3dCLightPtr aLightItem = itemDynamicCast<VInspector_ItemGraphic3dCLight> (
|
||||
TreeModel_ModelBase::GetItemByIndex (anIndex));
|
||||
if (!aLightItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (aViewer->ActiveLights().Extent() == 1) // not possible to remove the latest light
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_CLight) aLight = aLightItem->GetLight();
|
||||
aViewer->DelLight (aLight);
|
||||
aViewer->UpdateLights();
|
||||
|
||||
aViewer->Invalidate();
|
||||
aViewer->Redraw();
|
||||
UpdateTreeModel();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onOnOffLight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_Window::onOnOffLight()
|
||||
{
|
||||
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
|
||||
const Handle(V3d_Viewer) aViewer = aViewModel ? aViewModel->GetContext()->CurrentViewer() : NULL;
|
||||
if (aViewer.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
|
||||
|
||||
VInspector_ItemGraphic3dCLightPtr anItemLight = itemDynamicCast<VInspector_ItemGraphic3dCLight> (
|
||||
TreeModel_ModelBase::GetItemByIndex (anIndex));
|
||||
if (anItemLight->GetLight().IsNull())
|
||||
return;
|
||||
|
||||
bool isOn = anItemLight->GetLight()->IsEnabled();
|
||||
anItemLight->GetLight()->SetEnabled (!isOn);
|
||||
|
||||
aViewer->UpdateLights();
|
||||
aViewer->Invalidate();
|
||||
aViewer->Redraw();
|
||||
UpdateTreeModel();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onDisplayActionTypeClicked
|
||||
// purpose :
|
||||
@@ -760,23 +769,6 @@ void VInspector_Window::onCollapseAll()
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UpdateTreeModel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_Window::OnTestAddChild()
|
||||
{
|
||||
Handle(AIS_Shape) aPresentation = new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt()));
|
||||
|
||||
aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt (10., 10., 10.))));
|
||||
aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(20., 10., 10.))));
|
||||
aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(30., 10., 10.))));
|
||||
|
||||
displayer()->DisplayPresentation (aPresentation);
|
||||
|
||||
UpdateTreeModel();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UpdateTreeModel
|
||||
// purpose :
|
||||
@@ -912,3 +904,32 @@ View_Displayer* VInspector_Window::displayer()
|
||||
|
||||
return myDisplayer;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : addLight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void VInspector_Window::addLight (const Graphic3d_TypeOfLightSource& theSourceLight,
|
||||
const Handle(V3d_Viewer)& theViewer)
|
||||
{
|
||||
Standard_Boolean aNeedDirection = theSourceLight == Graphic3d_TOLS_DIRECTIONAL ||
|
||||
theSourceLight == Graphic3d_TOLS_SPOT;
|
||||
|
||||
Handle(Graphic3d_CLight) aLight = new Graphic3d_CLight (theSourceLight);
|
||||
if (aNeedDirection)
|
||||
{
|
||||
aLight->SetDirection (gp::DZ());
|
||||
}
|
||||
if (theSourceLight == Graphic3d_TOLS_SPOT)
|
||||
{
|
||||
aLight->SetAngle ((Standard_ShortReal)M_PI - ShortRealEpsilon());
|
||||
aLight->SetPosition (gp_Pnt (-100, -100, -100));
|
||||
}
|
||||
|
||||
theViewer->AddLight (aLight);
|
||||
theViewer->SetLightOn (aLight);
|
||||
|
||||
theViewer->Invalidate();
|
||||
theViewer->Redraw();
|
||||
UpdateTreeModel();
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
|
||||
#include <inspector/TInspectorAPI_PluginParameters.hxx>
|
||||
#include <inspector/VInspector_CallBack.hxx>
|
||||
#include <inspector/View_DisplayActionType.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
@@ -119,12 +118,6 @@ private slots:
|
||||
//! \param isToggled true if the property dock widget is shown
|
||||
void onPropertyPanelShown (bool isToggled);
|
||||
|
||||
//! Synchronization selection between history and tree view. Selection by history view
|
||||
//! \param theSelected a selected items
|
||||
//! \param theDeselected a deselected items
|
||||
void onHistoryViewSelectionChanged (const QItemSelection& theSelected,
|
||||
const QItemSelection& theDeselected);
|
||||
|
||||
//! Processes selection in tree view: make presentation or owner selected in the context if corresponding
|
||||
//! check box is checked
|
||||
//! \param theSelected a selected items
|
||||
@@ -134,6 +127,15 @@ private slots:
|
||||
//! Exports the first selected shape into ShapeViewer plugin.
|
||||
void onExportToShapeView();
|
||||
|
||||
//! Appends lights into the active V3d view
|
||||
void onAddLight();
|
||||
|
||||
//! Removes selected light from the active V3d view
|
||||
void onRemoveLight();
|
||||
|
||||
//! Switch On/Off for selected light
|
||||
void onOnOffLight();
|
||||
|
||||
//! Apply activated display action
|
||||
void onDisplayActionTypeClicked();
|
||||
|
||||
@@ -146,9 +148,6 @@ private slots:
|
||||
//! Collapse all levels for all selected items
|
||||
void onCollapseAll();
|
||||
|
||||
//! Creates a tree of inherited presentable objects
|
||||
void OnTestAddChild();
|
||||
|
||||
private:
|
||||
|
||||
//! Inits the window content by the given context
|
||||
@@ -179,6 +178,11 @@ private:
|
||||
//! \return a context of created view.
|
||||
Handle(AIS_InteractiveContext) createView();
|
||||
|
||||
//! Creates a new default light into V3d viewer
|
||||
//! \param theSourceLight type of light source
|
||||
//! \param theViewer viewer to add the created light
|
||||
void addLight (const Graphic3d_TypeOfLightSource& theSourceLight, const Handle(V3d_Viewer)& theViewer);
|
||||
|
||||
private:
|
||||
|
||||
QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
|
||||
@@ -190,8 +194,6 @@ private:
|
||||
ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
|
||||
|
||||
QTreeView* myTreeView; //!< tree view of AIS content
|
||||
QTreeView* myHistoryView; //!< history of AIS context calls
|
||||
Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
|
||||
|
||||
ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
|
||||
View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
|
||||
|
Reference in New Issue
Block a user