-TModelingData TKShapeView TKMessageModel TKMessageView
+TModelingData TKShapeView
TVisualization TKView TKVInspector
TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
TTool TKTInspector TKToolsDraw TInspectorEXE
\ No newline at end of file
const Standard_Real SquareTolerance = Precision::SquareConfusion();
-namespace
-{
- static Standard_CString AIS_Table_PrintDisplayMode[2] =
- {
- "WIREFRAME", "SHADING"
- };
-
- static Standard_CString AIS_Table_PrintDisplayStatus[3] =
- {
- "DISPLAYED", "ERASED", "NONE"
- };
-
- static Standard_CString AIS_Table_PrintKindOfInteractive[6] =
- {
- "NONE", "DATUM", "SHAPE", "OBJECT", "RELATION", "DIMENSION"
- };
-}
-
//=======================================================================
//function : Nearest
//purpose :
StdPrs_WFShape::Add (aPresentation, MakEd.Edge(), aDrawer);
}
}
-
-//=======================================================================
-//function : DisplayModeToString
-//purpose :
-//=======================================================================
-Standard_CString AIS::DisplayModeToString (AIS_DisplayMode theType)
-{
- return AIS_Table_PrintDisplayMode[theType];
-}
-
-//=======================================================================
-//function : DisplayModeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean AIS::DisplayModeFromString (Standard_CString theTypeString,
- AIS_DisplayMode& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= AIS_Shaded; ++aTypeIter)
- {
- Standard_CString aTypeName = AIS_Table_PrintDisplayMode[aTypeIter];
- if (aName == aTypeName)
- {
- theType = AIS_DisplayMode (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DisplayStatusToString
-//purpose :
-//=======================================================================
-Standard_CString AIS::DisplayStatusToString (AIS_DisplayStatus theType)
-{
- return AIS_Table_PrintDisplayStatus[theType];
-}
-
-//=======================================================================
-//function : DisplayStatusFromString
-//purpose :
-//=======================================================================
-Standard_Boolean AIS::DisplayStatusFromString (Standard_CString theTypeString,
- AIS_DisplayStatus& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= AIS_DS_None; ++aTypeIter)
- {
- Standard_CString aTypeName = AIS_Table_PrintDisplayStatus[aTypeIter];
- if (aName == aTypeName)
- {
- theType = AIS_DisplayStatus (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : KindOfInteractiveToString
-//purpose :
-//=======================================================================
-Standard_CString AIS::KindOfInteractiveToString (AIS_KindOfInteractive theType)
-{
- return AIS_Table_PrintKindOfInteractive[theType];
-}
-
-//=======================================================================
-//function : KindOfInteractiveFromString
-//purpose :
-//=======================================================================
-Standard_Boolean AIS::KindOfInteractiveFromString (Standard_CString theTypeString,
- AIS_KindOfInteractive& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= AIS_KOI_Dimension; ++aTypeIter)
- {
- Standard_CString aTypeName = AIS_Table_PrintKindOfInteractive[aTypeIter];
- if (aName == aTypeName)
- {
- theType = AIS_KindOfInteractive (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
#ifndef _AIS_HeaderFile
#define _AIS_HeaderFile
-#include <AIS_DisplayStatus.hxx>
-#include <AIS_DisplayMode.hxx>
-#include <AIS_KindOfInteractive.hxx>
#include <AIS_KindOfSurface.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_TypeOfMarker.hxx>
Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
- //! Returns the string name for a given enum type.
- //! @param theType display mode
- //! @return string identifier
- Standard_EXPORT static Standard_CString DisplayModeToString (AIS_DisplayMode theType);
-
- //! Returns the display mode from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return status type or AIS_WireFrame if string identifier is invalid
- static AIS_DisplayMode DisplayModeFromString (Standard_CString theTypeString)
- {
- AIS_DisplayMode aType = AIS_WireFrame;
- DisplayModeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the display mode from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected display status
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DisplayModeFromString (const Standard_CString theTypeString,
- AIS_DisplayMode& theType);
-
- //! Returns the string name for a given enum type.
- //! @param theType display status
- //! @return string identifier
- Standard_EXPORT static Standard_CString DisplayStatusToString (AIS_DisplayStatus theType);
-
- //! Returns the display status from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return status type or AIS_DS_None if string identifier is invalid
- static AIS_DisplayStatus DisplayStatusFromString (Standard_CString theTypeString)
- {
- AIS_DisplayStatus aType = AIS_DS_None;
- DisplayStatusFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected display status
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DisplayStatusFromString (const Standard_CString theTypeString,
- AIS_DisplayStatus& theType);
-
- //! Returns the string name for a given enum type.
- //! @param theType display status
- //! @return string identifier
- Standard_EXPORT static Standard_CString KindOfInteractiveToString (AIS_KindOfInteractive theType);
-
- //! Returns the display status from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return status type or AIS_KOI_None if string identifier is invalid
- static AIS_KindOfInteractive KindOfInteractiveFromString (Standard_CString theTypeString)
- {
- AIS_KindOfInteractive aType = AIS_KOI_None;
- KindOfInteractiveFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected display status
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean KindOfInteractiveFromString (const Standard_CString theTypeString,
- AIS_KindOfInteractive& theType);
-
};
#endif // _AIS_HeaderFile
aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect());
}
}
-
-const TCollection_AsciiString AIS_InteractiveObject_ClassName = "AIS_InteractiveObject";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void AIS_InteractiveObject::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, AIS_InteractiveObject_ClassName);
-
- {
- Standard_SStream aTmpStream;
- SelectMgr_SelectableObject::Dump (aTmpStream);
- DUMP_VALUES (OS, "SelectMgr_SelectableObject", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "InteractiveContext", TCollection::GetPointerInfo (myCTXPtr));
- DUMP_VALUES (OS, "Owner", TCollection::GetPointerInfo (myOwner));
-
- DUMP_STOP_KEY (OS, AIS_InteractiveObject_ClassName);
-
-}
Standard_DEPRECATED("Deprecated method, results might be undefined")
Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
//! The TypeOfPresention3d means that the interactive object
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Aspect.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString Aspect_Table_PrintTypeOfDeflection[2] =
- {
- "RELATIVE", "ABSOLUTE"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfFacingModel[3] =
- {
- "BOTH", "BACK", "FRONT"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfHighlightMethod[2] =
- {
- "COLOR", "BOUNDBOX"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfLine[6] =
- {
- "EMPTY", "SOLID", "DASH", "DOT", "DOT_DASH", "USER_DEFINED"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfMarker[15] =
- {
- "EMPTY", "POINT", "PLUS", "STAR", "X", "O", "O_POINT", "O_PLUS", "O_STAR", "O_X",
- "RING1", "RING2", "RING3", "BALL", "USER_DEFINED"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfDisplayText[6] =
- {
- "NORMAL", "SUBTITLE", "DEKALE", "BLEND", "DIMENSION", "SHADOW"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfStyleText[2] =
- {
- "NORMAL", "ANNOTATION"
- };
-
- static Standard_CString Aspect_Table_PrintInteriorStyle[6] =
- {
- "EMPTY", "HOLLOW", "HATCH", "SOLID", "HIDDEN_LINE", "POINT"
- };
-
- static Standard_CString Aspect_Table_PrintPolygonOffsetMode[7] =
- {
- "OFF", "FILL", "LINE", "POINT", "ALL", "NONE", "MASK"
- };
-
- static Standard_CString Aspect_Table_PrintHatchStyle[14] =
- {
- "SOLID", "HORIZONTAL", "HORIZONTAL_WIDE", "VERTICAL", "VERTICAL_WIDE",
- "DIAGONAL_45", "DIAGONAL_45_WIDE", "DIAGONAL_135", "DIAGONAL_135_WIDE",
- "GRID", "GRID_WIDE", "GRID_DIAGONAL", "GRID_DIAGONAL_WIDE", "NB"
- };
-
- static Standard_CString Aspect_Table_PrintTypeOfTriedronPosition[9] =
- {
- "CENTER", "TOP", "BOTTOM", "LEFT", "RIGHT", "LEFT_LOWER", "LEFT_UPPER", "RIGHT_LOWER", "RIGHT_UPPER"
- };
-}
-
-//=======================================================================
-//function : TypeOfDeflectionToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfDeflectionToString (Aspect_TypeOfDeflection theType)
-{
- return Aspect_Table_PrintTypeOfDeflection[theType];
-}
-
-//=======================================================================
-//function : TypeOfDeflectionFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfDeflectionFromString (Standard_CString theTypeString,
- Aspect_TypeOfDeflection& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Aspect_TOD_ABSOLUTE; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfDeflection[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfDeflection (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfFacingModelToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfFacingModelToString (Aspect_TypeOfFacingModel theType)
-{
- return Aspect_Table_PrintTypeOfFacingModel[theType];
-}
-
-//=======================================================================
-//function : TypeOfFacingModelFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfFacingModelFromString (Standard_CString theTypeString,
- Aspect_TypeOfFacingModel& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Aspect_TOFM_FRONT_SIDE; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfFacingModel[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfFacingModel (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfHighlightMethodToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfHighlightMethodToString (Aspect_TypeOfHighlightMethod theType)
-{
- return Aspect_Table_PrintTypeOfHighlightMethod[theType];
-}
-
-//=======================================================================
-//function : TypeOfHighlightMethodFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfHighlightMethodFromString (Standard_CString theTypeString,
- Aspect_TypeOfHighlightMethod& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Aspect_TOHM_BOUNDBOX; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfHighlightMethod[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfHighlightMethod (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfLineToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfLineToString (Aspect_TypeOfLine theType)
-{
- return Aspect_Table_PrintTypeOfLine[theType];
-}
-
-//=======================================================================
-//function : TypeOfLineFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfLineFromString (Standard_CString theTypeString,
- Aspect_TypeOfLine& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Aspect_TOL_EMPTY; aTypeIter <= Aspect_TOL_USERDEFINED; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfLine[aTypeIter + 1];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfLine (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfMarkerToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfMarkerToString (Aspect_TypeOfMarker theType)
-{
- return Aspect_Table_PrintTypeOfMarker[theType];
-}
-
-//=======================================================================
-//function : TypeOfMarkerFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfMarkerFromString (Standard_CString theTypeString,
- Aspect_TypeOfMarker& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Aspect_TOM_EMPTY; aTypeIter <= Aspect_TOM_USERDEFINED; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfMarker[aTypeIter + 1];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfMarker (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfDisplayTextToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfDisplayTextToString (Aspect_TypeOfDisplayText theType)
-{
- return Aspect_Table_PrintTypeOfDisplayText[theType];
-}
-
-//=======================================================================
-//function : TypeOfDisplayTextFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfDisplayTextFromString (Standard_CString theTypeString,
- Aspect_TypeOfDisplayText& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Aspect_TODT_NORMAL; aTypeIter <= Aspect_TODT_SHADOW; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfDisplayText[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfDisplayText (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfStyleTextToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfStyleTextToString (Aspect_TypeOfStyleText theType)
-{
- return Aspect_Table_PrintTypeOfStyleText[theType];
-}
-
-//=======================================================================
-//function : TypeOfStyleTextFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfStyleTextFromString (Standard_CString theTypeString,
- Aspect_TypeOfStyleText& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Aspect_TOST_NORMAL; aTypeIter <= Aspect_TOST_ANNOTATION; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintTypeOfStyleText[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Aspect_TypeOfStyleText (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : InteriorStyleToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::InteriorStyleToString (Aspect_InteriorStyle theType)
-{
- return Aspect_Table_PrintInteriorStyle[theType];
-}
-
-//=======================================================================
-//function : InteriorStyleFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::InteriorStyleFromString (Standard_CString theTypeString,
- Aspect_InteriorStyle& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Aspect_IS_EMPTY; aTypeIter <= Aspect_IS_POINT; ++aTypeIter)
- {
- Standard_CString aTypeName = Aspect_Table_PrintInteriorStyle[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Aspect_InteriorStyle (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : PolygonOffsetModeToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::PolygonOffsetModeToString (Aspect_PolygonOffsetMode theType)
-{
- switch (theType)
- {
- case Aspect_POM_Off: return Aspect_Table_PrintPolygonOffsetMode[0];
- case Aspect_POM_Fill: return Aspect_Table_PrintPolygonOffsetMode[1];
- case Aspect_POM_Line: return Aspect_Table_PrintPolygonOffsetMode[2];
- case Aspect_POM_Point: return Aspect_Table_PrintPolygonOffsetMode[3];
- case Aspect_POM_All: return Aspect_Table_PrintPolygonOffsetMode[4];
- case Aspect_POM_None: return Aspect_Table_PrintPolygonOffsetMode[5];
- case Aspect_POM_Mask: return Aspect_Table_PrintPolygonOffsetMode[6];
- }
- return "";
-}
-
-//=======================================================================
-//function : PolygonOffsetModeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::PolygonOffsetModeFromString (Standard_CString theTypeString,
- Aspect_PolygonOffsetMode& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- if (aName == Aspect_Table_PrintPolygonOffsetMode[0]) { theType = Aspect_POM_Off; return Standard_True; }
- else if (aName == Aspect_Table_PrintPolygonOffsetMode[1]) { theType = Aspect_POM_Fill; return Standard_True; }
- else if (aName == Aspect_Table_PrintPolygonOffsetMode[2]) { theType = Aspect_POM_Line; return Standard_True; }
- else if (aName == Aspect_Table_PrintPolygonOffsetMode[3]) { theType = Aspect_POM_Point; return Standard_True; }
- else if (aName == Aspect_Table_PrintPolygonOffsetMode[4]) { theType = Aspect_POM_All; return Standard_True; }
- else if (aName == Aspect_Table_PrintPolygonOffsetMode[5]) { theType = Aspect_POM_None; return Standard_True; }
- else if (aName == Aspect_Table_PrintPolygonOffsetMode[6]) { theType = Aspect_POM_Mask; return Standard_True; }
-
- return Standard_False;
-}
-
-//=======================================================================
-//function : HatchStyleToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::HatchStyleToString (Aspect_HatchStyle theType)
-{
- return Aspect_Table_PrintHatchStyle[theType];
- switch (theType)
- {
- case Aspect_HS_SOLID: return Aspect_Table_PrintHatchStyle[0];
- case Aspect_HS_HORIZONTAL: return Aspect_Table_PrintHatchStyle[1];
- case Aspect_HS_HORIZONTAL_WIDE: return Aspect_Table_PrintHatchStyle[2];
- case Aspect_HS_VERTICAL: return Aspect_Table_PrintHatchStyle[3];
- case Aspect_HS_VERTICAL_WIDE: return Aspect_Table_PrintHatchStyle[4];
- case Aspect_HS_DIAGONAL_45: return Aspect_Table_PrintHatchStyle[5];
- case Aspect_HS_DIAGONAL_45_WIDE: return Aspect_Table_PrintHatchStyle[6];
- case Aspect_HS_DIAGONAL_135: return Aspect_Table_PrintHatchStyle[7];
- case Aspect_HS_DIAGONAL_135_WIDE: return Aspect_Table_PrintHatchStyle[8];
- case Aspect_HS_GRID: return Aspect_Table_PrintHatchStyle[9];
- case Aspect_HS_GRID_WIDE: return Aspect_Table_PrintHatchStyle[10];
- case Aspect_HS_GRID_DIAGONAL: return Aspect_Table_PrintHatchStyle[11];
- case Aspect_HS_GRID_DIAGONAL_WIDE: return Aspect_Table_PrintHatchStyle[12];
- case Aspect_HS_NB: return Aspect_Table_PrintHatchStyle[13];
- }
- return "";
-}
-
-//=======================================================================
-//function : HatchStyleFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::HatchStyleFromString (Standard_CString theTypeString,
- Aspect_HatchStyle& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- if (aName == Aspect_Table_PrintHatchStyle[0]) { theType = Aspect_HS_SOLID; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[1]) { theType = Aspect_HS_HORIZONTAL; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[2]) { theType = Aspect_HS_HORIZONTAL_WIDE; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[3]) { theType = Aspect_HS_VERTICAL; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[4]) { theType = Aspect_HS_VERTICAL_WIDE; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[5]) { theType = Aspect_HS_DIAGONAL_45; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[6]) { theType = Aspect_HS_DIAGONAL_45_WIDE; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[7]) { theType = Aspect_HS_DIAGONAL_135; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[8]) { theType = Aspect_HS_DIAGONAL_135_WIDE; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[9]) { theType = Aspect_HS_GRID; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[10]) { theType = Aspect_HS_GRID_WIDE; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[11]) { theType = Aspect_HS_GRID_DIAGONAL; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[12]) { theType = Aspect_HS_GRID_DIAGONAL_WIDE; return Standard_True; }
- else if (aName == Aspect_Table_PrintHatchStyle[13]) { theType = Aspect_HS_NB; return Standard_True; }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfTriedronPositionToString
-//purpose :
-//=======================================================================
-Standard_CString Aspect::TypeOfTriedronPositionToString (Aspect_TypeOfTriedronPosition theType)
-{
- return Aspect_Table_PrintTypeOfTriedronPosition[theType];
- switch (theType)
- {
- case Aspect_TOTP_CENTER: return Aspect_Table_PrintTypeOfTriedronPosition[0];
- case Aspect_TOTP_TOP: return Aspect_Table_PrintTypeOfTriedronPosition[1];
- case Aspect_TOTP_BOTTOM: return Aspect_Table_PrintTypeOfTriedronPosition[2];
- case Aspect_TOTP_LEFT: return Aspect_Table_PrintTypeOfTriedronPosition[3];
- case Aspect_TOTP_RIGHT: return Aspect_Table_PrintTypeOfTriedronPosition[4];
- case Aspect_TOTP_LEFT_LOWER: return Aspect_Table_PrintTypeOfTriedronPosition[5];
- case Aspect_TOTP_LEFT_UPPER: return Aspect_Table_PrintTypeOfTriedronPosition[6];
- case Aspect_TOTP_RIGHT_LOWER: return Aspect_Table_PrintTypeOfTriedronPosition[7];
- case Aspect_TOTP_RIGHT_UPPER: return Aspect_Table_PrintTypeOfTriedronPosition[8];
- }
- return "";
-}
-
-//=======================================================================
-//function : TypeOfTriedronPositionFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Aspect::TypeOfTriedronPositionFromString (Standard_CString theTypeString,
- Aspect_TypeOfTriedronPosition& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- if (aName == Aspect_Table_PrintTypeOfTriedronPosition[0]) { theType = Aspect_TOTP_CENTER; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[1]) { theType = Aspect_TOTP_TOP; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[2]) { theType = Aspect_TOTP_BOTTOM; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[3]) { theType = Aspect_TOTP_LEFT; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[4]) { theType = Aspect_TOTP_RIGHT; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[5]) { theType = Aspect_TOTP_LEFT_LOWER; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[6]) { theType = Aspect_TOTP_LEFT_UPPER; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[7]) { theType = Aspect_TOTP_RIGHT_LOWER; return Standard_True; }
- else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[8]) { theType = Aspect_TOTP_RIGHT_UPPER; return Standard_True; }
- return Standard_False;
-}
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Aspect_HeaderFile
-#define _Aspect_HeaderFile
-
-#include <Aspect_HatchStyle.hxx>
-#include <Aspect_InteriorStyle.hxx>
-#include <Aspect_PolygonOffsetMode.hxx>
-#include <Aspect_TypeOfDeflection.hxx>
-#include <Aspect_TypeOfDisplayText.hxx>
-#include <Aspect_TypeOfFacingModel.hxx>
-#include <Aspect_TypeOfHighlightMethod.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <Aspect_TypeOfStyleText.hxx>
-#include <Aspect_TypeOfTriedronPosition.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-
-//! Provides methods to cast enumerations of package to string value
-class Aspect
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfDeflectionToString (Aspect_TypeOfDeflection theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOFM_BOTH_SIDE if string identifier is invalid
- static Aspect_TypeOfDeflection TypeOfDeflectionFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfDeflection aType = Aspect_TOD_RELATIVE;
- TypeOfDeflectionFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfDeflectionFromString (const Standard_CString theTypeString,
- Aspect_TypeOfDeflection& theType);
-
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfFacingModelToString (Aspect_TypeOfFacingModel theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOFM_BOTH_SIDE if string identifier is invalid
- static Aspect_TypeOfFacingModel TypeOfFacingModelFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfFacingModel aType = Aspect_TOFM_BOTH_SIDE;
- TypeOfFacingModelFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfFacingModelFromString (const Standard_CString theTypeString,
- Aspect_TypeOfFacingModel& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfHighlightMethodToString (Aspect_TypeOfHighlightMethod theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOHM_COLOR if string identifier is invalid
- static Aspect_TypeOfHighlightMethod TypeOfHighlightMethodFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfHighlightMethod aType = Aspect_TOHM_COLOR;
- TypeOfHighlightMethodFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfHighlightMethodFromString (const Standard_CString theTypeString,
- Aspect_TypeOfHighlightMethod& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfLineToString (Aspect_TypeOfLine theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOL_EMPTY if string identifier is invalid
- static Aspect_TypeOfLine TypeOfLineFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfLine aType = Aspect_TOL_EMPTY;
- TypeOfLineFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfLineFromString (const Standard_CString theTypeString,
- Aspect_TypeOfLine& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfMarkerToString (Aspect_TypeOfMarker theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOM_EMPTY if string identifier is invalid
- static Aspect_TypeOfMarker TypeOfMarkerFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfMarker aType = Aspect_TOM_EMPTY;
- TypeOfMarkerFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfMarkerFromString (const Standard_CString theTypeString,
- Aspect_TypeOfMarker& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfDisplayTextToString (Aspect_TypeOfDisplayText theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TODT_NORMAL if string identifier is invalid
- static Aspect_TypeOfDisplayText TypeOfDisplayTextFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfDisplayText aType = Aspect_TODT_NORMAL;
- TypeOfDisplayTextFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfDisplayTextFromString (const Standard_CString theTypeString,
- Aspect_TypeOfDisplayText& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfStyleTextToString (Aspect_TypeOfStyleText theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TODT_NORMAL if string identifier is invalid
- static Aspect_TypeOfStyleText TypeOfStyleTextFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfStyleText aType = Aspect_TOST_NORMAL;
- TypeOfStyleTextFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfStyleTextFromString (const Standard_CString theTypeString,
- Aspect_TypeOfStyleText& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString InteriorStyleToString (Aspect_InteriorStyle theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_IS_EMPTY if string identifier is invalid
- static Aspect_InteriorStyle InteriorStyleFromString (Standard_CString theTypeString)
- {
- Aspect_InteriorStyle aType = Aspect_IS_EMPTY;
- InteriorStyleFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean InteriorStyleFromString (const Standard_CString theTypeString,
- Aspect_InteriorStyle& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString PolygonOffsetModeToString (Aspect_PolygonOffsetMode theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_POM_Off if string identifier is invalid
- static Aspect_PolygonOffsetMode PolygonOffsetModeFromString (Standard_CString theTypeString)
- {
- Aspect_PolygonOffsetMode aType = Aspect_POM_Off;
- PolygonOffsetModeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean PolygonOffsetModeFromString (const Standard_CString theTypeString,
- Aspect_PolygonOffsetMode& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString HatchStyleToString (Aspect_HatchStyle theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_POM_Off if string identifier is invalid
- static Aspect_HatchStyle HatchStyleFromString (Standard_CString theTypeString)
- {
- Aspect_HatchStyle aType = Aspect_HS_SOLID;
- HatchStyleFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean HatchStyleFromString (const Standard_CString theTypeString,
- Aspect_HatchStyle& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfTriedronPositionToString (Aspect_TypeOfTriedronPosition theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOTP_CENTER if string identifier is invalid
- static Aspect_TypeOfTriedronPosition TypeOfTriedronPositionFromString (Standard_CString theTypeString)
- {
- Aspect_TypeOfTriedronPosition aType = Aspect_TOTP_CENTER;
- TypeOfTriedronPositionFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfTriedronPositionFromString (const Standard_CString theTypeString,
- Aspect_TypeOfTriedronPosition& theType);
-
-};
-
-#endif // _Aspect_HeaderFile
-Aspect.cxx
-Aspect.hxx
Aspect_AspectFillAreaDefinitionError.hxx
Aspect_AspectLineDefinitionError.hxx
Aspect_AspectMarkerDefinitionError.hxx
#include <BVH_Constants.hxx>
#include <BVH_Types.hxx>
-#include <Message_Alerts.hxx>
#include <Standard_ShortReal.hxx>
-#include <TCollection.hxx>
#include <limits>
//! Returns center of bounding box along the given axis.
T Center (const Standard_Integer theAxis) const;
- //! Dumps the content of me on the stream <OS>.
- void Dump (Standard_OStream& OS) const
- {
- DUMP_VALUES (OS, "BVH_Box", 2);
- DUMP_VALUES (OS, "IsValid", IsValid());
-
- OS << "Bnd_Box" << TCollection::DumpSeparator();
- BVH::ToBndBox (CornerMin(), CornerMax()).Dump (OS);
- OS << TCollection::DumpSeparator();
- }
-
public:
//! Checks if the Box is out of the other box.
#include <BVH_Box.hxx>
-#include <Message_Alerts.hxx>
-
-#include <Standard_Macro.hxx>
-#include <Standard_OStream.hxx>
-
template<class T, int N> class BVH_Builder;
//! A non-template class for using as base for BVH_TreeBase
DEFINE_STANDARD_RTTIEXT(BVH_TreeBaseTransient, Standard_Transient)
protected:
BVH_TreeBaseTransient() {}
-
- //! Dumps the content of me on the stream <OS>.
- virtual void Dump (Standard_OStream& OS) const { (void)OS; }
-
- //! Dumps the content of the given node on the stream <OS>.
- virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const
- { (void)theNodeIndex; (void)OS; }
};
//! Stores parameters of bounding volume hierarchy (BVH).
return myMaxPointBuffer;
}
-
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE
- {
- DUMP_VALUES (OS, "BVH_Tree", 2);
-
- DUMP_VALUES (OS, "Depth", Depth());
- DUMP_VALUES (OS, "Length", Length());
-
- for (Standard_Integer aNodeIdx = 0; aNodeIdx < Length(); ++aNodeIdx)
- {
- DumpNode (aNodeIdx, OS);
- }
- }
-
- //! Dumps the content of the given node on the stream <OS>.
- Standard_EXPORT virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const Standard_OVERRIDE
- {
- DUMP_VALUES (OS, "BVH_TreeNode", 2);
- DUMP_VALUES (OS, "NodeIndex", theNodeIndex);
-
- OS << "Bnd_Box" << TCollection::DumpSeparator();
- BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)).Dump (OS);
- OS << TCollection::DumpSeparator();
-
- DUMP_VALUES (OS, "BegPrimitive", BegPrimitive (theNodeIndex));
- DUMP_VALUES (OS, "EndPrimitive", EndPrimitive (theNodeIndex));
- DUMP_VALUES (OS, "Level", Level (theNodeIndex));
- DUMP_VALUES (OS, "IsOuter", IsOuter (theNodeIndex));
- }
-
public: //! @name protected fields
//! Array of node data records.
#include <vector>
-#include <Bnd_Box.hxx>
#include <NCollection_Mat4.hxx>
#include <NCollection_Vec2.hxx>
#include <NCollection_Vec3.hxx>
#include <NCollection_Vector.hxx>
-#include <Standard_OStream.hxx>
#include <Standard_Type.hxx>
// GCC supports shrink function only in C++11 mode
typedef NCollection_Vec3<T> Type;
};
- template<class T> Bnd_Box ToBndBox (const T& theType1, const T& theType2)
- {
- return Bnd_Box (theType1, 0., 0., theType2, 0., 0.);
- }
-
- template<class T> Bnd_Box ToBndBox (const NCollection_Vec2<T>& theType1,
- const NCollection_Vec2<T>& theType2)
- {
- return Bnd_Box (theType1.x(), theType1.y(), 0.,
- theType2.x(), theType2.y(), 0.);
- }
-
- template<class T> Bnd_Box ToBndBox (const NCollection_Vec3<T>& theType1,
- const NCollection_Vec3<T>& theType2)
- {
- return Bnd_Box (theType1.x(), theType1.y(), theType1.z(),
- theType2.x(), theType2.y(), theType2.z());
- }
-
- template<class T> Bnd_Box ToBndBox (const NCollection_Vec4<T>& theType1,
- const NCollection_Vec4<T>& theType2)
- {
- return Bnd_Box (theType1.x(), theType1.y(), theType1.z(),
- theType2.x(), theType2.y(), theType2.z());
- }
-
template<class T> struct VectorType<T, 4>
{
typedef NCollection_Vec4<T> Type;
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
-#include <NCollection_List.hxx>
#include <Standard_ConstructionError.hxx>
-#include <TCollection.hxx>
-#include <TCollection_AsciiString.hxx>
// set the flag to one
#define ClearVoidFlag() ( Flags &= ~VoidMask )
SetVoid();
}
-//=======================================================================
-//function : Bnd_Box
-//purpose :
-//=======================================================================
-
-Bnd_Box::Bnd_Box (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
- const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
-: Gap (0.0)
-{
- SetVoid();
- Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
-}
-
//=======================================================================
//function : Set
//purpose :
std::cout << "\n Gap : " << Gap;
std::cout << "\n";
}
-
-//=======================================================================
-//function : PointsSeparator
-//purpose :
-//=======================================================================
-TCollection_AsciiString PointsSeparator()
-{
- return " - ";
-}
-
-
-const TCollection_AsciiString Bnd_Box_ClassName = "Bnd_Box";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void Bnd_Box::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Bnd_Box_ClassName);
-
- DUMP_VALUES (OS, "Xmin", Xmin);
- DUMP_VALUES (OS, "Ymin", Ymin);
- DUMP_VALUES (OS, "Zmin", Zmin);
- DUMP_VALUES (OS, "Xmax", Xmax);
- DUMP_VALUES (OS, "Ymax", Ymax);
- DUMP_VALUES (OS, "Zmax", Zmax);
- DUMP_VALUES (OS, "Gap", Gap);
- DUMP_VALUES (OS, "Flags", Flags);
-
- DUMP_STOP_KEY (OS, Bnd_Box_ClassName);
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-Standard_Boolean Bnd_Box::Init (const Standard_SStream& OS)
-{
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aStreamValues;
- TCollection_AsciiString aKey;
- TCollection::Split (OS, aStreamValues, aKey);
-
- TCollection_AsciiString aXmin, anYmin, aZmin, aXmax, anYmax, aZmax, aGap, aFlags;
- if (!aStreamValues.FindFromKey ("Xmin", aXmin) ||
- !aStreamValues.FindFromKey ("Ymin", anYmin) ||
- !aStreamValues.FindFromKey ("Zmin", aZmin) ||
- !aStreamValues.FindFromKey ("Xmax", aXmax) ||
- !aStreamValues.FindFromKey ("Ymax", anYmax) ||
- !aStreamValues.FindFromKey ("Zmax", aZmax) ||
- !aStreamValues.FindFromKey ("Gap", aGap) ||
- !aStreamValues.FindFromKey ("Flags", aFlags))
- return Standard_False;
-
- Xmin = aXmin.RealValue();
- Ymin = anYmin.RealValue();
- Zmin = aZmin.RealValue();
- Xmax = aXmax.RealValue();
- Ymax = anYmax.RealValue();
- Zmax = aZmax.RealValue();
-
- Gap = aGap.RealValue();
- Flags = aFlags.IntegerValue();
-
- return Standard_True;
-}
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <gp_XYZ.hxx>
-
class Standard_ConstructionError;
class gp_Pnt;
class gp_Dir;
//! The constructed box is qualified Void. Its gap is null.
Standard_EXPORT Bnd_Box();
- //! Creates a bounding box, it contains:
- //! - interval [ aXmin,aXmax ] in the "X Direction",
- //! - interval [ aYmin,aYmax ] in the "Y Direction",
- //! - interval [ aZmin,aZmax ] in the "Z Direction";
- //! The constructed box is qualified Void. Its gap is null.
- Standard_EXPORT Bnd_Box (const Standard_Real aXmin, const Standard_Real aYmin, const Standard_Real aZmin,
- const Standard_Real aXmax, const Standard_Real aYmax, const Standard_Real aZmax);
-
//! Sets this bounding box so that it covers the whole of 3D space.
//! It is infinitely long in all directions.
void SetWhole() { Flags = WholeMask; }
&& Xmax >= Xmin;
}
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT Standard_Boolean Init (const Standard_SStream& OS);
-
- //! Covers bounding box into string in format: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
- //! \return the string value
- Standard_EXPORT TCollection_AsciiString ToString() const { return ""; }
-
- //! Converts text value into parameters if possible, the string format is: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
- //! \return true if conversion is done
- Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue) { (void)theValue; return Standard_False; }
-
protected:
//! Bit flags.
#include <NCollection_Array1.hxx>
#include <Precision.hxx>
-#include <TCollection.hxx>
#include <TColStd_Array1OfReal.hxx>
//! Auxiliary class to select from the points stored in
ReBuild(TColgp_Array1OfPnt(aList[0], 0, 15));
}
-const TCollection_AsciiString Bnd_OBB_ClassName = "Bnd_OBB";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void Bnd_OBB::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Bnd_OBB_ClassName);
- {
- Standard_SStream aTmpStream;
- myCenter.Dump (aTmpStream);
- DUMP_VALUES (OS, "Center", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myAxes[0].Dump (aTmpStream);
- DUMP_VALUES (OS, "XAxis", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myAxes[1].Dump (aTmpStream);
- DUMP_VALUES (OS, "YAxis", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myAxes[2].Dump (aTmpStream);
- DUMP_VALUES (OS, "ZAxis", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "XHSize", XHSize());
- DUMP_VALUES (OS, "YHSize", YHSize());
- DUMP_VALUES (OS, "ZHSize", ZHSize());
- DUMP_VALUES (OS, "IsAABox", myIsAABox);
-
- DUMP_STOP_KEY (OS, Bnd_OBB_ClassName);
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-Standard_Boolean Bnd_OBB::Init (const Standard_SStream& /*OS*/)
-{
- //NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStreamValues;
- //TCollection::Split (OS, aStreamValues, aKey);
-
- //TCollection_AsciiString anXYZValue;
- //if (aStreamValues.Size() == 1)
- //{
- // NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>::Iterator anIterator (aStreamValues);
- // TCollection_AsciiString aValueStr = anIterator.Value();
- // Standard_Integer aPosition = aValueStr.Search (Bnd_Box_ClassName + TCollection::ClassNameSeparator());
- // if (aPosition < 1)
- // return Standard_False;
- // anXYZValue = aValueStr.Split (aPosition);
- //}
-
- //NCollection_Vector<Standard_Real> aValues;
- //if (!TCollection::SplitReal (anXYZValue, TCollection::VectorSeparator(), aValues))
- // return Standard_False;
-
- //if (aValues.Size() != 8)
- // return Standard_False;
-
- //Update (aValues.Value (1), aValues.Value (2), aValues.Value (3), aValues.Value (4), aValues.Value (5), aValues.Value (6));
- //Gap = aValues.Value (7);
- //Flags = (Standard_Integer)aValues.Value (8);
-
- //return Standard_True;
-
- return Standard_False;
-}
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
-#include <Standard_OStream.hxx>
#include <Bnd_Box.hxx>
#include <gp_Ax3.hxx>
//! (which it was created from) and theP.
Standard_EXPORT void Add(const gp_Pnt& theP);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT Standard_Boolean Init (const Standard_SStream& OS);
-
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
- //! Covers bounding box into string in format: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
- //! \return the string value
- Standard_EXPORT TCollection_AsciiString ToString() const { return ""; }
-
- //! Converts text value into parameters if possible, the string format is: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
- //! \return true if conversion is done
- Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue) { (void)theValue; return Standard_False; }
-
protected:
void ProcessOnePoint(const gp_Pnt& theP)
{
theList.Append(Bnd_Range(aValPrev, myLast));
}
-}
-
-//=======================================================================
-//function : ToString
-//purpose :
-//=======================================================================
-TCollection_AsciiString Bnd_Range::ToString() const
-{
- return TCollection_AsciiString ("[") + myFirst + ", " + myLast + "]";
-}
+}
\ No newline at end of file
#include <Standard_Real.hxx>
#include <Standard_ConstructionError.hxx>
-#include <TCollection_AsciiString.hxx>
#include <NCollection_List.hxx>
return ((myFirst == theOther.myFirst) && (myLast == theOther.myLast));
}
- //! Covers point into string in format: [myFirst, myLast]
- //! \return the string value
- Standard_EXPORT TCollection_AsciiString ToString() const;
-
private:
Standard_Real myFirst; //!< Start of range
-Font.cxx
-Font.hxx
Font_BRepFont.cxx
Font_BRepFont.hxx
Font_BRepTextBuilder.cxx
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Font.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString Font_Table_PrintFontAspect[5] =
- {
- "UNDEFINED", "REGULAR", "BOLD", "ITALIC", "BOLD_ITALIC"
- };
-
-}
-
-//=======================================================================
-//function : FontAspectToString
-//purpose :
-//=======================================================================
-Standard_CString Font::FontAspectToString (Font_FontAspect theType)
-{
- return Font_Table_PrintFontAspect[theType];
-}
-
-//=======================================================================
-//function : FontAspectFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Font::FontAspectFromString (Standard_CString theTypeString,
- Font_FontAspect& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Font_FA_BoldItalic; ++aTypeIter)
- {
- Standard_CString aTypeName = Font_Table_PrintFontAspect[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Font_FontAspect (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Font_HeaderFile
-#define _Font_HeaderFile
-
-#include <Font_FontAspect.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-
-//! Provides methods to cast enumerations of package to string value
-class Font
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString FontAspectToString (Font_FontAspect theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Aspect_TOFM_BOTH_SIDE if string identifier is invalid
- static Font_FontAspect FontAspectFromString (Standard_CString theTypeString)
- {
- Font_FontAspect aType = Font_FA_Undefined;
- FontAspectFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean FontAspectFromString (const Standard_CString theTypeString,
- Font_FontAspect& theType);
-
-
-};
-
-#endif // _Font_HeaderFile
-Graphic3d.cxx
-Graphic3d.hxx
Graphic3d_AlphaMode.hxx
Graphic3d_ArrayFlags.hxx
Graphic3d_ArrayOfPoints.hxx
Graphic3d_NameOfTextureEnv.hxx
Graphic3d_NameOfTexturePlane.hxx
Graphic3d_NMapOfTransient.hxx
-Graphic3d_PolygonOffset.cxx
Graphic3d_PolygonOffset.hxx
Graphic3d_PriorityDefinitionError.hxx
Graphic3d_RenderingMode.hxx
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Graphic3d.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString Graphic3d_Table_PrintZLayerId[6] =
- {
- "UNKNOWN", "DEFAULT", "TOP", "TOPMOST", "TOP_OSD", "BOT_OSD"
- };
-
- static Standard_CString Graphic3d_Table_PrintHorizontalTextAlignment[3] =
- {
- "LEFT", "CENTER", "RIGHT"
- };
-
- static Standard_CString Graphic3d_Table_PrintVerticalTextAlignment[4] =
- {
- "BOTTOM", "CENTER", "TOP", "TOP_FIRST_LINE"
- };
-
- static Standard_CString Graphic3d_Table_PrintTextPath[4] =
- {
- "UP", "DOWN", "LEFT", "RIGHT"
- };
-
- static Standard_CString Graphic3d_Table_PrintAlphaMode[4] =
- {
- "BLEND_AUTO", "OPAQUE", "MASK", "BLEND"
- };
-
- static Standard_CString Graphic3d_Table_PrintTypeOfShadingModel[5] =
- {
- "DEFAULT", "UNLIT", "FACET", "VERTEX", "FRAGMENT"
- };
-
- static Standard_CString Graphic3d_Table_PrintTypeOfAttribute[5] =
- {
- "POS", "NORM", "UV", "COLOR", "CUSTOM"
- };
-
- static Standard_CString Graphic3d_Table_PrintTypeOfData[7] =
- {
- "USHORT", "UINT", "VEC2", "VEC3", "VEC4", "VEC4UB", "FLOAT"
- };
-
- static Standard_CString Graphic3d_Table_PrintTransModeFlags[6] =
- {
- "NONE", "ZOOM_PERS", "ROTATE_PERS", "TRIEDRON_PERS", "2d", "ZOOM_ROTATE_PERS"
- };
-
- static Standard_CString Graphic3d_Table_PrintCameraProjection[5] =
- {
- "ORTHOGRAPHIC", "PERSPECTIVE", "STEREO", "MONOLEFTEYE", "MONORIGHTEYE"
- };
-
- static Standard_CString Graphic3d_Table_PrintFocusType[2] =
- {
- "ABSOLUTE", "RELATIVE"
- };
-
- static Standard_CString Graphic3d_Table_PrintIODType[2] =
- {
- "ABSOLUTE", "RELATIVE"
- };
-
- static Standard_CString Graphic3d_Table_PrintNameOfMaterial[26] =
- {
- "BRASS", "BRONZE", "COPPER", "GOLD", "PEWTER", "PLASTER", "PLASTIC", "SILVER", // 8
- "STEEL", "STONE", "SHINY_PLASTIC", "SATIN", "METALIZED", "NEON_GNC", "CHROME", // 7
- "ALUMINIUM", "OBSIDIAN", "NEON_PHC", "JADE", "CHARCOAL", "WATER", "GLASS", // 7
- "DIAMOND", "TRANSPARENT", "DEFAULT", "UserDefined" // 4
- };
-}
-
-//=======================================================================
-//function : ZLayerIdToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId theType)
-{
- switch (theType)
- {
- case Graphic3d_ZLayerId_UNKNOWN: return Graphic3d_Table_PrintZLayerId[0]; break;
- case Graphic3d_ZLayerId_Default: return Graphic3d_Table_PrintZLayerId[1]; break;
- case Graphic3d_ZLayerId_Top: return Graphic3d_Table_PrintZLayerId[2]; break;
- case Graphic3d_ZLayerId_Topmost: return Graphic3d_Table_PrintZLayerId[3]; break;
- case Graphic3d_ZLayerId_TopOSD: return Graphic3d_Table_PrintZLayerId[4]; break;
- case Graphic3d_ZLayerId_BotOSD: return Graphic3d_Table_PrintZLayerId[5]; break;
- }
- return "";
-}
-
-//=======================================================================
-//function : ZLayerIdFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::ZLayerIdFromString (Standard_CString theTypeString,
- Graphic3d_ZLayerId& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= 5; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintZLayerId[aTypeIter];
- if (aName == aTypeName)
- {
- switch (aTypeIter)
- {
- case 0: theType = Graphic3d_ZLayerId_UNKNOWN; break;
- case 1: theType = Graphic3d_ZLayerId_Default; break;
- case 2: theType = Graphic3d_ZLayerId_Top; break;
- case 3: theType = Graphic3d_ZLayerId_Topmost; break;
- case 4: theType = Graphic3d_ZLayerId_TopOSD; break;
- case 5: theType = Graphic3d_ZLayerId_BotOSD; break;
- }
- return Standard_True;
- }
- }
-
- if (aName.IsIntegerValue())
- {
- theType = aName.IntegerValue();
- return Standard_True;
- }
-
- return Standard_False;
-}
-
-//=======================================================================
-//function : HorizontalTextAlignmentToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::HorizontalTextAlignmentToString (Graphic3d_HorizontalTextAlignment theType)
-{
- return Graphic3d_Table_PrintHorizontalTextAlignment[theType];
-}
-
-//=======================================================================
-//function : HorizontalTextAlignmentFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::HorizontalTextAlignmentFromString (Standard_CString theTypeString,
- Graphic3d_HorizontalTextAlignment& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_HTA_LEFT; aTypeIter <= Graphic3d_HTA_RIGHT; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintHorizontalTextAlignment[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_HorizontalTextAlignment (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : VerticalTextAlignmentToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::VerticalTextAlignmentToString (Graphic3d_VerticalTextAlignment theType)
-{
- return Graphic3d_Table_PrintVerticalTextAlignment[theType];
-}
-
-//=======================================================================
-//function : VerticalTextAlignmentFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::VerticalTextAlignmentFromString (Standard_CString theTypeString,
- Graphic3d_VerticalTextAlignment& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_VTA_BOTTOM; aTypeIter <= Graphic3d_VTA_TOPFIRSTLINE; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintVerticalTextAlignment[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_VerticalTextAlignment (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TextPathToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::TextPathToString (Graphic3d_TextPath theType)
-{
- return Graphic3d_Table_PrintTextPath[theType];
-}
-
-//=======================================================================
-//function : TextPathFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::TextPathFromString (Standard_CString theTypeString,
- Graphic3d_TextPath& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_TP_UP; aTypeIter <= Graphic3d_TP_RIGHT; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintTextPath[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_TextPath (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : AlphaModeToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::AlphaModeToString (Graphic3d_AlphaMode theType)
-{
- return Graphic3d_Table_PrintAlphaMode[theType + 1];
-}
-
-//=======================================================================
-//function : AlphaModeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::AlphaModeFromString (Standard_CString theTypeString,
- Graphic3d_AlphaMode& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_AlphaMode_BlendAuto; aTypeIter <= Graphic3d_AlphaMode_Blend; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintAlphaMode[aTypeIter + 1];
- if (aName == aTypeName)
- {
- theType = Graphic3d_AlphaMode (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfShadingModelToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::TypeOfShadingModelToString (Graphic3d_TypeOfShadingModel theType)
-{
- return Graphic3d_Table_PrintTypeOfShadingModel[theType + 1];
-}
-
-//=======================================================================
-//function : TypeOfShadingModelFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::TypeOfShadingModelFromString (Standard_CString theTypeString,
- Graphic3d_TypeOfShadingModel& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_TOSM_DEFAULT; aTypeIter <= Graphic3d_TOSM_FRAGMENT; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintTypeOfShadingModel[aTypeIter + 1];
- if (aName == aTypeName)
- {
- theType = Graphic3d_TypeOfShadingModel (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfAttributeToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::TypeOfAttributeToString (Graphic3d_TypeOfAttribute theType)
-{
- return Graphic3d_Table_PrintTypeOfAttribute[theType];
-}
-
-//=======================================================================
-//function : TypeOfAttributeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::TypeOfAttributeFromString (Standard_CString theTypeString,
- Graphic3d_TypeOfAttribute& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_TOA_POS; aTypeIter <= Graphic3d_TOA_CUSTOM; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintTypeOfAttribute[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_TypeOfAttribute (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfDataToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::TypeOfDataToString (Graphic3d_TypeOfData theType)
-{
- return Graphic3d_Table_PrintTypeOfData[theType];
-}
-
-//=======================================================================
-//function : TypeOfDataFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::TypeOfDataFromString (Standard_CString theTypeString,
- Graphic3d_TypeOfData& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_TOD_USHORT; aTypeIter <= Graphic3d_TOD_FLOAT; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintTypeOfData[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_TypeOfData (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TransModeFlagsToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::TransModeFlagsToString (Graphic3d_TransModeFlags theType)
-{
- switch (theType)
- {
- case Graphic3d_TMF_None: return Graphic3d_Table_PrintTransModeFlags[0]; break;
- case Graphic3d_TMF_ZoomPers: return Graphic3d_Table_PrintTransModeFlags[1]; break;
- case Graphic3d_TMF_RotatePers: return Graphic3d_Table_PrintTransModeFlags[2]; break;
- case Graphic3d_TMF_TriedronPers: return Graphic3d_Table_PrintTransModeFlags[3]; break;
- case Graphic3d_TMF_2d: return Graphic3d_Table_PrintTransModeFlags[4]; break;
- case Graphic3d_TMF_ZoomRotatePers: return Graphic3d_Table_PrintTransModeFlags[5]; break;
- }
- return "";
-}
-
-//=======================================================================
-//function : ZLayerIdFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::TransModeFlagsFromString (Standard_CString theTypeString,
- Graphic3d_TransModeFlags& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= 5; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintTransModeFlags[aTypeIter];
- if (aName == aTypeName)
- {
- switch (aTypeIter)
- {
- case 0: theType = Graphic3d_TMF_None; break;
- case 1: theType = Graphic3d_TMF_ZoomPers; break;
- case 2: theType = Graphic3d_TMF_RotatePers; break;
- case 3: theType = Graphic3d_TMF_TriedronPers; break;
- case 4: theType = Graphic3d_TMF_2d; break;
- case 5: theType = Graphic3d_TMF_ZoomRotatePers; break;
- }
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : CameraProjectionToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::CameraProjectionToString (Graphic3d_Camera::Projection theType)
-{
- return Graphic3d_Table_PrintCameraProjection[theType];
-}
-
-//=======================================================================
-//function : CameraProjectionFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::CameraProjectionFromString (Standard_CString theTypeString,
- Graphic3d_Camera::Projection& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_Camera::Projection_Orthographic;
- aTypeIter <= Graphic3d_Camera::Projection_MonoRightEye; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintCameraProjection[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_Camera::Projection (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : CameraFocusTypeToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::CameraFocusTypeToString (Graphic3d_Camera::FocusType theType)
-{
- return Graphic3d_Table_PrintFocusType[theType];
-}
-
-//=======================================================================
-//function : FocusTypeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::CameraFocusTypeFromString (Standard_CString theTypeString,
- Graphic3d_Camera::FocusType& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_Camera::FocusType_Absolute;
- aTypeIter <= Graphic3d_Camera::FocusType_Relative; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintFocusType[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_Camera::FocusType (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : CameraIODTypeToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::CameraIODTypeToString (Graphic3d_Camera::IODType theType)
-{
- return Graphic3d_Table_PrintIODType[theType];
-}
-
-//=======================================================================
-//function : IODTypeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::CameraIODTypeFromString (Standard_CString theTypeString,
- Graphic3d_Camera::IODType& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_Camera::IODType_Absolute;
- aTypeIter <= Graphic3d_Camera::IODType_Relative; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintIODType[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_Camera::IODType (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : NameOfMaterialToString
-//purpose :
-//=======================================================================
-Standard_CString Graphic3d::NameOfMaterialToString (Graphic3d_NameOfMaterial theType)
-{
- return Graphic3d_Table_PrintNameOfMaterial[theType];
-}
-
-//=======================================================================
-//function : NameOfMaterialFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Graphic3d::NameOfMaterialFromString (Standard_CString theTypeString,
- Graphic3d_NameOfMaterial& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = Graphic3d_TOD_USHORT; aTypeIter <= Graphic3d_TOD_FLOAT; ++aTypeIter)
- {
- Standard_CString aTypeName = Graphic3d_Table_PrintNameOfMaterial[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Graphic3d_NameOfMaterial (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Graphic3d_HeaderFile
-#define _Graphic3d_HeaderFile
-
-#include <Graphic3d_AlphaMode.hxx>
-#include <Graphic3d_Buffer.hxx>
-#include <Graphic3d_Camera.hxx>
-#include <Graphic3d_HorizontalTextAlignment.hxx>
-#include <Graphic3d_VerticalTextAlignment.hxx>
-#include <Graphic3d_TextPath.hxx>
-#include <Graphic3d_TransModeFlags.hxx>
-#include <Graphic3d_TypeOfShadingModel.hxx>
-#include <Graphic3d_NameOfMaterial.hxx>
-
-#include <Graphic3d_ZLayerId.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-
-//! Provides methods to cast enumerations of package to string value
-class Graphic3d
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString ZLayerIdToString (Graphic3d_ZLayerId theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_ZLayerId_UNKNOWN if string identifier is invalid
- static Graphic3d_ZLayerId ZLayerIdFromString (Standard_CString theTypeString)
- {
- Graphic3d_ZLayerId aType = Graphic3d_ZLayerId_UNKNOWN;
- ZLayerIdFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean ZLayerIdFromString (const Standard_CString theTypeString,
- Graphic3d_ZLayerId& theType);
-
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString HorizontalTextAlignmentToString (Graphic3d_HorizontalTextAlignment theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_HTA_LEFT if string identifier is invalid
- static Graphic3d_HorizontalTextAlignment HorizontalTextAlignmentFromString (Standard_CString theTypeString)
- {
- Graphic3d_HorizontalTextAlignment aType = Graphic3d_HTA_LEFT;
- HorizontalTextAlignmentFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean HorizontalTextAlignmentFromString (const Standard_CString theTypeString,
- Graphic3d_HorizontalTextAlignment& theType);
-
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString VerticalTextAlignmentToString (Graphic3d_VerticalTextAlignment theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_VTA_BOTTOM if string identifier is invalid
- static Graphic3d_VerticalTextAlignment VerticalTextAlignmentFromString (Standard_CString theTypeString)
- {
- Graphic3d_VerticalTextAlignment aType = Graphic3d_VTA_BOTTOM;
- VerticalTextAlignmentFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean VerticalTextAlignmentFromString (const Standard_CString theTypeString,
- Graphic3d_VerticalTextAlignment& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TextPathToString (Graphic3d_TextPath theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_TP_UP if string identifier is invalid
- static Graphic3d_TextPath TextPathFromString (Standard_CString theTypeString)
- {
- Graphic3d_TextPath aType = Graphic3d_TP_UP;
- TextPathFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TextPathFromString (const Standard_CString theTypeString,
- Graphic3d_TextPath& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString AlphaModeToString (Graphic3d_AlphaMode theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_AlphaMode_Opaque if string identifier is invalid
- static Graphic3d_AlphaMode AlphaModeFromString (Standard_CString theTypeString)
- {
- Graphic3d_AlphaMode aType = Graphic3d_AlphaMode_Opaque;
- AlphaModeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean AlphaModeFromString (const Standard_CString theTypeString,
- Graphic3d_AlphaMode& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfShadingModelToString (Graphic3d_TypeOfShadingModel theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_TOSM_DEFAULT if string identifier is invalid
- static Graphic3d_TypeOfShadingModel TypeOfShadingModelFromString (Standard_CString theTypeString)
- {
- Graphic3d_TypeOfShadingModel aType = Graphic3d_TOSM_DEFAULT;
- TypeOfShadingModelFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfShadingModelFromString (const Standard_CString theTypeString,
- Graphic3d_TypeOfShadingModel& theType);
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfAttributeToString (Graphic3d_TypeOfAttribute theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_TOA_POS if string identifier is invalid
- static Graphic3d_TypeOfAttribute TypeOfAttributeFromString (Standard_CString theTypeString)
- {
- Graphic3d_TypeOfAttribute aType = Graphic3d_TOA_POS;
- TypeOfAttributeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfAttributeFromString (const Standard_CString theTypeString,
- Graphic3d_TypeOfAttribute& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfDataToString (Graphic3d_TypeOfData theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_TOSM_DEFAULT if string identifier is invalid
- static Graphic3d_TypeOfData TypeOfDataFromString (Standard_CString theTypeString)
- {
- Graphic3d_TypeOfData aType = Graphic3d_TOD_USHORT;
- TypeOfDataFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfDataFromString (const Standard_CString theTypeString,
- Graphic3d_TypeOfData& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TransModeFlagsToString (Graphic3d_TransModeFlags theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Graphic3d_TOSM_DEFAULT if string identifier is invalid
- static Graphic3d_TransModeFlags TransModeFlagsFromString (Standard_CString theTypeString)
- {
- Graphic3d_TransModeFlags aType = Graphic3d_TMF_None;
- TransModeFlagsFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TransModeFlagsFromString (const Standard_CString theTypeString,
- Graphic3d_TransModeFlags& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString CameraProjectionToString (Graphic3d_Camera::Projection theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Projection_Orthographic if string identifier is invalid
- static Graphic3d_Camera::Projection CameraProjectionFromString (Standard_CString theTypeString)
- {
- Graphic3d_Camera::Projection aType = Graphic3d_Camera::Projection_Orthographic;
- CameraProjectionFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean CameraProjectionFromString (const Standard_CString theTypeString,
- Graphic3d_Camera::Projection& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString CameraFocusTypeToString (Graphic3d_Camera::FocusType theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or FocusType_Absolute if string identifier is invalid
- static Graphic3d_Camera::FocusType CameraFocusTypeFromString (Standard_CString theTypeString)
- {
- Graphic3d_Camera::FocusType aType = Graphic3d_Camera::FocusType_Absolute;
- CameraFocusTypeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean CameraFocusTypeFromString (const Standard_CString theTypeString,
- Graphic3d_Camera::FocusType& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString CameraIODTypeToString (Graphic3d_Camera::IODType theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or IODType_Absolute if string identifier is invalid
- static Graphic3d_Camera::IODType CameraIODTypeFromString (Standard_CString theTypeString)
- {
- Graphic3d_Camera::IODType aType = Graphic3d_Camera::IODType_Absolute;
- CameraIODTypeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean CameraIODTypeFromString (const Standard_CString theTypeString,
- Graphic3d_Camera::IODType& theType);
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString NameOfMaterialToString (Graphic3d_NameOfMaterial theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or IODType_Absolute if string identifier is invalid
- static Graphic3d_NameOfMaterial NameOfMaterialFromString (Standard_CString theTypeString)
- {
- Graphic3d_NameOfMaterial aType = Graphic3d_NOM_BRASS;
- NameOfMaterialFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean NameOfMaterialFromString (const Standard_CString theTypeString,
- Graphic3d_NameOfMaterial& theType);
-};
-
-#endif // _Graphic3d_HeaderFile
// commercial license or contractual agreement.
#include <Graphic3d_Aspects.hxx>
-#include <TCollection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
myTextureSet = new Graphic3d_TextureSet (theTexture);
}
-
-const TCollection_AsciiString Graphic3d_Aspects_ClassName = "Graphic3d_Aspects";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void Graphic3d_Aspects::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Graphic3d_Aspects_ClassName);
-
- /*Handle(Graphic3d_ShaderProgram) myProgram;
- Handle(Graphic3d_TextureSet) myTextureSet;
- Handle(Graphic3d_MarkerImage) myMarkerImage;
- Handle(Graphic3d_HatchStyle) myHatchStyle;
- Handle(TCollection_HAsciiString) myTextFont;
- Graphic3d_MaterialAspect myFrontMaterial;
- Graphic3d_MaterialAspect myBackMaterial;
- */
-
- Standard_SStream aTmpStream;
- myInteriorColor.Dump (aTmpStream);
- DUMP_VALUES (OS, "InteriorColor", TCollection::ToDumpString (aTmpStream));
-
- aTmpStream.str ("");
- myBackInteriorColor.Dump (aTmpStream);
- DUMP_VALUES (OS, "BackInteriorColor", TCollection::ToDumpString (aTmpStream));
-
- aTmpStream.str ("");
- myEdgeColor.Dump (aTmpStream);
- DUMP_VALUES (OS, "EdgeColor", TCollection::ToDumpString (aTmpStream));
-
- aTmpStream.str ("");
- myPolygonOffset.Dump (aTmpStream);
- DUMP_VALUES (OS, "PolygonOffset", TCollection::ToDumpString (aTmpStream));
-
-
- /*Aspect_InteriorStyle myInteriorStyle;
- Graphic3d_TypeOfShadingModel myShadingModel;
- Graphic3d_AlphaMode myAlphaMode;
- Standard_ShortReal myAlphaCutoff;
-
- Aspect_TypeOfLine myLineType;
- Standard_ShortReal myLineWidth;
-
- Aspect_TypeOfMarker myMarkerType;
- Standard_ShortReal myMarkerScale;
-
- Aspect_TypeOfStyleText myTextStyle;
- Aspect_TypeOfDisplayText myTextDisplayType;
- Font_FontAspect myTextFontAspect;
- Standard_ShortReal myTextAngle;
- */
-
- DUMP_VALUES (OS, "ToSkipFirstEdge", myToSkipFirstEdge);
- DUMP_VALUES (OS, "ToDistinguishMaterials", myToDistinguishMaterials);
- DUMP_VALUES (OS, "ToDrawEdges", myToDrawEdges);
- DUMP_VALUES (OS, "ToDrawSilhouette", myToDrawSilhouette);
- DUMP_VALUES (OS, "ToSuppressBackFaces", myToSuppressBackFaces);
- DUMP_VALUES (OS, "ToMapTexture", myToMapTexture);
- DUMP_VALUES (OS, "IsTextZoomable", myIsTextZoomable);
-
-
- DUMP_STOP_KEY (OS, Graphic3d_Aspects_ClassName);
-}
&& myIsTextZoomable == theOther.myIsTextZoomable;
}
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
protected:
Handle(Graphic3d_ShaderProgram) myProgram;
Update();
}
-
-const TCollection_AsciiString Graphic3d_Group_ClassName = "Graphic3d_Group";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Graphic3d_Group::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Graphic3d_Group_ClassName);
-
- //Graphic3d_Structure* myStructure; //!< pointer to the parent structure
- //Graphic3d_BndBox4f myBounds; //!< bounding box
-
- DUMP_VALUES (OS, "IsClosed", myIsClosed);
- DUMP_VALUES (OS, "ContainsFacet", myContainsFacet);
-
- DUMP_STOP_KEY (OS, Graphic3d_Group_ClassName);
-}
const Standard_Boolean theHasOwnAnchor = Standard_True);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
-
protected:
//! Creates a group in the structure <AStructure>.
+++ /dev/null
-// Copyright (c) 2016 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 <Graphic3d_PolygonOffset.hxx>
-
-#include <Aspect.hxx>
-#include <TCollection.hxx>
-
-const TCollection_AsciiString Graphic3d_PolygonOffset_ClassName = "Graphic3d_PolygonOffset";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void Graphic3d_PolygonOffset::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Graphic3d_PolygonOffset_ClassName);
-
- DUMP_VALUES (OS, "Mode", Aspect::PolygonOffsetModeToString (Mode));
- DUMP_VALUES (OS, "Factor", Factor);
- DUMP_VALUES (OS, "Units", Units);
-
- DUMP_STOP_KEY (OS, Graphic3d_PolygonOffset_ClassName);
-}
#define _Graphic3d_PolygonOffset_HeaderFile
#include <Aspect_PolygonOffsetMode.hxx>
-#include <Standard_OStream.hxx>
//! Polygon offset parameters.
struct Graphic3d_PolygonOffset
&& Factor == theOther.Factor
&& Units == theOther.Units;
}
-
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
};
#endif // _Graphic3d_PolygonOffset_HeaderFile
Message.cxx
Message.hxx
-Message_Alert.cxx
-Message_Alert.hxx
-Message_AlertExtended.cxx
-Message_AlertExtended.hxx
-Message_Alerts.hxx
Message_Algorithm.cxx
Message_Algorithm.hxx
Message_Algorithm.lxx
-Message_Attribute.cxx
-Message_Attribute.hxx
-Message_AttributeObject.cxx
-Message_AttributeObject.hxx
-Message_AttributeStream.cxx
-Message_AttributeStream.hxx
-Message_CompositeAlerts.cxx
-Message_CompositeAlerts.hxx
Message_ExecStatus.hxx
Message_Gravity.hxx
Message_HArrayOfMsg.hxx
Message_Msg.lxx
Message_MsgFile.cxx
Message_MsgFile.hxx
-Message_PerfMeter.cxx
-Message_PerfMeter.hxx
-Message_PerfMeterMode.hxx
Message_Printer.cxx
Message_Printer.hxx
Message_PrinterOStream.cxx
Message_SequenceOfProgressScale.hxx
Message_Status.hxx
Message_StatusType.hxx
+Message_Alert.cxx
+Message_Alert.hxx
Message_ListOfAlert.hxx
Message_Report.cxx
Message_Report.hxx
-Message_ReportCallBack.cxx
-Message_ReportCallBack.hxx
Sprintf (t, "%.2fs", second);
return TCollection_AsciiString (t);
}
-
-namespace
-{
- static Standard_CString Message_Table_PrintGravityEnum[5] =
- {
- "TRACE", "INFO", "WARNING", "ALARM", "FAIL"
- };
-
- static Standard_CString Message_Table_PrintPerfMeterModeEnum[10] =
- {
- "NONE", "USER_TIME_CPU", "SYSTEM_TIME_CPU", "MEM_PRIVATE", "MEM_VIRTUAL",
- "MEM_WORKING_SET", "MEM_WORKING_SET_PEAK", "MEM_SWAP_USAGE", "MEM_SWAP_USAGE_PEAK", "MEM_HEAP_USAGE"
- };
-}
-
-//=======================================================================
-//function : GravityToString
-//purpose :
-//=======================================================================
-
-Standard_CString Message::GravityToString (const Message_Gravity theGravity)
-{
- return Message_Table_PrintGravityEnum[theGravity];
-}
-
-//=======================================================================
-//function : GravityFromString
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message::GravityFromString (const Standard_CString theGravityString,
- Message_Gravity& theGravity)
-{
- TCollection_AsciiString aName (theGravityString);
- aName.UpperCase();
- for (Standard_Integer aGravityIter = 0; aGravityIter <= Message_Fail; ++aGravityIter)
- {
- Standard_CString aGravityName = Message_Table_PrintGravityEnum[aGravityIter];
- if (aName == aGravityName)
- {
- theGravity = Message_Gravity (aGravityIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : PerfMeterModeToString
-//purpose :
-//=======================================================================
-
-Standard_CString Message::PerfMeterModeToString (const Message_PerfMeterMode theValue)
-{
- return Message_Table_PrintPerfMeterModeEnum[theValue];
-}
-
-//=======================================================================
-//function : PerfMeterModeFromString
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message::PerfMeterModeFromString (const Standard_CString theString,
- Message_PerfMeterMode& theValue)
-{
- TCollection_AsciiString aName (theString);
- aName.UpperCase();
- for (Standard_Integer aModeIter = 0; aModeIter <= Message_PerfMeterMode_MemHeapUsage; ++aModeIter)
- {
- Standard_CString aModeName = Message_Table_PrintPerfMeterModeEnum[aModeIter];
- if (aName == aModeName)
- {
- theValue = Message_PerfMeterMode (aModeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::TransientToString (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- if (thePointer.IsNull())
- return TCollection_AsciiString();
-
- return PointerToString(thePointer.operator->(), isShortInfo);
-}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::PointerToString (const void* thePointer, const bool isShortInfo)
-{
- std::ostringstream aPtrStr;
- aPtrStr << thePointer;
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend("0x");
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
-// =======================================================================
-// function : StrVectorToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::StrVectorToString
- (const NCollection_Vector<TCollection_AsciiString>& theValues)
-{
- TCollection_AsciiString aValue;
- for (NCollection_Vector<TCollection_AsciiString>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
- {
- aValue += aValuesIt.Value();
- if (aValuesIt.More())
- aValue += VectorSeparator();
- }
- return aValue;
-}
-
-// =======================================================================
-// function : StrVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::StrVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<TCollection_AsciiString>& theValues)
-{
- TCollection_AsciiString aCurrentString = theValue, aValueString;
-
- while (!aCurrentString.IsEmpty())
- {
- Standard_Integer aPosition = aCurrentString.Search (", ");
- aValueString = aCurrentString;
- if (aPosition > 0)
- aCurrentString = aValueString.Split (aPosition - 1);
- theValues.Append (aValueString.RealValue());
- if (aPosition > 0)
- aCurrentString = aCurrentString.Split (2);
- }
- return Standard_True;
-}
-
-// =======================================================================
-// function : RealVectorToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::RealVectorToString
- (const NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aValue = ("(");
-
- for (NCollection_Vector<Standard_Real>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
- {
- aValue += aValuesIt.Value();
- if (aValuesIt.More())
- aValue += VectorSeparator();
- }
- aValue += ")";
-
- return aValue;
-}
-
-// =======================================================================
-// function : RealVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::RealVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aCurrentString = theValue, aValueString;
-
- Standard_Integer aPosition = aCurrentString.Search ("(");
- if (aPosition != 1)
- return Standard_False;
- aCurrentString = aCurrentString.Split (aPosition);
-
- aPosition = aCurrentString.Search (")");
- if (aPosition != 1)
- return Standard_False;
- aValueString = aCurrentString.Split (aPosition);
-
-
- while (!aCurrentString.IsEmpty())
- {
- // x value
- aPosition = aCurrentString.Search (", ");
- aValueString = aCurrentString;
- if (aPosition > 0)
- aCurrentString = aValueString.Split (aPosition - 1);
- theValues.Append (aValueString.RealValue());
- if (aPosition > 0)
- aCurrentString = aCurrentString.Split (2);
- }
- return Standard_True;
-}
-
-// =======================================================================
-// function : CoordVectorToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::CoordVectorToString
- (const NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aValue = ("(");
- aValue += RealVectorToString (theValues);
- aValue += ")";
-
- return aValue;
-}
-
-// =======================================================================
-// function : CoordVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::CoordVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aCurrentString = theValue, aValueString;
-
- Standard_Integer aPosition = aCurrentString.Search ("(");
- if (aPosition != 1)
- return Standard_False;
- aCurrentString = aCurrentString.Split (aPosition);
-
- aPosition = aCurrentString.Search (")");
- if (aPosition != 1)
- return Standard_False;
- aValueString = aCurrentString.Split (aPosition);
-
- return RealVectorFromString (aCurrentString, theValues);
-}
-
-// =======================================================================
-// function : ColorVectorToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::ColorVectorToString
- (const NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aValue = ("[");
- aValue += RealVectorToString (theValues);
- aValue += "]";
-
- return aValue;
-}
-
-// =======================================================================
-// function : ColorVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::ColorVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aCurrentString = theValue, aValueString;
-
- Standard_Integer aPosition = aCurrentString.Search ("[");
- if (aPosition != 1)
- return Standard_False;
- aCurrentString = aCurrentString.Split (aPosition);
-
- aPosition = aCurrentString.Search ("]");
- if (aPosition != 1)
- return Standard_False;
- aValueString = aCurrentString.Split (aPosition);
-
- return RealVectorFromString (aCurrentString, theValues);
-}
-
-// =======================================================================
-// function : ConvertStream
-// purpose :
-// =======================================================================
-void Message::ConvertStream (const Standard_SStream& theStream,
- Standard_Integer& theColumnCount,
- NCollection_Vector<TCollection_AsciiString>& theValues)
-{
- TCollection_AsciiString aStream (theStream.str().c_str());
- Standard_Character aSeparator = Message::DumpSeparator();
- Standard_Integer aColumnCount = 0;
-
- TCollection_AsciiString aCurrentString = aStream;
- Standard_Integer aPosition = aCurrentString.Search (aSeparator);
- if (aPosition >= 1)
- {
- TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
- Standard_Boolean aClassNameFound = Standard_False;
- while (!aCurrentString.IsEmpty())
- {
- TCollection_AsciiString aValueString = aCurrentString;
- aPosition = aValueString.Search (aSeparator);
- if (aPosition < 0 )
- break;
- aCurrentString = aValueString.Split (aPosition - 1);
-
- if (!aColumnCount)
- {
- if (!aClassNameFound)
- aClassNameFound = Standard_True;
- else
- {
- if (!aValueString.IsIntegerValue())
- break; // not correct Dump, in correct the first value is number of property columns
- aColumnCount = aValueString.IntegerValue();
- }
- }
- else
- theValues.Append (aValueString);
-
- if (aTailString.IsEmpty())
- break;
- aCurrentString = aTailString;
- aPosition = aCurrentString.Search (aSeparator);
- if (aPosition < 0 )
- {
- aCurrentString = aTailString;
- aTailString = TCollection_AsciiString();
- }
- else
- aTailString = aCurrentString.Split (aPosition);
- }
- }
- theColumnCount = aColumnCount;
-}
#ifndef _Message_HeaderFile
#define _Message_HeaderFile
-#include <Message_Gravity.hxx>
-#include <Message_PerfMeterMode.hxx>
-#include <NCollection_Vector.hxx>
-
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
-#include <TCollection_AsciiString.hxx>
-
class Message_Messenger;
+class TCollection_AsciiString;
class Message_Msg;
class Message_MsgFile;
class Message_Messenger;
//! 3. (0, 0, 4.5 ) returns "4.50s"
Standard_EXPORT static TCollection_AsciiString FillTime (const Standard_Integer Hour, const Standard_Integer Minute, const Standard_Real Second);
- //! Returns the string name for a given gravity.
- //! @param Gravity gravity type
- //! @return string identifier from the list Message_Trace, Message_Info, Message_Warning, Message_Alarm and Message_Fail
- Standard_EXPORT static Standard_CString GravityToString (const Message_Gravity theGravity);
-
- //! Returns the gravity type from the given string identifier (using case-insensitive comparison).
- //! @param theGravityString string identifier
- //! @return gravity or Message_Trace if string identifier is invalid
- static Message_Gravity GravityFromString (const Standard_CString theGravityString)
- {
- Message_Gravity aGravity = Message_Trace;
- GravityFromString (theGravityString, aGravity);
- return aGravity;
- }
-
- //! Determines the gravity from the given string identifier (using case-insensitive comparison).
- //! @param theGravityString string identifier
- //! @param theGravity detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean GravityFromString (const Standard_CString theGravityString,
- Message_Gravity& theGravity);
-
- //! Returns the string name for a perf meter mode.
- //! @param theValue mode
- //! @return string identifier
- Standard_EXPORT static Standard_CString PerfMeterModeToString (const Message_PerfMeterMode theValue);
-
- //! Returns the enum value from the given string identifier (using case-insensitive comparison).
- //! @param theString string identifier
- //! @return enum or Message_PerfMeterMode_None if string identifier is invalid
- static Message_PerfMeterMode PerfMeterModeFromString (const Standard_CString theString)
- {
- Message_PerfMeterMode aValue = Message_PerfMeterMode_None;
- PerfMeterModeFromString (theString, aValue);
- return aValue;
- }
-
- //! Returns the enum value from the given string identifier (using case-insensitive comparison).
- //! @param theString string identifier
- //! @return enum or Message_PerfMeterMode_None if string identifier is invalid
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean PerfMeterModeFromString (const Standard_CString theString,
- Message_PerfMeterMode& theValue);
-
-
- //! Returns separator symbol of Dump information
- static Standard_Character DumpSeparator() { return '\\'; }
-
- //! Returns separator symbol of values vector union
- static TCollection_AsciiString VectorSeparator() { return " ,"; }
-
- //! Convert handle pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString TransientToString (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo = true);
-
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString PointerToString (const void* thePointer,
- const bool isShortInfo = true);
- //! Convert vector of real values to string, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString StrVectorToString
- (const NCollection_Vector<TCollection_AsciiString>& theValues);
-
- //! Convert string to vector of real values, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static Standard_Boolean StrVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<TCollection_AsciiString>& theValues);
-
- //! Convert vector of real values to string, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString RealVectorToString
- (const NCollection_Vector<Standard_Real>& theValues);
-
- //! Convert string to vector of real values, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static Standard_Boolean RealVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<Standard_Real>& theValues);
-
- //! Convert vector of real values to string, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString CoordVectorToString
- (const NCollection_Vector<Standard_Real>& theValues);
-
- //! Convert string to vector of real values, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static Standard_Boolean CoordVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<Standard_Real>& theValues);
-
- //! Convert vector of real values to string, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString ColorVectorToString
- (const NCollection_Vector<Standard_Real>& theValues);
-
- //! Convert string to vector of real values, separator is vector separator
- //! \param thePointer a container of real values
- //! \return the string value
- Standard_EXPORT static Standard_Boolean ColorVectorFromString
- (const TCollection_AsciiString& theValue,
- NCollection_Vector<Standard_Real>& theValues);
-
- //! Converts stream to vector of values and column count
- //! \param theStream stream value
- //! \param theColumnCount [out] number of columns
- //! \param theValues [out] container of split values
- static Standard_EXPORT void ConvertStream (const Standard_SStream& theStream,
- Standard_Integer& theColumnCount,
- NCollection_Vector<TCollection_AsciiString>& theValues);
+
+
protected:
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <Message_AlertExtended.hxx>
-#include <Message_Attribute.hxx>
-#include <Message_CompositeAlerts.hxx>
-#include <Message_Report.hxx>
-
-#include <Precision.hxx>
-#include <Standard_Assert.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_AlertExtended,Message_Alert)
-
-//=======================================================================
-//function : GetMessageKey
-//purpose :
-//=======================================================================
-
-Standard_CString Message_AlertExtended::GetMessageKey () const
-{
- if (myAttribute.IsNull())
- return Message_Alert::GetMessageKey();
-
- return myAttribute->GetMessageKey();
-}
-
-//=======================================================================
-//function : GetCompositeAlerts
-//purpose :
-//=======================================================================
-
-Handle (Message_CompositeAlerts) Message_AlertExtended::GetCompositeAlerts (const Standard_Boolean isCreate)
-{
- if (myCompositAlerts.IsNull() && isCreate)
- myCompositAlerts = new Message_CompositeAlerts();
-
- return myCompositAlerts;
-}
-
-//=======================================================================
-//function : IsMetricValid
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message_AlertExtended::IsMetricValid() const
-{
- return fabs (myMetricStart - GetUndefinedMetric()) > Precision::Confusion() &&
- fabs (myMetricStop - GetUndefinedMetric()) > Precision::Confusion();
-}
-
-//=======================================================================
-//function : AddAlert
-//purpose :
-//=======================================================================
-
-Handle(Message_Alert) Message_AlertExtended::AddAlert (const Handle(Message_Report)& theReport,
- const Handle(Message_Attribute)& theAttribute,
- Message_PerfMeter* thePerfMeter,
- const Handle(Message_Alert)& theParentAlert)
-{
- if (!theReport->IsActive (Message_Info))
- return Handle(Message_Alert)();
-
- Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
- anAlert->SetAttribute (theAttribute);
- theReport->AddAlert (Message_Info, anAlert, thePerfMeter, theParentAlert);
-
- return anAlert;
-}
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_AlertExtended_HeaderFile
-#define _Message_AlertExtended_HeaderFile
-
-#include <Message_Alert.hxx>
-#include <TCollection_AsciiString.hxx>
-
-class Message_Attribute;
-class Message_PerfMeter;
-class Message_Report;
-
-DEFINE_STANDARD_HANDLE(Message_AlertExtended, Message_Alert)
-
-class Message_CompositeAlerts;
-
-//! Inherited class of Message_Alert with some additional information.
-//!
-//! It has Message_Attributes to provide the alert name, description and
-//! other custom information
-//!
-//! It is possible to set performance meter into alert to store time/memory metric information
-//! spent between the next alert adding. Also time of child alerts are collected
-//!
-//! It has a container of composite alerts, if the alert might provide
-//! sub-alerts collecting.
-//!
-
-class Message_AlertExtended : public Message_Alert
-{
-public:
- //! Empty constructor
- Standard_EXPORT Message_AlertExtended()
- : Message_Alert(), myMetricStart (GetUndefinedMetric()), myMetricStop (GetUndefinedMetric()) {}
-
- //! Return a C string to be used as a key for generating text user
- //! messages describing this alert.
- //! The messages are generated with help of Message_Msg class, in
- //! Message_Report::Dump().
- //! Base implementation returns dynamic type name of the instance.
- virtual Standard_EXPORT Standard_CString GetMessageKey () const;
-
- //! Sets container of the alert attributes
- //! \param theAttributes an attribute values
- void SetAttribute (const Handle(Message_Attribute)& theAttribute) { myAttribute = theAttribute; }
-
- //! Returns container of the alert attributes
- //! \param theAttributes an attribute values
- const Handle(Message_Attribute)& Attribute () const { return myAttribute; }
-
- //! Returns class provided hierarchy of alerts if created or create if the parameter is true
- //! \param isCreate if composite alert has not been created for this alert, it should be created
- //! \return instance or NULL
- Standard_EXPORT Handle (Message_CompositeAlerts) GetCompositeAlerts (const Standard_Boolean isCreate = Standard_False);
-
- //! Returns performance meter
- //! \return instance or NULL
- Message_PerfMeter* GetPerfMeter() { return myPerfMeter; }
-
- //! Returns true if metric is computed
- //! @return value
- Standard_EXPORT Standard_Boolean IsMetricValid() const;
-
- //! Returns the alert cumulative metric. It includes time/mem of sub alerts
- //! @return value
- Standard_Real MetricStart() const { return myMetricStart; }
-
- //! Returns the alert cumulative metric. It includes time/mem of sub alerts
- //! @return value
- Standard_Real MetricStop() const { return myMetricStop; }
-
- //! Sets cumulative time/mem of alert
- //! \param theCumulativeMetric time/mem of the alert
- void SetMetricValues (const Standard_Real theStartValue, const Standard_Real theStopValue)
- { myMetricStart = theStartValue; myMetricStop = theStopValue; }
-
- //! Return true if this type of alert can be merged with other
- //! of the same type to avoid duplication.
- //! Basis implementation returns true.
- virtual Standard_EXPORT Standard_Boolean SupportsMerge () const { return Standard_False; }
-
- //! Returns default value of the time/mem when it is not defined
- //! \return integer value
- static Standard_Real GetUndefinedMetric() { return -1.0; }
-
- //! Creates new instance of the alert and put it into report with Message_Info gravity.
- //! It does nothing if such kind of gravity is not active in the report
- //! @param theReport the message report where new alert is placed
- //! @param theAttribute container of additional values of the alert
- //! @param thePerfMeter performance meter calculates the alert spent time and participate in searching the last alert if needed
- //! @param theParentAlert parent for the new alert, or alert is placed under the report
- //! @return created alert or NULL if Message_Info is not active in report
- static Standard_EXPORT Handle(Message_Alert) AddAlert (const Handle(Message_Report)& theReport,
- const Handle(Message_Attribute)& theAttribute,
- Message_PerfMeter* thePerfMeter,
- const Handle(Message_Alert)& theParentAlert = Handle(Message_Alert)());
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
-
-protected:
- //! Sets performance meter
- //! \param theMeter instance pointer or NULL
- void SetPerfMeter (Message_PerfMeter* theMeter) { myPerfMeter = theMeter; }
-
-protected:
-
- Handle(Message_CompositeAlerts) myCompositAlerts; //!< class provided hierarchical structure of alerts
- //!< It should be created by an attempt of a child alert creation
-
- Handle(Message_Attribute) myAttribute; //!< container of the alert attributes
-
- Message_PerfMeter* myPerfMeter; //!< performance meter
- Standard_Real myMetricStart; //!< value on start metric computation
- Standard_Real myMetricStop; //!< value on stop metric computation
-
- friend Message_PerfMeter;
-};
-
-#endif // _Message_Alert_HeaderFile
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_Alerts_HeaderFile
-#define _Message_Alerts_HeaderFile
-
-#include <Message.hxx>
-#include <Message_AlertExtended.hxx>
-#include <Message_AttributeObject.hxx>
-#include <Message_AttributeStream.hxx>
-#include <Message_Gravity.hxx>
-#include <Message_Report.hxx>
-
-#include <NCollection_Vector.hxx>
-#include <TCollection_AsciiString.hxx>
-
-static Handle(Message_Alert) OCCT_Message_Alert;
-
-#define MESSAGE_INFO(Name, Description, PerfMeter, ParentAlert) \
- { \
- if (!Message_Report::CurrentReport().IsNull() && \
- Message_Report::CurrentReport()->IsActive (Message_Info)) \
- { \
- OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
- new Message_Attribute (Name, Description), PerfMeter, ParentAlert); \
- } \
- }
-
-#define MESSAGE_INFO_OBJECT(Object, StreamValues, Name, Description, PerfMeter, ParentAlert) \
- { \
- if (!Message_Report::CurrentReport().IsNull() && \
- Message_Report::CurrentReport()->IsActive (Message_Info)) \
- { \
- OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
- new Message_AttributeObject (Object, StreamValues, Name, Description), PerfMeter, ParentAlert ); \
- } \
- }
-
-#define MESSAGE_INFO_STREAM(StreamValues, Name, Description, PerfMeter, ParentAlert) \
- { \
- if (!Message_Report::CurrentReport().IsNull() && \
- Message_Report::CurrentReport()->IsActive (Message_Info)) \
- { \
- OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
- new Message_AttributeStream (StreamValues, Name, Description), PerfMeter, ParentAlert ); \
- } \
- }
-
-//#define DUMP_VALUE(OS, Value) \
-// { \
-// OS << Value << Message::DumpSeparator(); \
-// }
-//
-//#define DUMP_VALUES_COLUMNS(OS, ObjectName, ColumnCount) \
-// { \
-// OS << ObjectName << Message::DumpSeparator() << ColumnCount << Message::DumpSeparator(); \
-// }
-//
-//#define DUMP_VALUES(OS, Value1, Value2) \
-// { \
-// OS << Value1 << Message::DumpSeparator() << Value2 << Message::DumpSeparator(); \
-// }
-//
-//#define DUMP_VEC_COLOR(Values, Value) \
-// { \
-// Value = Message::ColorVectorToString (aValues); \
-// }
-//
-//#define DUMP_VEC_COLOR_SPLIT(Value, Values) \
-// { \
-// Message::ColorVectorFromString (Value, Values); \
-// }
-//
-//#define DUMP_VEC_COORD(Values, Value) \
-// { \
-// Value = Message::CoordVectorToString (aValues); \
-// }
-//
-//#define DUMP_VEC_COORD_SPLIT(Value, Values) \
-// { \
-// Message::CoordVectorFromString (Value, Values); \
-// }
-//
-//
-//#define DUMP_VALUES_SPLIT(OS, ColumnCount, Values) \
-// { \
-// Message::ConvertStream (OS, aColumnCount, aValues); \
-// }
-
-#endif // _Message_Alerts_HeaderFile
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <Message_Attribute.hxx>
-
-#include <Standard_Assert.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
-
-//=======================================================================
-//function : GetMessageKey
-//purpose :
-//=======================================================================
-
-Standard_CString Message_Attribute::GetMessageKey () const
-{
- return !myName.IsEmpty() ? myName.ToCString() : "";
-}
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_Attribute_HeaderFile
-#define _Message_Attribute_HeaderFile
-
-#include <Standard_Transient.hxx>
-#include <TCollection_AsciiString.hxx>
-
-DEFINE_STANDARD_HANDLE(Message_Attribute, Standard_Transient)
-
-//! Additional information of extended alert attribute
-//! To provide other custom attribute container, it might be redefined.
-class Message_Attribute : public Standard_Transient
-{
-public:
- //! Empty constructor
- Standard_EXPORT Message_Attribute (const TCollection_AsciiString& theName = TCollection_AsciiString(),
- const TCollection_AsciiString& theDescription = TCollection_AsciiString())
- : myName (theName), myDescription (theDescription) {}
-
- //! Return a C string to be used as a key for generating text user
- //! messages describing this alert.
- //! The messages are generated with help of Message_Msg class, in
- //! Message_Report::Dump().
- //! Base implementation returns dynamic type name of the instance.
- virtual Standard_EXPORT Standard_CString GetMessageKey () const;
-
- //! Returns custom name of alert if it is set
- //! @return alert name
- const TCollection_AsciiString& GetName() const { return myName; }
-
- //! Sets the custom name of alert
- //! @param theName a name for the alert
- void SetName (const TCollection_AsciiString& theName) { myName = theName; }
-
- //! Sets desription of alert
- //! @param theName a name for the alert
- void SetDescription (const TCollection_AsciiString& theDescription) { myDescription = theDescription; }
-
- //! Returns description of alert if it is set
- //! @return alert description
- virtual const TCollection_AsciiString& GetDescription() const { return myDescription; }
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
-
-private:
-
- TCollection_AsciiString myName; //!< alert name, if defined is used in GetMessageKey
- TCollection_AsciiString myDescription; //!< alert description if defined
-
-};
-
-#endif // _Message_Attribute_HeaderFile
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <Message_AttributeObject.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
-
-//=======================================================================
-//function : Message_AttributeObject
-//purpose :
-//=======================================================================
-
-Message_AttributeObject::Message_AttributeObject (const Handle(Standard_Transient)& theObject,
- const Standard_SStream& theStream,
- const TCollection_AsciiString& theName,
- const TCollection_AsciiString& theDescription)
-: Message_AttributeStream (theStream, theName, theDescription)
-{
- myObject = theObject;
-}
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_AttributeObject_HeaderFile
-#define _Message_AttributeObject_HeaderFile
-
-#include <Message_AttributeStream.hxx>
-#include <TCollection_AsciiString.hxx>
-
-//! Alert object storing Transient object in its field
-class Message_AttributeObject : public Message_AttributeStream
-{
-public:
- //! Constructor with string argument
- Standard_EXPORT Message_AttributeObject (const Handle(Standard_Transient)& theObject,
- const Standard_SStream& theStream,
- const TCollection_AsciiString& theName = TCollection_AsciiString(),
- const TCollection_AsciiString& theDescription = TCollection_AsciiString());
-
- //! Sets the object
- //! @param theObject an instance
- void SetObject (const Handle(Standard_Transient)& theObject) { myObject = theObject; }
-
- //! Returns object
- Handle(Standard_Transient) GetObject() const { return myObject; }
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
-
-private:
- Handle(Standard_Transient) myObject;
-};
-
-#endif // _Message_AttributeObject_HeaderFile
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <Message_AttributeStream.hxx>
-
-#include <Message.hxx>
-#include <Message_Msg.hxx>
-#include <Message_PerfMeter.hxx>
-#include <Message_Report.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
-
-//=======================================================================
-//function : SetValues
-//purpose :
-//=======================================================================
-Message_AttributeStream::Message_AttributeStream (const Standard_SStream& theStream,
- const TCollection_AsciiString& theName,
- const TCollection_AsciiString& theDescription)
-: Message_Attribute(theName, theDescription)
-{
- SetStream (theStream);
-}
-
-//=======================================================================
-//function : SetStream
-//purpose :
-//=======================================================================
-
-void Message_AttributeStream::SetStream (const Standard_SStream& theStream)
-{
- TCollection_AsciiString aStreamStr (theStream.str().c_str());
- myStream << aStreamStr;
-}
-
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_AttributeStream_HeaderFile
-#define _Message_AttributeStream_HeaderFile
-
-#include <Message_Attribute.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <NCollection_Vector.hxx>
-
-class Message_PerfMeter;
-class Message_Report;
-
-//! Alert object storing container of Standard_Real values in its field
-class Message_AttributeStream : public Message_Attribute
-{
-public:
-
- //! Constructor with string argument
- Standard_EXPORT Message_AttributeStream (const Standard_SStream& theStream,
- const TCollection_AsciiString& theName = TCollection_AsciiString(),
- const TCollection_AsciiString& theDescription = TCollection_AsciiString());
-
- //! Sets stream value
- Standard_EXPORT void SetStream (const Standard_SStream& theStream);
-
- //! Returns stream value
- const Standard_SStream& GetStream() const { return myStream; }
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
-
-private:
- Standard_SStream myStream; //!< container of values
-};
-
-#endif // _Message_AttributeStream_HeaderFile
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <Message_CompositeAlerts.hxx>
-#include <Message_AlertExtended.hxx>
-#include <Standard_Assert.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_CompositeAlerts, Standard_Transient)
-
-//=======================================================================
-//function : Merge
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message_CompositeAlerts::Merge (const Handle(Message_Alert)& theTarget)
-{
- Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theTarget);
- if (!anExtAlert.IsNull() && !anExtAlert->GetCompositeAlerts().IsNull())
- {
- Handle(Message_CompositeAlerts) anExtCompositeAlert = anExtAlert->GetCompositeAlerts();
- // hierarchical alerts can not be merged
- for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
- {
- if (!GetAlerts ((Message_Gravity)iGravity).IsEmpty() ||
- !anExtCompositeAlert->GetAlerts ((Message_Gravity)iGravity).IsEmpty())
- return Standard_False;
- }
- }
- // by default, merge trivially
- return Standard_True;
-}
-
-//=======================================================================
-//function : GetAlerts
-//purpose :
-//=======================================================================
-
-Message_ListOfAlert& Message_CompositeAlerts::GetAlerts (const Message_Gravity theGravity)
-{
- return myChildAlerts[theGravity];
-}
-
-//=======================================================================
-//function : HasAlerts
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message_CompositeAlerts::HasAlert (const Handle(Message_Alert)& theAlert)
-{
- for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
- {
- Message_ListOfAlert& anAlerts = GetAlerts ((Message_Gravity)iGravity);
- if (anAlerts.Contains (theAlert))
- return Standard_True;
- }
- return Standard_False;
-}
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_CompositeAlerts_HeaderFile
-#define _Message_CompositeAlerts_HeaderFile
-
-#include <Message_Alert.hxx>
-#include <Message_Gravity.hxx>
-#include <Message_ListOfAlert.hxx>
-#include <Standard_Transient.hxx>
-
-class Message_CompositeAlerts;
-DEFINE_STANDARD_HANDLE(Message_CompositeAlerts, Standard_Transient)
-
-//! Base class of the hierarchy of classes describing various situations
-//! occurring during execution of some algorithm or procedure.
-//!
-//! Alert should provide unique text identifier that can be used to distinguish
-//! particular type of alerts, e.g. to get text message string describing it.
-//! See method GetMessageKey(); by default, dynamic type name is used.
-//!
-//! Alert can contain some data. To avoid duplication of data, new alert
-//! can be merged with another one of the same type. Method SupportsMerge()
-//! should return true if merge is supported; method Merge() should do the
-//! merge if possible and return true in that case and false otherwise.
-//!
-class Message_CompositeAlerts : public Standard_Transient
-{
-public:
- //! Empty constructor
- Standard_EXPORT Message_CompositeAlerts () {}
-
- //! If possible, merge data contained in this alert to theTarget.
- //! @return True if merged.
- //! Base implementation always returns true.
- virtual Standard_EXPORT Standard_Boolean Merge (const Handle(Message_Alert)& theTarget);
-
- //! Returns list of collected alerts with specified gravity
- Standard_EXPORT Message_ListOfAlert& GetAlerts (const Message_Gravity theGravity);
-
- //! Returns true if the alert belong the list of the child alerts.
- //! \param theAlert an alert to be checked as a child alert
- //! \return true if the alert is found in a container of children
- Standard_EXPORT Standard_Boolean HasAlert (const Handle(Message_Alert)& theAlert);
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(Message_CompositeAlerts,Standard_Transient)
-
-protected:
- // store messages in a lists sorted by gravity;
- // here we rely on knowledge that Message_Fail is the last element of the enum
- Message_ListOfAlert myChildAlerts[Message_Fail + 1];
-};
-
-#endif // _Message_CompositeAlerts_HeaderFile
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <Message_PerfMeter.hxx>
-
-#include <Message_AlertExtended.hxx>
-#include <Message_CompositeAlerts.hxx>
-
-#include <OSD_Chronometer.hxx>
-#include <OSD_MemInfo.hxx>
-
-//=======================================================================
-//function : Destructor
-//purpose :
-//=======================================================================
-
-Message_PerfMeter::~Message_PerfMeter()
-{
- releaseAlert (0);
-}
-
-//=======================================================================
-//function : GetAlert
-//purpose :
-//=======================================================================
-
-Handle(Message_AlertExtended) Message_PerfMeter::GetAlert (const Standard_Integer theLevelId) const
-{
- if (!myActiveAlerts.IsBound (theLevelId))
- return Handle(Message_AlertExtended)();
-
- return myActiveAlerts.Find (theLevelId).myAlert;
-}
-
-//=======================================================================
-//function : AddAlert
-//purpose :
-//=======================================================================
-
-void Message_PerfMeter::AddAlert (const Handle(Message_Alert)& theAlert,
- const Message_PerfMeterMode theMode)
-{
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anExtendedAlert.IsNull())
- return;
-
- if (myActiveAlerts.IsEmpty())
- {
- setAlert (0, theAlert, theMode);
- return;
- }
-
- Standard_Integer aSize = myActiveAlerts.Size();
- // looking for the parent of the parameter alert to release the previous alert
- for (Standard_Integer aLevelId = 0; aLevelId < aSize; aLevelId++)
- {
- Handle(Message_AlertExtended) anAlert = GetAlert (aLevelId);
- Handle(Message_CompositeAlerts) aCompositeAlert = anAlert->GetCompositeAlerts();
- Standard_ASSERT_RETURN (! aCompositeAlert.IsNull(), "Any alert of the performance meter has composite and children",);
- if (!aCompositeAlert->HasAlert (theAlert))
- continue;
- // parent alert is found
- if (myActiveAlerts.IsBound (aLevelId + 1))
- releaseAlert (aLevelId + 1);
-
- setAlert (aLevelId + 1, theAlert, theMode);
- return;
- }
- Standard_Boolean isDone = Standard_True;
- Standard_ASSERT_RETURN (!isDone, "Alert should be processed above",);
-}
-
-//=======================================================================
-//function : setAlert
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message_PerfMeter::setAlert (const Standard_Integer theLevelId,
- const Handle(Message_Alert)& theAlert,
- const Message_PerfMeterMode theMode)
-{
- if (!GetAlert (theLevelId).IsNull())
- return Standard_False;
-
- Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anAlertExtended.IsNull())
- return Standard_False;
-
- myActiveAlerts.Bind (theLevelId, AlertInfo (anAlertExtended, getCurrentInfo (theMode)));
- anAlertExtended->SetPerfMeter (this);
- myMode = theMode;
- return Standard_True;
-}
-
-//=======================================================================
-//function : releaseAlert
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message_PerfMeter::releaseAlert (const Standard_Integer theLevelId)
-{
- // release alerts from the tail till the given alert
- for (Standard_Integer aLevelId = myActiveAlerts.Extent() - 1; aLevelId >= theLevelId; aLevelId--)
- {
- if (!myActiveAlerts.IsBound (aLevelId))
- continue;
- stopAlert (aLevelId);
- }
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : stopAlert
-//purpose :
-//=======================================================================
-
-Standard_Boolean Message_PerfMeter::stopAlert (const Standard_Integer theLevelId)
-{
- if (!myActiveAlerts.IsBound (theLevelId))
- return Standard_False;
-
- AlertInfo anAlertInfo = myActiveAlerts.Find (theLevelId);
- Handle(Message_AlertExtended) anExtendedAlert = anAlertInfo.myAlert;
-
- anExtendedAlert->SetMetricValues (anAlertInfo.myStartValue, getCurrentInfo(myMode));
- anExtendedAlert->SetPerfMeter (0);
- myActiveAlerts.UnBind (theLevelId);
-
- return Standard_True;
-}
-
-//=======================================================================
-//function : getLevel
-//purpose :
-//=======================================================================
-
-Standard_Integer Message_PerfMeter::getLevel (const Handle(Message_Alert)& theAlert)
-{
- for (NCollection_DataMap<Standard_Integer, AlertInfo>::Iterator anIterator (myActiveAlerts);
- anIterator.More(); anIterator.Next())
- {
- if (anIterator.Value().myAlert == theAlert)
- return anIterator.Key();
- }
- return -1;
-}
-
-//=======================================================================
-//function : getCurrentInfo
-//purpose :
-//=======================================================================
-
-Standard_Real Message_PerfMeter::getCurrentInfo (const Message_PerfMeterMode theMode)
-{
- if (theMode == Message_PerfMeterMode_UserTimeCPU ||
- theMode == Message_PerfMeterMode_SystemTimeInfo)
- {
- Standard_Real aUserSeconds, aSystemSeconds;
- OSD_Chronometer::GetThreadCPU (aUserSeconds, aSystemSeconds);
- return theMode == Message_PerfMeterMode_UserTimeCPU ? aUserSeconds : aSystemSeconds;
- }
-
- OSD_MemInfo::Counter aType;
- switch (theMode)
- {
- case Message_PerfMeterMode_MemPrivate: aType = OSD_MemInfo::MemPrivate; break;
- case Message_PerfMeterMode_MemVirtual: aType = OSD_MemInfo::MemVirtual; break;
- case Message_PerfMeterMode_MemWorkingSet: aType = OSD_MemInfo::MemWorkingSet; break;
- case Message_PerfMeterMode_MemWorkingSetPeak: aType = OSD_MemInfo::MemWorkingSetPeak; break;
- case Message_PerfMeterMode_MemSwapUsage: aType = OSD_MemInfo::MemSwapUsage; break;
- case Message_PerfMeterMode_MemSwapUsagePeak: aType = OSD_MemInfo::MemSwapUsagePeak; break;
- case Message_PerfMeterMode_MemHeapUsage: aType = OSD_MemInfo::MemHeapUsage; break;
- default: return Message_AlertExtended::GetUndefinedMetric(); break;
- }
-
- OSD_MemInfo aMemInfo (Standard_False);
- aMemInfo.Update (aType);
- return (Standard_Real)aMemInfo.ValuePreciseMiB (aType);
-}
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _Message_PerfMeter_HeaderFile
-#define _Message_PerfMeter_HeaderFile
-
-#include <Message_AlertExtended.hxx>
-#include <Message_Gravity.hxx>
-#include <Message_PerfMeterMode.hxx>
-
-#include <NCollection_DataMap.hxx>
-#include <Standard.hxx>
-
-//! This class is performance meter for message alerts. The usage is create the simple instance of it (not a pointer)
-//! in a method. Finalizing of the method will call destructor of the meter and store time into alert.
-class Message_PerfMeter
-{
-
-public:
- //! Constructs and starts (if autoStart is true) the named meter
- //! One string key is used for all alert meters. The perf meter is not started automatically, it will be done in
- //! AddAlert method
- Message_PerfMeter() : myGravity (Message_Info), myMode (Message_PerfMeterMode_None) {}
-
- //! Assures stopping upon destruction
- Standard_EXPORT ~Message_PerfMeter();
-
- //! Returns message alert on the level, by default the upper alert is returned
- //! \param theLevelId a level of child position inside the upper alert of performance meter
- //! \return alert instance or NULL
- Handle(Message_AlertExtended) GetAlert (const Standard_Integer theLevelId = 0) const;
-
- //! Processes the parameter alert. There are some variants:
- //! - current alert is NULL, the alert becomes the current one and perf meter is started
- //! - last alert of the current alert is stopped (perf meter becomes NULL, time is calculated),
- //! the parameter alert is started (perf meter becomes the current one)
- Standard_EXPORT void AddAlert (const Handle(Message_Alert)& theAlert,
- const Message_PerfMeterMode theMode);
-
-protected:
-
- //! Sets message alert on the level
- //! \param theLevelId a level of child position inside the upper alert of performance meter
- //! \param theAlert an alert to be stored
- //! \return true if succeeded, false if there is stored alert on the given level
- Standard_Boolean setAlert (const Standard_Integer theLevelId,
- const Handle(Message_Alert)& theAlert,
- const Message_PerfMeterMode theMode);
-
- //! Stop alert, store time into the alert and last child alert
- //! \param theLevelId a level of child position inside the upper alert of performance meter
- Standard_Boolean releaseAlert (const Standard_Integer theLevelId);
-
- //! Sets NULL perf meter and parameter time into the alert
- //! \param theLevelId a level of child position inside the upper alert of performance meter
- Standard_Boolean stopAlert (const Standard_Integer theLevelId);
-
- //! Returns level of given alert if it participates in the performance meter
- //! \param theAlert modified alert
- //! \return level value or -1
- Standard_Integer getLevel (const Handle(Message_Alert)& theAlert);
-
- //! Returns cumulative info of the performance meter
- //! \param theMeterId a performance meter index
- //! \return time value
- static Standard_Real getCurrentInfo (const Message_PerfMeterMode theMode);
-
-protected:
- //! Struct to store start time for the alert
- struct AlertInfo
- {
- AlertInfo (const Handle(Message_AlertExtended)& theAlert, Standard_Real theStartValue)
- : myAlert (theAlert), myStartValue (theStartValue) {}
-
- Handle(Message_AlertExtended) myAlert; //!< an alert
- Standard_Real myStartValue; //!< start alert information
- };
-
- NCollection_DataMap<Standard_Integer, AlertInfo> myActiveAlerts; //!< container of current alerts
- Message_Gravity myGravity; //!< perf meter alert gravity
- Message_PerfMeterMode myMode; //!< mode to define which information to collect
-};
-
-
-#endif // _Message_PerfMeter_HeaderFile
+++ /dev/null
-// Created on: 2019-08-13
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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 _Message_PerfMeterMode_HeaderFile
-#define _Message_PerfMeterMode_HeaderFile
-
-//! Specifies kind of report information to collect
-enum Message_PerfMeterMode
-{
- Message_PerfMeterMode_None, //!< no computation
- Message_PerfMeterMode_UserTimeCPU, //!< the current CPU user time in seconds
- Message_PerfMeterMode_SystemTimeInfo, //!< the current CPU system time in seconds
- Message_PerfMeterMode_MemPrivate, //!< OSD_MemInfo::MemPrivate
- Message_PerfMeterMode_MemVirtual, //!< OSD_MemInfo::MemVirtual
- Message_PerfMeterMode_MemWorkingSet, //!< OSD_MemInfo::MemWorkingSet
- Message_PerfMeterMode_MemWorkingSetPeak, //!< OSD_MemInfo::MemWorkingSetPeak
- Message_PerfMeterMode_MemSwapUsage, //!< OSD_MemInfo::MemSwapUsage
- Message_PerfMeterMode_MemSwapUsagePeak, //!< OSD_MemInfo::MemSwapUsagePeak
- Message_PerfMeterMode_MemHeapUsage //!< OSD_MemInfo::MemHeapUsage
-};
-
-#endif // _Message_PerfMeterKind_HeaderFile
// commercial license or contractual agreement.
#include <Message_Report.hxx>
-
-#include <Message_AlertExtended.hxx>
-#include <Message_CompositeAlerts.hxx>
#include <Message_Msg.hxx>
#include <Message_Messenger.hxx>
-#include <Message_PerfMeter.hxx>
-#include <Message_ReportCallBack.hxx>
-
#include <NCollection_Map.hxx>
-#include <Precision.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
-static Handle(Message_Report) MyReport;
-
//=======================================================================
//function : Message_Report
//purpose :
//=======================================================================
Message_Report::Message_Report ()
-: myPerfMeterMode (Message_PerfMeterMode_None), myLimit (-1)
-{
- SetActive (Standard_True);
-}
-
-//=======================================================================
-//function : CurrentReport
-//purpose :
-//=======================================================================
-Handle(Message_Report) Message_Report::CurrentReport(const Standard_Boolean theToCreate)
{
- if (MyReport.IsNull() && theToCreate)
- MyReport = new Message_Report();
-
- return MyReport;
}
//=======================================================================
void Message_Report::AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert)
{
- if (!IsActive (theGravity))
- return;
-
Standard_ASSERT_RETURN (! theAlert.IsNull(), "Attempt to add null alert",);
Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]),
"Adding alert with gravity not in valid range",);
// if not merged, just add to the list
aList.Append (theAlert);
-
- if (!myCallBack.IsNull())
- myCallBack->Update (theAlert);
-}
-
-//=======================================================================
-//function : AddAlert
-//purpose :
-//=======================================================================
-
-void Message_Report::AddAlert (const Message_Gravity theGravity, const Handle(Message_Alert)& theAlert,
- Message_PerfMeter* thePerfMeter, const Handle(Message_Alert)& theParentAlert)
-{
- if (!IsActive (theGravity))
- return;
-
- Standard_ASSERT_RETURN (!theAlert.IsNull(), "Attempt to add null alert",);
- Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]),
- "Adding alert with gravity not in valid range",);
-
- Standard_Mutex::Sentry aSentry (myMutex);
-
- // iterate by already recorded alerts and try to merge new one with one of those
- Handle(Message_Alert) aParentAlert = theParentAlert;
- if (aParentAlert.IsNull() && thePerfMeter)
- aParentAlert = thePerfMeter->GetAlert();
- if (aParentAlert.IsNull())
- aParentAlert = getLastAlertInPerfMeter(theGravity);
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(aParentAlert);
- Handle(Message_CompositeAlerts) aCompositeAlert = !anExtendedAlert.IsNull() ? anExtendedAlert->GetCompositeAlerts (Standard_True)
- : Handle(Message_CompositeAlerts)();
- Message_ListOfAlert& aList = !aCompositeAlert.IsNull() ? aCompositeAlert->GetAlerts (theGravity) : myAlerts[theGravity];
-
- if (theAlert->SupportsMerge() && !aList.IsEmpty())
- {
- // merge is performed only for alerts of exactly same type and same name
- const Handle(Standard_Type)& aType = theAlert->DynamicType();
- for (Message_ListOfAlert::Iterator anIt(aList); anIt.More(); anIt.Next())
- {
- // if merged successfully, just return
- if (aType == anIt.Value()->DynamicType() && theAlert->Merge (anIt.Value()))
- return;
- }
- }
-
- // if not merged, just add to the list
- aList.Append (theAlert);
- // remove alerts under the report only
- if (theParentAlert.IsNull() && aParentAlert.IsNull() && myLimit > 0 && aList.Extent() > myLimit)
- aList.RemoveFirst();
-
- if (thePerfMeter)
- thePerfMeter->AddAlert (theAlert, PerfMeterMode());
-
- if (!myCallBack.IsNull())
- myCallBack->Update(theAlert);
}
//=======================================================================
return myAlerts[theGravity];
}
-//=======================================================================
-//function : CumulativeMetric
-//purpose :
-//=======================================================================
-
-Standard_Real Message_Report::CumulativeMetric (const Message_Gravity theGravity) const
-{
- switch (myPerfMeterMode)
- {
- case Message_PerfMeterMode_None: return 0.0;
- case Message_PerfMeterMode_UserTimeCPU:
- case Message_PerfMeterMode_SystemTimeInfo:
- {
- Standard_Real aStartTime = Message_AlertExtended::GetUndefinedMetric();
- Standard_Boolean isFound = Standard_False;
- for (Message_ListOfAlert::Iterator anAlertsIt (GetAlerts (theGravity)); anAlertsIt.More(); anAlertsIt.Next())
- {
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlertsIt.Value());
- if (anExtendedAlert.IsNull() && anExtendedAlert->IsMetricValid())
- {
- aStartTime = anExtendedAlert->MetricStart();
- isFound = Standard_True;
- break;
- }
- }
- if (!isFound)
- return 0.0;
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(getLastAlert (theGravity));
- if (anExtendedAlert.IsNull() || !anExtendedAlert->IsMetricValid())
- return 0.0;
-
- return anExtendedAlert->MetricStop() - aStartTime;
- }
- case Message_PerfMeterMode_MemPrivate:
- case Message_PerfMeterMode_MemVirtual:
- case Message_PerfMeterMode_MemWorkingSet:
- {
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(getLastAlert (theGravity));
- if (!anExtendedAlert.IsNull())
- return anExtendedAlert->MetricStop();
- }
- }
- return 0.0;
-}
-
-//=======================================================================
-//function : getLastAlert
-//purpose :
-//=======================================================================
-
-Handle(Message_Alert) Message_Report::getLastAlert (const Message_Gravity theGravity) const
-{
- if (!IsActive (theGravity))
- return Handle(Message_Alert)();
-
- const Message_ListOfAlert& anAlerts = GetAlerts (theGravity);
- if (anAlerts.IsEmpty())
- return Handle(Message_Alert)();
-
- Handle(Message_Alert) aLastAlert = anAlerts.Last();
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
- if (anExtendedAlert.IsNull())
- return aLastAlert;
- Handle(Message_CompositeAlerts) aCompositeAlert = anExtendedAlert->GetCompositeAlerts (Standard_True);
- if (aCompositeAlert.IsNull())
- return aLastAlert;
-
- while (!aCompositeAlert.IsNull() && !aCompositeAlert->GetAlerts (theGravity).IsEmpty())
- {
- Handle(Message_Alert) anAlert = aCompositeAlert->GetAlerts (theGravity).Last();
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (anAlert);
- if (anExtendedAlert.IsNull())
- {
- aLastAlert = anAlert;
- break;
- }
-
- aLastAlert = anExtendedAlert;
- aCompositeAlert = anExtendedAlert->GetCompositeAlerts();
- }
-
- // if alert has perf meter, use as the last alert, an alert of the perf meter
- anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
- if (anExtendedAlert.IsNull())
- return aLastAlert;
-
- return aLastAlert;
-}
-
-//=======================================================================
-//function : getLastAlertInPerfMeter
-//purpose :
-//=======================================================================
-
-Handle(Message_Alert) Message_Report::getLastAlertInPerfMeter (const Message_Gravity theGravity) const
-{
- if (!IsActive (theGravity))
- return Handle(Message_Alert)();
-
- const Message_ListOfAlert& anAlerts = GetAlerts (theGravity);
- if (anAlerts.IsEmpty())
- return Handle(Message_Alert)();
-
- Handle(Message_Alert) aLastAlert = anAlerts.Last();
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
- if (anExtendedAlert.IsNull())
- return aLastAlert;
- Handle(Message_CompositeAlerts) aCompositeAlert = anExtendedAlert->GetCompositeAlerts (Standard_True);
- if (aCompositeAlert.IsNull())
- return aLastAlert;
-
- Standard_Boolean aHasPerfMeter = anExtendedAlert->GetPerfMeter() != NULL;
- if (!aHasPerfMeter) // the alert has finished and is not the last alert anymore
- return Handle(Message_Alert)();
-
- while (!aCompositeAlert.IsNull() && !aCompositeAlert->GetAlerts (theGravity).IsEmpty())
- {
- Handle(Message_Alert) anAlert = aCompositeAlert->GetAlerts (theGravity).Last();
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (anAlert);
- if (anExtendedAlert.IsNull())
- {
- if (!aHasPerfMeter) // if there is a perf meter, use alert of it
- aLastAlert = anAlert;
- break;
- }
-
- if (!aHasPerfMeter)
- aHasPerfMeter = anExtendedAlert->GetPerfMeter() != NULL;
- else if (!anExtendedAlert->GetPerfMeter())
- break; // last alert is the previous alert where perf meter is not NULL
-
- aLastAlert = anExtendedAlert;
- aCompositeAlert = anExtendedAlert->GetCompositeAlerts();
- }
-
- // if alert has perf meter, use as the last alert, an alert of the perf meter
- anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
- if (anExtendedAlert.IsNull())
- return aLastAlert;
- //if (anExtendedAlert->GetPerfMeter())
- // aLastAlert = anExtendedAlert->GetPerfMeter()->GetAlert();
-
- return aLastAlert;
-}
-
//=======================================================================
//function : HasAlert
//purpose :
AddAlert (theGravity, anIt.Value());
}
}
-
-//=======================================================================
-//function : SetActive
-//purpose :
-//=======================================================================
-
-void Message_Report::SetActive (const Standard_Boolean theActive, const Standard_Integer theGravity)
-{
- if (theGravity < 0)
- {
- for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
- SetActive (theActive, iGravity);
- return;
- }
-
- Standard_ASSERT_RETURN (theGravity >= 0 && size_t (theGravity) < sizeof (myAlerts) / sizeof (myAlerts[0]),
- "Set active report with gravity not in valid range", );
- myIsActive[theGravity] = theActive;
-}
#include <Message_Gravity.hxx>
#include <Message_ListOfAlert.hxx>
-#include <Message_PerfMeterMode.hxx>
#include <Standard_Mutex.hxx>
class Message_Messenger;
-class Message_PerfMeter;
-class Message_Report;
-class Message_ReportCallBack;
-DEFINE_STANDARD_HANDLE(Message_Report, Standard_Transient)
+class Message_Report;
+DEFINE_STANDARD_HANDLE(Message_Report, MMgt_TShared)
//! Container for alert messages, sorted according to their gravity.
//!
//! Empty constructor
Standard_EXPORT Message_Report ();
- //! returns the only one instance of Report
- //! When theToCreate is true - automatically creates message report when not exist.
- //! that has been created.
- Standard_EXPORT static Handle(Message_Report) CurrentReport (const Standard_Boolean theToCreate = Standard_False);
-
//! Add alert with specified gravity.
//! This method is thread-safe, i.e. alerts can be added from parallel threads safely.
Standard_EXPORT void AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert);
- //! Add alert with specified gravity. The alert is a sub-alert of report or another alert
- //! The parent alert is the parameter alert or the last alert if found else report.
- //! \param theGravity a message gravity
- //! \param theAlert a new alert to be added
- //! \param thePerfMeter performance meter calculates the alert spent time and participate in searching the last alert if needed
- //! \param theParentAlert if not NULL specifies parent alert where the alert should be placed, if the parent is an extednded alert
- Standard_EXPORT void AddAlert (const Message_Gravity theGravity, const Handle(Message_Alert)& theAlert,
- Message_PerfMeter* thePerfMeter, const Handle(Message_Alert)& theParentAlert = Handle(Message_Alert)());
-
//! Returns list of collected alerts with specified gravity
Standard_EXPORT const Message_ListOfAlert& GetAlerts (Message_Gravity theGravity) const;
//! Merges alerts with specified gravity from theOther report into this
Standard_EXPORT void Merge (const Handle(Message_Report)& theOther, Message_Gravity theGravity);
- //! Returns a state whether the report is active
- //! \return the state
- Standard_Boolean IsActive (const Message_Gravity theGravity) const { return myIsActive[theGravity]; }
-
- //! Starts a timer to compute time between messages. If a timer has already been started, it will be stopped
- //! \param theActive new state of report active
- //! \param theGravity gravity type, if '-1', apply value for all gravity kinds
- Standard_EXPORT void SetActive (const Standard_Boolean theActive, const Standard_Integer theGravity = -1);
-
- //! Sets a perf meter mode
- //! \param theMode new mode
- Standard_EXPORT void SetPerfMeterMode (const Message_PerfMeterMode theMode)
- { myPerfMeterMode = theMode; }
-
- //! Returns mode of perf meter
- //! \return the state
- Standard_EXPORT Message_PerfMeterMode PerfMeterMode() const
- { return myPerfMeterMode; }
-
- //! Returns maximum number of collecting alerts. If the limit is achieved,
- //! adding of a new alert after removing the first cached alert.
- //! \return the limit value
- Standard_EXPORT Standard_Integer GetLimit() const { return myLimit; }
-
- //! Sets maximum number of collecting alerts.
- //! \return theLimit limit value
- Standard_EXPORT void SetLimit(const Standard_Integer theLimit) { myLimit = theLimit; }
-
- //! Returns the report cumulative metric. It includes time/mem of sub alerts depending on PerfMeter mode
- //! @return value
- Standard_EXPORT Standard_Real CumulativeMetric (const Message_Gravity theGravity) const;
-
- //! Sets a listener for the report events
- void SetCallBack(const Handle(Message_ReportCallBack)& theCallBack) { myCallBack = theCallBack; }
-
- //! Returns listener of the reports events
- const Handle(Message_ReportCallBack)& GetCallBack() const { return myCallBack; }
-
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
-protected:
- //! Returns last alert in list of report alerts or last alert in hierarchical tree of alerts provided by
- //! the last alert
- //! \parm theGravity a message gravity
- Standard_EXPORT Handle(Message_Alert) getLastAlert (const Message_Gravity theGravity) const;
-
- //! Returns last alert in list of report alerts or last alert in hierarchical tree of alerts provided by
- //! the last alert
- //! \parm theGravity a message gravity
- Standard_EXPORT Handle(Message_Alert) getLastAlertInPerfMeter (const Message_Gravity theGravity) const;
-
protected:
Standard_Mutex myMutex;
// store messages in a lists sorted by gravity;
// here we rely on knowledge that Message_Fail is the last element of the enum
Message_ListOfAlert myAlerts[Message_Fail + 1];
-
- Standard_Boolean myIsActive[Message_Fail + 1];
- Message_PerfMeterMode myPerfMeterMode; //! If true, each alert will store the mode information
- Standard_Integer myLimit; //! Maximum number of collected alerts
-
- Handle(Message_ReportCallBack) myCallBack; //! signal about performed modifications
};
#endif // _Message_Report_HeaderFile
+++ /dev/null
-// Created on: 2017-12-01
-// 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 "Message_ReportCallBack.hxx"
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_ReportCallBack, Standard_Transient)
-
-Message_ReportCallBack::Message_ReportCallBack ()
-{
-}
+++ /dev/null
-// Created on: 2017-12-01
-// 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 _Message_ReportCallBack_HeaderFile
-#define _Message_ReportCallBack_HeaderFile
-
-#include <Standard_Handle.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Type.hxx>
-
-class Message_Alert;
-class Message_ReportCallBack;
-DEFINE_STANDARD_HANDLE(Message_ReportCallBack, Standard_Transient)
-
-//! Interface to have possibility of processing message report events.
-class Message_ReportCallBack : public Standard_Transient
-{
-public:
-
- //! Empty constructor
- Standard_EXPORT Message_ReportCallBack ();
- ~Message_ReportCallBack () {}
-
- //! Interface to be implemented in the child to process the message report event
- //! \param theAlert created or modified message alert
- virtual void Update(const Handle(Message_Alert)& theAlert) = 0;
-
- //! OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(Message_ReportCallBack, Standard_Transient)
-};
-
-#endif // _Message_ReportCallBack_HeaderFile
#endif
}
-// =======================================================================
-// function : Update
-// purpose :
-// =======================================================================
-void OSD_MemInfo::Update (const OSD_MemInfo::Counter theCounter)
-{
-#ifndef OCCT_UWP
-#if defined(_WIN32)
-
- if (theCounter == MemVirtual)
- {
- #if (_WIN32_WINNT >= 0x0500)
- MEMORYSTATUSEX aStatEx;
- aStatEx.dwLength = sizeof(aStatEx);
- GlobalMemoryStatusEx (&aStatEx);
- myCounters[MemVirtual] = Standard_Size(aStatEx.ullTotalVirtual - aStatEx.ullAvailVirtual);
- #else
- MEMORYSTATUS aStat;
- aStat.dwLength = sizeof(aStat);
- GlobalMemoryStatus (&aStat);
- myCounters[MemVirtual] = Standard_Size(aStat.dwTotalVirtual - aStat.dwAvailVirtual);
- #endif
-
- return;
- }
-
- if (theCounter == MemPrivate ||
- theCounter == MemWorkingSet ||
- theCounter == MemWorkingSetPeak ||
- theCounter == MemSwapUsage ||
- theCounter == MemSwapUsagePeak)
- {
- // use Psapi library
- HANDLE aProcess = GetCurrentProcess();
- #if (_WIN32_WINNT >= 0x0501)
- PROCESS_MEMORY_COUNTERS_EX aProcMemCnts;
- #else
- PROCESS_MEMORY_COUNTERS aProcMemCnts;
- #endif
- if (GetProcessMemoryInfo (aProcess, (PROCESS_MEMORY_COUNTERS* )&aProcMemCnts, sizeof(aProcMemCnts)))
- {
- #if (_WIN32_WINNT >= 0x0501)
- myCounters[MemPrivate] = aProcMemCnts.PrivateUsage;
- #endif
- myCounters[MemWorkingSet] = aProcMemCnts.WorkingSetSize;
- myCounters[MemWorkingSetPeak] = aProcMemCnts.PeakWorkingSetSize;
- myCounters[MemSwapUsage] = aProcMemCnts.PagefileUsage;
- myCounters[MemSwapUsagePeak] = aProcMemCnts.PeakPagefileUsage;
- }
- return;
- }
-
- if (theCounter == MemHeapUsage)
- {
- _HEAPINFO hinfo;
- int heapstatus;
- hinfo._pentry = NULL;
-
- myCounters[MemHeapUsage] = 0;
- while((heapstatus = _heapwalk(&hinfo)) == _HEAPOK)
- {
- if(hinfo._useflag == _USEDENTRY)
- myCounters[MemHeapUsage] += hinfo._size;
- }
- return;
- }
-
-#elif (defined(__linux__) || defined(__linux))
-/*
- // use procfs on Linux
- char aBuff[4096];
- snprintf (aBuff, sizeof(aBuff), "/proc/%d/status", getpid());
- std::ifstream aFile;
- aFile.open (aBuff);
- if (!aFile.is_open())
- {
- return;
- }
-
- while (!aFile.eof())
- {
- memset (aBuff, 0, sizeof(aBuff));
- aFile.getline (aBuff, 4096);
- if (aBuff[0] == '\0')
- {
- continue;
- }
-
- if (strncmp (aBuff, "VmSize:", strlen ("VmSize:")) == 0)
- {
- myCounters[MemVirtual] = atol (aBuff + strlen ("VmSize:")) * 1024;
- }
- //else if (strncmp (aBuff, "VmPeak:", strlen ("VmPeak:")) == 0)
- // myVirtualPeak = atol (aBuff + strlen ("VmPeak:")) * 1024;
- else if (strncmp (aBuff, "VmRSS:", strlen ("VmRSS:")) == 0)
- {
- myCounters[MemWorkingSet] = atol (aBuff + strlen ("VmRSS:")) * 1024; // RSS - resident set size
- }
- else if (strncmp (aBuff, "VmHWM:", strlen ("VmHWM:")) == 0)
- {
- myCounters[MemWorkingSetPeak] = atol (aBuff + strlen ("VmHWM:")) * 1024; // HWM - high water mark
- }
- else if (strncmp (aBuff, "VmData:", strlen ("VmData:")) == 0)
- {
- if (myCounters[MemPrivate] == Standard_Size(-1)) ++myCounters[MemPrivate];
- myCounters[MemPrivate] += atol (aBuff + strlen ("VmData:")) * 1024;
- }
- else if (strncmp (aBuff, "VmStk:", strlen ("VmStk:")) == 0)
- {
- if (myCounters[MemPrivate] == Standard_Size(-1)) ++myCounters[MemPrivate];
- myCounters[MemPrivate] += atol (aBuff + strlen ("VmStk:")) * 1024;
- }
- }
- aFile.close();
-
- struct mallinfo aMI = mallinfo();
- myCounters[MemHeapUsage] = aMI.uordblks;
-
-#elif (defined(__APPLE__))
- struct task_basic_info aTaskInfo;
- mach_msg_type_number_t aTaskInfoCount = TASK_BASIC_INFO_COUNT;
- if (task_info (mach_task_self(), TASK_BASIC_INFO,
- (task_info_t )&aTaskInfo, &aTaskInfoCount) == KERN_SUCCESS)
- {
- // On Mac OS X, these values in bytes, not pages!
- myCounters[MemVirtual] = aTaskInfo.virtual_size;
- myCounters[MemWorkingSet] = aTaskInfo.resident_size;
-
- //Getting malloc statistics
- malloc_statistics_t aStats;
- malloc_zone_statistics (NULL, &aStats);
-
- myCounters[MemHeapUsage] = aStats.size_in_use;
- }
-*/
-#endif
-#endif
-}
-
// =======================================================================
// function : ToString
// purpose :
//! Update counters
Standard_EXPORT void Update();
- //! Update counter of specified counter
- Standard_EXPORT void Update (const OSD_MemInfo::Counter theCounter);
-
//! Return the string representation for all available counter.
Standard_EXPORT TCollection_AsciiString ToString() const;
#include <OpenGl_Context.hxx>
#include <OpenGl_Workspace.hxx>
-#include <Graphic3d.hxx>
#include <Graphic3d_TypeOfReflection.hxx>
#include <Graphic3d_MaterialAspect.hxx>
myResSprite.Release (theContext);
myResProgram.Release (theContext);
}
-
-const TCollection_AsciiString OpenGl_Aspects_ClassName = "OpenGl_Aspects";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void OpenGl_Aspects::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, OpenGl_Aspects_ClassName);
-
- {
- Standard_SStream aTmpStream;
- myAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "Aspect", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "myShadingModel", Graphic3d::TypeOfShadingModelToString (myShadingModel));
-
- //mutable OpenGl_AspectsProgram myResProgram;
- //mutable OpenGl_AspectsTextureSet myResTextureSet;
- //mutable OpenGl_AspectsSprite myResSprite;
-
- DUMP_STOP_KEY (OS, OpenGl_Aspects_ClassName);
-}
//! Update presentation aspects parameters after their modification.
virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
protected:
//! OpenGl resources
OpenGl_Element::Destroy (theGlCtx.get(), myAspects);
}
-
-const TCollection_AsciiString OpenGl_Group_ClassName = "OpenGl_Group";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void OpenGl_Group::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, OpenGl_Group_ClassName);
-
- {
- Standard_SStream aTmpStream;
- Graphic3d_Group::Dump (aTmpStream);
- DUMP_VALUES (OS, "Graphic3d_Group", TCollection::ToDumpString (aTmpStream));
- }
-
- if (myAspects)
- {
- Standard_SStream aTmpStream;
- myAspects->Dump (aTmpStream);
- DUMP_VALUES (OS, "Aspects", TCollection::ToDumpString (aTmpStream));
- }
- //OpenGl_CappingPlaneResource* myAspectFillCapping;
- //OpenGl_ElementNode* myFirst;
- //OpenGl_ElementNode* myLast;
-
- DUMP_VALUES (OS, "myIsRaytracable", myIsRaytracable);
-
- DUMP_STOP_KEY (OS, OpenGl_Group_ClassName);
-}
//! Returns OpenGL capping filling aspect.
const OpenGl_CappingPlaneResource* AspectFillCapping() const { return myAspectFillCapping; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Standard_EXPORT virtual ~OpenGl_Group();
//
}
+//=======================================================================
+//function : ~OpenGl_LayerList
+//purpose : Destructor
+//=======================================================================
+
+OpenGl_LayerList::~OpenGl_LayerList()
+{
+}
+
//=======================================================================
//function : SetFrustumCullingBVHBuilder
//purpose :
#include <NCollection_Sequence.hxx>
#include <NCollection_DataMap.hxx>
-class OpenGl_FrameBuffer;
class OpenGl_Structure;
class OpenGl_Workspace;
-
struct OpenGl_GlobalLayerSettings;
//! Class defining the list of layers.
public:
//! Constructor
- Standard_EXPORT OpenGl_LayerList (const Standard_Integer theNbPriorities);
+ OpenGl_LayerList (const Standard_Integer theNbPriorities);
//! Destructor
- virtual ~OpenGl_LayerList() {}
+ virtual ~OpenGl_LayerList();
//! Method returns the number of available priorities
Standard_Integer NbPriorities() const { return myNbPriorities; }
#include <TopoDS_Shape.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
-namespace
-{
- static Standard_CString Prs3d_Table_PrintTypeOfHighlight[7] =
- {
- "NONE", "SELECTED", "DYNAMIC", "LOCAL_SELECTED", "LOCAL_DYNAMIC", "SUB_INTENSITY", "NB"
- };
-
- static Standard_CString Prs3d_Table_PrintTypeOfHLR[3] =
- {
- "NOT_SET", "POLY_ALGO", "ALGO"
- };
-
- static Standard_CString Prs3d_Table_PrintVertexDrawMode[3] =
- {
- "ISOLATED", "ALL", "INHERITED"
- };
-
- static Standard_CString Prs3d_Table_PrintDatumParts[11] =
- {
- "ORIGIN", "X_AXIS", "Y_AXIS", "Z_AXIS", "X_ARROW", "Y_ARROW", "Z_ARROW",
- "XOY_AXIS", "YOZ_AXIS", "XOZ_AXIS", "NONE"
- };
-
- static Standard_CString Prs3d_Table_PrintDatumAttribute[8] =
- {
- "X_AXIS_LENGTH", "Y_AXIS_LENGTH", "Z_AXIS_LENGTH", "SHADING_TUBE_RADIUS_PERCENT",
- "SHADING_CONE_RADIUS_PERCENT", "SHADING_CONE_LENGTH_PERCENT", "SHADING_ORIGIN_RADIUS_PERCENT",
- "SHADING_NUMBER_OF_FACETTES"
- };
-
- static Standard_CString Prs3d_Table_PrintDatumAxes[7] =
- {
- "X_AXIS", "Y_AXIS", "Z_AXIS", "XY_AXIS", "YZ_AXIS", "XZ_AXIS", "XYZ_AXIS"
- };
-
- static Standard_CString Prs3d_Table_PrintDimensionArrowOrientation[3] =
- {
- "INTERNAL", "EXTERNAL", "FIT"
- };
-
- static Standard_CString Prs3d_Table_PrintDimensionTextHorizontalPosition[4] =
- {
- "LEFT", "RIGHT", "CENTER", "FIT"
- };
-
- static Standard_CString Prs3d_Table_PrintDimensionTextVerticalPosition[3] =
- {
- "ABOVE", "BELOW", "CENTER"
- };
-}
-
//=======================================================================
//function : MatchSegment
//purpose :
aGroup->AddPrimitiveArray (aPrims);
}
}
-
-//=======================================================================
-//function : TypeOfHighlightToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::TypeOfHighlightToString (Prs3d_TypeOfHighlight theType)
-{
- return Prs3d_Table_PrintTypeOfHighlight[theType];
-}
-
-//=======================================================================
-//function : TypeOfHighlightFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::TypeOfHighlightFromString (Standard_CString theTypeString,
- Prs3d_TypeOfHighlight& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_TypeOfHighlight_NB; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintTypeOfHighlight[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_TypeOfHighlight (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : TypeOfHLRToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::TypeOfHLRToString (Prs3d_TypeOfHLR theType)
-{
- return Prs3d_Table_PrintTypeOfHLR[theType];
-}
-
-//=======================================================================
-//function : TypeOfHLRFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::TypeOfHLRFromString (Standard_CString theTypeString,
- Prs3d_TypeOfHLR& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_TOH_Algo; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintTypeOfHLR[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_TypeOfHLR (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : VertexDrawModeToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::VertexDrawModeToString (Prs3d_VertexDrawMode theType)
-{
- return Prs3d_Table_PrintVertexDrawMode[theType];
-}
-
-//=======================================================================
-//function : VertexDrawModeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::VertexDrawModeFromString (Standard_CString theTypeString,
- Prs3d_VertexDrawMode& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_VDM_Inherited; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintVertexDrawMode[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_VertexDrawMode (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DatumPartsToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::DatumPartsToString (Prs3d_DatumParts theType)
-{
- return Prs3d_Table_PrintDatumParts[theType];
-}
-
-//=======================================================================
-//function : DatumPartsFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::DatumPartsFromString (Standard_CString theTypeString,
- Prs3d_DatumParts& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_DP_None; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintDatumParts[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_DatumParts (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DatumAttributeToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::DatumAttributeToString (Prs3d_DatumAttribute theType)
-{
- return Prs3d_Table_PrintDatumAttribute[theType];
-}
-
-//=======================================================================
-//function : DatumAttributeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::DatumAttributeFromString (Standard_CString theTypeString,
- Prs3d_DatumAttribute& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_DP_ShadingNumberOfFacettes; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintDatumAttribute[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_DatumAttribute (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DatumAxesToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::DatumAxesToString (Prs3d_DatumAxes theType)
-{
- return Prs3d_Table_PrintDatumAxes[theType];
-}
-
-//=======================================================================
-//function : DatumAxesFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::DatumAxesFromString (Standard_CString theTypeString,
- Prs3d_DatumAxes& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_DA_XYZAxis; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintDatumAxes[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_DatumAxes (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DimensionArrowOrientationToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::DimensionArrowOrientationToString (Prs3d_DimensionArrowOrientation theType)
-{
- return Prs3d_Table_PrintDimensionArrowOrientation[theType];
-}
-
-//=======================================================================
-//function : DimensionArrowOrientationFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::DimensionArrowOrientationFromString (Standard_CString theTypeString,
- Prs3d_DimensionArrowOrientation& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_DAO_Fit; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintDimensionArrowOrientation[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_DimensionArrowOrientation (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DimensionTextHorizontalPositionToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::DimensionTextHorizontalPositionToString (Prs3d_DimensionTextHorizontalPosition theType)
-{
- return Prs3d_Table_PrintDimensionTextHorizontalPosition[theType];
-}
-
-//=======================================================================
-//function : DimensionTextHorizontalPositionFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::DimensionTextHorizontalPositionFromString (Standard_CString theTypeString,
- Prs3d_DimensionTextHorizontalPosition& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_DTHP_Fit; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintDimensionTextHorizontalPosition[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_DimensionTextHorizontalPosition (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : DimensionTextVerticalPositionToString
-//purpose :
-//=======================================================================
-Standard_CString Prs3d::DimensionTextVerticalPositionToString (Prs3d_DimensionTextVerticalPosition theType)
-{
- return Prs3d_Table_PrintDimensionTextVerticalPosition[theType];
-}
-
-//=======================================================================
-//function : DimensionTextVerticalPositionFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Prs3d::DimensionTextVerticalPositionFromString (Standard_CString theTypeString,
- Prs3d_DimensionTextVerticalPosition& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Prs3d_DTVP_Center; ++aTypeIter)
- {
- Standard_CString aTypeName = Prs3d_Table_PrintDimensionTextVerticalPosition[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Prs3d_DimensionTextVerticalPosition (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
#define _Prs3d_HeaderFile
#include <Graphic3d_ArrayOfPrimitives.hxx>
-#include <Prs3d_DatumAttribute.hxx>
-#include <Prs3d_DatumAxes.hxx>
-#include <Prs3d_DatumParts.hxx>
-#include <Prs3d_DimensionArrowOrientation.hxx>
-#include <Prs3d_DimensionTextHorizontalPosition.hxx>
-#include <Prs3d_DimensionTextVerticalPosition.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_NListOfSequenceOfPnt.hxx>
-#include <Prs3d_TypeOfHighlight.hxx>
-#include <Prs3d_TypeOfHLR.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Real.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_NListOfSequenceOfPnt.hxx>
#include <Prs3d_Presentation.hxx>
-#include <Prs3d_VertexDrawMode.hxx>
class TopoDS_Shape;
const Handle(Prs3d_LineAspect)& theAspect,
Prs3d_NListOfSequenceOfPnt& thePolylines);
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString TypeOfHighlightToString (Prs3d_TypeOfHighlight theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_TypeOfHighlight_None if string identifier is invalid
- static Prs3d_TypeOfHighlight TypeOfHighlightFromString (Standard_CString theTypeString)
- {
- Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None;
- TypeOfHighlightFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfHighlightFromString (const Standard_CString theTypeString,
- Prs3d_TypeOfHighlight& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString TypeOfHLRToString (Prs3d_TypeOfHLR theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_TOH_NotSet if string identifier is invalid
- static Prs3d_TypeOfHLR TypeOfHLRFromString (Standard_CString theTypeString)
- {
- Prs3d_TypeOfHLR aType = Prs3d_TOH_NotSet;
- TypeOfHLRFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfHLRFromString (const Standard_CString theTypeString,
- Prs3d_TypeOfHLR& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString VertexDrawModeToString (Prs3d_VertexDrawMode theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_VDM_Isolated if string identifier is invalid
- static Prs3d_VertexDrawMode VertexDrawModeFromString (Standard_CString theTypeString)
- {
- Prs3d_VertexDrawMode aType = Prs3d_VDM_Isolated;
- VertexDrawModeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean VertexDrawModeFromString (const Standard_CString theTypeString,
- Prs3d_VertexDrawMode& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString DatumPartsToString (Prs3d_DatumParts theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_DP_None if string identifier is invalid
- static Prs3d_DatumParts DatumPartsFromString (Standard_CString theTypeString)
- {
- Prs3d_DatumParts aType = Prs3d_DP_None;
- DatumPartsFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DatumPartsFromString (const Standard_CString theTypeString,
- Prs3d_DatumParts& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString DatumAttributeToString (Prs3d_DatumAttribute theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_DA_XAxisLength if string identifier is invalid
- static Prs3d_DatumAttribute DatumAttributeFromString (Standard_CString theTypeString)
- {
- Prs3d_DatumAttribute aType = Prs3d_DA_XAxisLength;
- DatumAttributeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DatumAttributeFromString (const Standard_CString theTypeString,
- Prs3d_DatumAttribute& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString DatumAxesToString (Prs3d_DatumAxes theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_DA_XAxis if string identifier is invalid
- static Prs3d_DatumAxes DatumAxesFromString (Standard_CString theTypeString)
- {
- Prs3d_DatumAxes aType = Prs3d_DA_XAxis;
- DatumAxesFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DatumAxesFromString (const Standard_CString theTypeString,
- Prs3d_DatumAxes& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString DimensionArrowOrientationToString (Prs3d_DimensionArrowOrientation theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_DAO_Internal if string identifier is invalid
- static Prs3d_DimensionArrowOrientation DimensionArrowOrientationFromString (Standard_CString theTypeString)
- {
- Prs3d_DimensionArrowOrientation aType = Prs3d_DAO_Internal;
- DimensionArrowOrientationFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DimensionArrowOrientationFromString (const Standard_CString theTypeString,
- Prs3d_DimensionArrowOrientation& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString DimensionTextHorizontalPositionToString (Prs3d_DimensionTextHorizontalPosition theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_DTHP_Left if string identifier is invalid
- static Prs3d_DimensionTextHorizontalPosition DimensionTextHorizontalPositionFromString (Standard_CString theTypeString)
- {
- Prs3d_DimensionTextHorizontalPosition aType = Prs3d_DTHP_Left;
- DimensionTextHorizontalPositionFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DimensionTextHorizontalPositionFromString (const Standard_CString theTypeString,
- Prs3d_DimensionTextHorizontalPosition& theType);
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString DimensionTextVerticalPositionToString (Prs3d_DimensionTextVerticalPosition theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or Prs3d_DTVP_Above if string identifier is invalid
- static Prs3d_DimensionTextVerticalPosition DimensionTextVerticalPositionFromString (Standard_CString theTypeString)
- {
- Prs3d_DimensionTextVerticalPosition aType = Prs3d_DTVP_Above;
- DimensionTextVerticalPositionFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DimensionTextVerticalPositionFromString (const Standard_CString theTypeString,
- Prs3d_DimensionTextVerticalPosition& theType);
-
};
#endif // _Prs3d_HeaderFile
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_InvalidAngle.hxx>
-#include <TCollection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ArrowAspect, Prs3d_BasicAspect)
|| theAngle >= M_PI / 2.0, "Prs3d_ArrowAspect::SetAngle() - angle out of range");
myAngle = theAngle;
}
-
-const TCollection_AsciiString Prs3d_ArrowAspect_ClassName = "Prs3d_ArrowAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_ArrowAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_ArrowAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myArrowAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "ArrowAspect", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "Angle", myAngle);
- DUMP_VALUES (OS, "Length", myLength);
-
- DUMP_STOP_KEY (OS, Prs3d_ArrowAspect_ClassName);
-}
void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { myArrowAspect = theAspect; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Graphic3d_AspectLine3d) myArrowAspect;
#define _Prs3d_BasicAspect_HeaderFile
#include <Standard.hxx>
-#include <Standard_OStream.hxx>
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class Prs3d_BasicAspect : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Prs3d_BasicAspect, Standard_Transient)
-
- //! Dumps the content of me on the stream <OS>.
- virtual void Dump (Standard_OStream& OS) const = 0;
-
};
DEFINE_STANDARD_HANDLE(Prs3d_BasicAspect, Standard_Transient)
#include <Prs3d_DatumAspect.hxx>
-#include <Prs3d.hxx>
-#include <TCollection.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
// =======================================================================
}
return Prs3d_DP_None;
}
-
-const TCollection_AsciiString Prs3d_DatumAspect_ClassName = "Prs3d_DatumAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_DatumAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_DatumAspect_ClassName);
-
- DUMP_VALUES (OS, "Axes", Prs3d::DatumAxesToString (myAxes));
- DUMP_VALUES (OS, "ToDrawLabels", myToDrawLabels);
- DUMP_VALUES (OS, "ToDrawArrows", myToDrawArrows);
-
- //NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
- //NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;
- //NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_LineAspect)> myLineAspects;
-
- {
- Standard_SStream aTmpStream;
- myTextAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "TextAspect", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myPointAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "PointAspect", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myArrowAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "ArrowAspect", TCollection::ToDumpString (aTmpStream));
- }
- DUMP_STOP_KEY (OS, Prs3d_DatumAspect_ClassName);
-}
-
//! Returns type of arrow for a type of axis
Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
private:
Prs3d_DatumAxes myAxes;
Standard_Boolean myToDrawLabels;
#include <Aspect_TypeOfLine.hxx>
#include <Graphic3d_AspectText3d.hxx>
-#include <Prs3d.hxx>
-#include <TCollection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect)
myTextAspect->SetColor (theColor);
myArrowAspect->SetColor (theColor);
}
-
-const TCollection_AsciiString Prs3d_DimensionAspect_ClassName = "Prs3d_DimensionAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_DimensionAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_DimensionAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myLineAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "LineAspect", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myTextAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "TextAspect", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myArrowAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "ArrowAspect", TCollection::ToDumpString (aTmpStream));
- }
- DUMP_VALUES (OS, "ValueStringFormat", myValueStringFormat);
- DUMP_VALUES (OS, "ExtensionSize", myExtensionSize);
- DUMP_VALUES (OS, "ArrowTailSize", myArrowTailSize);
- DUMP_VALUES (OS, "ArrowOrientation", Prs3d::DimensionArrowOrientationToString (myArrowOrientation));
- DUMP_VALUES (OS, "TextHPosition", Prs3d::DimensionTextHorizontalPositionToString (myTextHPosition));
- DUMP_VALUES (OS, "TextVPosition", Prs3d::DimensionTextVerticalPositionToString (myTextVPosition));
-
- DUMP_VALUES (OS, "ToDisplayUnits", myToDisplayUnits);
- DUMP_VALUES (OS, "IsText3d", myIsText3d);
- DUMP_VALUES (OS, "IsTextShaded", myIsTextShaded);
- DUMP_VALUES (OS, "IsArrows3d", myIsArrows3d);
-
- DUMP_STOP_KEY (OS, Prs3d_DimensionAspect_ClassName);
-}
-
//! Returns format.
const TCollection_AsciiString& ValueStringFormat() const { return myValueStringFormat; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Prs3d_LineAspect) myLineAspect;
#include <Prs3d_LineAspect.hxx>
-#include <TCollection.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_LineAspect, Prs3d_BasicAspect)
// =======================================================================
{
//
}
-
-const TCollection_AsciiString Prs3d_LineAspect_ClassName = "Prs3d_LineAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_LineAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_LineAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "Aspect", TCollection::ToDumpString (aTmpStream));
- }
- DUMP_STOP_KEY (OS, Prs3d_LineAspect_ClassName);
-}
-
void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) { myAspect = theAspect; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Graphic3d_AspectLine3d) myAspect;
#include <Prs3d_PlaneAspect.hxx>
-#include <TCollection.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PlaneAspect, Prs3d_BasicAspect)
// =======================================================================
{
//
}
-
-const TCollection_AsciiString Prs3d_PlaneAspect_ClassName = "Prs3d_PlaneAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_PlaneAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_PlaneAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myEdgesAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "EdgesAspect", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myIsoAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "IsoAspect", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- myArrowAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "ArrowAspect", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "ArrowsLength", myArrowsLength);
- DUMP_VALUES (OS, "ArrowsSize", myArrowsSize);
- DUMP_VALUES (OS, "ArrowsAngle", myArrowsAngle);
- DUMP_VALUES (OS, "PlaneXLength", myPlaneXLength);
- DUMP_VALUES (OS, "PlaneYLength", myPlaneYLength);
- DUMP_VALUES (OS, "IsoDistance", myIsoDistance);
- DUMP_VALUES (OS, "DrawCenterArrow", myDrawCenterArrow);
- DUMP_VALUES (OS, "DrawEdgesArrows", myDrawEdgesArrows);
- DUMP_VALUES (OS, "DrawEdges", myDrawEdges);
- DUMP_VALUES (OS, "DrawIso", myDrawIso);
-
- DUMP_STOP_KEY (OS, Prs3d_PlaneAspect_ClassName);
-}
-
//! Returns the distance between isoparameters used in the display of planes.
Standard_Real IsoDistance() const { return myIsoDistance; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Prs3d_LineAspect) myEdgesAspect;
#include <Prs3d_PointAspect.hxx>
-#include <TCollection.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PointAspect, Prs3d_BasicAspect)
// =======================================================================
{
//
}
-
-const TCollection_AsciiString Prs3d_PointAspect_ClassName = "Prs3d_PointAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_PointAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_PointAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "Aspect", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_STOP_KEY (OS, Prs3d_PointAspect_ClassName);
-}
-
//! Returns marker's texture.
const Handle(Graphic3d_MarkerImage)& GetTexture() const { return myAspect->GetMarkerImage(); }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Graphic3d_AspectMarker3d) myAspect;
#include <Graphic3d_MaterialAspect.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Type.hxx>
-#include <TCollection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_ShadingAspect, Prs3d_BasicAspect)
}
return 0.0;
}
-
-const TCollection_AsciiString Prs3d_ShadingAspect_ClassName = "Prs3d_ShadingAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_ShadingAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_ShadingAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "Aspect", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_STOP_KEY (OS, Prs3d_ShadingAspect_ClassName);
-}
-
void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { myAspect = theAspect; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Graphic3d_AspectFillArea3d) myAspect;
#include <Prs3d_TextAspect.hxx>
#include <Font_NameOfFont.hxx>
-#include <Graphic3d.hxx>
-#include <TCollection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect)
{
//
}
-
-const TCollection_AsciiString Prs3d_TextAspect_ClassName = "Prs3d_TextAspect";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void Prs3d_TextAspect::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Prs3d_TextAspect_ClassName);
- {
- Standard_SStream aTmpStream;
- myTextAspect->Dump (aTmpStream);
- DUMP_VALUES (OS, "TextAspect", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "Height", myHeight);
-
- DUMP_VALUES (OS, "HorizontalJustification", Graphic3d::HorizontalTextAlignmentToString (myHorizontalJustification));
- DUMP_VALUES (OS, "VerticalJustification", Graphic3d::VerticalTextAlignmentToString (myVerticalJustification));
- DUMP_VALUES (OS, "Orientation", Graphic3d::TextPathToString (myOrientation));
-
- DUMP_STOP_KEY (OS, Prs3d_TextAspect_ClassName);
-}
-
void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect = theAspect; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
protected:
Handle(Graphic3d_AspectText3d) myTextAspect;
-PrsMgr.cxx
-PrsMgr.hxx
PrsMgr_ListOfPresentableObjects.hxx
PrsMgr_ListOfPresentations.hxx
PrsMgr_PresentableObject.cxx
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <PrsMgr.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString PrsMgr_Table_PrintTypeOfPresentation3d[2] =
- {
- "ALL_VIEW", "PROJECTOR_DEPENDANT"
- };
-}
-
-//=======================================================================
-//function : TypeOfPresentation3dToString
-//purpose :
-//=======================================================================
-Standard_CString PrsMgr::TypeOfPresentation3dToString (PrsMgr_TypeOfPresentation3d theType)
-{
- return PrsMgr_Table_PrintTypeOfPresentation3d[theType];
-}
-
-//=======================================================================
-//function : TypeOfPresentation3dFromString
-//purpose :
-//=======================================================================
-Standard_Boolean PrsMgr::TypeOfPresentation3dFromString (Standard_CString theTypeString,
- PrsMgr_TypeOfPresentation3d& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= PrsMgr_TOP_ProjectorDependant; ++aTypeIter)
- {
- Standard_CString aTypeName = PrsMgr_Table_PrintTypeOfPresentation3d[aTypeIter];
- if (aName == aTypeName)
- {
- theType = PrsMgr_TypeOfPresentation3d (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _PrsMgr_HeaderFile
-#define _PrsMgr_HeaderFile
-
-#include <PrsMgr_TypeOfPresentation3d.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-
-//! Provides methods to cast enumerations of package to string value
-class PrsMgr
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TypeOfPresentation3dToString (PrsMgr_TypeOfPresentation3d theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or PrsMgr_TOP_AllView if string identifier is invalid
- static PrsMgr_TypeOfPresentation3d TypeOfPresentation3dFromString (Standard_CString theTypeString)
- {
- PrsMgr_TypeOfPresentation3d aType = PrsMgr_TOP_AllView;
- TypeOfPresentation3dFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TypeOfPresentation3dFromString (const Standard_CString theTypeString,
- PrsMgr_TypeOfPresentation3d& theType);
-
-};
-
-#endif // _PrsMgr_HeaderFile
myDrawer->ShadingAspect()->Aspect()->PolygonOffsets (theMode, theFactor, theUnits);
}
}
-
-const TCollection_AsciiString PrsMgr_PresentableObject_ClassName = "PrsMgr_PresentableObject";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void PrsMgr_PresentableObject::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, PrsMgr_PresentableObject_ClassName);
-
- DUMP_VALUES (OS, "Parent", TCollection::GetPointerInfo (myParent));
-
- DUMP_VALUES (OS, "Width", myOwnWidth);
- DUMP_VALUES (OS, "OwnColor", hasOwnColor);
- DUMP_VALUES (OS, "OwnMaterial", hasOwnMaterial);
-
- DUMP_VALUES (OS, "InfiniteState", myInfiniteState);
- DUMP_VALUES (OS, "IsMutable", myIsMutable);
- DUMP_VALUES (OS, "HasOwnPresentations", myHasOwnPresentations);
-
- DUMP_STOP_KEY (OS, PrsMgr_PresentableObject_ClassName);
-
-/*
- PrsMgr_Presentations myPresentations; //!< list of presentations
- Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; //!< sequence of object-specific clipping planes
- Handle(Prs3d_Drawer) myDrawer; //!< main presentation attributes
- Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object
- Handle(Prs3d_Drawer) myDynHilightDrawer; //!< (optional) custom presentation attributes for highlighting detected object
- Handle(Graphic3d_TransformPers) myTransformPersistence; //!< transformation persistence
- Handle(Geom_Transformation) myLocalTransformation; //!< local transformation relative to parent object
- Handle(Geom_Transformation) myTransformation; //!< absolute transformation of this object (combined parents + local transformations)
- Handle(Geom_Transformation) myCombinedParentTransform; //!< transformation of parent object (combined for all parents)
- PrsMgr_ListOfPresentableObjects myChildren; //!< list of children
- gp_GTrsf myInvTransformation; //!< inversion of absolute transformation (combined parents + local transformations)
- PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; //!< presentation type
-
- Aspect_TypeOfFacingModel myCurrentFacingModel; //!< current facing model
-*/
-}
//! Clears settings provided by the drawing tool aDrawer.
Standard_EXPORT virtual void UnsetAttributes();
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
-
public: //! @name deprecated methods
//! gives the list of modes which are flagged "to be updated".
-Quantity.cxx
-Quantity.hxx
Quantity_AbsorbedDose.hxx
Quantity_Acceleration.hxx
Quantity_AcousticIntensity.hxx
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation", with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively", this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Quantity.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString Quantity_Table_PrintNameOfColor[517] =
- {
- "BLACK", "MATRABLUE", "MATRAGRAY", "ALICEBLUE",
- "ANTIQUEWHITE", "ANTIQUEWHITE1", "ANTIQUEWHITE2", "ANTIQUEWHITE3", "ANTIQUEWHITE4",
- "AQUAMARINE1", "AQUAMARINE2", "AQUAMARINE4",
- "AZURE", "AZURE2", "AZURE3", "AZURE4",
- "BEIGE",
- "BISQUE", "BISQUE2", "BISQUE3", "BISQUE4",
- "BLANCHEDALMOND",
- "BLUE1", "BLUE2", "BLUE3", "BLUE4",
- "BLUEVIOLET",
- "BROWN", "BROWN1", "BROWN2", "BROWN3", "BROWN4",
- "BURLYWOOD", "BURLYWOOD1", "BURLYWOOD2", "BURLYWOOD3", "BURLYWOOD4",
- "CADETBLUE", "CADETBLUE1", "CADETBLUE2", "CADETBLUE3", "CADETBLUE4",
- "CHARTREUSE", "CHARTREUSE1", "CHARTREUSE2", "CHARTREUSE3", "CHARTREUSE4",
- "CHOCOLATE", "CHOCOLATE1", "CHOCOLATE2", "CHOCOLATE3", "CHOCOLATE4",
- "CORAL", "CORAL1", "CORAL2", "CORAL3", "CORAL4",
- "CORNFLOWERBLUE",
- "CORNSILK1", "CORNSILK2", "CORNSILK3", "CORNSILK4",
- "CYAN1", "CYAN2", "CYAN3", "CYAN4",
- "DARKGOLDENROD", "DARKGOLDENROD1", "DARKGOLDENROD2", "DARKGOLDENROD3", "DARKGOLDENROD4",
- "DARKGREEN",
- "DARKKHAKI",
- "DARKOLIVEGREEN", "DARKOLIVEGREEN1", "DARKOLIVEGREEN2", "DARKOLIVEGREEN3", "DARKOLIVEGREEN4",
- "DARKORANGE", "DARKORANGE1", "DARKORANGE2", "DARKORANGE3", "DARKORANGE4",
- "DARKORCHID", "DARKORCHID1", "DARKORCHID2", "DARKORCHID3", "DARKORCHID4",
- "DARKSALMON",
- "DARKSEAGREEN", "DARKSEAGREEN1", "DARKSEAGREEN2", "DARKSEAGREEN3", "DARKSEAGREEN4",
- "DARKSLATEBLUE",
- "DARKSLATEGRAY1", "DARKSLATEGRAY2", "DARKSLATEGRAY3", "DARKSLATEGRAY4", "DARKSLATEGRAY",
- "DARKTURQUOISE",
- "DARKVIOLET",
- "DEEPPINK", "DEEPPINK2", "DEEPPINK3", "DEEPPINK4",
- "DEEPSKYBLUE1", "DEEPSKYBLUE2", "DEEPSKYBLUE3", "DEEPSKYBLUE4",
- "DODGERBLUE1", "DODGERBLUE2", "DODGERBLUE3", "DODGERBLUE4",
- "FIREBRICK", "FIREBRICK1", "FIREBRICK2", "FIREBRICK3", "FIREBRICK4",
- "FLORALWHITE",
- "FORESTGREEN",
- "GAINSBORO",
- "GHOSTWHITE",
- "GOLD", "GOLD1", "GOLD2", "GOLD3", "GOLD4",
- "GOLDENROD", "GOLDENROD1", "GOLDENROD2", "GOLDENROD3", "GOLDENROD4",
- "GRAY", "GRAY0", "GRAY1", "GRAY10", "GRAY11", "GRAY12", "GRAY13", "GRAY14", "GRAY15", "GRAY16",
- "GRAY17", "GRAY18", "GRAY19", "GRAY2", "GRAY20", "GRAY21", "GRAY22", "GRAY23", "GRAY24", "GRAY25",
- "GRAY26", "GRAY27", "GRAY28", "GRAY29", "GRAY3", "GRAY30", "GRAY31", "GRAY32", "GRAY33", "GRAY34",
- "GRAY35", "GRAY36", "GRAY37", "GRAY38", "GRAY39", "GRAY4", "GRAY40", "GRAY41", "GRAY42", "GRAY43",
- "GRAY44", "GRAY45", "GRAY46", "GRAY47", "GRAY48", "GRAY49", "GRAY5", "GRAY50", "GRAY51", "GRAY52",
- "GRAY53", "GRAY54", "GRAY55", "GRAY56", "GRAY57", "GRAY58", "GRAY59", "GRAY6", "GRAY60", "GRAY61",
- "GRAY62", "GRAY63", "GRAY64", "GRAY65", "GRAY66", "GRAY67", "GRAY68", "GRAY69", "GRAY7", "GRAY70",
- "GRAY71", "GRAY72", "GRAY73", "GRAY74", "GRAY75", "GRAY76", "GRAY77", "GRAY78", "GRAY79", "GRAY8",
- "GRAY80", "GRAY81", "GRAY82", "GRAY83", "GRAY85", "GRAY86", "GRAY87", "GRAY88", "GRAY89", "GRAY9",
- "GRAY90", "GRAY91", "GRAY92", "GRAY93", "GRAY94", "GRAY95",
- "GREEN", "GREEN1", "GREEN2", "GREEN3", "GREEN4",
- "GREENYELLOW",
- "GRAY97", "GRAY98", "GRAY99",
- "HONEYDEW", "HONEYDEW2", "HONEYDEW3", "HONEYDEW4",
- "HOTPINK", "HOTPINK1", "HOTPINK2", "HOTPINK3", "HOTPINK4",
- "INDIANRED", "INDIANRED1", "INDIANRED2", "INDIANRED3", "INDIANRED4",
- "IVORY", "IVORY2", "IVORY3", "IVORY4",
- "KHAKI", "KHAKI1", "KHAKI2", "KHAKI3", "KHAKI4",
- "LAVENDER", "LAVENDERBLUSH1", "LAVENDERBLUSH2", "LAVENDERBLUSH3", "LAVENDERBLUSH4",
- "LAWNGREEN", "LEMONCHIFFON1", "LEMONCHIFFON2", "LEMONCHIFFON3", "LEMONCHIFFON4",
- "LIGHTBLUE", "LIGHTBLUE1", "LIGHTBLUE2", "LIGHTBLUE3", "LIGHTBLUE4",
- "LIGHTCORAL",
- "LIGHTCYAN1", "LIGHTCYAN2", "LIGHTCYAN3", "LIGHTCYAN4",
- "LIGHTGOLDENROD", "LIGHTGOLDENROD1", "LIGHTGOLDENROD2", "LIGHTGOLDENROD3", "LIGHTGOLDENROD4",
- "LIGHTGOLDENRODYELLOW",
- "LIGHTGRAY"
- "LIGHTPINK", "LIGHTPINK1", "LIGHTPINK2", "LIGHTPINK3", "LIGHTPINK4",
- "LIGHTSALMON1", "LIGHTSALMON2", "LIGHTSALMON3", "LIGHTSALMON4",
- "LIGHTSEAGREEN",
- "LIGHTSKYBLUE", "LIGHTSKYBLUE1", "LIGHTSKYBLUE2", "LIGHTSKYBLUE3", "LIGHTSKYBLUE4",
- "LIGHTSLATEBLUE",
- "LIGHTSLATEGRAY",
- "LIGHTSTEELBLUE", "LIGHTSTEELBLUE1", "LIGHTSTEELBLUE2", "LIGHTSTEELBLUE3", "LIGHTSTEELBLUE4",
- "LIGHTYELLOW", "LIGHTYELLOW2", "LIGHTYELLOW3", "LIGHTYELLOW4",
- "LIMEGREEN",
- "LINEN",
- "MAGENTA1", "MAGENTA2", "MAGENTA3", "MAGENTA4",
- "MAROON", "MAROON1", "MAROON2", "MAROON3", "MAROON4",
- "MEDIUMAQUAMARINE",
- "MEDIUMORCHID", "MEDIUMORCHID1", "MEDIUMORCHID2", "MEDIUMORCHID3", "MEDIUMORCHID4",
- "MEDIUMPURPLE", "MEDIUMPURPLE1", "MEDIUMPURPLE2", "MEDIUMPURPLE3", "MEDIUMPURPLE4",
- "MEDIUMSEAGREEN",
- "MEDIUMSLATEBLUE",
- "MEDIUMSPRINGGREEN",
- "MEDIUMTURQUOISE",
- "MEDIUMVIOLETRED",
- "MIDNIGHTBLUE",
- "MINTCREAM",
- "MISTYROSE", "MISTYROSE2", "MISTYROSE3", "MISTYROSE4",
- "MOCCASIN",
- "NAVAJOWHITE1", "NAVAJOWHITE2", "NAVAJOWHITE3", "NAVAJOWHITE4",
- "NAVYBLUE",
- "OLDLACE",
- "OLIVEDRAB", "OLIVEDRAB1", "OLIVEDRAB2", "OLIVEDRAB3", "OLIVEDRAB4",
- "ORANGE", "ORANGE1", "ORANGE2", "ORANGE3", "ORANGE4",
- "ORANGERED", "ORANGERED1", "ORANGERED2", "ORANGERED3", "ORANGERED4",
- "ORCHID", "ORCHID1", "ORCHID2", "ORCHID3", "ORCHID4",
- "PALEGOLDENROD",
- "PALEGREEN", "PALEGREEN1", "PALEGREEN2", "PALEGREEN3", "PALEGREEN4",
- "PALETURQUOISE", "PALETURQUOISE1", "PALETURQUOISE2", "PALETURQUOISE3", "PALETURQUOISE4",
- "PALEVIOLETRED", "PALEVIOLETRED1", "PALEVIOLETRED2", "PALEVIOLETRED3", "PALEVIOLETRED4",
- "PAPAYAWHIP",
- "PEACHPUFF", "PEACHPUFF2", "PEACHPUFF3", "PEACHPUFF4",
- "PERU",
- "PINK", "PINK1", "PINK2", "PINK3", "PINK4",
- "PLUM", "PLUM1", "PLUM2", "PLUM3", "PLUM4",
- "POWDERBLUE",
- "PURPLE", "PURPLE1", "PURPLE2", "PURPLE3", "PURPLE4",
- "RED", "RED1", "RED2", "RED3", "RED4",
- "ROSYBROWN", "ROSYBROWN1", "ROSYBROWN2", "ROSYBROWN3", "ROSYBROWN4",
- "ROYALBLUE", "ROYALBLUE1", "ROYALBLUE2", "ROYALBLUE3", "ROYALBLUE4",
- "SADDLEBROWN",
- "SALMON", "SALMON1", "SALMON2", "SALMON3", "SALMON4",
- "SANDYBROWN",
- "SEAGREEN", "SEAGREEN1", "SEAGREEN2", "SEAGREEN3", "SEAGREEN4",
- "SEASHELL", "SEASHELL2", "SEASHELL3", "SEASHELL4",
- "BEET",
- "TEAL",
- "SIENNA", "SIENNA1", "SIENNA2", "SIENNA3", "SIENNA4",
- "SKYBLUE", "SKYBLUE1", "SKYBLUE2", "SKYBLUE3", "SKYBLUE4",
- "SLATEBLUE", "SLATEBLUE1", "SLATEBLUE2", "SLATEBLUE3", "SLATEBLUE4",
- "SLATEGRAY1", "SLATEGRAY2", "SLATEGRAY3", "SLATEGRAY4", "SLATEGRAY",
- "SNOW", "SNOW2", "SNOW3", "SNOW4",
- "SPRINGGREEN", "SPRINGGREEN2", "SPRINGGREEN3", "SPRINGGREEN4",
- "STEELBLUE", "STEELBLUE1", "STEELBLUE2", "STEELBLUE3", "STEELBLUE4",
- "TAN", "TAN1", "TAN2", "TAN3", "TAN4",
- "THISTLE", "THISTLE1", "THISTLE2", "THISTLE3", "THISTLE4",
- "TOMATO", "TOMATO1", "TOMATO2", "TOMATO3", "TOMATO4",
- "TURQUOISE", "TURQUOISE1", "TURQUOISE2", "TURQUOISE3", "TURQUOISE4",
- "VIOLET",
- "VIOLETRED", "VIOLETRED1", "VIOLETRED2", "VIOLETRED3", "VIOLETRED4",
- "WHEAT", "WHEAT1", "WHEAT2", "WHEAT3", "WHEAT4",
- "WHITESMOKE",
- "YELLOW", "YELLOW1", "YELLOW2", "YELLOW3", "YELLOW4",
- "YELLOWGREEN",
- "WHITE"
- };
-
-}
-
-//=======================================================================
-//function : NameOfColorToString
-//purpose :
-//=======================================================================
-Standard_CString Quantity::NameOfColorToString (Quantity_NameOfColor theType)
-{
- return Quantity_Table_PrintNameOfColor[theType];
-}
-
-//=======================================================================
-//function : NameOfColorFromString
-//purpose :
-//=======================================================================
-Standard_Boolean Quantity::NameOfColorFromString (Standard_CString theTypeString,
- Quantity_NameOfColor& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= Quantity_NOC_WHITE; ++aTypeIter)
- {
- Standard_CString aTypeName = Quantity_Table_PrintNameOfColor[aTypeIter];
- if (aName == aTypeName)
- {
- theType = Quantity_NameOfColor (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Quantity_HeaderFile
-#define _Quantity_HeaderFile
-
-#include <Quantity_NameOfColor.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-
-//! Provides methods to cast enumerations of package to string value
-class Quantity
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString NameOfColorToString (Quantity_NameOfColor theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or Quantity_NOC_BLACK if string identifier is invalid
- static Quantity_NameOfColor NameOfColorFromString (Standard_CString theTypeString)
- {
- Quantity_NameOfColor aType = Quantity_NOC_BLACK;
- NameOfColorFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean NameOfColorFromString (const Standard_CString theTypeString,
- Quantity_NameOfColor& theType);
-
-};
-
-#endif // _Quantity_HeaderFile
#include <Quantity_Color.hxx>
-#include <Message_Alerts.hxx>
-#include <NCollection_Vector.hxx>
-
#include <Quantity_ColorDefinitionError.hxx>
#include <Quantity_ColorRGBA.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_OutOfRange.hxx>
-#include <TCollection.hxx>
#include <TCollection_AsciiString.hxx>
#include <string.h>
if (h < 0.0) h += 360.0;
}
}
-
-
-const TCollection_AsciiString Quantity_Color_ClassName = "Quantity_Color";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void Quantity_Color::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Quantity_Color_ClassName);
-
- DUMP_VALUES (OS, "MyRed", MyRed);
- DUMP_VALUES (OS, "MyGreen", MyGreen);
- DUMP_VALUES (OS, "MyBlue", MyBlue);
-
- DUMP_STOP_KEY (OS, Quantity_Color_ClassName);
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-Standard_Boolean Quantity_Color::Init (const Standard_OStream& /*OS*/)
-{
- return Standard_False;
-}
#include <Standard_Handle.hxx>
#include <Standard_ShortReal.hxx>
-#include <TCollection_AsciiString.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <Standard_Real.hxx>
//! Internal test
Standard_EXPORT static void Test();
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS);
-
private:
//! Converts HLS components into RGB ones.
#include <Quantity_ColorRGBA.hxx>
#include <Graphic3d_Vec4.hxx>
-#include <TCollection.hxx>
#include <algorithm>
const ColorInteger aColorComponentBase = isShort ? THE_HEX_COLOR_COMPONENT_SHORT_BASE : THE_HEX_COLOR_COMPONENT_BASE;
return convertIntegerToColorRGBA (aHexColorInteger, aColorComponentBase, hasAlphaComponent, theColor);
}
-
-const TCollection_AsciiString Quantity_ColorRGBA_ClassName = "Quantity_ColorRGBA";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void Quantity_ColorRGBA::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, Quantity_ColorRGBA_ClassName);
-
- DUMP_VALUES (OS, "Alpha", Alpha());
- {
- Standard_SStream aTmpStream;
- myRgb.Dump (aTmpStream);
- DUMP_VALUES (OS, "RGB", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_STOP_KEY (OS, Quantity_ColorRGBA_ClassName);
-}
Quantity_ColorRGBA& theColor,
const bool theAlphaComponentIsOff = false);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
private:
static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); }
-SelectMgr.cxx
-SelectMgr.hxx
SelectMgr_AndFilter.cxx
SelectMgr_AndFilter.hxx
SelectMgr_BaseFrustum.cxx
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <SelectMgr.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString SelectMgr_Table_PrintPickingStrategy[2] =
- {
- "FIRST_ACCEPTABLE", "ONLY_TOPMOST"
- };
-
- static Standard_CString SelectMgr_Table_PrintBVHSubset[4] =
- {
- "3d", "3dPersistent", "2dPersistent", "Nb"
- };
-}
-
-//=======================================================================
-//function : TypeOfOrientationToString
-//purpose :
-//=======================================================================
-Standard_CString SelectMgr::PickingStrategyToString (SelectMgr_PickingStrategy theType)
-{
- return SelectMgr_Table_PrintPickingStrategy[theType];
-}
-
-//=======================================================================
-//function : PickingStrategyFromString
-//purpose :
-//=======================================================================
-Standard_Boolean SelectMgr::PickingStrategyFromString (Standard_CString theTypeString,
- SelectMgr_PickingStrategy& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= SelectMgr_PickingStrategy_OnlyTopmost; ++aTypeIter)
- {
- Standard_CString aTypeName = SelectMgr_Table_PrintPickingStrategy[aTypeIter];
- if (aName == aTypeName)
- {
- theType = SelectMgr_PickingStrategy (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : BVHSubsetToString
-//purpose :
-//=======================================================================
-Standard_CString SelectMgr::BVHSubsetToString (SelectMgr_SelectableObjectSet::BVHSubset theType)
-{
- return SelectMgr_Table_PrintBVHSubset[theType];
-}
-
-//=======================================================================
-//function : BVHSubsetFromString
-//purpose :
-//=======================================================================
-Standard_Boolean SelectMgr::BVHSubsetFromString (Standard_CString theTypeString,
- SelectMgr_SelectableObjectSet::BVHSubset& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = 0; aTypeIter <= SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aTypeIter)
- {
- Standard_CString aTypeName = SelectMgr_Table_PrintBVHSubset[aTypeIter];
- if (aName == aTypeName)
- {
- theType = SelectMgr_SelectableObjectSet::BVHSubset (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
+++ /dev/null
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _SelectMgr_HeaderFile
-#define _SelectMgr_HeaderFile
-
-#include <SelectMgr_PickingStrategy.hxx>
-#include <SelectMgr_SelectableObjectSet.hxx>
-#include <SelectMgr_StateOfSelection.hxx>
-#include <SelectMgr_TypeOfBVHUpdate.hxx>
-#include <SelectMgr_TypeOfUpdate.hxx>
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_TypeDef.hxx>
-
-//! This package contains the set of commands and services of the SelectMgr
-class SelectMgr
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString PickingStrategyToString (SelectMgr_PickingStrategy theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or V3d_TypeOfOrientation if string identifier is invalid
- static SelectMgr_PickingStrategy PickingStrategyFromString (Standard_CString theTypeString)
- {
- SelectMgr_PickingStrategy aType = SelectMgr_PickingStrategy_FirstAcceptable;
- PickingStrategyFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean PickingStrategyFromString (const Standard_CString theTypeString,
- SelectMgr_PickingStrategy& theType);
-
-
-
- //! Returns the string name for a given orientation type.
- //! @param theType orientation type
- //! @return string identifier from the list Xpos, Ypos, Zpos and others
- Standard_EXPORT static Standard_CString BVHSubsetToString (SelectMgr_SelectableObjectSet::BVHSubset theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return orientation type or BVHSubset_3d if string identifier is invalid
- static SelectMgr_SelectableObjectSet::BVHSubset BVHSubsetFromString (Standard_CString theTypeString)
- {
- SelectMgr_SelectableObjectSet::BVHSubset aType = SelectMgr_SelectableObjectSet::BVHSubset_3d;
- BVHSubsetFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the shape type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected shape type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean BVHSubsetFromString (const Standard_CString theTypeString,
- SelectMgr_SelectableObjectSet::BVHSubset& theType);
-
-};
-
-#endif // _SelectMgr_HeaderFile
#include <SelectMgr_BaseFrustum.hxx>
-#include <Message.hxx>
-#include <Message_Alerts.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
//=======================================================================
{
return gp_Pnt (RealLast(), RealLast(), RealLast());
}
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-void SelectMgr_BaseFrustum::Dump(Standard_OStream& OS)const
-{
- DUMP_VALUES (OS, "SelectMgr_BaseFrustum", 2);
-
- DUMP_VALUES (OS, "myPixelTolerance", myPixelTolerance);
- DUMP_VALUES (OS, "myIsOrthographic", myIsOrthographic);
- DUMP_VALUES (OS, "myBuilder", Message::TransientToString (myBuilder));
- DUMP_VALUES (OS, "myCamera", Message::TransientToString (myCamera));
-}
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
-#include <Standard_OStream.hxx>
-
//! This class is an interface for different types of selecting frustums,
//! defining different selection types, like point, box or polyline
//! selection. It contains signatures of functions for detection of
return;
}
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
-
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
protected:
mySelectable->HilightOwnerWithColor (thePM, theStyle, this);
}
}
-
-const TCollection_AsciiString SelectMgr_EntityOwner_ClassName = "SelectMgr_EntityOwner";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void SelectMgr_EntityOwner::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, SelectMgr_EntityOwner_ClassName);
-
-
- DUMP_VALUES (OS, "Selectable", TCollection::GetPointerInfo (mySelectable));
- DUMP_VALUES (OS, "Priority", mypriority);
- DUMP_VALUES (OS, "IsSelected", myIsSelected);
- DUMP_VALUES (OS, "ComesFromDecomposition", myFromDecomposition);
-
- DUMP_STOP_KEY (OS, SelectMgr_EntityOwner_ClassName);
-}
//! Sets flag indicating this owner points to a part of object (TRUE) or to entire object (FALSE).
void SetComesFromDecomposition (const Standard_Boolean theIsFromDecomposition) { myFromDecomposition = theIsFromDecomposition; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
-
public:
//! Sets the selectable object.
{
return THE_NULL_ENTITYOWNER;
}
-
-const TCollection_AsciiString SelectMgr_SelectableObject_ClassName = "SelectMgr_SelectableObject";
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-void SelectMgr_SelectableObject::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, SelectMgr_SelectableObject_ClassName);
-
- {
- Standard_SStream aTmpStream;
- PrsMgr_PresentableObject::Dump (aTmpStream);
- DUMP_VALUES (OS, "PrsMgr_PresentableObject", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_VALUES (OS, "GlobalSelectionMode", myGlobalSelMode);
- //DUMP_VALUES (OS, "mycurrent", mycurrent);
- DUMP_VALUES (OS, "IsAutoHilight", myAutoHilight);
-
-/*
- SelectMgr_SequenceOfSelection myselections; //!< list of selections
- Handle(Prs3d_Presentation) mySelectionPrs; //!< optional presentation for highlighting selected object
- Handle(Prs3d_Presentation) myHilightPrs; //!< optional presentation for highlighting detected object
-*/
-
- DUMP_STOP_KEY (OS, SelectMgr_SelectableObject_ClassName);
-}
//! Returns common entity owner if the object is an assembly
Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
-
public:
//! Begins the iteration scanning for sensitive primitives.
return mySelectingVolumes[myActiveSelectionType / 2];
}
- //! Returns active selecting volume that was built during last
- //! run of OCCT selection mechanism
- Handle(SelectMgr_BaseFrustum) GetVolume (const SelectionType& theType) const
- {
- switch (theType)
- {
- case Point:
- case Box: return mySelectingVolumes[Frustum];
- case Polyline: return mySelectingVolumes[FrustumSet];
- default: return NULL;
- }
- }
-
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE
#include <Bnd_Range.hxx>
#include <Standard_TypeDef.hxx>
-#include <Standard_OStream.hxx>
-#include <TCollection.hxx>
#include <vector>
//! Adds a clipping sub-range (for clipping chains).
void AddClipSubRange (const Bnd_Range& theRange) { myClipRanges.push_back (theRange); }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const
- {
- DUMP_VALUES (OS, "SelectMgr_ViewClipRange", 2);
- DUMP_VALUES (OS, "myUnclipRange", myUnclipRange.ToString());
- DUMP_VALUES (OS, "myClipRanges", myClipRanges.size());
- for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
- DUMP_VALUES (OS, aRangeIter, myClipRanges[aRangeIter].ToString());
- }
-
private:
std::vector<Bnd_Range> myClipRanges;
#include <BVH_Tree.hxx>
#include <gp_GTrsf.hxx>
#include <gp_Pnt.hxx>
-#include <Message_Alerts.hxx>
#include <OSD_Environment.hxx>
#include <Precision.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_PickResult.hxx>
-#include <SelectMgr.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SortCriterion.hxx>
#include <SelectMgr_SensitiveEntitySet.hxx>
#include <algorithm>
-//#define REPORT_SELECTION_BUILD
-#ifdef REPORT_SELECTION_BUILD
-#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
-#endif
-
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_ViewerSelector, Standard_Transient)
namespace {
const gp_GTrsf& theInversedTrsf,
SelectMgr_SelectingVolumeManager& theMgr)
{
- #ifdef REPORT_SELECTION_BUILD
- Message_PerfMeter aPerfMeter;
- Standard_SStream aStream;
- MESSAGE_INFO_OBJECT (theEntity, aStream, "checkOverlap", "", &aPerfMeter, NULL);
- Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
- #endif
-
const Handle(SelectMgr_EntityOwner)& anOwner = theEntity->OwnerId();
Handle(SelectMgr_SelectableObject) aSelectable = !anOwner.IsNull() ? anOwner->Selectable() : Handle(SelectMgr_SelectableObject)();
SelectBasics_PickResult aPickResult;
- #ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO (TCollection_AsciiString ("Matches - start"), "", &aPerfMeter, aParentAlert);
- #endif
const Standard_Boolean isMatched = theEntity->Matches(theMgr, aPickResult);
- #ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO (TCollection_AsciiString ("Matches - end"), "", &aPerfMeter, aParentAlert);
- #endif
if (!isMatched
|| anOwner.IsNull())
{
return;
}
- //if (!mySelectingVolumeMgr.ViewClipping().IsNull())
- //{
- // Standard_Real aDepth = /*aPickResult.HasPickedPoint() ?*+/ aPickResult.Depth();// :*/ aPickResult.DistToGeomCenter();
- // Standard_Boolean isClipped = mySelectingVolumeMgr.IsClipped (*mySelectingVolumeMgr.ViewClipping(),
- // aDepth);
- // if (isClipped)
- // return;
- //}
-
SelectMgr_SortCriterion aCriterion;
myZLayerOrderMap.Find (!aSelectable.IsNull() ? aSelectable->ZLayer() : Graphic3d_ZLayerId_Default, aCriterion.ZLayerPosition);
aCriterion.Entity = theEntity;
return;
}
- #ifdef REPORT_SELECTION_BUILD
- Message_PerfMeter aPerfMeter;
- Standard_SStream aStream;
- MESSAGE_INFO_OBJECT (theObject, aStream, "traverseObject", "", &aPerfMeter, NULL);
- Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
- #endif
-
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& aSensitivesTree = anEntitySet->BVH();
gp_GTrsf aInversedTrsf;
if (theObject->HasTransformation() || !theObject->TransformPersistence().IsNull())
SelectMgr_SelectingVolumeManager aTmpMgr (false);
for (;;)
{
- #ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO (TCollection_AsciiString ("aNode") + aNode, "", &aPerfMeter, aParentAlert);
- #endif
-
if (!aSensitivesTree->IsOuter (aNode))
{
const Standard_Integer aLeftChildIdx = aSensitivesTree->Child<0> (aNode);
//=======================================================================
void SelectMgr_ViewerSelector::TraverseSensitives()
{
-#ifdef REPORT_SELECTION_BUILD
- Message_PerfMeter aPerfMeter;
- MESSAGE_INFO ("TraverseSensitives", "", &aPerfMeter, NULL);
- Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
-
- Standard_SStream aStream;
- Dump (aStream);
- MESSAGE_INFO_STREAM (aStream, "Parameters", "", &aPerfMeter, aParentAlert);
-#endif
-
mystored.Clear();
Standard_Integer aWidth;
Standard_Integer aHeight;
mySelectingVolumeMgr.WindowSize (aWidth, aHeight);
-#ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO ("UpdateBVH", "", &aPerfMeter, aParentAlert);
-#endif
mySelectableObjects.UpdateBVH (mySelectingVolumeMgr.Camera(),
mySelectingVolumeMgr.ProjectionMatrix(),
mySelectingVolumeMgr.WorldViewMatrix(),
SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset =
static_cast<SelectMgr_SelectableObjectSet::BVHSubset> (aBVHSetIt);
- #ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt"), SelectMgr::BVHSubsetToString (aBVHSubset), &aPerfMeter, aParentAlert);
- Handle(Message_Alert) aParentAlertLevel1 = OCCT_Message_Alert;
- #endif
-
if (mySelectableObjects.IsEmpty (aBVHSubset))
{
continue;
Standard_Integer aHead = -1;
for (;;)
{
- #ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO (TCollection_AsciiString ("aNode - ") + aNode, "", &aPerfMeter, aParentAlertLevel1);
- #endif
if (!aBVHTree->IsOuter (aNode))
{
const Standard_Integer aLeftChildIdx = aBVHTree->Child<0> (aNode);
}
}
-#ifdef REPORT_SELECTION_BUILD
- MESSAGE_INFO ("SortResult", "", &aPerfMeter, aParentAlert);
-#endif
SortResult();
-#ifdef REPORT_SELECTION_BUILD
- Standard_SStream aStreamDone;
- Dump (aStreamDone);
- MESSAGE_INFO_STREAM (aStreamDone, "Parameters", "", &aPerfMeter, aParentAlert);
-#endif
}
//==================================================
//=======================================================================
void SelectMgr_ViewerSelector::SortResult()
{
-#ifdef REPORT_SELECTION_BUILD
- Message_PerfMeter aPerfMeter;
- MESSAGE_INFO ("SortResult", "", &aPerfMeter, NULL);
- Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
-#endif
-
if(mystored.IsEmpty()) return;
const Standard_Integer anExtent = mystored.Extent();
{
mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);
}
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-void SelectMgr_ViewerSelector::Dump(Standard_OStream& OS)const
-{
- DUMP_VALUES (OS, "SelectMgr_ViewerSelector", 2);
-
- DUMP_VALUES (OS, "IsPickClosest", IsPickClosest());
- DUMP_VALUES (OS, "ToUpdateTolerance", myToUpdateTolerance);
- DUMP_VALUES (OS, "mystored", mystored.Extent());
- //DUMP_VALUES (OS, "mySelectingVolumeMgr", mySelectingVolumeMgr);
-
- Standard_Integer aNbOfSelected = 0;
- for (SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); aSelectableIt.More(); aSelectableIt.Next())
- {
- aNbOfSelected++;
- }
- DUMP_VALUES (OS, "mySelectableObjects", aNbOfSelected);
- DUMP_VALUES (OS, "myTolerances.Tolerance()", myTolerances.Tolerance());
- DUMP_VALUES (OS, "myTolerances.CustomTolerance()", myTolerances.CustomTolerance());
- DUMP_VALUES (OS, "myZLayerOrderMap", myZLayerOrderMap.Size());
-}
//! depth which is used to choose among objects of the same priority.
void SetPickClosest (const Standard_Boolean theToPreferClosest) { preferclosest = theToPreferClosest; }
- //! Return preference of selecting one object for OnePicked() method
- Standard_Boolean IsPickClosest() const { return preferclosest; }
-
//! Returns the number of detected owners.
Standard_Integer NbPicked() const { return mystored.Extent(); }
//! Returns instance of selecting volume manager of the viewer selector
SelectMgr_SelectingVolumeManager& GetManager() { return mySelectingVolumeMgr; }
- //! Returns container of selectable objects
- const SelectMgr_SelectableObjectSet& GetSelectableObjects() const { return mySelectableObjects; }
-
- //! Returns container of sensitives
- const SelectMgr_MapOfObjectSensitives& GetObjectSensitives() const { return myMapOfObjectSensitives; }
-
//! Marks all added sensitive entities of all objects as non-selectable
Standard_EXPORT void ResetSelectionActivationStatus();
//! mark both included and overlapped entities as matched
Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
public:
//! Begins an iteration scanning for the owners detected at a position in the view.
#include <TCollection.hxx>
#include <Standard_OutOfRange.hxx>
-#include <TCollection_AsciiString.hxx>
// The array of prime numbers used as consequtive steps for
// size of array of buckets in the map.
}
throw Standard_OutOfRange ("TCollection::NextPrimeForMap() - requested too big size");
}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-
-TCollection_AsciiString TCollection::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- if (thePointer.IsNull())
- return TCollection_AsciiString();
-
- return GetPointerInfo(thePointer.operator->(), isShortInfo);
-}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-
-TCollection_AsciiString TCollection::GetPointerInfo (const void* thePointer, const bool isShortInfo)
-{
- std::ostringstream aPtrStr;
- aPtrStr << thePointer;
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend(GetPointerPrefix());
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
-// ----------------------------------------------------------------------------
-// Join
-// ----------------------------------------------------------------------------
-
-TCollection_AsciiString TCollection::Join (const NCollection_List<TCollection_AsciiString>& theValues,
- const TCollection_AsciiString& theSeparator)
-{
- TCollection_AsciiString aValue;
- for (NCollection_List<TCollection_AsciiString>::Iterator anIterator (theValues); anIterator.More(); anIterator.Next())
- {
- if (!aValue.IsEmpty())
- aValue += theSeparator;
-
- aValue += anIterator.Value();
- }
-
- return aValue;
-}
-
-// ----------------------------------------------------------------------------
-// Split
-// ----------------------------------------------------------------------------
-
-void TCollection::Split (const Standard_SStream& theStream,
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues,
- TCollection_AsciiString& theKey)
-{
- TCollection_AsciiString aStreamStr (theStream.str().c_str());
-
- TCollection_AsciiString aSplitValue, aTailValue, aKey;
- if (SplitKey (aStreamStr, aSplitValue, aTailValue, aKey))
- {
- if (aTailValue.IsEmpty())
- {
- theKey = aKey;
- aStreamStr = aSplitValue;
- }
- }
-
- NCollection_List<TCollection_AsciiString> aValues;
- split (aStreamStr, DumpSeparator(), aValues);
-
- for (NCollection_List<TCollection_AsciiString>::Iterator anIterator (aValues); anIterator.More(); anIterator.Next())
- {
- TCollection_AsciiString aKey = anIterator.Value();
- anIterator.Next();
- if (!anIterator.More())
- break;
- theValues.Add (aKey, anIterator.Value());
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// split
-// ----------------------------------------------------------------------------
-
-void TCollection::split (const TCollection_AsciiString& theValue,
- const TCollection_AsciiString& theSeparator,
- NCollection_List<TCollection_AsciiString>& theValues)
-{
- TCollection_AsciiString aCurrentString = theValue;
-
- TCollection_AsciiString aSplitValue, aTailValue, aKey;
- while (!aCurrentString.IsEmpty())
- {
- TCollection_AsciiString aValueString = aCurrentString;
- if (SplitDumped (aValueString, aSplitValue, aTailValue, aKey))
- {
- aValueString = aSplitValue;
- aCurrentString = aTailValue;
- }
- else
- {
- Standard_Integer aPosition = aValueString.Search (theSeparator);
- if (aPosition < 0 )
- break;
- aCurrentString = aValueString.Split (aPosition - 1);
- }
- theValues.Append (aValueString);
- if (aCurrentString.IsEmpty())
- break;
-
- aCurrentString = aCurrentString.Split (theSeparator.Length());
- }
-}
-
-// ----------------------------------------------------------------------------
-// SplitReal
-// ----------------------------------------------------------------------------
-
-Standard_Boolean TCollection::SplitReal (const TCollection_AsciiString& theValue,
- const TCollection_AsciiString& theSeparator,
- NCollection_Vector<Standard_Real>& theValues)
-{
- TCollection_AsciiString aCurrentString = theValue;
-
- while (!aCurrentString.IsEmpty())
- {
- TCollection_AsciiString aValueString = aCurrentString;
- Standard_Integer aPosition = aValueString.Search (theSeparator);
- if (aPosition < 0 )
- break;
-
- aCurrentString = aValueString.Split (aPosition);
- if (!aValueString.IsRealValue())
- return Standard_False;
-
- theValues.Append (aValueString.RealValue());
- aCurrentString = aCurrentString.Split (theSeparator.Length() + 1);
- }
-
- return !theValues.IsEmpty();
-}
-
-// ----------------------------------------------------------------------------
-// ToDumpString
-// ----------------------------------------------------------------------------
-
-TCollection_AsciiString TCollection::ToDumpString (const NCollection_List<TCollection_AsciiString>& theValues)
-{
- return TCollection::Join (theValues, TCollection::VectorSeparator());
-}
-
-// ----------------------------------------------------------------------------
-// ToString
-// ----------------------------------------------------------------------------
-
-TCollection_AsciiString TCollection::ToDumpString (const Standard_SStream& theStream)
-{
- return TCollection_AsciiString (theStream.str().c_str());
-}
-
-// ----------------------------------------------------------------------------
-// ConvertDumpToText
-// ----------------------------------------------------------------------------
-
-TCollection_AsciiString TCollection::ConvertDumpToText (const TCollection_AsciiString& theValue)
-{
- TCollection_AsciiString aText = theValue;
-
- //TCollection_AsciiString aCurrentString = theValue;
- //while (!aCurrentString.IsEmpty())
- //{
- // TCollection_AsciiString aValueString = aCurrentString;
- // Standard_Integer aPosition = aValueString.Search (theSeparator);
- // if (aPosition < 0 )
- // break;
-
- // aCurrentString = aValueString.Split (aPosition);
- // theValues.Append (aValueString);
-
- // aCurrentString = aCurrentString.Split (theSeparator.Length() + 1);
- //}
-
- //TCollection_AsciiString XMLBracketOpen() { return TCollection_AsciiString ("<"); }
- //TCollection_AsciiString XMLBracketClose() { return TCollection_AsciiString (">"); }
- //TCollection_AsciiString XMLFinishKey() { return TCollection_AsciiString ("\\"); }
-
- return aText;
-}
-
-// ----------------------------------------------------------------------------
-// SplitDumped
-// ----------------------------------------------------------------------------
-
-Standard_Boolean TCollection::SplitDumped (const TCollection_AsciiString& theSourceValue,
- TCollection_AsciiString& theSplitValue,
- TCollection_AsciiString& theTailValue,
- TCollection_AsciiString& theKey)
-{
- Standard_Integer aBracketPosition = theSourceValue.Search (XMLBracketOpen());
- // the first symbol is bracket
- if (aBracketPosition != 1 || aBracketPosition >= theSourceValue.Length())
- return Standard_False;
-
- TCollection_AsciiString aValue = theSourceValue.SubString (aBracketPosition + 1, theSourceValue.Length());
-
- aBracketPosition = aValue.Search (XMLBracketClose());
- if (aBracketPosition <= 1 || aBracketPosition >= theSourceValue.Length())
- return Standard_False;
-
- theKey = aValue;
-
- TCollection_AsciiString aTailValue = theKey.Split (aBracketPosition - 1);
- aTailValue = aTailValue.SubString (2, aTailValue.Length()); // remove close bracket
- TCollection_AsciiString aStopKey = StopKey (theKey);
-
- aBracketPosition = theSourceValue.Search (aStopKey);
-
- Standard_Integer aStopKeyLastPosition = aBracketPosition + aStopKey.Length() - 1;
-
- //aBracketPosition = aTailValue.Search (aStopKey);
- if (aBracketPosition <= 1 || aStopKeyLastPosition > theSourceValue.Length())
- return Standard_False;
-
- theSplitValue = theSourceValue;
- theTailValue = theSplitValue.Split (aStopKeyLastPosition);
- //theSplitValue = aTailValue;
- //aTailValue = theSplitValue.Split (aBracketPosition - 1);
-
- //if (aTailValue.Length() < aStopKey.Length())
- // return Standard_False;
-
- //if (aTailValue.Length() == aStopKey.Length())
- //{
- // theTailValue = TCollection_AsciiString();
- // return Standard_True;
- //}
-
- //theTailValue = aTailValue.Split (aStopKey.Length());
- return Standard_True;
-}
-
-// ----------------------------------------------------------------------------
-// SplitKey
-// ----------------------------------------------------------------------------
-
-Standard_Boolean TCollection::SplitKey (const TCollection_AsciiString& theSourceValue,
- TCollection_AsciiString& theSplitValue,
- TCollection_AsciiString& theTailValue,
- TCollection_AsciiString& theKey)
-{
- Standard_Integer aBracketPosition = theSourceValue.Search (XMLBracketOpen());
- // the first symbol is bracket
- if (aBracketPosition != 1 || aBracketPosition >= theSourceValue.Length())
- return Standard_False;
-
- TCollection_AsciiString aValue = theSourceValue.SubString (aBracketPosition + 1, theSourceValue.Length());
-
- aBracketPosition = aValue.Search (XMLBracketClose());
- if (aBracketPosition <= 1 || aBracketPosition >= theSourceValue.Length())
- return Standard_False;
-
- theKey = aValue;
-
- TCollection_AsciiString aTailValue = theKey.Split (aBracketPosition - 1);
- aTailValue = aTailValue.SubString (2, aTailValue.Length()); // remove close bracket
- TCollection_AsciiString aStopKey = StopKey (theKey);
-
- aBracketPosition = aTailValue.Search (aStopKey);
- if (aBracketPosition <= 1 || aBracketPosition >= aTailValue.Length())
- return Standard_False;
-
- theSplitValue = aTailValue;
- aTailValue = theSplitValue.Split (aBracketPosition - 1);
-
- if (aTailValue.Length() == aStopKey.Length())
- theTailValue = "";
- else
- theTailValue = aTailValue.SubString (aStopKey.Length(), aTailValue.Length());
- return Standard_True;
-}
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <NCollection_IndexedDataMap.hxx>
-#include <NCollection_IndexedMap.hxx>
-#include <NCollection_List.hxx>
-#include <NCollection_Vector.hxx>
-
+class TCollection_AsciiString;
class TCollection_ExtendedString;
class TCollection_HAsciiString;
class TCollection_HExtendedString;
DEFINE_STANDARD_ALLOC
- //! Returns default prefix added for each pointer info string
- Standard_EXPORT static TCollection_AsciiString GetPointerPrefix() { return "0x"; }
-
- //! Convert handle pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo = true);
-
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const void* thePointer,
- const bool isShortInfo = true);
-
//! Returns a prime number greater than <I> suitable
//! to dimension a Map. When <I> becomes great there
//! is a limit on the result (today the limit is
//! there will be more collisions in the map.
Standard_EXPORT static Standard_Integer NextPrimeForMap (const Standard_Integer I);
- //! Returns separator symbol of Dump information
- static Standard_Character DumpSeparator() { return '\\'; }
- //! Returns separator symbol of values vector union
- static Standard_CString VectorSeparator() { return " ,"; }
- //! Returns separator symbol of class name prefix
- static inline Standard_CString ClassNameSeparator() { return " ,"; }
-
- //! Unites list of string into one string using the separator
- Standard_EXPORT static TCollection_AsciiString Join (const NCollection_List<TCollection_AsciiString>& theValues,
- const TCollection_AsciiString& theSeparator);
-
- //! Converts stream to map of values where the key is each odd, value is each even value
- //! \param theStream stream value
- //! \param theValues [out] container of split values
- Standard_EXPORT static void Split (const Standard_SStream& theStream,
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues,
- TCollection_AsciiString& theKey);
-
-private:
- //! Unites list of string into one string using the separator
- Standard_EXPORT static void split (const TCollection_AsciiString& theValue,
- const TCollection_AsciiString& theSeparator,
- NCollection_List<TCollection_AsciiString>& theValues);
-public:
- //! Unites list of string into one string using the separator
- Standard_EXPORT static Standard_Boolean SplitReal (const TCollection_AsciiString& theValue,
- const TCollection_AsciiString& theSeparator,
- NCollection_Vector<Standard_Real>& theValues);
-
- //! Unites vector to string value using VectorSeparator.
- Standard_EXPORT static TCollection_AsciiString ToDumpString (const NCollection_List<TCollection_AsciiString>& theValues);
- //! Converts stream value to string value
- Standard_EXPORT static TCollection_AsciiString ToDumpString (const Standard_SStream& theStream);
-
- //! Converts stream value to string value
- static TCollection_AsciiString StartKey (const TCollection_AsciiString& theValue)
- { return XMLBracketOpen() + theValue + XMLBracketClose(); }
-
- //! Converts stream value to string value
- static TCollection_AsciiString StopKey (const TCollection_AsciiString& theValue)
- { return XMLBracketOpen() + XMLFinishKey() + theValue + XMLBracketClose(); }
-
- Standard_EXPORT static TCollection_AsciiString ConvertDumpToText (const TCollection_AsciiString& theValue);
-
- //! Splits a AsciiString into two sub-strings using Dump keys.
- //! Example:
- //! aString contains "<key>abc</key>defg"
- //! aString.SplitDumped() gives theSplitValue = "abc", theTailValue = "defg", theKey = "key"
- Standard_EXPORT static Standard_Boolean SplitDumped (const TCollection_AsciiString& theSourceValue,
- TCollection_AsciiString& theSplitValue,
- TCollection_AsciiString& theTailValue,
- TCollection_AsciiString& theKey);
-
- //! Splits value that contains a key in form: <key>value</key>. In this case the values are:
- //! theSplitValue = value, theKey = key.
- Standard_EXPORT static Standard_Boolean SplitKey (const TCollection_AsciiString& theSourceValue,
- TCollection_AsciiString& theSplitValue,
- TCollection_AsciiString& theTailValue,
- TCollection_AsciiString& theKey);
-
- //! Returns true if the value has bracket key
- static Standard_Boolean HasBracketKey (const TCollection_AsciiString& theSourceValue)
- { return theSourceValue.Search (TCollection::XMLBracketOpen()) >= 0; }
-
-protected:
- static TCollection_AsciiString XMLBracketOpen() { return TCollection_AsciiString ("<"); }
- static TCollection_AsciiString XMLBracketClose() { return TCollection_AsciiString (">"); }
- static TCollection_AsciiString XMLFinishKey() { return TCollection_AsciiString ("\\"); }
protected:
};
-#define DUMP_VALUES(OS, Value1, Value2) \
-{ \
- OS << Value1 << TCollection::DumpSeparator() << Value2 << TCollection::DumpSeparator(); \
-}
-
-#define DUMP_START_KEY(OS, Value1) { OS << TCollection::StartKey (Value1); }
-#define DUMP_STOP_KEY(OS, Value1) { OS << TCollection::StopKey (Value1); }
#include <Standard_ConstructionError.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Type.hxx>
-#include <TCollection.hxx>
#include <TopLoc_Datum3D.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TopLoc_Datum3D,Standard_Transient)
{
}
-const TCollection_AsciiString TopLoc_Datum3D_ClassName = "TopLoc_Datum3D";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void TopLoc_Datum3D::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, TopLoc_Datum3D_ClassName);
-
- Standard_SStream aTmpStream;
- myTrsf.Dump (aTmpStream);
- DUMP_VALUES (OS, "Transformation", TCollection::ToDumpString (aTmpStream));
-
- DUMP_START_KEY (OS, TopLoc_Datum3D_ClassName);
-}
-
//=======================================================================
//function : ShallowDump
//purpose :
const gp_Trsf& Transformation() const;
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
//! Writes the contents of this Datum3D to the stream S.
Standard_EXPORT void ShallowDump (Standard_OStream& S) const;
#include <TopLoc_Datum3D.hxx>
-#include <TCollection.hxx>
#include <TopLoc_ItemLocation.hxx>
#include <TopLoc_Location.hxx>
#include <TopLoc_SListOfItemLocation.hxx>
myTrsf (D->Transformation().Powered (P))
{
}
-
-const TCollection_AsciiString TopLoc_ItemLocation_ClassName = "TopLoc_ItemLocation";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void TopLoc_ItemLocation::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, TopLoc_ItemLocation_ClassName);
-
- DUMP_VALUES (OS, "Power", myPower);
- {
- Standard_SStream aTmpStream;
- myTrsf.Dump (aTmpStream);
- DUMP_VALUES (OS, "Trsf", TCollection::ToDumpString (aTmpStream));
- }
- {
- Standard_SStream aTmpStream;
- if (!myDatum.IsNull())
- myDatum->Dump (aTmpStream);
- DUMP_VALUES (OS, "Datum", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_STOP_KEY (OS, TopLoc_ItemLocation_ClassName);
-}
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_OStream.hxx>
#include <gp_Trsf.hxx>
class TopLoc_Datum3D;
class TopLoc_Location;
//! Sets the exponent to <P>
Standard_EXPORT TopLoc_ItemLocation(const Handle(TopLoc_Datum3D)& D, const Standard_Integer P);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
friend class TopLoc_Location;
friend class TopLoc_SListOfItemLocation;
#include <gp_Trsf.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_NoSuchObject.hxx>
-#include <TCollection.hxx>
#include <TopLoc_Datum3D.hxx>
#include <TopLoc_ItemLocation.hxx>
#include <TopLoc_Location.hxx>
return !IsEqual(Other);
}
-const TCollection_AsciiString TopLoc_Location_ClassName = "TopLoc_Location";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void TopLoc_Location::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, TopLoc_Location_ClassName);
-
- DUMP_VALUES (OS, "IsIdentity", IsIdentity());
- {
- Standard_SStream aTmpStream;
- Transformation().Dump (aTmpStream);
- DUMP_VALUES (OS, "Transformation", TCollection::ToDumpString (aTmpStream));
- }
-
- /*TopLoc_SListOfItemLocation items = myItems;
- if (!items.IsEmpty())
- {
- while (items.More())
- {
- Standard_SStream aTmpStream;
- items.Value().Dump (aTmpStream);
- DUMP_VALUES (OS, "Item", TCollection::ToDumpString (aTmpStream));
-
- items.Next();
- }
- }*/
- DUMP_STOP_KEY (OS, TopLoc_Location_ClassName);
-}
-
//=======================================================================
//function : ShallowDump
//purpose :
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
-
class Standard_NoSuchObject;
class Standard_ConstructionError;
class gp_Trsf;
return IsDifferent(Other);
}
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
//! Prints the contents of <me> on the stream <s>.
Standard_EXPORT void ShallowDump (Standard_OStream& S) const;
TopoDS.hxx
TopoDS.lxx
-TopoDS_AlertAttribute.hxx
-TopoDS_AlertAttribute.cxx
TopoDS_Builder.cxx
TopoDS_Builder.hxx
TopoDS_Builder.lxx
+++ /dev/null
-// Created on: 2018-06-10
-// 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 <TopoDS_AlertAttribute.hxx>
-
-#include <Message_Msg.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_Attribute)
-
-//=======================================================================
-//function : TopoDS_AlertAttribute
-//purpose :
-//=======================================================================
-
-
-TopoDS_AlertAttribute::TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
- const TCollection_AsciiString& theName,
- const TCollection_AsciiString& theDescription)
-: Message_AttributeStream (Standard_SStream(), theName, theDescription), myShape (theShape)
-{
- Standard_SStream aStream;
- theShape.Dump (aStream);
-
- SetStream (aStream);
-}
+++ /dev/null
-// Created on: 2018-06-10
-// 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 _TopoDS_AlertAttribute_HeaderFile
-#define _TopoDS_AlertAttribute_HeaderFile
-
-#include <Message_AttributeStream.hxx>
-#include <TopoDS_Shape.hxx>
-
-//! Alert attributre object storing TopoDS shape in its field
-class TopoDS_AlertAttribute : public Message_AttributeStream
-{
-public:
- //! Constructor with shape argument
- Standard_EXPORT TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
- const TCollection_AsciiString& theName = TCollection_AsciiString(),
- const TCollection_AsciiString& theDescription = TCollection_AsciiString());
-
- //! Returns contained shape
- const TopoDS_Shape& GetShape() const { return myShape; }
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_AttributeStream)
-
-private:
- TopoDS_Shape myShape;
-};
-
-#define MESSAGE_INFO_SHAPE(Shape, Name, Description, PerfMeter, ParentAlert) \
- { \
- if (!Message_Report::CurrentReport().IsNull() && \
- Message_Report::CurrentReport()->IsActive (Message_Info)) \
- { \
- OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
- new TopoDS_AlertAttribute (Shape, Name, Description), PerfMeter, ParentAlert); \
- } \
- }
-
-#endif // _TopoDS_AlertAttribute_HeaderFile
#include <Standard_DomainError.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_TypeMismatch.hxx>
-#include <TCollection.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_TShape.hxx>
const Standard_Integer aHL = myLocation.HashCode (theUpperBound);
return ::HashCode (aHS ^ aHL, theUpperBound);
}
-
-const TCollection_AsciiString TopoDS_Shape_ClassName = "TopoDS_Shape";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void TopoDS_Shape::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, TopoDS_Shape_ClassName);
-
- DUMP_VALUES (OS, "TShape", TCollection::GetPointerInfo (myTShape));
- DUMP_VALUES (OS, "Orientation", TopAbs::ShapeOrientationToString (myOrient));
- {
- Standard_SStream aTmpStream;
- myLocation.Dump (aTmpStream);
- DUMP_VALUES (OS, "Location", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_STOP_KEY (OS, TopoDS_Shape_ClassName);
-}
void TShape (const Handle(TopoDS_TShape)& theTShape) { myTShape = theTShape; }
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
private:
Handle(TopoDS_TShape) myTShape;
myDefaultViewAxis.SetCoord (theVx, theVy, theVz);
}
-//=============================================================================
-//function : Axis
-//purpose :
-//=============================================================================
-void V3d_View::Axis (Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ,
- Standard_Real& theVx, Standard_Real& theVy, Standard_Real& theVz)
-{
- myDefaultViewPoint.Coord (theX, theY, theZ);
- myDefaultViewAxis.Coord (theVx, theVy, theVz);
-}
-
//=============================================================================
//function : SetShadingModel
//purpose :
Standard_EXPORT void SetAxis (const Standard_Real X, const Standard_Real Y, const Standard_Real Z,
const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz);
- //! Returns an axis from its origin and
- //! its orientation .
- //! This is the current axis for rotations and movements.
- Standard_EXPORT void Axis (Standard_Real& X, Standard_Real& Y, Standard_Real& Z,
- Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz);
-
//! Defines the shading model for the visualization. Various models are available.
Standard_EXPORT void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel);
#include <XCAFPrs_Style.hxx>
-#include <TCollection.hxx>
-
//=======================================================================
//function : XCAFPrs_Style
//purpose :
myHasColorCurv = Standard_False;
myColorCurv.SetValues (Quantity_NOC_YELLOW);
}
-
-const TCollection_AsciiString XCAFPrs_Style_ClassName = "XCAFPrs_Style";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void XCAFPrs_Style::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, XCAFPrs_Style_ClassName);
-
- DUMP_VALUES (OS, "HasColorSurf", myHasColorSurf);
- {
- Standard_SStream aTmpStream;
- myColorSurf.Dump (aTmpStream);
- DUMP_VALUES (OS, "ColorSurf", TCollection::ToDumpString (aTmpStream));
- }
- DUMP_VALUES (OS, "HasColorCurv", myHasColorCurv);
- {
- Standard_SStream aTmpStream;
- myColorCurv.Dump (aTmpStream);
- DUMP_VALUES (OS, "ColorCurv", TCollection::ToDumpString (aTmpStream));
- }
- DUMP_VALUES (OS, "IsVisible", myIsVisible);
-
- DUMP_STOP_KEY (OS, XCAFPrs_Style_ClassName);
-}
return theS1.IsEqual (theS2);
}
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
protected:
Quantity_ColorRGBA myColorSurf;
XmlDrivers_DocumentRetrievalDriver.hxx
XmlDrivers_DocumentStorageDriver.cxx
XmlDrivers_DocumentStorageDriver.hxx
-XmlDrivers_MessageReportStorage.cxx
-XmlDrivers_MessageReportStorage.hxx
+++ /dev/null
-// Created on: 2018-06-10
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2001-2014 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 <XmlDrivers_MessageReportStorage.hxx>
-
-#include <Message.hxx>
-#include <Message_AlertExtended.hxx>
-#include <Message_AttributeStream.hxx>
-#include <Message_CompositeAlerts.hxx>
-#include <Message_Report.hxx>
-
-#include <TCollection.hxx>
-#include <TDataStd_AsciiString.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TDataStd_Real.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_ExtStringArray.hxx>
-#include <TDF_ChildIterator.hxx>
-#include <TDocStd_Application.hxx>
-#include <TDocStd_Document.hxx>
-#include <XmlDrivers.hxx>
-
-// =======================================================================
-// function : GetApplication
-// purpose :
-// =======================================================================
-
-const Handle(TDocStd_Application)& GetApplication()
-{
- static Handle(TDocStd_Application) anApp;
- if (anApp.IsNull())
- {
- anApp = new TDocStd_Application;
- XmlDrivers::DefineFormat (anApp);
- }
- return anApp;
-}
-
-// =======================================================================
-// function : ExportReport
-// purpose :
-// =======================================================================
-
-void XmlDrivers_MessageReportStorage::ExportReport (const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theFileName)
-{
- if (theReport.IsNull())
- return;
-
- Handle(TDocStd_Document) aDocument;
- GetApplication()->NewDocument (TCollection_ExtendedString ("XmlOcaf"), aDocument);
-
- TDF_Label aMainLabel = aDocument->Main();
-
- for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++)
- {
- Message_Gravity aGravity = (Message_Gravity)aGravityId;
-
- if (theReport->GetAlerts (aGravity).Size() == 0)
- continue;
- // Gravity Label
- TDF_Label aGravityLabel = aMainLabel.NewChild();
- // set gravity kind string
- TCollection_ExtendedString aName (Message::GravityToString ((Message_Gravity)aGravity));
- if (!aName.IsEmpty())
- TDataStd_Name::Set (aGravityLabel, aName);
-
- /// reserved label to store gravity information
- //TDF_Label aFirstAlertLabel = aGravityLabel.NewChild();
-
- // Alert Labels: labels are started from the second index
- const Message_ListOfAlert& anAlerts = theReport->GetAlerts (aGravity);
- for (Message_ListOfAlert::Iterator anAlertsIt (anAlerts); anAlertsIt.More(); anAlertsIt.Next())
- {
- exportAlert (anAlertsIt.Value(), aGravityLabel);
- }
- }
- GetApplication()->SaveAs (aDocument, theFileName);
-}
-
-// =======================================================================
-// function : ImportReport
-// purpose :
-// =======================================================================
-
-Handle(Message_Report) XmlDrivers_MessageReportStorage::ImportReport (const TCollection_AsciiString& theFileName)
-{
- Handle(TDocStd_Application) anApplication = GetApplication();
- Standard_Integer aDocumentId = anApplication->IsInSession (theFileName);
- if (aDocumentId > 0)
- {
- Handle(TDocStd_Document) aDocument;
- anApplication->GetDocument (aDocumentId, aDocument);
- anApplication->Close (aDocument);
- }
-
- Handle(TDocStd_Document) aDocument;
- GetApplication()->Open (theFileName, aDocument);
- if (aDocument.IsNull())
- return Handle(Message_Report)();
-
- TDF_Label aMainLabel = aDocument->Main();
- if (aMainLabel.IsNull())
- return Handle(Message_Report)();
-
- TDF_Label aLabel;
- Handle(Message_Report) aReport = new Message_Report();
- for (TDF_ChildIterator aLabelsIt(aMainLabel); aLabelsIt.More(); aLabelsIt.Next())
- {
- TDF_Label aGravityLabel = aLabelsIt.Value();
- if (aGravityLabel.IsNull())
- continue;
- Handle(TDF_Attribute) anAttribute;
- if (!aGravityLabel.FindAttribute (TDataStd_Name::GetID(), anAttribute))
- continue;
- Handle(TDataStd_Name) aNameAttribute = Handle(TDataStd_Name)::DownCast (anAttribute);
- if (aNameAttribute.IsNull())
- continue;
-
- // get gravity type
- const TCollection_ExtendedString& aGravityName = aNameAttribute->Get();
- Message_Gravity aGravity = Message::GravityFromString (TCollection_AsciiString (aGravityName).ToCString());
-
- /// reserved label to store gravity information
- //TDF_Label aFirstAlertLabel = aGravityLabel.FindChild (1, Standard_False);
-
- // find alerts information, add corresponded alerts to the report
- for (TDF_ChildIterator anAlertLabelsIt (aGravityLabel); anAlertLabelsIt.More(); anAlertLabelsIt.Next())
- {
- TDF_Label anAlertLabel = anAlertLabelsIt.Value();
- if (anAlertLabel.IsNull())
- continue;
-
- importAlert (anAlertLabel, aGravity, aReport, Handle(Message_Alert)());
- }
- }
- return aReport;
-}
-
-// =======================================================================
-// function : exportAlert
-// purpose :
-// =======================================================================
-
-void XmlDrivers_MessageReportStorage::exportAlert (const Handle(Message_Alert)& theAlert, const TDF_Label& theParentLabel)
-{
- TDF_Label anAlertLabel = theParentLabel.NewChild();
- TDataStd_Name::Set (anAlertLabel, theAlert->DynamicType()->Name());
-
- /// reserved label to store parameters of the current label
- TDF_Label anAlertParmetersLabel = anAlertLabel.NewChild();
- exportAlertParameters (theAlert, anAlertParmetersLabel);
-
- for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++)
- {
- // Gravity Label
- TDF_Label aGravityLabel = anAlertLabel.NewChild();
- // set gravity kind string
- TDataStd_Name::Set (aGravityLabel, Message::GravityToString ((Message_Gravity)aGravityId));
-
- Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anAlertExtended.IsNull())
- continue;
- Handle(Message_CompositeAlerts) aComposite = anAlertExtended->GetCompositeAlerts();
- if (aComposite.IsNull())
- continue;
-
- const Message_ListOfAlert& anAlerts = aComposite->GetAlerts ((Message_Gravity)aGravityId);
- for (Message_ListOfAlert::Iterator anAlertsIt (anAlerts); anAlertsIt.More(); anAlertsIt.Next())
- exportAlert (anAlertsIt.Value(), aGravityLabel);
- }
-}
-
-// =======================================================================
-// function : importAlert
-// purpose :
-// =======================================================================
-
-void XmlDrivers_MessageReportStorage::importAlert (const TDF_Label& theAlertLabel,
- const Message_Gravity theGravity,
- Handle(Message_Report)& theReport,
- const Handle(Message_Alert)& theParentAlert)
-{
- TDF_Label aParametersLabel = theAlertLabel.FindChild (1, Standard_False);
- Handle(Message_Alert) anAlert = importAlertParameters (aParametersLabel);
- if (anAlert.IsNull())
- return;
-
- TDF_Label aLabel;
- TDF_ChildIterator aSubAlertsLabelsIt (theAlertLabel);
- aSubAlertsLabelsIt.Next(); // do not processing the first (parameters) label
- for (; aSubAlertsLabelsIt.More(); aSubAlertsLabelsIt.Next())
- {
- TDF_Label aGravityLabel = aSubAlertsLabelsIt.Value();
- if (aGravityLabel.IsNull())
- continue;
- Handle(TDF_Attribute) anAttribute;
- if (!aGravityLabel.FindAttribute (TDataStd_Name::GetID(), anAttribute))
- continue;
- Handle(TDataStd_Name) aNameAttribute = Handle(TDataStd_Name)::DownCast (anAttribute);
- if (aNameAttribute.IsNull())
- continue;
-
- // get gravity type
- Message_Gravity aGravity = Message::GravityFromString (TCollection_AsciiString (aNameAttribute->Get()).ToCString());
- // find alerts information, add corresponded alerts to the report
- for (TDF_ChildIterator anAlertLabelsIt (aGravityLabel); anAlertLabelsIt.More(); anAlertLabelsIt.Next())
- {
- TDF_Label anAlertLabel = anAlertLabelsIt.Value();
- if (anAlertLabel.IsNull())
- continue;
-
- importAlert (anAlertLabel, aGravity, theReport, anAlert);
- }
- }
- theReport->AddAlert (theGravity, anAlert, 0, theParentAlert);
-}
-
-// =======================================================================
-// function : exportAlertParameters
-// purpose :
-// =======================================================================
-void XmlDrivers_MessageReportStorage::exportAlertParameters (const Handle(Message_Alert)& theAlert, const TDF_Label& theAlertLabel)
-{
- Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anAlertExtended.IsNull()) // name attribute is empty
- return;
-
- // store attribute time
- Handle(Message_Attribute) anAttribute = anAlertExtended->Attribute();
-
- TDataStd_Name::Set (theAlertLabel, anAttribute->DynamicType()->Name());
- //TDataStd_Real::Set (theAlertLabel, anAlertExtended->CumulativeMetric());
-
- TDataStd_AsciiString::Set (theAlertLabel, anAttribute->GetName());
- TCollection_AsciiString aDescription = anAttribute->GetDescription();
- if (!aDescription.IsEmpty())
- TDataStd_Comment::Set (theAlertLabel, anAttribute->GetDescription());
-
- Standard_CString aDynamicTypeName = anAttribute->DynamicType()->Name();
- if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name())
- {
- Handle(Message_AttributeStream) aValuesArrayAlert = Handle(Message_AttributeStream)::DownCast (anAttribute);
- // store values
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aValues;
- TCollection_AsciiString aKey;
- TCollection::Split (aValuesArrayAlert->GetStream(), aValues, aKey);
- if (aValues.IsEmpty())
- return;
- int anArraySize = 2 * aValues.Size();
- Handle(TDataStd_ExtStringArray) aListAttribute = TDataStd_ExtStringArray::Set (theAlertLabel, 0, anArraySize - 1);
- for (int aValueId = 0; aValueId < anArraySize; aValueId++)
- {
- TCollection_AsciiString aKey = aValues.FindKey (aValueId);
- aListAttribute->SetValue (aValueId * 2, aKey);
- aListAttribute->SetValue (aValueId * 2 + 1, aValues.FindFromKey (aKey));
- }
- }
-}
-
-// =======================================================================
-// function : importAlertParameters
-// purpose :
-// =======================================================================
-Handle(Message_Alert) XmlDrivers_MessageReportStorage::importAlertParameters (const TDF_Label& aParametersLabel)
-{
- Handle(TDF_Attribute) anAttribute;
- if (!aParametersLabel.FindAttribute (TDataStd_Name::GetID(), anAttribute))
- return Handle(Message_Alert)();
-
- Handle(TDataStd_Name) aDynamicTypeAttribute = Handle(TDataStd_Name)::DownCast (anAttribute);
- if (aDynamicTypeAttribute.IsNull())
- return Handle(Message_Alert)();
- const TCollection_ExtendedString& aDynamicTypeName = aDynamicTypeAttribute->Get();
-
- TCollection_ExtendedString aDescription;
- if (aParametersLabel.FindAttribute (TDataStd_Comment::GetID(), anAttribute))
- {
- Handle(TDataStd_Comment) aDescriptionAttribute = Handle(TDataStd_Comment)::DownCast (anAttribute);
- if (!aDescriptionAttribute.IsNull())
- aDescription = aDescriptionAttribute->Get();
- }
-
- Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
- Handle(Message_Attribute) aMessageAttribute;
- if (aDynamicTypeName == STANDARD_TYPE (Message_Attribute)->Name())
- aMessageAttribute = new Message_Attribute();
- else if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name())
- {
- // values
- NCollection_Vector<TCollection_AsciiString> anArrayValues;
- if (!aParametersLabel.FindAttribute (TDataStd_ExtStringArray::GetID(), anAttribute))
- return Handle(Message_Alert)();
-
- Handle(TDataStd_ExtStringArray) aValuesAttribute = Handle(TDataStd_ExtStringArray)::DownCast (anAttribute);
- if (aValuesAttribute.IsNull())
- return Handle(Message_Alert)();
-
- Standard_SStream aStream;
- for (int aValueId = aValuesAttribute->Lower(); aValueId <= aValuesAttribute->Upper(); aValueId++)
- {
- TCollection_AsciiString aKey = aValuesAttribute->Value (aValueId++);
- if (aValueId > aValuesAttribute->Upper())
- break;
- DUMP_VALUES (aStream, aKey, aValuesAttribute->Value (aValueId));
- }
- Handle(Message_AttributeStream) anAlert = new Message_AttributeStream (aStream);
- aMessageAttribute = anAlert;
- }
-
- if (!aMessageAttribute.IsNull())
- {
- // name
- if (!aParametersLabel.FindAttribute (TDataStd_AsciiString::GetID(), anAttribute))
- return Handle(Message_Alert)();
- Handle(TDataStd_AsciiString) aNameAttribute = Handle(TDataStd_AsciiString)::DownCast (anAttribute);
- if (aNameAttribute.IsNull())
- return Handle(Message_Alert)();
-
- aMessageAttribute->SetName (aNameAttribute->Get());
- aMessageAttribute->SetDescription (aDescription);
-
- anAlert->SetAttribute (aMessageAttribute);
- }
-
- // time
- Standard_Real aTime = -1;
- Handle(TDataStd_Real) aTimeAttribute;
- if (aParametersLabel.FindAttribute (TDataStd_Real::GetID(), aTimeAttribute))
- aTime = aTimeAttribute->Get();
-
- //anAlert->SetCumulativeMetric (aTime);
- return anAlert;
-}
+++ /dev/null
-// Created on: 2018-06-10
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2001-2014 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 _XmlDrivers_MessageReportStorage
-#define _XmlDrivers_MessageReportStorage
-
-#include <Standard_Handle.hxx>
-
-#include <Message_Report.hxx>
-#include <Message_Alert.hxx>
-#include <TDF_Label.hxx>
-
-//! Base class to store/restore Message_Report content in XML document
-class XmlDrivers_MessageReportStorage
-{
-public:
- //! Create document for the report
- //! \param theReport the source report
- //! \param theFileName a file name
- Standard_EXPORT static void ExportReport (const Handle(Message_Report)& theReport, const TCollection_AsciiString& theFileName);
-
- //! Restores document file content into report instance
- //! \param theFileName a file name
- //! \return new report or NULL
- Standard_EXPORT static Handle(Message_Report) ImportReport (const TCollection_AsciiString& theFileName);
-
-private:
- //! Create labels/attributes for the alert and place it under the parent label.
- //! It is recursive as alerts may contains other alerts
- //! \param theAlert a source alert
- //! \parm theParentLabel a label where alert label is placed
- static void exportAlert (const Handle(Message_Alert)& theAlert, const TDF_Label& theParentLabel);
-
- //! Creates a new alert by the label parameters
- //! \param theAlertLabel a source document label
- //! \param theGravity an alert gravity
- //! \param theReport a container of alerts
- //! \param theParentAlert a parent alert, if null, the parent is report
- static void importAlert (const TDF_Label& theAlertLabel,
- const Message_Gravity theGravity,
- Handle(Message_Report)& theReport,
- const Handle(Message_Alert)& theParentAlert);
-
- //! Convert alert to a custom type and store parameters in child labels and attributes
- //! \param theAlert a source alert
- //! \parm theAlertLabel an alert label
- static void exportAlertParameters (const Handle(Message_Alert)& theAlert,
- const TDF_Label& theAlertLabel);
-
- //! Creates alert by label type filled by the label content
- //! \param theParametersLabel a label
- //! \return new alert or NULL
- static Handle(Message_Alert) importAlertParameters (const TDF_Label& aParametersLabel);
-};
-
-#endif // _XmlDrivers_MessageReportStorage
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
-#include <TCollection_AsciiString.hxx>
-
-namespace
-{
- static Standard_CString gp_Table_PrintTrsfForm[9] =
- {
- "IDENTITY", "ROTATION", "TRANSLATION", "PNTMIRROR", "AX1MIRROR", "AX2MIRROR",
- "SCALE", "COMPOUNDSTRSF", "OTHER2"
- };
-}
-
//=======================================================================
//function : Origin
//purpose :
return gp_OY2d;
}
-//=======================================================================
-//function : TypeOfTrsfFormToString
-//purpose :
-//=======================================================================
-Standard_CString gp::TrsfFormToString (gp_TrsfForm theType)
-{
- return gp_Table_PrintTrsfForm[theType];
-}
-
-//=======================================================================
-//function : TrsfFormFromString
-//purpose :
-//=======================================================================
-Standard_Boolean gp::TrsfFormFromString (Standard_CString theTypeString,
- gp_TrsfForm& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- aName.UpperCase();
- for (Standard_Integer aTypeIter = gp_Identity; aTypeIter <= gp_Other; ++aTypeIter)
- {
- Standard_CString aTypeName = gp_Table_PrintTrsfForm[aTypeIter];
- if (aName == aTypeName)
- {
- theType = gp_TrsfForm (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
#ifndef _gp_HeaderFile
#define _gp_HeaderFile
-#include <gp_TrsfForm.hxx>
-
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
Standard_EXPORT static const gp_Ax2d& OY2d();
- //! Returns the string name for a given type.
- //! @param theType an enumeration type
- //! @return string identifier from the enumeration list
- Standard_EXPORT static Standard_CString TrsfFormToString (gp_TrsfForm theType);
-
- //! Returns the orientation type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return enumeration type or gp_Identity if string identifier is invalid
- static gp_TrsfForm TrsfFormFromString (Standard_CString theTypeString)
- {
- gp_TrsfForm aType = gp_Identity;
- TrsfFormFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean TrsfFormFromString (const Standard_CString theTypeString,
- gp_TrsfForm& theType);
protected:
#include <gp_Mat.hxx>
#include <gp_Trsf.hxx>
#include <gp_XYZ.hxx>
-#include <NCollection_List.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
-#include <TCollection.hxx>
-#include <TCollection_AsciiString.hxx>
#define M00 ((Standard_Real*)M)[0]
#define M01 ((Standard_Real*)M)[1]
}
}
-const TCollection_AsciiString gp_Map_ClassName = "gp_Mat";
-
-void gp_Mat::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, gp_Map_ClassName);
-
- DUMP_VALUES (OS, "Mat00", Mat00);
- DUMP_VALUES (OS, "Mat01", Mat01);
- DUMP_VALUES (OS, "Mat02", Mat02);
-
- DUMP_VALUES (OS, "Mat10", Mat10);
- DUMP_VALUES (OS, "Mat11", Mat11);
- DUMP_VALUES (OS, "Mat12", Mat12);
-
- DUMP_VALUES (OS, "Mat20", Mat20);
- DUMP_VALUES (OS, "Mat21", Mat21);
- DUMP_VALUES (OS, "Mat22", Mat22);
-
- DUMP_STOP_KEY (OS, gp_Map_ClassName);
-}
//! Transposes the matrix. A(j, i) -> A (i, j)
Standard_NODISCARD gp_Mat Transposed() const;
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
friend class gp_XYZ;
friend class gp_Trsf;
#include <gp_XYZ.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
-#include <TCollection.hxx>
//=======================================================================
//function : gp_Trsf
matrix = aTM;
}
-
-const TCollection_AsciiString gp_Trsf_ClassName = "gp_Trsf";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void gp_Trsf::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, gp_Trsf_ClassName);
-
- DUMP_VALUES (OS, "Form", gp::TrsfFormToString (Form()));
- {
- Standard_SStream aTmpStream;
- loc.Dump (aTmpStream);
- DUMP_VALUES (OS, "TranslationPart", TCollection::ToDumpString (aTmpStream));
- }
- DUMP_VALUES (OS, "ScaleFactor", ScaleFactor());
- {
- Standard_SStream aTmpStream;
- matrix.Dump (aTmpStream);
- DUMP_VALUES (OS, "HVectorialPart", TCollection::ToDumpString (aTmpStream));
- }
-
- DUMP_STOP_KEY (OS, gp_Trsf_ClassName);
-}
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Handle.hxx>
-#include <Standard_OStream.hxx>
#include <Standard_Real.hxx>
class Standard_ConstructionError;
theMat.SetValue (3, 3, static_cast<T> (1));
}
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
friend class gp_GTrsf;
protected:
#include <gp_Mat.hxx>
#include <gp_XYZ.hxx>
-#include <NCollection_List.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
-#include <TCollection.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <TCollection_AsciiString.hxx>
Standard_Boolean gp_XYZ::IsEqual (const gp_XYZ& Other,
const Standard_Real Tolerance) const {
return Standard_True;
}
-const TCollection_AsciiString gp_XYZ_ClassName = "gp_XYZ";
-
-//=======================================================================
-//function : Dump
-//purpose :
-//=======================================================================
-
-void gp_XYZ::Dump (Standard_OStream& OS) const
-{
- DUMP_START_KEY (OS, gp_XYZ_ClassName);
-
- DUMP_VALUES (OS, "X", x);
- DUMP_VALUES (OS, "Y", y);
- DUMP_VALUES (OS, "Z", z);
-
- DUMP_STOP_KEY (OS, gp_XYZ_ClassName);
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-Standard_Boolean gp_XYZ::Init (const Standard_OStream& /*OS*/)
-{
- return Standard_False;
-}
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
-
-#include <Standard_OStream.hxx>
-
class Standard_ConstructionError;
class Standard_OutOfRange;
class gp_Mat;
void SetLinearForm (const gp_XYZ& XYZ1, const gp_XYZ& XYZ2);
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT void Dump (Standard_OStream& OS) const;
-
- //! Dumps the content of me on the stream <OS>.
- Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS);
-
protected:
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/Convert_Tools.hxx>
-
-#include <TColgp_Array1OfPnt.hxx>
-#include <TCollection.hxx>
-#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-#include <BRepPrimAPI_MakeBox.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-
-//=======================================================================
-//function : CreateShape
-//purpose :
-//=======================================================================
-TopoDS_Shape Convert_Tools::CreateShape (const Bnd_Box& theBoundingBox)
-{
- if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole())
- return TopoDS_Shape();
-
- Standard_Real aXmin, anYmin, aZmin, aXmax, anYmax, aZmax;
- theBoundingBox.Get (aXmin, anYmin, aZmin, aXmax, anYmax, aZmax);
-
- gp_Pnt aPntMin = gp_Pnt (aXmin, anYmin, aZmin);
- gp_Pnt aPntMax = gp_Pnt (aXmax, anYmax, aZmax);
-
- return CreateBoxShape (aPntMin, aPntMax);
-}
-
-//=======================================================================
-//function : CreateShape
-//purpose :
-//=======================================================================
-TopoDS_Shape Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox)
-{
- if (theBoundingBox.IsVoid())
- return TopoDS_Shape();
-
- TColgp_Array1OfPnt anArrPnts(0, 8);
- theBoundingBox.GetVertex(&anArrPnts(0));
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
-
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(1))));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(2))));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(1)), gp_Pnt (anArrPnts.Value(3))));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(2)), gp_Pnt (anArrPnts.Value(3))));
-
- return aCompound;
-}
-
-//=======================================================================
-//function : CreateBoxShape
-//purpose :
-//=======================================================================
-TopoDS_Shape Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax)
-{
- Standard_Boolean aThinOnX = fabs (thePntMin.X() - thePntMax.X()) < Precision::Confusion();
- Standard_Boolean aThinOnY = fabs (thePntMin.Y() - thePntMax.Y()) < Precision::Confusion();
- Standard_Boolean aThinOnZ = fabs (thePntMin.Z() - thePntMax.Z()) < Precision::Confusion();
-
- if (((int)aThinOnX + (int)aThinOnY + (int)aThinOnZ) > 1) // thin box in several directions is a point
- {
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (thePntMin));
- return aCompound;
- }
-
- if (aThinOnX || aThinOnY || aThinOnZ)
- {
- gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4 ;
- if (aThinOnX)
- {
- aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
- aPnt2 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z());
- aPnt3 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMax.Z());
- aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z());
- }
- else if (aThinOnY)
- {
- aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
- aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z());
- aPnt3 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMax.Z());
- aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z());
- }
- else if (aThinOnZ)
- {
- aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
- aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z());
- aPnt3 = gp_Pnt(thePntMax.X(), thePntMax.Y(), thePntMin.Z());
- aPnt4 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z());
- }
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt1, aPnt2));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt2, aPnt3));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt3, aPnt4));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt4, aPnt1));
-
- return aCompound;
- }
- else
- {
- BRepPrimAPI_MakeBox aBoxBuilder (thePntMin, thePntMax);
- return aBoxBuilder.Shape();
- }
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef Convert_Tools_H
-#define Convert_Tools_H
-
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_XYZ.hxx>
-#include <Bnd_Box.hxx>
-#include <Bnd_OBB.hxx>
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TCollection.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QString>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class Geom_Transformation;
-
-//! \class Convert_Tools
-//! \brief The tool that gives auxiliary methods for qt elements manipulation
-class Convert_Tools
-{
-public:
- //! Creates box shape
- //! \param theBoundingBox box shape parameters
- //! \return created shape
- Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_Box& theBoundingBox);
-
- //! Creates box shape
- //! \param theBoundingBox box shape parameters
- //! \return created shape
- Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox);
-
- //! Creates box shape
- //! \param thePntMin minimum point on the bounding box
- //! \param thePntMax maximum point on the bounding box
- //! \return created shape
- Standard_EXPORT static TopoDS_Shape CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax);
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-04-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/Convert_TransientShape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(Convert_TransientShape, Standard_Transient)
+++ /dev/null
-// Created on: 2019-04-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef Convert_TransientShape_H
-#define Convert_TransientShape_H
-
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-
-#include <TopoDS_Shape.hxx>
-
-DEFINE_STANDARD_HANDLE (Convert_TransientShape, Standard_Transient)
-
-//! \class Convert_TransientShape
-//! \brief An interface to create custom panes by transient object name.
-class Convert_TransientShape : public Standard_Transient
-{
-public:
-
- //! Constructor
- Convert_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); }
-
- //! Destructor
- virtual ~Convert_TransientShape() {}
-
- //! Fills current shape
- void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; }
-
- //! Returns current shape
- const TopoDS_Shape GetShape() const { return myShape; }
-
- DEFINE_STANDARD_RTTIEXT (Convert_TransientShape, Standard_Transient)
-
-private:
- TopoDS_Shape myShape;
-};
-
-#endif
+++ /dev/null
-Convert_Tools.cxx
-Convert_Tools.hxx
-Convert_TransientShape.cxx
-Convert_TransientShape.hxx
}
return;
}
- else
- {
- if (anApplication.IsNull() && CDF_Session::Exists())
- anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
- }
myModule = new DFBrowser_Module();
myModule->CreateViewModel (myMainWindow);
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
{
int aLevels = 2;
- TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
}
QApplication::restoreOverrideCursor();
}
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
{
int aLevels = -1;
- TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
}
QApplication::restoreOverrideCursor();
}
QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++) {
int aLevels = -1;
- TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+ setExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
}
}
thePresentations.Append (aPresentation);
}
}
+
+// =======================================================================
+// function : setExpanded
+// purpose :
+// =======================================================================
+void DFBrowser_Window::setExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
+ int& theLevels)
+{
+ bool isToExpand = theLevels == -1 || theLevels > 0;
+ if (!isToExpand)
+ return;
+
+ theTreeView->setExpanded (theIndex, isExpanded);
+ if (theLevels != -1)
+ theLevels--;
+
+ QAbstractItemModel* aModel = theTreeView->model();
+ for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
+ {
+ int aLevels = theLevels;
+ setExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
+ }
+}
//! \return container of presentations or NULL
void findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations);
+ //! Recursive items expanding in tree view staring from the index
+ //! \param theTreeView an OCAF tree view
+ //! \param theParentIndex an index which children should be expanded
+ //! \param isExpanded a boolean state if the item should be expanded or collapsed
+ //! \param theLevels a number of levels to be expanded, or -1 for all levels
+ static void setExpanded (QTreeView* theTreeView, const QModelIndex& theParentIndex, const bool isExpanded, int& theLevels);
+
private:
DFBrowser_Module* myModule; //!< current module
+++ /dev/null
-MessageModel.qrc
-MessageModel_Actions.cxx
-MessageModel_Actions.hxx
-MessageModel_ActionType.hxx
-MessageModel_ItemAlert.cxx
-MessageModel_ItemAlert.hxx
-MessageModel_ItemBase.cxx
-MessageModel_ItemBase.hxx
-MessageModel_ItemPropertiesReport.cxx
-MessageModel_ItemPropertiesReport.hxx
-MessageModel_ItemReport.cxx
-MessageModel_ItemReport.hxx
-MessageModel_ItemRoot.cxx
-MessageModel_ItemRoot.hxx
-MessageModel_ReportCallBack.cxx
-MessageModel_ReportCallBack.hxx
-MessageModel_Tools.cxx
-MessageModel_Tools.hxx
-MessageModel_TreeModel.cxx
-MessageModel_TreeModel.hxx
+++ /dev/null
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource>
- <file>icons/item_shape.png</file>
- <file>icons/item_vectorOfValues.png</file>
- </qresource>
-</RCC>
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_ActionType_H
-#define MessageModel_ActionType_H
-
-//! Kind of action type for tree view context menu item
-enum MessageModel_ActionType
-{
- MessageModel_ActionType_Activate, //!< set Message_Report active
- MessageModel_ActionType_Deactivate, //!< set Message_Report not active
- MessageModel_ActionType_Clear, //!< clear Message_Report alerts
- MessageModel_ActionType_ExportToShapeView, //!< export TopoDS_Shape of selected item into TKShapeView plugin
- MessageModel_ActionType_TestMetric, //!< test alerts
- MessageModel_ActionType_TestProperties //!< test alerts
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/MessageModel_Actions.hxx>
-
-#include <inspector/MessageModel_ItemReport.hxx>
-#include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_ItemAlert.hxx>
-#include <inspector/MessageModel_Tools.hxx>
-#include <inspector/MessageModel_TreeModel.hxx>
-#include <inspector/TInspectorAPI_PluginParameters.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Message_AlertExtended.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <TopoDS_AlertAttribute.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAction>
-#include <QFileDialog>
-#include <QItemSelectionModel>
-#include <QMenu>
-#include <QMessageBox>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-#define DEBUG_ALERTS
-
-#ifdef DEBUG_ALERTS
-#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
-#endif
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-MessageModel_Actions::MessageModel_Actions (QWidget* theParent,
- MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel)
-: QObject (theParent), myTreeModel (theTreeModel), mySelectionModel (theModel)
-{
- myActions.insert (MessageModel_ActionType_Deactivate,
- ViewControl_Tools::CreateAction ("Deactivate", SLOT (OnDeactivateReport()), parent(), this));
- myActions.insert (MessageModel_ActionType_Activate,
- ViewControl_Tools::CreateAction ("Activate", SLOT (OnActivateReport()), parent(), this));
- myActions.insert (MessageModel_ActionType_Clear,
- ViewControl_Tools::CreateAction ("Clear", SLOT (OnClearReport()), parent(), this));
- myActions.insert (MessageModel_ActionType_ExportToShapeView,
- ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this));
-#ifdef DEBUG_ALERTS
- myActions.insert (MessageModel_ActionType_TestMetric,
- ViewControl_Tools::CreateAction ("Test <metric>", SLOT (OnTestMetric()), parent(), this));
- myActions.insert (MessageModel_ActionType_TestProperties,
- ViewControl_Tools::CreateAction ("Test <PropertyPanel>", SLOT (OnTestPropertyPanel()), parent(), this));
-#endif
-}
-
-// =======================================================================
-// function : GetAction
-// purpose :
-// =======================================================================
-QAction* MessageModel_Actions::GetAction (const MessageModel_ActionType& theType)
-{
- if (myActions.contains (theType))
- return myActions[theType];
-
- return 0;
-}
-
-// =======================================================================
-// function : AddMenuActions
-// purpose :
-// =======================================================================
-void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu)
-{
- MessageModel_ItemRootPtr aRootItem;
- MessageModel_ItemReportPtr aReportItem;
- MessageModel_ItemAlertPtr anAlertItem;
- for (QModelIndexList::const_iterator aSelIt = theSelectedIndices.begin(); aSelIt != theSelectedIndices.end(); aSelIt++)
- {
- QModelIndex anIndex = *aSelIt;
- if (anIndex.column() != 0)
- continue;
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- continue;
-
- aRootItem = itemDynamicCast<MessageModel_ItemRoot> (anItemBase);
- if (aRootItem)
- break;
-
- aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
- if (aReportItem)
- break;
-
- anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (anItemBase);
- if (anAlertItem)
- break;
- }
-
- if (aReportItem && !aReportItem->GetReport().IsNull())
- {
- theMenu->addAction (myActions[MessageModel_ActionType_Deactivate]);
- theMenu->addAction (myActions[MessageModel_ActionType_Activate]);
- theMenu->addAction (myActions[MessageModel_ActionType_Clear]);
-#ifdef DEBUG_ALERTS
- theMenu->addAction (myActions[MessageModel_ActionType_TestMetric]);
- theMenu->addAction (myActions[MessageModel_ActionType_TestProperties]);
-#endif
- }
- else if (anAlertItem)
- {
- theMenu->addAction (myActions[MessageModel_ActionType_ExportToShapeView]);
- }
-
- theMenu->addSeparator();
-}
-
-// =======================================================================
-// function : onImportReport
-// purpose :
-// =======================================================================
-Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& theReportIndex) const
-{
- MessageModel_ItemReportPtr aReportItem;
- QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes();
- for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- QModelIndex anIndex = *aSelIt;
- if (anIndex.column() != 0)
- continue;
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- continue;
-
- aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
- theReportIndex = anIndex;
- if (aReportItem)
- break;
- }
- if (!aReportItem)
- return NULL;
-
- return aReportItem->GetReport();
-}
-
-// =======================================================================
-// function : OnDeactivateReport
-// purpose :
-// =======================================================================
-void MessageModel_Actions::OnDeactivateReport()
-{
- QModelIndex aReportIndex;
- Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
- if (aReport.IsNull())
- return;
-
- aReport->SetActive (Standard_False);
- ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
-}
-
-// =======================================================================
-// function : OnActivateReport
-// purpose :
-// =======================================================================
-void MessageModel_Actions::OnActivateReport()
-{
- QModelIndex aReportIndex;
- Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
- if (aReport.IsNull())
- return;
-
- aReport->SetActive (Standard_True);
- ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
-}
-
-// =======================================================================
-// function : OnClearReport
-// purpose :
-// =======================================================================
-void MessageModel_Actions::OnClearReport()
-{
- QModelIndex aReportIndex;
- Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
- if (aReport.IsNull())
- return;
-
- aReport->Clear();
- ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
-}
-
-// =======================================================================
-// function : OnExportToShapeView
-// purpose :
-// =======================================================================
-void MessageModel_Actions::OnExportToShapeView()
-{
- TCollection_AsciiString aPluginName ("TKShapeView");
-
- NCollection_List<Handle(Standard_Transient)> aPluginParameters;
- if (myParameters->FindParameters (aPluginName))
- aPluginParameters = myParameters->Parameters (aPluginName);
- NCollection_List<TCollection_AsciiString> anItemNames;
- if (myParameters->FindSelectedNames (aPluginName))
- anItemNames = myParameters->GetSelectedNames (aPluginName);
-
- QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes();
- QStringList anExportedPointers;
- for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- QModelIndex anIndex = *aSelIt;
- if (anIndex.column() != 0)
- continue;
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- continue;
-
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (anItemBase);
- if (!anAlertItem)
- continue;
-
- Handle(Message_Alert) anAlert = anAlertItem->GetAlert();
- if (anAlert.IsNull())
- continue;
-
- Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (anAlert);
- if (anExtAlert.IsNull())
- continue;
-
- Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
- if (anAttribute.IsNull())
- continue;
-
- if (!anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
- continue;
-
- const TopoDS_Shape aShape = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape();
- if (aShape.IsNull())
- continue;
- aPluginParameters.Append (aShape.TShape());
- anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString (aShape));
-
- anExportedPointers.append (MessageModel_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
- }
-
- if (anExportedPointers.empty())
- return;
- myParameters->SetSelectedNames (aPluginName, anItemNames);
- myParameters->SetParameters (aPluginName, aPluginParameters);
- QMessageBox::information (0, "Information", QString ("TShapes '%1' are sent to %2 tool.")
- .arg (anExportedPointers.join (", ")).arg (QString (aPluginName.ToCString())));
-}
-
-// =======================================================================
-// function : OnTestMetric
-// purpose :
-// =======================================================================
-#include <OSD_Chronometer.hxx>
-#include <ctime>
-void MessageModel_Actions::OnTestMetric()
-{
-#ifdef DEBUG_ALERTS
- QModelIndex aReportIndex;
- Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
- if (aReport.IsNull())
- return;
-
- Message_PerfMeter aPerfMeter;
- MESSAGE_INFO ("MessageModel_Actions::OnTestAlerts()", "", &aPerfMeter, NULL);
- unsigned int start_time = clock();
- //Standard_Real aSystemSeconds, aCurrentSeconds;
- //OSD_Chronometer::GetThreadCPU (aCurrentSeconds, aSystemSeconds);
-
- Standard_Integer aCounter = 5000;//0;
- Standard_Real aValue = 0., aValue2 = 0.1;
-
- double* aMemValue;
- for (int aTopIt = 0; aTopIt < 4; aTopIt++)
- {
- for (int j = 0; j < aCounter; j++)
- {
- for (int i = 0; i < aCounter; i++)
- {
- aValue = (aValue * 2. + 3.) * 0.5 - 0.3 * 0.5;
-
- Standard_Real aValue3 = aValue + aValue2 * 0.2;
- (void)aValue3;
-
- aMemValue = new double;
- }
- }
- MESSAGE_INFO ("Calculate", "", &aPerfMeter, NULL);
- }
-
- //((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged();
-
- myTreeModel->UpdateTreeModel();
-
- //Standard_Real aSystemSeconds1, aCurrentSeconds1;
- //OSD_Chronometer::GetThreadCPU (aCurrentSeconds1, aSystemSeconds1);
-
- //std::cout << aValue << std::endl;
- //std::cout << "user time = " << aCurrentSeconds1 - aCurrentSeconds
- // << ", system time = " << aSystemSeconds1 - aSystemSeconds << std::endl;
-
- unsigned int end_time = clock();
- std::cout << "clock() = " << end_time - start_time << std::endl;
-#endif
-}
-
-// =======================================================================
-// function : OnTestPropertyPanel
-// purpose :
-// =======================================================================
-void MessageModel_Actions::OnTestPropertyPanel()
-{
-#ifdef DEBUG_ALERTS
- QModelIndex aReportIndex;
- Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
- if (aReport.IsNull())
- return;
-
- Message_PerfMeter aPerfMeter;
- MESSAGE_INFO ("MessageModel_Actions::OnTestAlerts()", "", &aPerfMeter, NULL);
-
- // gp_XYZ
- {
- gp_XYZ aCoords (1.3, 2.3, 3.4);
- Standard_SStream aStream;
- aCoords.Dump (aStream);
- MESSAGE_INFO_STREAM(aStream, "gp_XYZ", "", &aPerfMeter, NULL);
- }
- // Bnd_Box
- {
- Bnd_Box aBox(20., 15., 10., 25., 20., 15.);
- Standard_SStream aStream;
- aBox.Dump (aStream);
- MESSAGE_INFO_STREAM(aStream, "Bnd_Box", "", &aPerfMeter, NULL);
- }
- // Bnd_OBB
- {
- Bnd_OBB anOBB (gp_Pnt (-10., -15., -10.), gp_Dir (1., 0., 0.), gp_Dir (0., 1., 0.), gp_Dir (0., 0., 1.),
- 5., 10., 5.);
- Standard_SStream aStream;
- anOBB.Dump (aStream);
- MESSAGE_INFO_STREAM(aStream, "Bnd_OBB", "", &aPerfMeter, NULL);
- }
- myTreeModel->UpdateTreeModel();
-#endif
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_Actions_H
-#define MessageModel_Actions_H
-
-#include <Standard.hxx>
-#include <Standard_Transient.hxx>
-
-#include <inspector/MessageModel_ActionType.hxx>
-#include <inspector/TInspectorAPI_PluginParameters.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QObject>
-#include <QMap>
-#include <QModelIndexList>
-#include <QPoint>
-#include <QString>
-#include <Standard_WarningsRestore.hxx>
-
-class Message_Report;
-class MessageModel_TreeModel;
-
-class QAction;
-class QItemSelectionModel;
-class QMenu;
-class QWidget;
-
-//! \class MessageModel_Actions
-//! \brief This is a listener of popup context menu items and selection change in message model
-class MessageModel_Actions : public QObject
-{
- Q_OBJECT
-
-public:
-
- //! Constructor
- Standard_EXPORT MessageModel_Actions (QWidget* theParent,
- MessageModel_TreeModel* theTreeModel,
- QItemSelectionModel* theModel);
-
- //! Destructor
- virtual ~MessageModel_Actions() Standard_OVERRIDE {}
-
- //! Returns action by the type
- //! \param theType an action type
- //! \return an action instance if it exists
- Standard_EXPORT QAction* GetAction (const MessageModel_ActionType& theType);
-
- //! Fills popup menu with actions depending on the current selection
- //! \param theSelectedIndices tree model selected indices
- //! \param theMenu menu to be filled
- Standard_EXPORT void AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu);
-
- //! Sets parameters container, it should be used when the plugin is initialized or in update content
- //! \param theParameters a parameters container
- void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters)
- { myParameters = theParameters; }
-
-public slots:
- //! Set selected report not active
- void OnDeactivateReport();
-
- //! Set selected report active
- void OnActivateReport();
-
- //! Clears container of alerts of selected report
- void OnClearReport();
-
- //! Exports the first selected shape into ShapeViewer plugin.
- void OnExportToShapeView();
-
- //! Sending several alerts to check metric of message-alert-tool mechanizm
- void OnTestMetric();
-
- //! Sending several alerts to check property panel/presentations of message-alert-tool mechanizm
- void OnTestPropertyPanel();
-
-protected:
- //! Returns report of selected tree view item if a report item is selected
- //! \param theReportIndex tree model index of the found report
- //! \return report instance or NULL
- Handle(Message_Report) getSelectedReport (QModelIndex& theReportIndex) const;
-
-protected:
- MessageModel_TreeModel* myTreeModel; //< tree model
- QItemSelectionModel* mySelectionModel; //< selection model
- Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
- QMap<MessageModel_ActionType, QAction*> myActions; //!< container of all actions
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageModel_ItemAlert.hxx>
-
-#include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_ItemReport.hxx>
-#include <inspector/MessageModel_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/Convert_TransientShape.hxx>
-#include <inspector/TreeModel_Tools.hxx>
-
-#include <Message_AlertExtended.hxx>
-#include <Message_AttributeObject.hxx>
-#include <Message_AttributeStream.hxx>
-#include <Message_CompositeAlerts.hxx>
-
-#include <Bnd_Box.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TopoDS_AlertAttribute.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QColor>
-#include <QIcon>
-#include <Standard_WarningsRestore.hxx>
-
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant MessageModel_ItemAlert::initValue (const int theRole) const
-{
- QVariant aParentValue = MessageModel_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- MessageModel_ItemReportPtr aReportItem = MessageModel_ItemReport::FindReportItem (Parent());
- if (!aReportItem)
- return QVariant();
-
- Handle(Message_Report) aReport = aReportItem->GetReport();
- if (aReport.IsNull())
- return QVariant();
-
- Standard_Boolean isTimeReport = aReport->PerfMeterMode() == Message_PerfMeterMode_UserTimeCPU ||
- aReport->PerfMeterMode() == Message_PerfMeterMode_SystemTimeInfo;
-
- if (aReport->PerfMeterMode() == Message_PerfMeterMode_UserTimeCPU ||
- aReport->PerfMeterMode() == Message_PerfMeterMode_SystemTimeInfo)
-
- if (theRole == Qt::ForegroundRole)
- {
- if (!aReport->GetAlerts (Message_Fail).IsEmpty())
- return QColor(Qt::darkRed);
-
- for (int aGravityId = (int)Message_Trace; aGravityId <= (int)Message_Fail; aGravityId++)
- {
- if (!aReport->IsActive ((Message_Gravity)aGravityId))
- return QColor(Qt::darkGray);
- }
- return QVariant();
- }
-
- Handle(Message_Alert) anAlert = getAlert();
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
-
- // if the alert is composite, process the real alert
- if (theRole == Qt::DecorationRole && Column() == 0)
- {
- if (anExtendedAlert.IsNull())
- return QVariant();
-
- Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
-
- if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
- return QIcon (":/icons/item_shape.png");
- else if (!Handle(Message_AttributeStream)::DownCast (anAttribute).IsNull())
- return QIcon (":/icons/item_vectorOfValues.png");
- else
- return QVariant();
- }
-
- if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole)
- return QVariant();
-
- if (anAlert.IsNull())
- return QVariant();
-
- switch (Column())
- {
- case 0:
- return theRole == Qt::DisplayRole ? anAlert->GetMessageKey() : anAlert->DynamicType()->Name();
- //case 1: return QVariant(); // visibility state
- //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
- //case 3: return anAlert->ElapsedTime() < 0 ? QVariant() : anAlert->ElapsedTime();
- case 4:
- {
- if (!anExtendedAlert->IsMetricValid())
- return QVariant();
-
- if (isTimeReport)
- return anExtendedAlert->MetricStop() - anExtendedAlert->MetricStart();
- else
- return anExtendedAlert->MetricStart();
- }
- case 5:
- {
- if (!anExtendedAlert->IsMetricValid())
- return QVariant();
-
- if (isTimeReport)
- {
- TreeModel_ItemBasePtr aParentItem = Parent();
- MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport> (aParentItem);
- while (!aReportItem)
- {
- aParentItem = aParentItem->Parent();
- aReportItem = itemDynamicCast<MessageModel_ItemReport> (aParentItem);
- }
- double aDivideTo = aReport->CumulativeMetric (Message_Info);
- double anAlertTime = anExtendedAlert->MetricStop() - anExtendedAlert->MetricStart();
-
- return aDivideTo == 0 ? QVariant() : 100. * anAlertTime / aDivideTo;
- }
- else
- {
- TreeModel_ItemBasePtr aParentItem = Parent();
- //MessageModel_ItemAlertPtr aParentAlertItem = itemDynamicCast<MessageModel_ItemAlert> (aParentItem);
- //if (aParentAlertItem)
- //{
- //double aDeltaToParent = CumulativeMetric (anAlert) - CumulativeMetric (aParentAlertItem->GetAlert());
-
- //return fabs (aDeltaToParent) > Precision::Confusion() ? QVariant (aDeltaToParent) : QVariant();
- //}
- double anAlertMem = anExtendedAlert->MetricStop() - anExtendedAlert->MetricStart();
- return anAlertMem;
- }
- }
- case 6: return MessageModel_Tools::GetPointerAlertInfo (anAlert).ToCString();
- case 7: return MessageModel_Tools::GetShapeTypeAlertInfo (anAlert).ToCString();
- case 8: return MessageModel_Tools::GetStandardTypeAlertInfo (anAlert).ToCString();
- case 9:
- {
- if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull())
- {
- TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription();
- return theRole == Qt::DisplayRole ? TreeModel_Tools::CutString (aDescription.ToCString())
- : aDescription.ToCString();
- }
- }
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int MessageModel_ItemAlert::initRowCount() const
-{
- const Handle(Message_Alert)& anAlert = getAlert();
- if (anAlert.IsNull())
- return 0;
-
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
- if (anExtendedAlert.IsNull())
- return 0;
-
- Handle(Message_CompositeAlerts) aCompositeAlert = anExtendedAlert->GetCompositeAlerts();
- if (aCompositeAlert.IsNull())
- return 0;
-
- MessageModel_ItemAlert* aCurrentItem = (MessageModel_ItemAlert*)this;
- for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++)
- {
- const Message_ListOfAlert& anAlerts = aCompositeAlert->GetAlerts ((Message_Gravity)aGravityId);
- {
- for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next())
- {
- Message_ListOfAlert aCurAlerts;
- aCurAlerts.Append (anIt.Value());
- aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts);
- }
- }
- }
-
- return aCurrentItem->myChildAlerts.Size();
-}
-
-// =======================================================================
-// function : GetStream
-// purpose :
-// =======================================================================
-void MessageModel_ItemAlert::GetStream (Standard_OStream& OS) const
-{
- return;
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert());
- if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull())
- {
- Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
- if (!anAttribute.IsNull())
- {
- if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull())
- {
- //if (GetProperties().IsNull())
- //{
- // TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
- // SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem));
- //}
- Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute());
- //Handle(MessageModel_ItemPropertiesAttributeStream) aProperties = Handle(MessageModel_ItemPropertiesAttributeStream)::DownCast (GetProperties());
- OS << anAttributeStream->GetStream().str();
- }
- }
- }
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr MessageModel_ItemAlert::createChild (int theRow, int theColumn)
-{
- return MessageModel_ItemAlert::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void MessageModel_ItemAlert::Init()
-{
- MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport> (Parent());
- MessageModel_ItemAlertPtr anAlertItem;
- Handle(Message_Alert) anAlert;
- if (aReportItem)
- {
- Message_ListOfAlert anAlerts;
- if (aReportItem->GetChildAlerts (Row(), anAlerts))
- {
- myAlert = anAlerts.First();
- }
- }
- else
- {
- anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (Parent());
- if (anAlertItem)
- {
- Message_ListOfAlert anAlerts;
- if (anAlertItem->GetChildAlerts (Row(), anAlerts))
- {
- myAlert = anAlerts.First();
- }
- }
- }
-
- /*Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(myAlert);
- if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull())
- {
- Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
- if (!anAttribute.IsNull())
- {
- if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull())
- {
- if (GetProperties().IsNull())
- {
- TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
- SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem));
- }
- Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute());
- Handle(MessageModel_ItemPropertiesAttributeStream) aProperties = Handle(MessageModel_ItemPropertiesAttributeStream)::DownCast (GetProperties());
- aProperties->Init (anAttributeStream->GetStream());
- }
- //if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject)))
- // myPresentations.Append (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject());
- //if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
- // myPresentations.Append (new Convert_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape()));
- }
- //TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription();
- //Bnd_Box aBox;
- //if (aBox.Init (Standard_SStream (aDescription.ToCString())))
- // myPresentations.Append (new Convert_TransientShape (Convert_Tools::CreateShape (aBox)));
- }*/
- MessageModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void MessageModel_ItemAlert::Reset()
-{
- MessageModel_ItemBase::Reset();
- myAlert = Handle(Message_Alert)();
- myChildAlerts.Clear();
- myPresentations.Clear();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void MessageModel_ItemAlert::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<MessageModel_ItemAlert*>(this)->Init();
-}
-
-// =======================================================================
-// function : getAlert
-// purpose :
-// =======================================================================
-const Handle(Message_Alert)& MessageModel_ItemAlert::getAlert() const
-{
- initItem();
- return myAlert;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_ItemAlert_H
-#define MessageModel_ItemAlert_H
-
-#include <inspector/MessageModel_ItemBase.hxx>
-#include <Message_Alert.hxx>
-#include <Message_ListOfAlert.hxx>
-#include <Message_Report.hxx>
-#include <NCollection_DataMap.hxx>
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QMap>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-#include <NCollection_List.hxx>
-#include <NCollection_Vector.hxx>
-
-class QAbstractTableModel;
-
-class MessageModel_ItemAlert;
-typedef QExplicitlySharedDataPointer<MessageModel_ItemAlert> MessageModel_ItemAlertPtr;
-
-//! \class MessageModel_ItemAlert
-//! This item is connected to Message_Alert.
-//! Parent is either MessageModel_ItemRoot or MessageModel_ItemAlert, children are MessageModel_ItemAlert or no children
-class MessageModel_ItemAlert : public MessageModel_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- //! \return the pointer to the created item
- static MessageModel_ItemAlertPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return MessageModel_ItemAlertPtr (new MessageModel_ItemAlert (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~MessageModel_ItemAlert() Standard_OVERRIDE {};
-
- //! Returns the current shape
- const Handle(Message_Alert)& GetAlert() const { return myAlert; }
-
- //! Returns alert of the report for the parameter row
- Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Return data value for the role.
- //! \param theRole a value role
- //! \return the value
- Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
-
- //! \return number of children.
- Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE;
-
- //! Sets some shape to present the item
- //! \param theShape shape instance
- void SetCustomShape (const TopoDS_Shape& theShape) { myCustomShape = theShape; }
-
- //! Returns custom shape to present the item
- //! \return instance of the shape
- const TopoDS_Shape& GetCustomShape() const { return myCustomShape; }
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \thePresentations [out] container of presentation handles to be visualized
- void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
- { thePresentations.Append (myPresentations); }
-
-
- ////! Returns summ of children alert elapsed times. The method is recusive.
- ////! \param theAlert a message alert
- ////! \return double value
- //Standard_EXPORT static double CumulativeMetric (const Handle(Message_Alert)& theAlert);
-
-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;
-
- //! Returns current alert, initialized item if it has not been initialized yet
- //! \return alert value
- const Handle(Message_Alert)& getAlert() const;
-
-private:
-
- //! Constructor
- MessageModel_ItemAlert (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : MessageModel_ItemBase (theParent, theRow, theColumn) {}
-
-private:
- Handle(Message_Alert) myAlert;
-
- NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
-
- TopoDS_Shape myCustomShape;
- NCollection_List<Handle(Standard_Transient)> myPresentations;
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/MessageModel_ItemBase.hxx>
-#include <inspector/MessageModel_ItemRoot.hxx>
-
-// =======================================================================
-// function : isReversed
-// purpose :
-// =======================================================================
-Standard_Boolean MessageModel_ItemBase::isReversed() const
-{
- TreeModel_ItemBasePtr aParentItem = GetRootItem();
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (aParentItem);
- return aRootItem ? aRootItem->IsReversed() : Standard_False;
-}
-
-// =======================================================================
-// function : GetRootItem
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr MessageModel_ItemBase::GetRootItem() const
-{
- TreeModel_ItemBasePtr anItem = Parent();
- while (anItem)
- {
- if (MessageModel_ItemRootPtr aThisRootItem = itemDynamicCast<MessageModel_ItemRoot> (anItem))
- {
- return aThisRootItem;
- }
- anItem = anItem->Parent();
- }
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_ItemBase_H
-#define MessageModel_ItemBase_H
-
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-class MessageModel_ItemBase;
-typedef QExplicitlySharedDataPointer<MessageModel_ItemBase> MessageModel_ItemBasePtr;
-
-//! \class MessageModel_ItemBase
-// \brief Declaration of the tree model base item.
-class MessageModel_ItemBase : public TreeModel_ItemBase
-{
-public:
-
- //! Resets cached values
- virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- virtual void initItem() const {};
-
- //! Constructor
- //! param theParent a parent item
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- MessageModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : TreeModel_ItemBase (theParent, theRow, theColumn) {}
-
- //! Return whether the view is reversed or not
- //! \return boolean value
- Standard_Boolean isReversed() const;
-
- //! Return root item
- //! \return an item instance
- TreeModel_ItemBasePtr GetRootItem() const;
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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/MessageModel_ItemPropertiesReport.hxx>
-#include <inspector/MessageModel_ItemReport.hxx>
-#include <inspector/ShapeView_ItemShape.hxx>
-#include <inspector/ShapeView_Tools.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-#include <BRep_Tool.hxx>
-#include <Message.hxx>
-#include <TopoDS.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ItemPropertiesReport, TreeModel_ItemProperties)
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int MessageModel_ItemPropertiesReport::GetTableRowCount() const
-{
- return 2;
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant MessageModel_ItemPropertiesReport::GetTableData (const int theRow, const int theColumn, int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(Message_Report) aReport = getItemReport();
- switch (theRow)
- {
- case 0: return theColumn == 0 ? QVariant ("Limit") : QVariant (aReport->GetLimit());
- case 1: return theColumn == 0 ? QVariant ("PerfMeterMode")
- : QVariant (Message::PerfMeterModeToString (aReport->PerfMeterMode()));
- default: break;
- }
-
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType MessageModel_ItemPropertiesReport::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- case 0: return ViewControl_EditType_Spin;
- case 1: return ViewControl_EditType_Combo;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> MessageModel_ItemPropertiesReport::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 1:
- {
- for (int i = 0; i <= Message_PerfMeterMode_MemHeapUsage; i++)
- aValues.append (Message::PerfMeterModeToString((Message_PerfMeterMode)i));
- }
- break;
- default: break;
- }
- return aValues;
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool MessageModel_ItemPropertiesReport::SetTableData (const int theRow, const int theColumn, const QVariant& theValue)
-{
- Handle(Message_Report) aReport = getItemReport();
- switch (theRow)
- {
- case 0: aReport->SetLimit (theValue.toInt()); break;
- case 1: aReport->SetPerfMeterMode (Message::PerfMeterModeFromString (theValue.toString().toStdString().c_str())); break;
- default: break;
- }
- Reset();
- return true;
-}
-
-// =======================================================================
-// function : getItemReport
-// purpose :
-// =======================================================================
-
-Handle(Message_Report) MessageModel_ItemPropertiesReport::getItemReport() const
-{
- MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(getItem());
- if (!aReportItem)
- return NULL;
-
- return aReportItem->GetReport();
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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 MessageModel_ItemReportProperties_H
-#define MessageModel_ItemReportProperties_H
-
-#include <Standard.hxx>
-#include <Message_Report.hxx>
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-DEFINE_STANDARD_HANDLE (MessageModel_ItemPropertiesReport, TreeModel_ItemProperties)
-
-//! \class MessageModel_ItemPropertiesReport
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class MessageModel_ItemPropertiesReport : public TreeModel_ItemProperties
-{
-public:
-
- //! Constructor
- Standard_EXPORT MessageModel_ItemPropertiesReport (TreeModel_ItemBasePtr theItem)
- : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- virtual ~MessageModel_ItemPropertiesReport() {}
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- Standard_EXPORT virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- Standard_EXPORT virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- Standard_EXPORT virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
- DEFINE_STANDARD_RTTIEXT (MessageModel_ItemPropertiesReport, TreeModel_ItemProperties)
-
-protected:
- //! Returns report
- Handle(Message_Report) getItemReport() const;
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageModel_ItemReport.hxx>
-
-#include <inspector/MessageModel_ItemAlert.hxx>
-#include <inspector/MessageModel_ItemPropertiesReport.hxx>
-#include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_Tools.hxx>
-
-#include <OSD_Path.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant MessageModel_ItemReport::initValue (const int theRole) const
-{
- QVariant aParentValue = MessageModel_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- const Handle(Message_Report)& aReport = getReport();
- if (aReport.IsNull())
- return QVariant();
-
- if (theRole == Qt::ForegroundRole)
- {
- if (!aReport->GetAlerts (Message_Fail).IsEmpty())
- return QColor(Qt::darkRed);
-
- for (int aGravityId = (int)Message_Trace; aGravityId <= (int)Message_Fail; aGravityId++)
- {
- if (!aReport->IsActive ((Message_Gravity)aGravityId))
- return QColor(Qt::darkGray);
- }
- return QVariant();
- }
- if (theRole == Qt::ToolTipRole && !myDescription.IsEmpty() && Column() == 8)
- return myDescription.ToCString();
-
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- switch (Column())
- {
- case 0: return aReport->DynamicType()->Name();
- //case 1: return QVariant(); // visibility state
- //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
- case 4: return aReport->CumulativeMetric (Message_Info);
- case 5:
- {
- if (aReport->PerfMeterMode() == Message_PerfMeterMode_UserTimeCPU ||
- aReport->PerfMeterMode() == Message_PerfMeterMode_SystemTimeInfo)
- return "100";
- else
- return QVariant();
- }
- case 9:
- {
- if (myDescription.IsEmpty())
- return QVariant();
-
- OSD_Path aPath(myDescription);
- return QString ("%1%2").arg (aPath.Name().ToCString()).arg (aPath.Extension().ToCString());
- }
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int MessageModel_ItemReport::initRowCount() const
-{
- const Handle(Message_Report)& aReport = getReport();
- if (aReport.IsNull())
- return 0;
-
- MessageModel_ItemReport* aCurrentItem = (MessageModel_ItemReport*)this;
- for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++)
- {
- const Message_ListOfAlert& anAlerts = aReport->GetAlerts ((Message_Gravity)aGravityId);
- for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next())
- {
- Message_ListOfAlert aCurAlerts;
- aCurAlerts.Append (anIt.Value());
- aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts);
- }
- }
- return aCurrentItem->myChildAlerts.Size();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr MessageModel_ItemReport::createChild (int theRow, int theColumn)
-{
- return MessageModel_ItemAlert::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void MessageModel_ItemReport::Init()
-{
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (Parent());
- myReport = aRootItem ? aRootItem->GetReport (Row(), myDescription) : Handle(Message_Report)();
-
- TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
- SetProperties (new MessageModel_ItemPropertiesReport (anItem));
-
- MessageModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : getReport
-// purpose :
-// =======================================================================
-const Handle(Message_Report)& MessageModel_ItemReport::getReport() const
-{
- initItem();
- return myReport;
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void MessageModel_ItemReport::Reset()
-{
- MessageModel_ItemBase::Reset();
- myReport = Handle(Message_Report)();
- myChildAlerts.Clear();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void MessageModel_ItemReport::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<MessageModel_ItemReport*>(this)->Init();
-}
-
-// =======================================================================
-// function : FindReportItem
-// purpose :
-// =======================================================================
-MessageModel_ItemReportPtr MessageModel_ItemReport::FindReportItem (const TreeModel_ItemBasePtr& theItem)
-{
- TreeModel_ItemBasePtr anItem = theItem;
- while (anItem)
- {
- if (MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItem))
- return aReportItem;
-
- anItem = anItem->Parent();
- }
- return MessageModel_ItemReportPtr();
-}
-
-// =======================================================================
-// function : FindReport
-// purpose :
-// =======================================================================
-Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_ItemBasePtr& theItem)
-{
- Handle(Message_Report) aReport;
-
- MessageModel_ItemBasePtr anItem = theItem;
- while (anItem)
- {
- MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItem);
-
- if (aReportItem)
- return aReportItem->GetReport();
-
- anItem = itemDynamicCast<MessageModel_ItemBase>(anItem->Parent());
- }
- return NULL;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_ItemReport_H
-#define MessageModel_ItemReport_H
-
-#include <inspector/MessageModel_ItemBase.hxx>
-#include <Standard.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Message_Alert.hxx>
-#include <Message_Report.hxx>
-#include <NCollection_DataMap.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QMap>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class MessageModel_ItemReport;
-typedef QExplicitlySharedDataPointer<MessageModel_ItemReport> MessageModel_ItemReportPtr;
-
-//! \class MessageModel_ItemReport
-//! This item is connected to Message_Alert.
-//! Parent is MessageModel_ItemRoot, children are MessageModel_ItemAlert or no children
-class MessageModel_ItemReport : public MessageModel_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- //! \return the pointer to the created item
- static MessageModel_ItemReportPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return MessageModel_ItemReportPtr (new MessageModel_ItemReport (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~MessageModel_ItemReport() Standard_OVERRIDE {};
-
- //! Returns the current shape
- const Handle(Message_Report)& GetReport() const { return myReport; }
-
- //! Returns alert of the report for the parameter row
- Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); }
-
- //! Returns the report description or NULL
- const TCollection_AsciiString& GetDescription() const { return myDescription; }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Return data value for the role.
- //! \param theRole a value role
- //! \return the value
- Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
-
- //! \return number of children.
- Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns report of the tree model item. Iterates up by parents intil the report item is found.
- //! \return an item or NULL
- Standard_EXPORT static MessageModel_ItemReportPtr FindReportItem (const TreeModel_ItemBasePtr& theItem);
-
- //! Returns report of the item
- static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem);
-
-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;
-
- //! Returns number of child shapes. Init item if it is not initialized
- //! \return integer value
- int getRowCount() const;
-
- //! Returns current shape, initialized item if it has not been initialized yet
- //! \return shape value
- const Handle(Message_Report)& getReport() const;
-
-private:
-
- //! Constructor
- MessageModel_ItemReport (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : MessageModel_ItemBase (theParent, theRow, theColumn) {}
-
-private:
-
- NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
-
- Handle(Message_Report) myReport; //!< current report
- TCollection_AsciiString myDescription; //!< description
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_ItemReport.hxx>
-
-// =======================================================================
-// function : SetReport
-// purpose :
-// =======================================================================
-void MessageModel_ItemRoot::SetReport (const int theRowId, const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription)
-{
- NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt (myReports);
- for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++)
- {
- if (aRowId == theRowId)
- break;
- }
- aReportsIt.Value().myReport = theReport;
- aReportsIt.Value().myDescription = theReportDescription;
-}
-
-// =======================================================================
-// function : GetReport
-// purpose :
-// =======================================================================
-const Handle(Message_Report)& MessageModel_ItemRoot::GetReport (const int theRowId,
- TCollection_AsciiString& theReportDescription)
-{
- NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt (myReports);
- for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++)
- {
- if (aRowId == theRowId)
- break;
- }
- theReportDescription = aReportsIt.Value().myDescription;
- return aReportsIt.Value().myReport;
-}
-
-// =======================================================================
-// function : HasReport
-// purpose :
-// =======================================================================
-Standard_Boolean MessageModel_ItemRoot::HasReport (const Handle(Message_Report)& theReport)
-{
- NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt (myReports);
- for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++)
- {
- if (aReportsIt.Value().myReport == theReport)
- return Standard_True;
- }
- return Standard_False;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant MessageModel_ItemRoot::initValue (const int theRole) const
-{
- QVariant aParentValue = MessageModel_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (Column() != 0)
- return QVariant();
-
- if (theRole == Qt::DisplayRole)
- return myName.IsEmpty() ? "Message_Reports" : myName.ToCString();
-
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr MessageModel_ItemRoot::createChild (int theRow, int theColumn)
-{
- return MessageModel_ItemReport::CreateItem (currentItem(), theRow, theColumn);
-}
-
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_ItemRoot_H
-#define MessageModel_ItemRoot_H
-
-#include <Message_Alert.hxx>
-#include <Message_Report.hxx>
-#include <NCollection_List.hxx>
-#include <Standard.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <inspector/MessageModel_ItemBase.hxx>
-
-class MessageModel_ItemRoot;
-typedef QExplicitlySharedDataPointer<MessageModel_ItemRoot> MessageModel_ItemRootPtr;
-
-//! \class MessageModel_ItemRoot
-//! Collects message reports that should be visualized in tree view. Reports are cached and if reports are not needed,
-//! cache should be cleared using RemoveAllReports
-//! Parent is NULL, children are MessageModel_ItemReport items.
-class MessageModel_ItemRoot : public MessageModel_ItemBase
-{
-private:
- //! \struct to extend report by description
- struct MessageModel_ReportInformation
- {
- //! Constructor
- MessageModel_ReportInformation (Handle(Message_Report) theReport, const TCollection_AsciiString& theDescription)
- : myReport (theReport), myDescription (theDescription) {}
-
- Handle(Message_Report) myReport; //! report
- TCollection_AsciiString myDescription; //! report description
- };
-public:
-
- //! Creates an item wrapped by a shared pointer
- static MessageModel_ItemRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return MessageModel_ItemRootPtr (new MessageModel_ItemRoot (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~MessageModel_ItemRoot() Standard_OVERRIDE {};
-
- //! Appends new report
- //! \param theReport a report instance
- //! \param theReportDescription an additional report information
- void AddReport (const Handle(Message_Report)& theReport, const TCollection_AsciiString& theReportDescription)
- { myReports.Append (MessageModel_ReportInformation (theReport, theReportDescription)); }
-
- //! Set report, se it into the given row index
- //! \param theRowId a report child row
- //! \param theReport a report instance
- //! \param theReportDescription an additional report information
- Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription = "");
-
- //! Returns true if report exists is in the list of the current reports
- //! \param theReport a report instance
- //! \return boolen value
- Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport);
-
- //! Clears internal container of added reports
- void RemoveAllReports() { myReports.Clear(); }
-
- //! Returns report by the number
- //! \param theRowId an index of the report in the internal container.
- Standard_EXPORT const Handle(Message_Report)& GetReport (const int theRowId, TCollection_AsciiString& theReportDescription);
-
- //! Set the view reversed. If reversed, the last report alert is upper item in the tree view
- //! \param theReversed boolean flag
- void SetReversed (const Standard_Boolean& theReversed) { myIsReversed = theReversed; }
-
- //! Return whether the view is reversed or not
- //! \return boolean value
- Standard_Boolean IsReversed() const { return myIsReversed; };
-
- //! Set the view reversed. If reversed, the last report alert is upper item in the tree view
- //! \param theReversed boolean flag
- void SetName (const TCollection_AsciiString& theName) { myName = theName; }
-
-protected:
-
- //! Return data value for the role.
- //! \param theRole a value role
- //! \return the value
- virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE { return myReports.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
- MessageModel_ItemRoot (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : MessageModel_ItemBase (theParent, theRow, theColumn), myIsReversed (Standard_False) {}
-
-private:
-
- NCollection_List<MessageModel_ReportInformation> myReports; //!< reports sent by algorithms
- Standard_Boolean myIsReversed; //!< state if the model is reversed
- TCollection_AsciiString myName; //!< DisplayRole data, if defined
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-06-20
-// 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 "MessageModel_ReportCallBack.hxx"
-
-IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ReportCallBack, Message_ReportCallBack)
+++ /dev/null
-// Created on: 2018-06-20
-// 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 _MessageModel_ReportCallBack_HeaderFile
-#define _MessageModel_ReportCallBack_HeaderFile
-
-#include <Message_ReportCallBack.hxx>
-
-#include "inspector/TInspectorAPI_Communicator.hxx"
-
-class TInspectorAPI_Communicator;
-DEFINE_STANDARD_HANDLE(MessageModel_ReportCallBack, Message_ReportCallBack)
-
-//! Class to update tree view model by message report events.
-class MessageModel_ReportCallBack : public Message_ReportCallBack
-{
-public:
-
- //! Constructor
- MessageModel_ReportCallBack (TInspectorAPI_Communicator* theWindow) : Message_ReportCallBack(), myCommunicator (theWindow) {}
-
- //! Destructor
- ~MessageModel_ReportCallBack() {}
-
- // Interface to be implemented in the child to process the message report event
- // \theAlert updated alert
- virtual void Update(const Handle(Message_Alert)& theAlert) { (void)theAlert; /*myCommunicator->UpdateContent();*/ }
-
- // OCCT RTTI
- DEFINE_STANDARD_RTTIEXT(MessageModel_ReportCallBack, Message_ReportCallBack)
-
-private:
- TInspectorAPI_Communicator* myCommunicator; //< communicator
-};
-
-#endif // _MessageModel_ReportCallBack_HeaderFile
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageModel_Tools.hxx>
-#include <inspector/MessageModel_ItemAlert.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/ViewControl_TableModelValuesDefault.hxx>
-
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepTools.hxx>
-#include <Message_AlertExtended.hxx>
-#include <Message_AttributeObject.hxx>
-#include <Message_AttributeStream.hxx>
-
-#include <Precision.hxx>
-#include <TopoDS_AlertAttribute.hxx>
-#include <TopoDS_Edge.hxx>
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- if (thePointer.IsNull())
- return TCollection_AsciiString();
-
- std::ostringstream aPtrStr;
- aPtrStr << thePointer.operator->();
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString (aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend("0x");
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();
-}
-
-// =======================================================================
-// function : GetPointerAlertInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetPointerAlertInfo (const Handle(Message_Alert)& theAlert)
-{
- Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anExtAlert.IsNull())
- return TCollection_AsciiString();
-
- Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
- if (anAttribute.IsNull())
- return TCollection_AsciiString();
-
- if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
- return GetPointerInfo (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape().TShape());
- else if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject)))
- return GetPointerInfo (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject());
- return TCollection_AsciiString();
-}
-
-// =======================================================================
-// function : GetShapeTypeAlertInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetShapeTypeAlertInfo (const Handle(Message_Alert)& theAlert)
-{
- Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anExtAlert.IsNull())
- return TCollection_AsciiString();
-
- Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
- if (anAttribute.IsNull())
- return TCollection_AsciiString();
-
- TopoDS_Shape aShape;
- if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
- aShape = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape();
-
- if (aShape.IsNull())
- return TCollection_AsciiString();
-
- TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
- Standard_SStream aSStream;
- TopAbs::Print ((TopAbs_ShapeEnum)aShapeType, aSStream);
- return aSStream.str().c_str();
-}
-
-// =======================================================================
-// function : GetStandardTypeAlertInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetStandardTypeAlertInfo (const Handle(Message_Alert)& theAlert)
-{
- Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
- if (anExtAlert.IsNull())
- return TCollection_AsciiString();
-
- Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
- if (anAttribute.IsNull())
- return TCollection_AsciiString();
-
- Handle(Standard_Transient) aPointer;
- if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
- aPointer = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape().TShape();
- else if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject)))
- aPointer = Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject();
-
- if (aPointer.IsNull())
- return TCollection_AsciiString();
-
- return aPointer->DynamicType()->Name();
-}
-
-// =======================================================================
-// function : GetPropertyTableValues
-// purpose :
-// =======================================================================
-void MessageModel_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
- QList<ViewControl_TableModelValues*>& theTableValues)
-{
- Handle(TreeModel_ItemProperties) anItemProperties = theItem->GetProperties();
- if (!anItemProperties.IsNull())
- {
- ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues();
- aTableValues->SetProperties (anItemProperties);
- theTableValues.append (aTableValues);
- return;
- }
-
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(theItem);
- if (!anAlertItem)
- return;
-
- const Handle(Message_Alert)& anAlert = anAlertItem->GetAlert();
- Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
- if (anExtendedAlert.IsNull())
- return;
-
- Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
- if (anAttribute.IsNull())
- return;
-
- //if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeStream)))
- //{
- //int aSectionSize = 200;
- //ViewControl_TableModelValues* aTableValues = new MessageModel_TableModelValues (anAttribute, aSectionSize);
- //theTableValues.append (aTableValues);
- //}
- //else
- //{
- if (!anAttribute->GetDescription().IsEmpty())
- {
- ViewControl_TableModelValuesDefault* aTableValues = new ViewControl_TableModelValuesDefault();
- QList<TreeModel_HeaderSection> aHeaderValues;
- QVector<QVariant> aValues;
- aHeaderValues << TreeModel_HeaderSection ("Description", -2);
- aValues << anAttribute->GetDescription().ToCString();
- aTableValues->SetHeaderValues (aHeaderValues, Qt::Horizontal);
-
- QString aValueStr = anAttribute->GetDescription().ToCString();
- QStringList aValueStrList = aValueStr.split ("\n");
- int aNbRows = aValueStrList.size();
-
- QFontMetrics aFontMetrics (qApp->font());
- int aHeight = aFontMetrics.boundingRect(aValueStr).height();
- aHeight = (aHeight + TreeModel_Tools::HeaderSectionMargin()) * aNbRows;
- aTableValues->SetValues (aValues);
- aTableValues->SetDefaultSectionSize(Qt::Vertical, aHeight);
-
- theTableValues.append (aTableValues);
- }
- //}
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_Tools_H
-#define MessageModel_Tools_H
-
-#include <Standard.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <Message_ListOfAlert.hxx>
-#include <NCollection_DataMap.hxx>
-#include <NCollection_Vector.hxx>
-#include <Standard_Transient.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QList>
-#include <Standard_WarningsRestore.hxx>
-
-class Message_Alert;
-class ViewControl_TableModelValues;
-
-class ViewControl_Table;
-
-//! \class MessageModel_Tools
-//! It gives auxiliary methods for Message classes manipulation
-class MessageModel_Tools
-{
-public:
-
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo = true);
-
- //! Returns pointer alert information depening on type of alert (Transient_Object or TopoDS_TShape)
- //! \param theAlert a message alert
- //! \return text presentation
- Standard_EXPORT static TCollection_AsciiString GetPointerAlertInfo (const Handle(Message_Alert)& theAlert);
-
- //! Returns TopoDS_Shape type alert information or empty string
- //! \param theAlert a message alert
- //! \return text presentation
- Standard_EXPORT static TCollection_AsciiString GetShapeTypeAlertInfo (const Handle(Message_Alert)& theAlert);
-
- //! Returns dynamic type of an alert object/shape
- //! \param theAlert a message alert
- //! \return text presentation
- Standard_EXPORT static TCollection_AsciiString GetStandardTypeAlertInfo (const Handle(Message_Alert)& theAlert);
-
- //! Fills container of table values
- //! \param theAlert a message alert
- //! \param theTableValue container of values
- Standard_EXPORT static void GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
- QList<ViewControl_TableModelValues*>& theTableValues);
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageModel_TreeModel.hxx>
-
-#include <inspector/MessageModel_ItemAlert.hxx>
-#include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_ItemReport.hxx>
-
-const int COLUMN_NAME_WIDTH = 310;
-const int COLUMN_SIZE_WIDTH = 30;
-const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
-const int COLUMN_STANDARD_TYPE_WIDTH = 120;
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
-: TreeModel_ModelBase (theParent), myIsReversed (Standard_False)
-{
- SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
- SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
- SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (3, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
-
- //SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
- // column 1 is reserved for visiblity state
- //SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-
- SetHeaderItem (4, TreeModel_HeaderSection ("Metric", -1));
- SetHeaderItem (5, TreeModel_HeaderSection ("Difference", -1));
-
- SetHeaderItem (6, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (7, TreeModel_HeaderSection ("Shape Type", COLUMN_SHAPE_TYPE_WIDTH));
- SetHeaderItem (8, TreeModel_HeaderSection ("Standard Type", COLUMN_STANDARD_TYPE_WIDTH));
- SetHeaderItem (9, TreeModel_HeaderSection ("Description", -1));
-}
-
-// =======================================================================
-// function : createRootItem
-// purpose :
-// =======================================================================
-void MessageModel_TreeModel::createRootItem (const int theColumnId)
-{
- myRootItems.insert (theColumnId, MessageModel_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
- if (theColumnId == 0)
- m_pRootItem = myRootItems[0];
-}
-
-// =======================================================================
-// function : HasShape
-// purpose :
-// =======================================================================
-Standard_Boolean MessageModel_TreeModel::HasReport (const Handle(Message_Report)& theReport)
-{
- if (columnCount() == 0)
- return Standard_False;
-
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (0));
- return aRootItem && aRootItem->HasReport (theReport);
-}
-
-// =======================================================================
-// function : AddShape
-// purpose :
-// =======================================================================
-void MessageModel_TreeModel::AddReport (const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription)
-{
- for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
- {
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (aColId));
- if (!aRootItem)
- continue;
- aRootItem->AddReport (theReport, theReportDescription);
- aRootItem->SetReversed (myIsReversed);
- }
-
- Reset();
- EmitLayoutChanged();
-}
-
-// =======================================================================
-// function : SetReport
-// purpose :
-// =======================================================================
-void MessageModel_TreeModel::SetReport (const int theRowId, const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription)
-{
- for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
- {
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (aColId));
- if (!aRootItem)
- continue;
- aRootItem->SetReport (theRowId, theReport, theReportDescription);
- }
- Reset();
- EmitLayoutChanged();
-}
-
-// =======================================================================
-// function : SetReversed
-// purpose :
-// =======================================================================
-void MessageModel_TreeModel::SetReversed (const Standard_Boolean& theReversed)
-{
- myIsReversed = theReversed;
-
- for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
- {
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (aColId));
- if (aRootItem)
- aRootItem->SetReversed (myIsReversed);
- }
-
- Reset();
- EmitLayoutChanged();
-}
-
-// =======================================================================
-// function : UpdateTreeModel
-// purpose :
-// =======================================================================
-void MessageModel_TreeModel::SetRootItemName (const TCollection_AsciiString& theName)
-{
- MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (0));
- if (aRootItem)
- aRootItem->SetName (theName);
-}
-
-// =======================================================================
-// function : UpdateTreeModel
-// purpose :
-// =======================================================================
-void MessageModel_TreeModel::UpdateTreeModel()
-{
- Reset();
- EmitLayoutChanged();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageModel_TreeModel_H
-#define MessageModel_TreeModel_H
-
-#include <inspector/MessageModel_ItemBase.hxx>
-#include <Standard.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Message_Report.hxx>
-#include <inspector/TreeModel_ModelBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QMap>
-#include <QObject>
-#include <Standard_WarningsRestore.hxx>
-
-class MessageModel_TreeModel;
-
-//! \class MessageModel_TreeModel
-//! View model to visualize MessageReport/s content
-class MessageModel_TreeModel : public TreeModel_ModelBase
-{
-public:
-
- //! Constructor
- Standard_EXPORT MessageModel_TreeModel (QObject* theParent);
-
- //! Destructor
- virtual ~MessageModel_TreeModel() Standard_OVERRIDE {};
-
- //! Returns true if parameter report was added into the model
- //! \param theReport a report instance
- //! \return boolen value
- Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport);
-
- //! Add shape, append it to the model root item
- //! \param theReport a report instance
- //! \param theReportDescription an additional report information
- Standard_EXPORT void AddReport (const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription = "");
-
- //! Set report, se it into the given row index
- //! \param theRowId a report child row
- //! \param theReport a report instance
- //! \param theReportDescription an additional report information
- Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription = "");
-
- //! Set the view reversed. If reversed, the last report alert is upper item in the tree view
- //! \param theReversed boolean flag
- Standard_EXPORT void SetReversed (const Standard_Boolean& theReversed);
-
- //! Return whether the view is reversed or not
- //! \return boolean value
- Standard_Boolean IsReversed() const { return myIsReversed; };
-
- //! Sets the text value of the Root item, only "Name" column accepts the parameter value
- //! \theName visulized text of root item
- Standard_EXPORT void SetRootItemName (const TCollection_AsciiString& theName);
-
- //! Returns root item by column
- //! \param theColumn an index of the column
- //! \return root item instance
- virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
- { return myRootItems.contains (theColumn) ? myRootItems[theColumn] : TreeModel_ItemBasePtr(); }
-
- //! Updates tree model
- Standard_EXPORT void UpdateTreeModel();
-
-protected:
- //! Creates root item
- //! \param theColumnId index of a column
- virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
-
-private:
- QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
- Standard_Boolean myIsReversed; //!< state if the model is reversed
-};
-
-#endif
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="20"
- height="20"
- viewBox="0 0 5.2916664 5.2916666"
- version="1.1"
- id="svg8"
- inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
- sodipodi:docname="item_shape.svg"
- inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_shape.png"
- inkscape:export-xdpi="96"
- inkscape:export-ydpi="96">
- <defs
- id="defs2">
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
- inkscape:vp_y="0 : 1028.295 : 0"
- inkscape:vp_z="9.504499 : -1.1228559 : 1"
- inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
- id="perspective3711" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="15.839192"
- inkscape:cx="4.9829441"
- inkscape:cy="7.75434"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:window-width="1446"
- inkscape:window-height="676"
- inkscape:window-x="1766"
- inkscape:window-y="124"
- inkscape:window-maximized="0"
- units="px" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(71.966667,-93.642022)">
- <g
- sodipodi:type="inkscape:box3d"
- id="g3741"
- inkscape:perspectiveID="#perspective3711"
- inkscape:corner0="0.78884625 : 0.0054590483 : 0 : 1"
- inkscape:corner7="-0.14713316 : 0.0022509206 : 0.25 : 1">
- <path
- sodipodi:type="inkscape:box3dside"
- id="path3743"
- style="fill:#353564;fill-rule:evenodd;stroke:none;stroke-width:1.45609081;stroke-linejoin:round"
- inkscape:box3dsidetype="6"
- d="m -71.590875,96.691829 v 1.844151 l 1.119347,0.186449 v -1.618024 z"
- points="-71.590875,98.53598 -70.471528,98.722429 -70.471528,97.104405 -71.590875,96.691829 " />
- <path
- sodipodi:type="inkscape:box3dside"
- id="path3753"
- style="fill:#e9e9ff;fill-rule:evenodd;stroke:none;stroke-width:1.45609081;stroke-linejoin:round"
- inkscape:box3dsidetype="11"
- d="m -70.471528,97.104405 3.521639,-1.795967 v 2.991206 l -3.521639,0.422785 z"
- points="-66.949889,95.308438 -66.949889,98.299644 -70.471528,98.722429 -70.471528,97.104405 " />
- <path
- sodipodi:type="inkscape:box3dside"
- id="path3745"
- style="fill:#4d4d9f;fill-rule:evenodd;stroke:none;stroke-width:1.45609081;stroke-linejoin:round"
- inkscape:box3dsidetype="5"
- d="m -71.590875,96.691829 3.325505,-2.775198 1.315481,1.391807 -3.521639,1.795967 z"
- points="-68.26537,93.916631 -66.949889,95.308438 -70.471528,97.104405 -71.590875,96.691829 " />
- <path
- sodipodi:type="inkscape:box3dside"
- id="path3751"
- style="fill:#afafde;fill-rule:evenodd;stroke:none;stroke-width:1.45609081;stroke-linejoin:round"
- inkscape:box3dsidetype="13"
- d="m -71.590875,98.53598 3.325505,-0.751334 1.315481,0.514998 -3.521639,0.422785 z"
- points="-68.26537,97.784646 -66.949889,98.299644 -70.471528,98.722429 -71.590875,98.53598 " />
- <path
- sodipodi:type="inkscape:box3dside"
- id="path3749"
- style="fill:#d7d7ff;fill-rule:evenodd;stroke:none;stroke-width:1.45609081;stroke-linejoin:round"
- inkscape:box3dsidetype="14"
- d="m -68.26537,93.916631 v 3.868015 l 1.315481,0.514998 v -2.991206 z"
- points="-68.26537,97.784646 -66.949889,98.299644 -66.949889,95.308438 -68.26537,93.916631 " />
- <path
- sodipodi:type="inkscape:box3dside"
- id="path3747"
- style="fill:#8686bf;fill-rule:evenodd;stroke:none;stroke-width:1.45609081;stroke-linejoin:round"
- inkscape:box3dsidetype="3"
- d="m -71.590875,96.691829 3.325505,-2.775198 v 3.868015 l -3.325505,0.751334 z"
- points="-68.26537,93.916631 -68.26537,97.784646 -71.590875,98.53598 -71.590875,96.691829 " />
- </g>
- </g>
-</svg>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="20"
- height="20"
- viewBox="0 0 5.2916664 5.2916666"
- version="1.1"
- id="svg8"
- inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
- sodipodi:docname="item_vectorOfReal.svg"
- inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
- inkscape:export-xdpi="96"
- inkscape:export-ydpi="96">
- <defs
- id="defs2">
- <linearGradient
- id="linearGradient4578"
- osb:paint="solid">
- <stop
- style="stop-color:#000000;stop-opacity:1;"
- offset="0"
- id="stop4576" />
- </linearGradient>
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
- inkscape:vp_y="0 : 1028.295 : 0"
- inkscape:vp_z="9.504499 : -1.1228559 : 1"
- inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
- id="perspective3711" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="15.839192"
- inkscape:cx="-10.548151"
- inkscape:cy="10.279721"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:window-width="1446"
- inkscape:window-height="838"
- inkscape:window-x="1733"
- inkscape:window-y="67"
- inkscape:window-maximized="0"
- units="px" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(71.966667,-93.642022)">
- <rect
- id="rect3769"
- width="4.660512"
- height="4.443356"
- x="-71.632576"
- y="94.056023"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-3"
- width="4.7041783"
- height="2.2966287"
- x="-71.676239"
- y="96.202751"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-9"
- width="2.3560426"
- height="4.4502382"
- x="-71.617508"
- y="94.071091"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
-</svg>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="20"
- height="20"
- viewBox="0 0 5.2916664 5.2916666"
- version="1.1"
- id="svg8"
- inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
- sodipodi:docname="item_vectorOfRealVec3.svg"
- inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
- inkscape:export-xdpi="96"
- inkscape:export-ydpi="96">
- <defs
- id="defs2">
- <linearGradient
- id="linearGradient4578"
- osb:paint="solid">
- <stop
- style="stop-color:#000000;stop-opacity:1;"
- offset="0"
- id="stop4576" />
- </linearGradient>
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
- inkscape:vp_y="0 : 1028.295 : 0"
- inkscape:vp_z="9.504499 : -1.1228559 : 1"
- inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
- id="perspective3711" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="15.839192"
- inkscape:cx="-10.548151"
- inkscape:cy="10.279721"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:window-width="1446"
- inkscape:window-height="838"
- inkscape:window-x="1733"
- inkscape:window-y="67"
- inkscape:window-maximized="0"
- units="px" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(71.966667,-93.642022)">
- <rect
- id="rect3769"
- width="4.660512"
- height="4.443356"
- x="-71.632576"
- y="94.056023"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-3"
- width="4.7041783"
- height="2.2966287"
- x="-71.676239"
- y="96.202751"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-9"
- width="2.3560426"
- height="4.4502382"
- x="-71.617508"
- y="94.071091"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-9-6"
- width="0.78304976"
- height="2.0045512"
- x="-71.618477"
- y="94.141006"
- style="opacity:1;fill:#dc8c8c;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.07284392;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-9-6-0"
- width="0.78304976"
- height="2.0045512"
- x="-70.835426"
- y="94.141006"
- style="opacity:1;fill:#8cdc8c;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.07284392;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-9-6-5"
- width="0.78304976"
- height="2.0045512"
- x="-70.052376"
- y="94.141006"
- style="opacity:1;fill:#8c8cdc;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.07284392;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
-</svg>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="20"
- height="20"
- viewBox="0 0 5.2916664 5.2916666"
- version="1.1"
- id="svg8"
- inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
- sodipodi:docname="item_vectorOfReal.svg"
- inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
- inkscape:export-xdpi="96"
- inkscape:export-ydpi="96">
- <defs
- id="defs2">
- <linearGradient
- id="linearGradient4578"
- osb:paint="solid">
- <stop
- style="stop-color:#000000;stop-opacity:1;"
- offset="0"
- id="stop4576" />
- </linearGradient>
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
- inkscape:vp_y="0 : 1028.295 : 0"
- inkscape:vp_z="9.504499 : -1.1228559 : 1"
- inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
- id="perspective3711" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="15.839192"
- inkscape:cx="-10.548151"
- inkscape:cy="10.279721"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:window-width="1446"
- inkscape:window-height="838"
- inkscape:window-x="1733"
- inkscape:window-y="67"
- inkscape:window-maximized="0"
- units="px" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(71.966667,-93.642022)">
- <rect
- id="rect3769"
- width="4.660512"
- height="4.443356"
- x="-71.632576"
- y="94.056023"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-3"
- width="4.7041783"
- height="2.2966287"
- x="-71.676239"
- y="96.202751"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- id="rect3769-9"
- width="2.3560426"
- height="4.4502382"
- x="-71.617508"
- y="94.071091"
- style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
-</svg>
+++ /dev/null
-MessageView_Communicator.cxx
-MessageView_Communicator.hxx
-MessageView_VisibilityState.cxx
-MessageView_VisibilityState.hxx
-MessageView_Window.cxx
-MessageView_Window.hxx
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageView_Communicator.hxx>
-
-
-// =======================================================================
-// function : CreateCommunicator
-// purpose : Creates a communicator by the library loading
-// =======================================================================
-Standard_EXPORTEXTERNC TInspectorAPI_Communicator* CreateCommunicator()
-{
- return new MessageView_Communicator();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageView_Communicator_H
-#define MessageView_Communicator_H
-
-#include <inspector/MessageModel_ReportCallBack.hxx>
-#include <inspector/MessageView_Window.hxx>
-#include <inspector/TInspectorAPI_Communicator.hxx>
-
-//! \class MessageView_Communicator.
-//! \brief This is a connector from TInspector application to MessageView window
-class MessageView_Communicator : public TInspectorAPI_Communicator
-{
-public:
-
- //! Constructor
- MessageView_Communicator() : TInspectorAPI_Communicator(), myWindow (new MessageView_Window (0))
- { myWindow->SetCallBack (new MessageModel_ReportCallBack (this)); }
-
- //! Destructor
- virtual ~MessageView_Communicator() Standard_OVERRIDE {}
-
- //! Provides the container with a parent where this container should be inserted.
- //! If Qt implementation, it should be QWidget with QLayout set inside
- //! \param theParent a parent class
- virtual void SetParent (void* theParent) Standard_OVERRIDE { myWindow->SetParent (theParent); }
-
- //! Sets parameters container, it should be used when the plugin is initialized or in update content
- //! \param theParameters a parameters container
- virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE
- { myWindow->SetParameters (theParameters); }
-
- //! Provide container for actions available in inspector on general level
- //! \param theMenu if Qt implementation, it is QMenu object
- virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
-
- //! Returns plugin preferences, empty implementation by default
- //! \param theItem container of preference elements
- virtual void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
- { myWindow->GetPreferences (theItem); }
-
- //! Stores plugin preferences, empty implementation by default
- //! \param theItem container of preference elements
- virtual void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
- { myWindow->SetPreferences (theItem); }
-
- //! Calls update of the plugin's content
- virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }
-
-private:
-
- MessageView_Window* myWindow; //!< current window
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageView_VisibilityState.hxx>
-#include <inspector/MessageModel_ItemAlert.hxx>
-
-#include <Message_AlertExtended.hxx>
-#include <Message_AttributeStream.hxx>
-
-#include <TopoDS_AlertAttribute.hxx>
-
-// =======================================================================
-// function : CanBeVisible
-// purpose :
-// =======================================================================
-bool MessageView_VisibilityState::CanBeVisible (const QModelIndex& theIndex) const
-{
- MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex);
- if (anAlertItem)
- {
- NCollection_List<Handle(Standard_Transient)> aPresentations;
- anAlertItem->GetPresentations (aPresentations);
- if (!aPresentations.IsEmpty())
- return true;
- }
-
- return !getShape (theIndex).IsNull();// || hasTableValues (theIndex);
-}
-
-// =======================================================================
-// function : SetVisible
-// purpose :
-// =======================================================================
-bool MessageView_VisibilityState::SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged)
-{
- TopoDS_Shape aShape = getShape (theIndex);
- if (aShape.IsNull())
- return false;
-
- myDisplayer->SetVisible (aShape, theState, myPresentationType);
-
- if (!theState) {
- MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex);
- if (anAlertItem && !anAlertItem->GetCustomShape().IsNull())
- anAlertItem->SetCustomShape (TopoDS_Shape());
- }
-
- if (toEmitDataChanged)
- {
- QModelIndex anIndex = theIndex;
- if (theIndex.column() != TreeModel_ColumnType_Visibility)
- anIndex = theIndex.model()->index(theIndex.row(), TreeModel_ColumnType_Visibility, theIndex.parent());
-
- getModel()->EmitDataChanged (anIndex, anIndex);
- }
- return true;
-}
-
-// =======================================================================
-// function : IsVisible
-// purpose :
-// =======================================================================
-bool MessageView_VisibilityState::IsVisible (const QModelIndex& theIndex) const
-{
- return myDisplayer->IsVisible (getShape (theIndex), myPresentationType);
-}
-
-// =======================================================================
-// function : getAlertItem
-// purpose :
-// =======================================================================
-MessageModel_ItemAlertPtr MessageView_VisibilityState::getAlertItem (const QModelIndex& theIndex) const
-{
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
- if (!anItemBase)
- return MessageModel_ItemAlertPtr();
-
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
- return anAlertItem;
-}
-
-// =======================================================================
-// function : getShape
-// purpose :
-// =======================================================================
-TopoDS_Shape MessageView_VisibilityState::getShape (const QModelIndex& theIndex) const
-{
- MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex);
- if (!anAlertItem)
- return TopoDS_Shape();
-
- if (!anAlertItem->GetCustomShape().IsNull())
- return anAlertItem->GetCustomShape();
-
- Handle(Message_Alert) anAlert = anAlertItem->GetAlert();
- if (anAlert.IsNull())
- return TopoDS_Shape();
-
- Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast(anAlert);
- if (anAlertExtended.IsNull())
- return TopoDS_Shape();
-
- Handle(TopoDS_AlertAttribute) aShapeAttribute = Handle(TopoDS_AlertAttribute)::DownCast (anAlertExtended->Attribute());
- if (!aShapeAttribute.IsNull())
- return aShapeAttribute->GetShape();
-
- return TopoDS_Shape();
-}
-
-// =======================================================================
-// function : hasTableValues
-// purpose :
-// =======================================================================
-bool MessageView_VisibilityState::hasTableValues (const QModelIndex& theIndex) const
-{
- MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex);
- if (!anAlertItem)
- return false;
-
- Handle(Message_Alert) anAlert = anAlertItem->GetAlert();
- if (anAlert.IsNull())
- return false;
-
- if (anAlert->IsKind (STANDARD_TYPE (Message_AttributeStream)))
- return true;
-
- return false;
-}
\ No newline at end of file
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageView_VisibilityState_H
-#define MessageView_VisibilityState_H
-
-#include <inspector/TreeModel_VisibilityState.hxx>
-
-#include <inspector/MessageModel_ItemAlert.hxx>
-
-#include <inspector/View_Displayer.hxx>
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <TopoDS_Shape.hxx>
-
-class TreeModel_ModelBase;
-
-//! \class MessageView_VisibilityState
-//! \brief Class provides connection between model and visualization control
-class MessageView_VisibilityState : public TreeModel_VisibilityState
-{
-public:
- //! Constructor
- MessageView_VisibilityState (TreeModel_ModelBase* theModel)
- : TreeModel_VisibilityState (theModel), myPresentationType (View_PresentationType_Main) {}
-
- //! Destructor
- ~MessageView_VisibilityState() {}
-
- //! Sets current displayer
- //! \theDisplayer class that provides connection to visualized objects
- void SetDisplayer (View_Displayer* theDisplayer) { myDisplayer = theDisplayer; }
-
- //! Sets presentation type for displayer
- //! \param theType type value
- void SetPresentationType (const View_PresentationType theType) { myPresentationType = theType; }
-
- //! Returns true if visibility of the item can be changed
- //! \param theIndex tree model index
- //! \return boolean value
- Standard_EXPORT virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE;
-
- //! Sets visibility state
- //! \theIndex tree model index
- //! \param theState visibility state
- //! \param toEmitDataChanged boolean flag whether emit of the model should be done immediatelly
- //! \return true if state is changed
- Standard_EXPORT virtual bool SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged) Standard_OVERRIDE;
-
- //! Returns visibility state value
- Standard_EXPORT virtual bool IsVisible (const QModelIndex& theIndex) const Standard_OVERRIDE;
-
-protected:
- //! Gets the alert item
- //! \theIndex tree model index
- //! \return item or NULL
- MessageModel_ItemAlertPtr getAlertItem (const QModelIndex& theIndex) const;
-
- //! Gets shape of the view model by the parameter index if it has a shape
- //! \param theIndex tree model index
- //! \return shape instance
- TopoDS_Shape getShape (const QModelIndex& theIndex) const;
-
- //! Returns true if alert of the item has table values
- //! \param theIndex tree model index
- //! \return boolean result
- bool hasTableValues (const QModelIndex& theIndex) const;
-
-private:
- View_Displayer* myDisplayer; //! view displayer
- View_PresentationType myPresentationType; //! presentation type
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/MessageView_Window.hxx>
-#include <inspector/MessageView_VisibilityState.hxx>
-
-#include <inspector/MessageModel_Actions.hxx>
-#include <inspector/MessageModel_ItemAlert.hxx>
-#include <inspector/MessageModel_ItemReport.hxx>
-#include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_ReportCallBack.hxx>
-#include <inspector/MessageModel_Tools.hxx>
-#include <inspector/MessageModel_TreeModel.hxx>
-
-#include <inspector/TreeModel_ContextMenu.hxx>
-#include <inspector/TreeModel_Tools.hxx>
-
-#include <inspector/ViewControl_PropertyView.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/ViewControl_TreeView.hxx>
-#include <inspector/Convert_TransientShape.hxx>
-
-#include <inspector/View_Tools.hxx>
-#include <inspector/View_Viewer.hxx>
-#include <inspector/View_Widget.hxx>
-
-#include <AIS_Shape.hxx>
-#include <Graphic3d_Camera.hxx>
-#include <OSD_Environment.hxx>
-
-#include <OSD_Directory.hxx>
-#include <OSD_Protection.hxx>
-
-#include <TCollection_AsciiString.hxx>
-//#include <TopoDS_AlertWithShape.hxx>
-
-#include <XmlDrivers_MessageReportStorage.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/View_Displayer.hxx>
-#include <inspector/View_ToolBar.hxx>
-#include <inspector/View_Widget.hxx>
-#include <inspector/View_Window.hxx>
-#include <inspector/View_Viewer.hxx>
-
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Path.hxx>
-
-#include <QApplication>
-#include <QAction>
-#include <QComboBox>
-#include <QDockWidget>
-#include <QDir>
-#include <QFile>
-#include <QFileDialog>
-#include <QHeaderView>
-#include <QMainWindow>
-#include <QMenu>
-#include <QMessageBox>
-#include <QPlainTextEdit>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QTextStream>
-#include <QToolBar>
-#include <QToolButton>
-#include <QTreeView>
-#include <QWidget>
-#include <QVBoxLayout>
-
-const int DEFAULT_TEXT_VIEW_WIDTH = 400;// 800;
-const int DEFAULT_TEXT_VIEW_HEIGHT = 700;
-const int DEFAULT_TEXT_VIEW_POSITION_X = 430;
-const int DEFAULT_TEXT_VIEW_POSITION_Y = 30;
-const int DEFAULT_TEXT_VIEW_DELTA = 100;
-
-const int DEFAULT_SHAPE_VIEW_WIDTH = 400;// 900;
-const int DEFAULT_SHAPE_VIEW_HEIGHT = 450;
-const int DEFAULT_SHAPE_VIEW_POSITION_X = 60;
-const int DEFAULT_SHAPE_VIEW_POSITION_Y = 60;
-
-const int DEFAULT_DETACH_POSITION_X = 5;
-const int DEFAULT_DETACH_POSITION_Y = 450;
-
-const int MESSAGEVIEW_DEFAULT_TREE_VIEW_WIDTH = 950; //600
-const int MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT = 500;
-
-const int MESSAGEVIEW_DEFAULT_VIEW_WIDTH = 200;// 400;
-const int MESSAGEVIEW_DEFAULT_VIEW_HEIGHT = 300;// 1000;
-
-#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-Handle(Prs3d_Drawer) GetPreviewAttributes (const Handle(AIS_InteractiveContext)& theContext)
-{
- Handle(Prs3d_Drawer) myDrawer = new Prs3d_Drawer();
- myDrawer->Link (theContext->DefaultDrawer());
-
- Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1));
- Standard_ShortReal aTransparency = 0.8;
-
- // point parameters
- myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
-
- // shading parameters
- Graphic3d_MaterialAspect aShadingMaterial;
- aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
- aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
-
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
- myDrawer->ShadingAspect()->SetColor (aColor);
- myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial);
-
- myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency);
- myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency);
- myDrawer->SetTransparency (aTransparency);
-
- // common parameters
- myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
-
- return myDrawer;
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-MessageView_Window::MessageView_Window (QWidget* theParent)
-: QObject (theParent)
-{
- myMainWindow = new QMainWindow (theParent);
-
- myTreeView = new ViewControl_TreeView (myMainWindow);
- ((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (MESSAGEVIEW_DEFAULT_TREE_VIEW_WIDTH,
- MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT));
- MessageModel_TreeModel* aModel = new MessageModel_TreeModel (myTreeView);
- //aModel->SetReversed (Standard_True);
- for (int i = 6; i <= 8; i++) // hide shape parameters columns
- {
- TreeModel_HeaderSection anItem = aModel->GetHeaderItem (i);
- anItem.SetIsHidden (true);
- aModel->SetHeaderItem (i, anItem);
- }
-
- myTreeView->setModel (aModel);
- MessageView_VisibilityState* aVisibilityState = new MessageView_VisibilityState (aModel);
- aModel->SetVisibilityState (aVisibilityState);
- connect (aVisibilityState, SIGNAL (itemClicked (const QModelIndex&)), this, SLOT(onTreeViewVisibilityClicked(const QModelIndex&)));
-
- TreeModel_Tools::UseVisibilityColumn (myTreeView);
-
- QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel);
- myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection);
- myTreeView->setSelectionModel (aSelectionModel);
- connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
-
- myTreeViewActions = new MessageModel_Actions (myMainWindow, aModel, aSelectionModel);
- myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
- connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
- this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
- new TreeModel_ContextMenu (myTreeView);
-
- QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
- myTreeView->setExpanded (aParentIndex, true);
-
- myMainWindow->setCentralWidget (myTreeView);
-
- // property view
- myPropertyView = new ViewControl_PropertyView (myMainWindow);
- myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
- myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
- myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
- myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
- myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
- connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool)));
- connect (myPropertyView, SIGNAL (propertyViewSelectionChanged()), this, SLOT (onPropertyViewSelectionChanged ()));
-
- // view
- myViewWindow = new View_Window (myMainWindow, false);
- connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
- aVisibilityState->SetDisplayer (myViewWindow->GetDisplayer());
- aVisibilityState->SetPresentationType (View_PresentationType_Main);
- myViewWindow->GetView()->SetPredefinedSize (MESSAGEVIEW_DEFAULT_VIEW_WIDTH, MESSAGEVIEW_DEFAULT_VIEW_HEIGHT);
-
- myViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
- myViewDockWidget->setObjectName (myViewDockWidget->windowTitle());
- myViewDockWidget->setWidget (myViewWindow);
- myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myViewDockWidget);
-
- myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
- myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
-}
-
-// =======================================================================
-// function : SetParent
-// purpose :
-// =======================================================================
-void MessageView_Window::SetParent (void* theParent)
-{
- QWidget* aParent = (QWidget*)theParent;
- if (aParent)
- {
- QLayout* aLayout = aParent->layout();
- if (aLayout)
- aLayout->addWidget (GetMainWindow());
- }
- else
- {
- GetMainWindow()->setParent (0);
- GetMainWindow()->setVisible (true);
- }
-}
-
-// =======================================================================
-// function : FillActionsMenu
-// purpose :
-// =======================================================================
-void MessageView_Window::FillActionsMenu (void* theMenu)
-{
- QMenu* aMenu = (QMenu*)theMenu;
- QList<QDockWidget*> aDockwidgets = myMainWindow->findChildren<QDockWidget*>();
- for (QList<QDockWidget*>::iterator it = aDockwidgets.begin(); it != aDockwidgets.end(); ++it)
- {
- QDockWidget* aDockWidget = *it;
- if (aDockWidget->parentWidget() == myMainWindow)
- aMenu->addAction (aDockWidget->toggleViewAction());
- }
-}
-
-// =======================================================================
-// function : GetPreferences
-// purpose :
-// =======================================================================
-void MessageView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
-{
- theItem.Clear();
- theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
-
- QMap<QString, QString> anItems;
- TreeModel_Tools::SaveState (myTreeView, anItems);
- View_Tools::SaveState (myViewWindow, anItems);
-
- for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
- theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
-}
-
-// =======================================================================
-// function : SetPreferences
-// purpose :
-// =======================================================================
-void MessageView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem)
-{
- if (theItem.IsEmpty())
- {
- TreeModel_Tools::SetDefaultHeaderSections (myTreeView);
- return;
- }
-
- for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
- {
- if (anItemIt.Key().IsEqual ("geometry"))
- myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
- else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
- continue;
- else if (View_Tools::RestoreState (myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
- continue;
- }
-}
-
-// =======================================================================
-// function : UpdateContent
-// purpose :
-// =======================================================================
-void MessageView_Window::UpdateContent()
-{
- bool isUpdated = false;
- TCollection_AsciiString aName = "TKMessageView";
- if (myParameters->FindParameters (aName))
- {
- NCollection_List<Handle(Standard_Transient)> aParameters = myParameters->Parameters (aName);
- // Init will remove from parameters those, that are processed only one time (TShape)
- Init (aParameters);
- myParameters->SetParameters (aName, aParameters);
- isUpdated = true;
- }
- if (myParameters->FindFileNames (aName))
- {
- for (NCollection_List<TCollection_AsciiString>::Iterator aFilesIt (myParameters->FileNames (aName));
- aFilesIt.More(); aFilesIt.Next())
- openFile (aFilesIt.Value());
-
- NCollection_List<TCollection_AsciiString> aNames;
- myParameters->SetFileNames (aName, aNames);
- isUpdated = true;
- }
- Handle(Message_Report) aDefaultReport = Message_Report::CurrentReport( Standard_False);
- MessageModel_TreeModel* aViewModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- if (!aDefaultReport.IsNull() && !aViewModel->HasReport (aDefaultReport))
- {
- aDefaultReport->SetCallBack (myCallBack);
- addReport (aDefaultReport);
- }
- // reload report of selected item
- onReloadReport();
-
- updateTreeModel();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& theParameters)
-{
- Handle(AIS_InteractiveContext) aContext;
- NCollection_List<Handle(Standard_Transient)> aParameters;
-
- Handle(Message_ReportCallBack) aReportCallBack;
- Handle(Graphic3d_Camera) aViewCamera;
-
- for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters);
- aParamsIt.More(); aParamsIt.Next())
- {
- Handle(Standard_Transient) anObject = aParamsIt.Value();
- Handle(Message_Report) aMessageReport = Handle(Message_Report)::DownCast (anObject);
- if (!aMessageReport.IsNull())
- {
- aMessageReport->SetCallBack (myCallBack);
- addReport (aMessageReport);
- }
- else if (!Handle(AIS_InteractiveContext)::DownCast (anObject).IsNull())
- {
- aParameters.Append (anObject);
- if (aContext.IsNull())
- aContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
- }
- else if (!Handle(Graphic3d_Camera)::DownCast (anObject).IsNull())
- {
- aViewCamera = Handle(Graphic3d_Camera)::DownCast (anObject);
- }
- }
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- if (!aTreeModel)
- return;
-
- aTreeModel->EmitLayoutChanged();
-
- if (!aContext.IsNull())
- {
- myViewWindow->SetContext (View_ContextType_External, aContext);
- }
-
- if (!aViewCamera.IsNull())
- myViewWindow->GetView()->GetViewer()->GetView()->Camera()->Copy (aViewCamera);
-
- theParameters = aParameters;
-}
-
-// =======================================================================
-// function : openFile
-// purpose :
-// =======================================================================
-void MessageView_Window::openFile(const TCollection_AsciiString& theFileName)
-{
- Handle(Message_Report) aReport = XmlDrivers_MessageReportStorage::ImportReport(theFileName);
- if (aReport.IsNull())
- return;
-
- addReport (aReport, theFileName);
-}
-
-// =======================================================================
-// function : updateTreeModel
-// purpose :
-// =======================================================================
-void MessageView_Window::updateTreeModel()
-{
- MessageModel_TreeModel* aViewModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- if (!aViewModel)
- return;
-
- aViewModel->UpdateTreeModel();
-}
-
-// =======================================================================
-// function : addReport
-// purpose :
-// =======================================================================
-void MessageView_Window::addReport (const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription)
-{
- MessageModel_TreeModel* aModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- aModel->AddReport (theReport, theReportDescription);
-}
-
-// =======================================================================
-// function : onTreeViewSelectionChanged
-// purpose :
-// =======================================================================
-void MessageView_Window::onTreeViewVisibilityClicked(const QModelIndex& theIndex)
-{
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- TreeModel_VisibilityState* aVisibilityState = aTreeModel->GetVisibilityState();
- if (!aVisibilityState->IsVisible (theIndex))
- myPropertyView->ClearActiveTablesSelection();
-}
-
-// =======================================================================
-// function : onTreeViewSelectionChanged
-// purpose :
-// =======================================================================
-void MessageView_Window::onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)
-{
- if (!myPropertyPanelWidget->toggleViewAction()->isChecked())
- return;
-
- updatePropertyPanelBySelection();
-
- NCollection_List<Handle(Standard_Transient)> aPresentations;
- MessageModel_ItemRootPtr aRootItem;
- QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes();
- for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- QModelIndex anIndex = *aSelIt;
- if (anIndex.column() != 0)
- continue;
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- continue;
-
- Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->GetProperties();
- if (anItemProperties)
- anItemProperties->GetPresentations (-1, -1, aPresentations);
-
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
- if (!anAlertItem)
- continue;
- anAlertItem->GetPresentations (aPresentations);
- }
- updatePreviewPresentation (aPresentations);
-}
-
-// =======================================================================
-// function : onTreeViewContextMenuRequested
-// purpose :
-// =======================================================================
-void MessageView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition)
-{
- QMenu* aMenu = new QMenu (GetMainWindow());
-
- MessageModel_ItemRootPtr aRootItem;
- MessageModel_ItemReportPtr aReportItem;
- QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes();
-
- for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- QModelIndex anIndex = *aSelIt;
- if (anIndex.column() != 0)
- continue;
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- continue;
-
- aRootItem = itemDynamicCast<MessageModel_ItemRoot> (anItemBase);
- if (aRootItem)
- break;
- aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
- if (aReportItem)
- break;
- }
- if (aRootItem)
- {
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Import Report"), SLOT (onImportReport()), myMainWindow, this));
- // unite
- //MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsUniteAlerts() ? tr ("SetUniteAlerts - OFF") : tr ("SetUniteAlerts - ON"),
- // SLOT (onUniteAlerts()), myMainWindow, this));
- // reversed
- //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsReversed() ? tr ("SetReversed - OFF") : tr ("SetReversed - ON"),
- // SLOT (onSetReversedAlerts()), myMainWindow, this));
- }
- else if (aReportItem)
- {
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export Report"), SLOT (onExportReport()), myMainWindow, this));
- const TCollection_AsciiString& aDescription = aReportItem->GetDescription();
- if (!aDescription.IsEmpty())
- {
- OSD_Path aPath(aDescription);
- OSD_File aDescriptionFile (aPath);
- if (aDescriptionFile.IsReadable())
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Reload"), SLOT (onReloadReport()), myMainWindow, this));
- }
- }
- aMenu->addSeparator();
- myTreeViewActions->AddMenuActions (aSelectedIndices, aMenu);
-
- QPoint aPoint = myTreeView->mapToGlobal (thePosition);
- aMenu->exec (aPoint);
-}
-
-// =======================================================================
-// function : onPropertyPanelShown
-// purpose :
-// =======================================================================
-void MessageView_Window::onPropertyPanelShown (bool isToggled)
-{
- if (!isToggled)
- return;
-
- updatePropertyPanelBySelection();
-}
-
-// =======================================================================
-// function : onPropertyViewSelectionChanged
-// purpose :
-// =======================================================================
-void MessageView_Window::onPropertyViewSelectionChanged()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
- QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
- QModelIndex anIndex = myTreeView->model()->index (aSelectedIndex.row(), TreeModel_ColumnType_Visibility, aSelectedIndex.parent());
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- return;
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
- if (!anAlertItem)
- return;
-
- QList<ViewControl_Table*> aPropertyTables;
- myPropertyView->GetActiveTables (aPropertyTables);
- if (aPropertyTables.isEmpty())
- return;
-
- ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables
-
- QMap<int, QList<int>> aSelectedIndices;
- aFirstTable->GetSelectedIndices (aSelectedIndices);
-
- // clear presentation if selection is empty
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- TreeModel_VisibilityState* aVisibilityState = aTreeModel->GetVisibilityState();
- if (aSelectedIndices.isEmpty() && aVisibilityState->IsVisible (anIndex))
- {
- aVisibilityState->SetVisible (anIndex, false, true);
- anAlertItem->SetCustomShape (TopoDS_Shape());
- return;
- }
-
- /*TopoDS_Shape aShapeOfSelection = MessageModel_Tools::BuildShape (anAlertItem->GetAlert(), aSelectedIndices[0], aFirstTable);
- if (aShapeOfSelection.IsNull())
- return;
-
- if (aVisibilityState->IsVisible (anIndex))
- {
- View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
-
- Handle(AIS_InteractiveObject) aPresentation = myViewWindow->GetDisplayer()->FindPresentation (anAlertItem->GetCustomShape());
-
- Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (aPresentation);
- aShapePresentation->Set (aShapeOfSelection);
-
- aDisplayer->RedisplayPresentation (aPresentation);
- anAlertItem->SetCustomShape (aShapeOfSelection);
- }
- else
- {
- anAlertItem->SetCustomShape (aShapeOfSelection);
- aVisibilityState->SetVisible (anIndex, true);
- }*/
-}
-
-// =======================================================================
-// function : onEraseAllPerformed
-// purpose :
-// =======================================================================
-void MessageView_Window::onEraseAllPerformed()
-{
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
-
- // TODO: provide update for only visibility state for better performance TopoDS_Shape myCustomShape;
-
- aTreeModel->Reset();
- aTreeModel->EmitLayoutChanged();
-}
-
-// =======================================================================
-// function : onExportReport
-// purpose :
-// =======================================================================
-void MessageView_Window::onExportReport()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- return;
- MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItemBase);
- if (!aReportItem)
- return;
-
- QString aFilter (tr ("Document file (*.xml *)"));
- QString aSelectedFilter;
- QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export report to file"), QString(), aFilter, &aSelectedFilter);
-
- XmlDrivers_MessageReportStorage::ExportReport (aReportItem->GetReport(),
- TCollection_AsciiString (aFileName.toStdString().c_str()));
-}
-
-// =======================================================================
-// function : onImportReport
-// purpose :
-// =======================================================================
-void MessageView_Window::onImportReport()
-{
- QString aFilter (tr ("Document file (*.cbf *)"));
- QString aSelectedFilter;
-
- QString aFileName = QFileDialog::getOpenFileName (0, tr("Import report"), QString(), aSelectedFilter);
- openFile (TCollection_AsciiString (aFileName.toStdString().c_str()));
-}
-
-// =======================================================================
-// function : onImportReport
-// purpose :
-// =======================================================================
-//void MessageView_Window::onUniteAlerts()
-//{
- //MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- //Standard_Boolean isUniteAlerts = aTreeModel->IsUniteAlerts();
-
- //aTreeModel->SetUniteAlerts (!isUniteAlerts);
-//}
-
-// =======================================================================
-// function : onSetReversedAlerts
-// purpose :
-// =======================================================================
-void MessageView_Window::onSetReversedAlerts()
-{
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- Standard_Boolean isReversed = aTreeModel->IsReversed();
-
- aTreeModel->SetReversed (!isReversed);
-}
-
-
-// =======================================================================
-// function : onReloadReport
-// purpose :
-// =======================================================================
-void MessageView_Window::onReloadReport()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- return;
- MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItemBase);
- if (!aReportItem)
- aReportItem = MessageModel_ItemReport::FindReportItem (anItemBase);
-
- if (!aReportItem)
- return;
-
- const TCollection_AsciiString aDescription = aReportItem->GetDescription();
- Handle(Message_Report) aReport = XmlDrivers_MessageReportStorage::ImportReport (aDescription);
- if (aReport.IsNull())
- return;
-
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- aModel->clearSelection();
- aTreeModel->SetReport (aReportItem->Row(), aReport, aDescription);
-}
-
-// =======================================================================
-// function : updatePropertyPanelBySelection
-// purpose :
-// =======================================================================
-void MessageView_Window::updatePropertyPanelBySelection()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
-
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- return;
-
- QList<ViewControl_TableModelValues*> aTableValues;
- MessageModel_Tools::GetPropertyTableValues (anItemBase, aTableValues);
-
- myPropertyView->Init (aTableValues);
-}
-
-// =======================================================================
-// function : updatePreviewPresentation
-// purpose :
-// =======================================================================
-void MessageView_Window::updatePreviewPresentation (const NCollection_List<Handle(Standard_Transient)>& thePresentations)
-{
- Handle(AIS_InteractiveContext) aContext = myViewWindow->GetViewToolBar()->GetCurrentContext();
- if (aContext.IsNull())
- return;
-
- if (!myPreviewPresentations.IsEmpty())
- {
- for (NCollection_List<Handle(Standard_Transient)>::Iterator aDisplayedIt (myPreviewPresentations); aDisplayedIt.More(); aDisplayedIt.Next())
- {
- Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (aDisplayedIt.Value());
- if (!aPrs.IsNull() && aPrs->GetContext() == aContext)
- aContext->Remove (aPrs, Standard_True);
- }
- }
- myPreviewPresentations.Clear();
-
- myPreviewPresentations = thePresentations;
- if (myPreviewPresentations.IsEmpty())
- return;
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- for (NCollection_List<Handle(Standard_Transient)>::Iterator aDisplayedIt (myPreviewPresentations); aDisplayedIt.More(); aDisplayedIt.Next())
- {
- Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (aDisplayedIt.Value());
- if (!aPrs.IsNull())
- {
- if (!aPrs->GetContext().IsNull())
- continue; // not possible to display one object in several contexts
- aContext->Display (aPrs, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
- }
- else if (!Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value()).IsNull())
- {
- Handle(Convert_TransientShape) aShapeObject = Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value());
- aBuilder.Add (aCompound, aShapeObject->GetShape());
- }
- }
-
- if (aCompound.IsNull())
- {
- if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext)
- aContext->Remove (myPreviewPresentation, Standard_True);
- myPreviewPresentation = NULL;
- return;
-
- }
- else
- {
- if (myPreviewPresentation.IsNull())
- {
- myPreviewPresentation = new AIS_Shape (aCompound);
- myPreviewPresentation->SetAttributes (GetPreviewAttributes(aContext));
- //myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
-
- //myPreviewPresentation->SetTransformPersistence(thePersistent);
- if (!aContext.IsNull())
- aContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
- }
- else
- {
- Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
- //myPreviewPresentation->SetTransformPersistence(thePersistent);
- if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext)
- aContext->Redisplay (myPreviewPresentation, Standard_True);
- }
- }
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef MessageView_Window_H
-#define MessageView_Window_H
-
-#include <Message_Report.hxx>
-#include <Standard.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <inspector/MessageModel_Actions.hxx>
-#include <inspector/TInspectorAPI_PluginParameters.hxx>
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <TopoDS_Shape.hxx>
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4127) // conditional expression is constant
-#endif
-#include <QItemSelection>
-#include <QList>
-#include <QModelIndexList>
-#include <QObject>
-#include <QPoint>
-#include <QString>
-#include <QTreeView>
-
-class View_Window;
-
-class ViewControl_PropertyView;
-class MessageModel_ReportCallBack;
-
-class QDockWidget;
-class QMainWindow;
-class QWidget;
-
-//! \class MessageView_Window
-//! Window that unites all MessageView controls.
-class MessageView_Window : public QObject
-{
- Q_OBJECT
-public:
-
- //! Constructor
- Standard_EXPORT MessageView_Window (QWidget* theParent);
-
- //! Destructor
- virtual ~MessageView_Window() {}
-
- //! Provides the container with a parent where this container should be inserted.
- //! If Qt implementation, it should be QWidget with QLayout set inside
- //! \param theParent a parent class
- Standard_EXPORT void SetParent (void* theParent);
-
- //! Sets parameters container, it should be used when the plugin is initialized or in update content
- //! \param theParameters a parameters container
- void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters)
- { myParameters = theParameters; myTreeViewActions->SetParameters (theParameters); }
-
- //! Sets message callback to update the current content of the view
- //! \param theCallBack
- void SetCallBack (const Handle(Message_ReportCallBack)& theCallBack) { myCallBack = theCallBack; }
-
- //! Provide container for actions available in inspector on general level
- //! \param theMenu if Qt implementation, it is QMenu object
- Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
-
- //! Returns plugin preferences: dock widgets state, tree view columns.
- //! \param theItem container of preference elements
- Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
-
- //! Applies plugin preferences
- //! \param theItem container of preference elements
- Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
-
- //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
- Standard_EXPORT void UpdateContent();
-
- //! Returns main control
- QMainWindow* GetMainWindow() const { return myMainWindow; }
-
- //! Returns current tree view
- QTreeView* GetTreeView() const { return myTreeView; }
-
-protected:
- //! Appends shape into tree view model
- //! \param theShape a shape instance
- //! \param theReportDescription an additional report information
- void addReport (const Handle(Message_Report)& theReport,
- const TCollection_AsciiString& theReportDescription = "");
-
-private:
-
- //! Fills controls of the plugin by parameters:
- //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
- //! \param theParameters a parameters container
- void Init (NCollection_List<Handle(Standard_Transient)>& theParameters);
-
- //! Read Shape from the file name, add Shape into tree view
- //! \param theFileName BREP file name
- void openFile (const TCollection_AsciiString& theFileName);
-
- //! Updates tree model
- void updateTreeModel();
-
-protected slots:
- //! Updates property view selection in table if the item is hidden
- //! \param theIndex tree view model index
- void onTreeViewVisibilityClicked(const QModelIndex& theIndex);
-
- //! Udpates all controls by changed selection in OCAF tree view
- //! \param theSelected list of selected tree view items
- //! \param theDeselected list of deselected tree view items
- void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
- //! Shows context menu for tree view selected item. It contains expand/collapse actions.
- //! \param thePosition a clicked point
- void onTreeViewContextMenuRequested (const QPoint& thePosition);
-
- //! Display content of selected tree view item if isToggled is true
- //! \param isToggled true if the property dock widget is shown
- void onPropertyPanelShown (bool isToggled);
-
- //! Update presentation of the selected tree view item using information about selection in property view
- //! \param theSelected container of selected table cells
- //! \param theDeselected container of selected table cells
- void onPropertyViewSelectionChanged();
-
- //! Updates visibility states by erase all in context
- void onEraseAllPerformed();
-
- //! Export report into document
- void onExportReport();
-
- //! Import report into document
- void onImportReport();
-
- //! Unite alerts in view model
- //void onUniteAlerts();
-
- //! Sets report reversed
- void onSetReversedAlerts();
-
- //! Reads if possible report of a selected item and updates this report in tree view
- void onReloadReport();
-
-protected:
- //! Updates property panel content by item selected in tree view.
- void updatePropertyPanelBySelection();
-
- //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes
- //!< \param theShape container of shapes
- void updatePreviewPresentation (const NCollection_List<Handle(Standard_Transient)>& thePresentations);
-
-private:
- QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls
- QDockWidget* myViewDockWidget; //!< view dock widget to hide/show
-
- QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
- ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
-
- View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
- QTreeView* myTreeView; //!< tree view visualized shapes
- MessageModel_Actions* myTreeViewActions; //!< processing history view actions
-
- Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
- Handle(Message_ReportCallBack) myCallBack; //! < message call back to update content of the view
-
- Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
- NCollection_List<Handle(Standard_Transient)> myPreviewPresentations;
-};
-
-#endif
ShapeView.qrc
ShapeView_Communicator.cxx
ShapeView_Communicator.hxx
-ShapeView_ItemBase.cxx
ShapeView_ItemBase.hxx
-ShapeView_ItemPropertiesEdge.cxx
-ShapeView_ItemPropertiesEdge.hxx
-ShapeView_ItemPropertiesFace.cxx
-ShapeView_ItemPropertiesFace.hxx
-ShapeView_ItemPropertiesVertex.cxx
-ShapeView_ItemPropertiesVertex.hxx
ShapeView_ItemRoot.cxx
ShapeView_ItemRoot.hxx
ShapeView_ItemShape.cxx
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ShapeView_ItemBase.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant ShapeView_ItemBase::initValue (const int theItemRole) const
-{
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- switch (Column())
- {
- case 2: { return rowCount(); }
- //case 3: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
- case 4: { return Row(); }
- }
-
- return QVariant();
-}
//! Resets cached values
virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
- //! Return data value for the role.
- //! \param theRole a value role
- //! \return the value
- Standard_EXPORT virtual QVariant initValue(const int theRole) const;
-
protected:
//! Initialize the current item. It creates a backup of the specific item information
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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/ShapeView_ItemPropertiesEdge.hxx>
-#include <inspector/ShapeView_ItemShape.hxx>
-#include <inspector/ShapeView_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Adaptor3d_Curve.hxx>
-#include <AIS_Shape.hxx>
-
-#include <BRepAdaptor_Curve.hxx>
-#include <BRepTools.hxx>
-#include <BRep_Builder.hxx>
-#include <BRep_Tool.hxx>
-
-#include <GCPnts_AbscissaPoint.hxx>
-
-#include <Geom_Curve.hxx>
-#include <GeomAdaptor_Curve.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(ShapeView_ItemPropertiesEdge, TreeModel_ItemProperties)
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int ShapeView_ItemPropertiesEdge::GetTableRowCount() const
-{
- return ShapeView_Tools::GetShapeGlobalPropertiesCount() + 7;
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-#include <BRep_CurveRepresentation.hxx>
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
-#include <BRep_TEdge.hxx>
-
-QVariant ShapeView_ItemPropertiesEdge::GetTableData (const int theRow, const int theColumn, int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- TopoDS_Shape aShape = getItemShape();
-
- if (aShape.ShapeType() != TopAbs_EDGE)
- return QVariant();
-
- TopoDS_Edge anEdge = TopoDS::Edge(aShape);
- double aFirst, aLast;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
-
- GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
- gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
- gp_Pnt aLastPnt = aAdaptor.Value(aLast);
-
- BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
- Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? "Length" : QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d));
- case 1: return isFirstColumn ? "Geom_Curve" : aCurve->DynamicType()->Name();
- case 2: return isFirstColumn ? "FirstPnt" : ViewControl_Tools::ToString (aFirstPnt).ToCString();
- case 3: return isFirstColumn ? "LastPnt" : ViewControl_Tools::ToString (aLastPnt).ToCString();
- case 4: return isFirstColumn ? "Continuity" : ShapeView_Tools::ToName (aCurve->Continuity());
- case 5: return isFirstColumn ? "IsClosed" : ShapeView_Tools::ToString (aCurve->IsClosed());
- case 6: return isFirstColumn ? "IsPeriodic" : aCurve->IsPeriodic() ? QString::number (aCurve->Period())
- : ShapeView_Tools::ToString (aCurve->IsPeriodic());
- default: break;
- }
-
- int anOwnRows = 7;
- /*int aTableRow = theRow - anOwnRows;
- // BRep_Tool::PolygonOnTriangulation // find the representation
-
- TopoDS_Edge E = TopoDS::Edge(aShape);
- Handle(Poly_PolygonOnTriangulation) P;
- Handle(Poly_Triangulation) T;
- TopLoc_Location L;
-
- const BRep_TEdge* TE = static_cast<const BRep_TEdge*>(anEdge.TShape().get());
- BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
-
- int aCurRow = 0;
- while (itcr.More()) {
- const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
- if (cr->IsPolygonOnTriangulation()) {
- if (aCurRow < aTableRow)
- continue;
- const BRep_PolygonOnTriangulation* PT =
- static_cast<const BRep_PolygonOnTriangulation*>(cr.get());
- P = PT->PolygonOnTriangulation();
- T = PT->Triangulation();
- L = E.Location() * PT->Location();
- return isFirstColumn ? QVariant("Polygon: ") : P.;
- }
- itcr.Next();
- }
- L.Identity();
- P.Nullify();
- T.Nullify();
-
-
- anOwnRows += aTableRow;
- */
- return ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow - anOwnRows, theColumn);
-}
-
-// =======================================================================
-// function : getItemShape
-// purpose :
-// =======================================================================
-
-TopoDS_Shape ShapeView_ItemPropertiesEdge::getItemShape() const
-{
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(getItem());
- if (!aShapeItem)
- return TopoDS_Shape();
-
- return aShapeItem->GetItemShape();
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ShapeView_ItemPropertiesEdge_H
-#define ShapeView_ItemPropertiesEdge_H
-
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-DEFINE_STANDARD_HANDLE (ShapeView_ItemPropertiesEdge, TreeModel_ItemProperties)
-
-//! \class ShapeView_ItemPropertiesEdge
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class ShapeView_ItemPropertiesEdge : public TreeModel_ItemProperties
-{
-public:
-
- //! Constructor
- Standard_EXPORT ShapeView_ItemPropertiesEdge (const TreeModel_ItemBasePtr& theItem)
- : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- virtual ~ShapeView_ItemPropertiesEdge() {}
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- DEFINE_STANDARD_RTTIEXT (ShapeView_ItemPropertiesEdge, TreeModel_ItemProperties)
-
-protected:
- //! Returns item shape
- TopoDS_Shape getItemShape() const;
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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/ShapeView_ItemPropertiesFace.hxx>
-#include <inspector/ShapeView_ItemShape.hxx>
-#include <inspector/ShapeView_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(ShapeView_ItemPropertiesFace, TreeModel_ItemProperties)
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int ShapeView_ItemPropertiesFace::GetTableRowCount() const
-{
- return ShapeView_Tools::GetShapeGlobalPropertiesCount();
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant ShapeView_ItemPropertiesFace::GetTableData (const int theRow, const int theColumn, int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- TopoDS_Shape aShape = getItemShape();
-
- QVariant aValue = ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow, theColumn);
-
- return aValue;
-}
-
-// =======================================================================
-// function : getItemShape
-// purpose :
-// =======================================================================
-
-TopoDS_Shape ShapeView_ItemPropertiesFace::getItemShape() const
-{
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(getItem());
- if (!aShapeItem)
- return TopoDS_Shape();
-
- return aShapeItem->GetItemShape();
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ShapeView_ItemPropertiesFace_H
-#define ShapeView_ItemPropertiesFace_H
-
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-DEFINE_STANDARD_HANDLE (ShapeView_ItemPropertiesFace, TreeModel_ItemProperties)
-
-//! \class ShapeView_ItemPropertiesFace
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class ShapeView_ItemPropertiesFace : public TreeModel_ItemProperties
-{
-public:
-
- //! Constructor
- Standard_EXPORT ShapeView_ItemPropertiesFace (const TreeModel_ItemBasePtr& theItem)
- : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- virtual ~ShapeView_ItemPropertiesFace() {}
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- DEFINE_STANDARD_RTTIEXT (ShapeView_ItemPropertiesFace, TreeModel_ItemProperties)
-
-protected:
- //! Returns item shape
- TopoDS_Shape getItemShape() const;
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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/ShapeView_ItemPropertiesVertex.hxx>
-#include <inspector/ShapeView_ItemShape.hxx>
-#include <inspector/ShapeView_Tools.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-#include <BRep_Tool.hxx>
-#include <TopoDS.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(ShapeView_ItemPropertiesVertex, TreeModel_ItemProperties)
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int ShapeView_ItemPropertiesVertex::GetTableRowCount() const
-{
- return ShapeView_Tools::GetShapeGlobalPropertiesCount() + 1;
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant ShapeView_ItemPropertiesVertex::GetTableData (const int theRow, const int theColumn, int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- TopoDS_Shape aShape = getItemShape();
- switch (theRow)
- {
- case 0: return theColumn == 0 ? "Vertex" : ViewControl_Tools::ToString (BRep_Tool::Pnt (TopoDS::Vertex (aShape))).ToCString();
- default: break;
- }
- int anOwnRows = 1;
-
- return ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow - anOwnRows, theColumn);
-}
-
-// =======================================================================
-// function : getItemShape
-// purpose :
-// =======================================================================
-
-TopoDS_Shape ShapeView_ItemPropertiesVertex::getItemShape() const
-{
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(getItem());
- if (!aShapeItem)
- return TopoDS_Shape();
-
- return aShapeItem->GetItemShape();
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ShapeView_ItemPropertiesVertex_H
-#define ShapeView_ItemPropertiesVertex_H
-
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-DEFINE_STANDARD_HANDLE (ShapeView_ItemPropertiesVertex, TreeModel_ItemProperties)
-
-//! \class ShapeView_ItemPropertiesVertex
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class ShapeView_ItemPropertiesVertex : public TreeModel_ItemProperties
-{
-public:
-
- //! Constructor
- Standard_EXPORT ShapeView_ItemPropertiesVertex (const TreeModel_ItemBasePtr& theItem)
- : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- virtual ~ShapeView_ItemPropertiesVertex() {}
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- DEFINE_STANDARD_RTTIEXT (ShapeView_ItemPropertiesVertex, TreeModel_ItemProperties)
-
-protected:
- //! Returns item shape
- TopoDS_Shape getItemShape() const;
-
-};
-
-#endif
#include <inspector/ShapeView_ItemShape.hxx>
-#include <inspector/ShapeView_ItemRoot.hxx>
-#include <inspector/ShapeView_ItemShape.hxx>
-#include <inspector/ShapeView_ItemPropertiesEdge.hxx>
-#include <inspector/ShapeView_ItemPropertiesFace.hxx>
-#include <inspector/ShapeView_ItemPropertiesVertex.hxx>
+#include <Adaptor3d_Curve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
-#include <inspector/ViewControl_Tools.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <Geom_Curve.hxx>
+#include <GeomAdaptor_Curve.hxx>
-#include <TopAbs.hxx>
+#include <inspector/ShapeView_ItemRoot.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
-
-#include <TopExp.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS_Vertex.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QObject>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
-// function : GetShape
+// function : ToString
// purpose :
// =======================================================================
-TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
+QString ToString (const Standard_Boolean& theValue)
+{
+ return theValue ? "1" : "0";
+}
+
+// =======================================================================
+// function : ToString
+// purpose :
+// =======================================================================
+QString ToString (const gp_Pnt& thePoint)
+{
+ return QString ("(%1, %2, %3)").arg (thePoint.X()).arg (thePoint.Y()).arg (thePoint.Z());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ToName (const TopAbs_ShapeEnum& theShapeType)
+{
+ Standard_SStream aSStream;
+ TopAbs::Print (theShapeType, aSStream);
+ return QString (aSStream.str().c_str());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ToName (const TopAbs_Orientation& theOrientation)
+{
+ Standard_SStream aSStream;
+ TopAbs::Print(theOrientation, aSStream);
+ return QString (aSStream.str().c_str());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ToName (const GeomAbs_Shape& theType)
{
- if (myChildShapes.IsEmpty())
+ switch (theType)
{
- ShapeView_ItemShape* aThis = (ShapeView_ItemShape*)this;
+ case GeomAbs_C0: return "GeomAbs_C0";
+ case GeomAbs_G1: return "GeomAbs_G1";
+ case GeomAbs_C1: return "GeomAbs_C1";
+ case GeomAbs_G2: return "GeomAbs_G2";
+ case GeomAbs_C2: return "GeomAbs_C2";
+ case GeomAbs_C3: return "GeomAbs_C3";
+ case GeomAbs_CN: return "GeomAbs_CN";
+ default: break;
+ }
+ return QString();
+}
- if (myExplodeType != TopAbs_SHAPE)
- {
- TopExp::MapShapes(myShape, myExplodeType, aThis->myChildShapes);
- }
- else
+// =======================================================================
+// function : ToOtherInfo
+// purpose :
+// =======================================================================
+void ToOtherInfo (const TopoDS_Shape& theShape, QVariant& theValue, QVariant& theInfo)
+{
+ switch (theShape.ShapeType())
+ {
+ case TopAbs_COMPOUND:
+ case TopAbs_COMPSOLID:
+ case TopAbs_SOLID:
+ case TopAbs_SHELL:
+ case TopAbs_FACE:
+ case TopAbs_WIRE:
+ break;
+ case TopAbs_EDGE:
{
- TopoDS_Iterator aSubShapeIt (myShape);
- for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
+ TopoDS_Edge anEdge = TopoDS::Edge(theShape);
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
+
+ GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
+ gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
+ gp_Pnt aLastPnt = aAdaptor.Value(aLast);
+
+ BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
+ Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
+
+ QStringList aValues, anInfo;
+ aValues.append (QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d)));
+ anInfo.append ("Length");
+
+ aValues.append (aCurve->DynamicType()->Name());
+ anInfo.append ("DynamicType");
+
+ aValues.append (ToString (aFirstPnt));
+ anInfo.append (QString ("First" + QString::number (aFirst)));
+
+ aValues.append (ToString (aLastPnt));
+ anInfo.append (QString ("Last" + QString::number (aLast)));
+
+ aValues.append (ToName (aCurve->Continuity()));
+ anInfo.append ("Continuity");
+
+ aValues.append (ToString (aCurve->IsClosed()));
+ anInfo.append ("IsClosed");
+
+ if (aCurve->IsPeriodic()) {
+ aValues.append (QString::number (aCurve->Period()));
+ anInfo.append ("IsPeriodic");
+ }
+ else
{
- aThis->myChildShapes.Add (aSubShapeIt.Value());
+ aValues.append (ToString (aCurve->IsPeriodic()));
+ anInfo.append ("IsPeriodic");
}
+ theValue = aValues.join (" / ");
+ theInfo = QString ("%1:\n%2").arg (anInfo.join (" / ")).arg (aValues.join ("\n"));
+ break;
}
+ case TopAbs_SHAPE:
+ default:
+ break;
+ }
+}
+
+// =======================================================================
+// function : locationInfo
+// purpose :
+// =======================================================================
+QString locationInfo (const TopLoc_Location& theLocation)
+{
+ QString anInfo;
+
+ gp_Trsf aTrsf = theLocation.Transformation();
+ QStringList aValues, aRowValues;
+ for (int aRowId = 1; aRowId <= 3; aRowId++)
+ {
+ aRowValues.clear();
+ for (int aColumnId = 1; aColumnId <= 4; aColumnId++)
+ aRowValues.append (QString::number (aTrsf.Value(aRowId, aColumnId)));
+ aValues.append (aRowValues.join (","));
}
- if (myChildShapes.Extent() >= theRowId + 1)
- return myChildShapes(theRowId + 1);
+ anInfo.append (aValues.join (" "));
+ return anInfo;
+}
- return TopoDS_Shape();
+// =======================================================================
+// function : GetShape
+// purpose :
+// =======================================================================
+TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
+{
+ TopoDS_Iterator aSubShapeIt (myShape);
+ for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
+ {
+ if (aCurrentIndex != theRowId)
+ continue;
+ break;
+ }
+ return aSubShapeIt.Value();
}
// =======================================================================
// =======================================================================
QVariant ShapeView_ItemShape::initValue(const int theRole) const
{
- QVariant aParentValue = ShapeView_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
TopoDS_Shape aShape = getShape();
if (aShape.IsNull())
return QVariant();
switch (Column())
{
- case 0: return TopAbs::ShapeTypeToString (aShape.ShapeType());
- //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
+ case 0: return ToName (aShape.ShapeType());
+ case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
case 3: return TShapePointer().ToCString();
- case 5: return TopAbs::ShapeOrientationToString (aShape.Orientation());
- case 6: return ViewControl_Tools::ToString (aShape.Location()).ToCString();
+ case 4: return ToName(aShape.Orientation());
+ case 5: return locationInfo(aShape.Location());
+ case 6: return ToString (aShape.Checked());
+ case 7: return ToString (aShape.Closed());
+ case 8: return ToString (aShape.Infinite());
+ case 9: return ToString (aShape.Locked());
+ case 10: return ToString (aShape.Modified());
+ case 11: return ToString (aShape.Orientable());
+ case 12:
+ {
+ if (aShape.ShapeType() != TopAbs_VERTEX)
+ return QVariant();
+ TopoDS_Vertex aVertex = TopoDS::Vertex (aShape);
+ gp_Pnt aPoint = BRep_Tool::Pnt (aVertex);
+ return ToString (aPoint);
+ }
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ {
+ if (aShape.ShapeType() != TopAbs_EDGE)
+ return QVariant();
+
+ TopoDS_Edge anEdge = TopoDS::Edge(aShape);
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
+
+ GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
+ gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
+ gp_Pnt aLastPnt = aAdaptor.Value(aLast);
+
+ BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
+ Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
+
+ switch (Column())
+ {
+ case 13: return QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d));
+ case 14: return aCurve->DynamicType()->Name();
+ case 15: return ToString (aFirstPnt);
+ case 16: return ToString (aLastPnt);
+ case 17: return ToName (aCurve->Continuity());
+ case 18: return ToString (aCurve->IsClosed());
+ case 19: return aCurve->IsPeriodic() ? QString::number (aCurve->Period()) : ToString (aCurve->IsPeriodic());
+ }
+ }
default: break;
}
return QVariant();
return 0;
int aRowsCount = 0;
- if (myExplodeType != TopAbs_SHAPE)
- {
- TopTools_IndexedMapOfShape aSubShapes;
- TopExp::MapShapes(aShape, myExplodeType, aSubShapes);
- aRowsCount = aSubShapes.Extent();
- }
- else
- {
- for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
- aRowsCount++;
- }
+ for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
+ aRowsCount++;
return aRowsCount;
}
ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot> (Parent());
ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape> (Parent());
myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
-
- SetProperties (createItemProperties());
}
// =======================================================================
void ShapeView_ItemShape::Reset()
{
myFileName = QString();
- myChildShapes.Clear();
- myShape = TopoDS_Shape();
ShapeView_ItemBase::Reset();
}
const_cast<ShapeView_ItemShape*>(this)->Init();
}
-// =======================================================================
-// function : createItemProperties
-// purpose :
-// =======================================================================
-Handle(TreeModel_ItemProperties) ShapeView_ItemShape::createItemProperties() const
-{
- if (myShape.IsNull())
- return NULL;
-
- TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
-
- switch (myShape.ShapeType())
- {
- case TopAbs_COMPOUND: break;
- case TopAbs_COMPSOLID: break;
- case TopAbs_SOLID: break;
- case TopAbs_SHELL: break;
- case TopAbs_FACE: return new ShapeView_ItemPropertiesFace (anItem);
- case TopAbs_WIRE: break;
- case TopAbs_EDGE: return new ShapeView_ItemPropertiesEdge (anItem);
- case TopAbs_VERTEX: return new ShapeView_ItemPropertiesVertex (anItem);
- case TopAbs_SHAPE: break;
- default: break;
- }
- return NULL;
-}
#define ShapeView_ItemShape_H
#include <inspector/ShapeView_ItemBase.hxx>
-
-#include <TopTools_IndexedMapOfShape.hxx>
-
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
//! Destructor
virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
- //! Sets explore type
- //! \param theType type of item explode. If TopAbs_SHAPE, no expode, only iteration by shape
- void SetExplodeType (const TopAbs_ShapeEnum theType) { myExplodeType = theType; }
-
- //! Returns expode type of the item
- TopAbs_ShapeEnum GetExplodeType() const { return myExplodeType; }
-
//! Returns the current shape
const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
//! \return the string value
static TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo = true);
- //! Creates container of item properties
- Standard_EXPORT Handle(TreeModel_ItemProperties) createItemProperties() const;
-
private:
//! Constructor
- ShapeView_ItemShape (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : ShapeView_ItemBase (theParent, theRow, theColumn), myExplodeType (TopAbs_SHAPE) {}
+ ShapeView_ItemShape(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : ShapeView_ItemBase(theParent, theRow, theColumn) {}
private:
- TopAbs_ShapeEnum myExplodeType; //!< type of explore own shape and get children
TopoDS_Shape myShape; //!< current shape
QString myFileName; //!< BREP file name
-
- TopTools_IndexedMapOfShape myChildShapes; //! cached container of child shapes
};
#endif
// commercial license or contractual agreement.
#include <inspector/ShapeView_Tools.hxx>
-#include <inspector/ShapeView_ItemShape.hxx>
-
-#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
-#include <BRep_Tool.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Iterator.hxx>
-
-#include <TopExp.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
+#include <BRepTools.hxx>
+#include <AIS_Shape.hxx>
// =======================================================================
// function : ReadShape
// purpose :
BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
return aShape;
}
-
-// =======================================================================
-// function : IsPossibleToExplode
-// purpose :
-// =======================================================================
-Standard_Boolean ShapeView_Tools::IsPossibleToExplode (const TopoDS_Shape& theShape,
- NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes)
-{
- TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
-
- if (!theExplodeTypes.Contains (aShapeType))
- theExplodeTypes.Append(aShapeType);
-
- if (theExplodeTypes.Extent() == TopAbs_SHAPE + 1) // all types are collected, stop
- return Standard_True;
-
- TopoDS_Iterator aSubShapeIt (theShape);
- for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
- {
- if (IsPossibleToExplode (aSubShapeIt.Value(), theExplodeTypes))
- return Standard_True;
- }
- return Standard_False;
-}
-
-// =======================================================================
-// function : GetPropertyTableValues
-// purpose :
-// =======================================================================
-void ShapeView_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
- QList<ViewControl_TableModelValues*>& theTableValues)
-{
- TreeModel_ItemBasePtr anItem = theItem;
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItem);
- if (!aShapeItem)
- return;
-
- Handle(TreeModel_ItemProperties) anItemProperties = aShapeItem->GetProperties();
- if (anItemProperties.IsNull())
- return;
-
- ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues();
- aTableValues->SetProperties (anItemProperties);
- theTableValues.append (aTableValues);
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-QString ShapeView_Tools::ToString (const Standard_Boolean& theValue)
-{
- return theValue ? "1" : "0";
-}
-
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-QString ShapeView_Tools::ToName (const GeomAbs_Shape& theType)
-{
- switch (theType)
- {
- case GeomAbs_C0: return "GeomAbs_C0";
- case GeomAbs_G1: return "GeomAbs_G1";
- case GeomAbs_C1: return "GeomAbs_C1";
- case GeomAbs_G2: return "GeomAbs_G2";
- case GeomAbs_C2: return "GeomAbs_C2";
- case GeomAbs_C3: return "GeomAbs_C3";
- case GeomAbs_CN: return "GeomAbs_CN";
- default: break;
- }
- return QString();
-}
-
-// =======================================================================
-// function : GetShapeGlobalPropertiesCount
-// purpose :
-// =======================================================================
-int ShapeView_Tools::GetShapeGlobalPropertiesCount()
-{
- return 6;
-}
-
-// =======================================================================
-// function : GetShapeGlobalProperties
-// purpose :
-// =======================================================================
-QVariant ShapeView_Tools::GetShapeGlobalProperties (const TopoDS_Shape& theShape,
- const int theRow,
- const int theColumn)
-{
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? "COMMON PROPERTIES" : "";
- case 1: return isFirstColumn ? "Checked" : ToString (theShape.Checked());
- case 2: return isFirstColumn ? "Closed" : ToString (theShape.Closed());
- case 3: return isFirstColumn ? "Infinite" : ToString (theShape.Infinite());
- case 4: return isFirstColumn ? "Locked" : ToString (theShape.Locked());
- case 5: return isFirstColumn ? "Modified" : ToString (theShape.Modified());
- case 6: return isFirstColumn ? "Orientable" : ToString (theShape.Orientable());
- }
- return QVariant();
-}
\ No newline at end of file
#include <Standard.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <NCollection_List.hxx>
#include <TCollection_AsciiString.hxx>
#include <Standard_Transient.hxx>
#include <TopoDS_Shape.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-
-#include <GeomAbs_Shape.hxx>
-#include <Standard_WarningsDisable.hxx>
-#include <QList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
//! \class ShapeView_Tools
//! It gives auxiliary methods for TopoDS_Shape manipulation
class ShapeView_Tools
//! \param theFileName a file name
//! \return shape or NULL
Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
-
- //! Checks whether it is possible to expode the shape. The search is recursive untill all types are collected.
- //! \param theShape source shape object
- //! \param theExplodeTypes container of possible shape types to be exploded
- //! \return true if explode is finished, all types are collected.
- Standard_EXPORT static Standard_Boolean IsPossibleToExplode(const TopoDS_Shape& theShape,
- NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes);
-
- //! Fills container of table values
- //! \param theAlert a message alert
- //! \param theTableValue container of values
- Standard_EXPORT static void GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
- QList<ViewControl_TableModelValues*>& theTableValues);
-
- //! Returns count of gloal properties (6)
- //! \return count value
- Standard_EXPORT static int GetShapeGlobalPropertiesCount();
-
- //! Returns shape global property by row/column
- //! \param theShape investigated shape
- //! \param theRow row index in [0, 6]
- //! \param theColumn column index in [0, 1]
- Standard_EXPORT static QVariant GetShapeGlobalProperties (const TopoDS_Shape& theShape,
- const int theRow,
- const int theColumn);
-
- //! Returns text presentation of boolean value
- Standard_EXPORT static QString ToString (const Standard_Boolean& theValue);
-
- //! Returns shape type name
- Standard_EXPORT static QString ToName (const GeomAbs_Shape& theType);
-
};
#endif
// column 1 is reserved for visiblity state
SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (4, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
- SetHeaderItem (5, TreeModel_HeaderSection ("Orientation", COLUMN_ORIENTATION_WIDTH));
- SetHeaderItem (6, TreeModel_HeaderSection ("Location", COLUMN_LOCATION_WIDTH));
+ SetHeaderItem (4, TreeModel_HeaderSection ("Orientation", COLUMN_ORIENTATION_WIDTH));
+ SetHeaderItem (5, TreeModel_HeaderSection ("Location", COLUMN_LOCATION_WIDTH));
+
+ SetHeaderItem (6, TreeModel_HeaderSection ("Checked", -1, true));
+ SetHeaderItem (7, TreeModel_HeaderSection ("Closed", -1, true));
+ SetHeaderItem (8, TreeModel_HeaderSection ("Infinite", -1, true));
+ SetHeaderItem (9, TreeModel_HeaderSection ("Locked", -1, true));
+ SetHeaderItem (10, TreeModel_HeaderSection ("Modified", -1, true));
+ SetHeaderItem (11, TreeModel_HeaderSection ("Orientable", -1, true));
+
+ SetHeaderItem (12, TreeModel_HeaderSection ("VERTEX: (X, Y, Z)", -1, true));
+
+ SetHeaderItem (13, TreeModel_HeaderSection ("EDGE: Length", -1, true));
+ SetHeaderItem (14, TreeModel_HeaderSection ("DynamicType", -1, true));
+ SetHeaderItem (15, TreeModel_HeaderSection ("First", -1, true));
+ SetHeaderItem (16, TreeModel_HeaderSection ("Last", -1, true));
+ SetHeaderItem (17, TreeModel_HeaderSection ("Continuity", -1, true));
+ SetHeaderItem (18, TreeModel_HeaderSection ("IsClosed", -1, true));
+ SetHeaderItem (19, TreeModel_HeaderSection ("IsPeriodic", -1, true));
}
// =======================================================================
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
-#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/ViewControl_TreeView.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
-#include <ShapeFix_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QApplication>
this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
new TreeModel_ContextMenu (myTreeView);
ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
- for (int i = 5; i <= 6; i++) // hide shape parameters columns
- {
- TreeModel_HeaderSection anItem = aModel->GetHeaderItem (i);
- anItem.SetIsHidden (true);
- aModel->SetHeaderItem (i, anItem);
- }
-
-
myTreeView->setModel (aModel);
ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState (aModel);
aModel->SetVisibilityState (aVisibilityState);
TreeModel_Tools::UseVisibilityColumn (myTreeView);
- QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
- myTreeView->setSelectionModel (aSelModel);
- connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
-
QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
myTreeView->setExpanded (aParentIndex, true);
myMainWindow->setCentralWidget (myTreeView);
- // property view
- //myPaneCreators.Append (new VInspectorPaneAIS_PaneCreator());
-
- myPropertyView = new ViewControl_PropertyView (myMainWindow,
- QSize(SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT));
- myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
- myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
- myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
- myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
- myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
-
// view
- myViewWindow = new View_Window (myMainWindow, NULL, false);
+ myViewWindow = new View_Window (myMainWindow, false);
connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
aVisibilityState->SetDisplayer (myViewWindow->GetDisplayer());
aVisibilityState->SetPresentationType (View_PresentationType_Main);
aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
- myMainWindow->splitDockWidget(myPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
-
myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
}
aMenu->addAction (ViewControl_Tools::CreateAction ("BREP view", SLOT (onBREPView()), myMainWindow, this));
aMenu->addAction (ViewControl_Tools::CreateAction ("Close All BREP views", SLOT (onCloseAllBREPViews()), myMainWindow, this));
aMenu->addAction (ViewControl_Tools::CreateAction ("BREP directory", SLOT (onBREPDirectory()), myMainWindow, this));
- aMenu->addAction (ViewControl_Tools::CreateAction ("ShapeFix_Shape", SLOT (onShapeFixShape()), myMainWindow, this));
-
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
- const TopoDS_Shape& aShape = aShapeItem->GetItemShape();
- TopAbs_ShapeEnum anExplodeType = aShapeItem->GetExplodeType();
- NCollection_List<TopAbs_ShapeEnum> anExplodeTypes;
- ShapeView_Tools::IsPossibleToExplode (aShape, anExplodeTypes);
- if (anExplodeTypes.Size() > 0)
- {
- QMenu* anExplodeMenu = aMenu->addMenu ("Explode");
- for (NCollection_List<TopAbs_ShapeEnum>::Iterator anExpIterator (anExplodeTypes); anExpIterator.More();
- anExpIterator.Next())
- {
- TopAbs_ShapeEnum aType = anExpIterator.Value();
- QAction* anAction = ViewControl_Tools::CreateAction (TopAbs::ShapeTypeToString (aType), SLOT (onExplode()), myMainWindow, this);
- anExplodeMenu->addAction (anAction);
- if (anExplodeType == aType)
- {
- anAction->setCheckable (true);
- anAction->setChecked (true);
- }
- }
- QAction* anAction = ViewControl_Tools::CreateAction ("NONE", SLOT (onExplode()), myMainWindow, this);
- anExplodeMenu->addSeparator();
- anExplodeMenu->addAction (anAction);
- }
}
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec (aPoint);
}
-// =======================================================================
-// function :
-// onTreeViewSelectionChanged
-// purpose :
-// =======================================================================
-void ShapeView_Window::onTreeViewSelectionChanged (const QItemSelection&,
- const QItemSelection&)
-{
- QApplication::setOverrideCursor (Qt::WaitCursor);
-
- if (myPropertyPanelWidget->toggleViewAction()->isChecked())
- updatePropertyPanelBySelection();
-
- QApplication::restoreOverrideCursor();
-}
-
// =======================================================================
// function : onEraseAllPerformed
// purpose :
viewFile (aFileName);
}
-// =======================================================================
-// function : onExplode
-// purpose :
-// =======================================================================
-void ShapeView_Window::onShapeFixShape()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
-
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
- if (!anItemBase)
- return;
-
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
- if (!aShapeItem)
- return;
-
- const TopoDS_Shape aShape = aShapeItem->GetItemShape();
-
- Standard_Real LinTol = Precision::Confusion();
- Standard_Real AngTol = Precision::Angular();
-
- Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape (aShape);
- Fixer->SetPrecision (LinTol);
- Fixer->SetMaxTolerance (LinTol);
- Fixer->Perform();
-
- TopoDS_Shape aFixedShape = Fixer->Shape();
- addShape (aFixedShape);
-}
-
-// =======================================================================
-// function : onExplode
-// purpose :
-// =======================================================================
-void ShapeView_Window::onExplode()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
-
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
- if (!anItemBase)
- return;
-
- ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
- if (!aShapeItem)
- return;
-
- QAction* anAction = (QAction*)sender();
- if (!anAction)
- return;
-
- QApplication::setOverrideCursor (Qt::WaitCursor);
- TopAbs_ShapeEnum aShapeType;
- if (anAction->text() == "NONE")
- aShapeType = TopAbs_SHAPE;
- else
- aShapeType = TopAbs::ShapeTypeFromString(anAction->text().toStdString().c_str());
-
- myViewWindow->GetDisplayer()->EraseAllPresentations();
- aShapeItem->SetExplodeType(aShapeType);
-
- //anItemBase->Parent()->Reset(); - TODO (update only modified sub-tree)
- ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
- aTreeModel->Reset();
- aTreeModel->EmitLayoutChanged();
- QApplication::restoreOverrideCursor();
-}
-
// =======================================================================
// function : onLoadFile
// purpose :
QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
aFileName = QDir().toNativeSeparators (aFileName);
- if (aFileName.isEmpty())
- return;
-
- QApplication::setOverrideCursor (Qt::WaitCursor);
+ if (!aFileName.isEmpty())
onOpenFile(aFileName);
- QApplication::restoreOverrideCursor();
}
// =======================================================================
QApplication::restoreOverrideCursor();
}
-
-// =======================================================================
-// function : updatePropertyPanelBySelection
-// purpose :
-// =======================================================================
-void ShapeView_Window::updatePropertyPanelBySelection()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
-
- QModelIndexList aSelected = TreeModel_ModelBase::GetSelected (aModel->selectedIndexes(), 0);
- QList<ViewControl_TableModelValues*> aTableValues;
-
- if (aSelected.size() == 1)
- {
- TreeModel_ItemBasePtr aSelectedItem = TreeModel_ModelBase::GetItemByIndex(aSelected.first());
- ShapeView_Tools::GetPropertyTableValues (aSelectedItem, aTableValues);
- }
- myPropertyView->Init (aTableValues);
-}
-
// =======================================================================
// function : removeBREPFiles
// purpose :
class View_Window;
-class ViewControl_PropertyView;
-
class QAction;
-class QDockWidget;
class QMainWindow;
class QWidget;
//! \param thePosition a clicked point
void onTreeViewContextMenuRequested (const QPoint& thePosition);
- //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
- //! check box is checked
- //! \param theSelected a selected items
- //! \param theDeselected a deselected items
- void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
//! Updates visibility states by erase all in context
void onEraseAllPerformed();
//! Exports shape to BREP file and view result file
void onBREPDirectory();
- //! Perform shape fix for the selected shape. Result is a new shape in the tree.
- void onShapeFixShape();
-
- //! Set the shape item exploded
- void onExplode();
-
//! Removes all shapes in tree view
void onClearView() { RemoveAllShapes(); }
protected:
- //! Updates property panel content by item selected in tree view.
- void updatePropertyPanelBySelection();
-
//! Views file name content in a text editor. It creates new Qt free control with content.
//! \param theFileName a file name
void viewFile (const QString& theFileName);
QMainWindow* myMainWindow; //!< main control, parent for all ShapeView controls
- QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
- ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
-
View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
QTreeView* myTreeView; //!< tree view visualized shapes
const int TINSPECTOR_DEFAULT_WIDTH = 650;
const int TINSPECTOR_DEFAULT_HEIGHT = 500;//350;
-const int TINSPECTOR_DEFAULT_POSITION_X = 100;//200;
+const int TINSPECTOR_DEFAULT_POSITION_X = 200;
const int TINSPECTOR_DEFAULT_POSITION_Y = 60;
// =======================================================================
#include <inspector/TInspector_Communicator.hxx>
-#include <Message_Report.hxx>
#include <OSD_Environment.hxx>
#include <Standard_WarningsDisable.hxx>
aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep");
else if (theName.IsEqual ("TKVInspector"))
{
- //aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep");
+ aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep");
anAdditionalFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep");
}
aRecentlyOpenedFiles.append (aFileName.ToCString());
if (!strcmp (argv[anArgId], "vinspector"))
aPlugins.insert ("TKVInspector");
-
- if (!strcmp (argv[anArgId], "messageview"))
- aPlugins.insert ("TKMessageView");
}
NCollection_List<Handle(Standard_Transient)> aParameters;
aPlugins.insert("TKShapeView");
aPlugins.insert("TKVInspector");
- Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True);
- aReport->SetLimit (100);//30);
- aReport->SetActive (Standard_True);//Standard_False);
- aPlugins.insert("TKMessageView");
-
- anActivatedPluginName = "TKVInspector";
- //anActivatedPluginName = "TKMessageView";
+ anActivatedPluginName = "TKDFBrowser";
}
else
anActivatedPluginName = *aPlugins.rbegin();
+++ /dev/null
-project(TKMessageModel)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+++ /dev/null
-TKMath
-TKBin
-TKBRep
-TKGeomBase
-TKG3d
-TKTInspectorAPI
-TKService
-TKTopAlgo
-TKTreeModel
-CSF_QT
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-MessageModel
+++ /dev/null
-project(TKMessageView)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+++ /dev/null
-TKTInspectorAPI
-TKMath
-TKMessageModel
-TKBin
-TKBRep
-TKGeomBase
-TKG3d
-TKService
-TKTopAlgo
-TKTreeModel
-TKView
-TKXml
-CSF_QT
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-MessageView
TKG3d
TKernel
TKLCAF
-TKMath
-TKBRep
-TKTopAlgo
-TKPrim
+TKMath
\ No newline at end of file
project(TKTreeModel)
-add_definitions("-D__ViewControl_DLL")
-
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
-TKernel
-TKMath
-TKPrim
-TKTopAlgo
-TKTInspectorAPI
CSF_QT
\ No newline at end of file
-VInspectorPaneAIS
VInspector
\ No newline at end of file
TKService
TKOpenGl
TKV3d
-TKTInspectorAPI
CSF_QT
\ No newline at end of file
static TInspector_Communicator* MyCommunicator;
-// =======================================================================
-// function : GetCommunicator
-// purpose : defines plugin library name by the command argument
-// =======================================================================
-TInspector_Communicator* ToolsDraw::GetCommunicator()
-{
- return MyCommunicator;
-}
-
// =======================================================================
// function : convertToPluginName
// purpose : defines plugin library name by the command argument
if (anArgument == "dfbrowser") { thePluginName = "TKDFBrowser"; return Standard_True; }
else if (anArgument == "shapeview") { thePluginName = "TKShapeView"; return Standard_True; }
else if (anArgument == "vinspector") { thePluginName = "TKVInspector"; return Standard_True; }
- else if (anArgument == "messageview") { thePluginName = "TKMessageView"; return Standard_True; }
return Standard_False;
}
aPlugins.Append ("TKDFBrowser");
aPlugins.Append ("TKShapeView");
aPlugins.Append ("TKVInspector");
- aPlugins.Append ("TKMessageView");
}
aPluginNameToActivate = !aPluginNameToActivate.IsEmpty() ? aPluginNameToActivate : aPlugins.First();
}
"\n\t\t: Starts tool of inspection."
"\n\t\t: Options:"
"\n\t\t: -plugins enters plugins that should be added in the inspector."
- "\n\t\t: Available names are: dfbrowser, vinspector, shapeview and messageview."
+ "\n\t\t: Available names are: dfbrowser, vinspector and shapeview."
"\n\t\t: Plugins order will be the same as defined in arguments."
"\n\t\t: 'all' adds all available plugins in the order:"
"\n\t\t: DFBrowser, VInspector and ShapeView."
#include <Draw_Interpretor.hxx>
#include <Standard.hxx>
-class TInspector_Communicator;
-
//! \class ToolsDraw
//! \brief Registers DRAW commands to connect to TInspector tools
class ToolsDraw
//! \param theCommands
Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
- Standard_EXPORT static TInspector_Communicator* GetCommunicator();
-
private:
};
TreeModel_HeaderSection.hxx
TreeModel_ItemBase.cxx
TreeModel_ItemBase.hxx
-TreeModel_ItemProperties.cxx
-TreeModel_ItemProperties.hxx
-TreeModel_ItemPropertiesCreator.cxx
-TreeModel_ItemPropertiesCreator.hxx
-TreeModel_ItemPropertiesStream.cxx
-TreeModel_ItemPropertiesStream.hxx
TreeModel_ItemRole.hxx
-TreeModel_ItemStream.cxx
-TreeModel_ItemStream.hxx
TreeModel_ModelBase.cxx
TreeModel_ModelBase.hxx
TreeModel_Tools.cxx
//! Destructor
~TreeModel_HeaderSection() {}
- //! Returns whether the header section is not initialized with values.
- //! The check is empty value of the name text
- //! \return boolean value
- bool IsEmpty() const { return myName.isEmpty(); }
-
//! Sets text value
//! \theName text value
void SetName (const QString& theName) { myName = theName; }
// commercial license or contractual agreement.
#include <inspector/TreeModel_ItemBase.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemPropertiesStream.hxx>
+
#include <inspector/TreeModel_ItemRole.hxx>
#include <Standard_WarningsDisable.hxx>
}
// =======================================================================
-// function : SetProperties
-// purpose :
-// =======================================================================
-void TreeModel_ItemBase::SetProperties (const Handle(TreeModel_ItemProperties)& theProperties)
-{
- myProperties = theProperties;
-}
-
-// =======================================================================
-// function : GetProperties
-// purpose :
-// =======================================================================
-Handle(TreeModel_ItemProperties) TreeModel_ItemBase::GetProperties() const
-{
- if (myProperties.IsNull() && Parent())
- {
- TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
- //TreeModel_ItemBase* anItem = (TreeModel_ItemBase*)this;
- anItem->SetProperties (new TreeModel_ItemPropertiesStream (anItem));
- }
-
- if (!myProperties.IsNull() && !myProperties->IsInitialized())
- {
- Handle(TreeModel_ItemPropertiesStream) aPropertiesStream = Handle(TreeModel_ItemPropertiesStream)::DownCast (myProperties);
- if (!aPropertiesStream.IsNull())
- {
- Standard_SStream aStream;
- GetStream (aStream);
- aPropertiesStream->Init (aStream);
- }
- }
-
- return myProperties;
-}
-
-// =======================================================================
-// function : Reset
+// function : reset
// purpose :
// =======================================================================
void TreeModel_ItemBase::Reset()
}
m_bInitialized = false;
myCachedValues.clear();
-
- if (!GetProperties().IsNull())
- GetProperties()->Reset();
}
// =======================================================================
// =======================================================================
void TreeModel_ItemBase::Reset (int theRole)
{
- if (!myCachedValues.contains (theRole))
+ if (!myCachedValues.contains (theRole))
return;
myCachedValues.remove (theRole);
TreeModel_ItemBasePtr anItem;
if (isToCreate) {
- int aRowCount = rowCount();
- Handle(TreeModel_ItemProperties) aProperties = GetProperties();
- int aChildOffset = aProperties.IsNull() ? 0 : aProperties->ChildItemCount();
- if (!aProperties.IsNull() && theRow < aChildOffset)
- anItem = aProperties->CreateChildItem (theRow, theColumn);
- else
- anItem = createChild (theRow - aChildOffset, theColumn);
- //if (aProperties.IsNull() || theRow < aRowCount - aProperties->ChildItemCount())
- // anItem = createChild (theRow, theColumn);
- //else if (!aProperties.IsNull())
- // anItem = aProperties->CreateChildItem (theRow, theColumn);
-
+ anItem = createChild (theRow, theColumn);
if (anItem)
m_ChildItems[aPos] = anItem;
}
if (myCachedValues.contains (theItemRole))
return myCachedValues[theItemRole];
- QVariant aValueToCache;
- if (theItemRole == TreeModel_ItemRole_RowCountRole)
- {
- int aRowCount = initRowCount();
- Handle(TreeModel_ItemProperties) aProperties = GetProperties();
- int aChildOffset = aProperties.IsNull() ? 0 : aProperties->ChildItemCount();
- aValueToCache = aRowCount + aChildOffset;
- }
- else
- aValueToCache = initValue (theItemRole);
+ const_cast<TreeModel_ItemBase*>(this)->myCachedValues.insert (theItemRole,
+ theItemRole == TreeModel_ItemRole_RowCountRole ? QVariant (initRowCount()) : initValue (theItemRole));
- const_cast<TreeModel_ItemBase*>(this)->myCachedValues.insert (theItemRole, aValueToCache);
return myCachedValues.contains (theItemRole) ? myCachedValues[theItemRole] : QVariant();
}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void TreeModel_ItemBase::Init()
-{
- //if (myProperties.IsNull() && Parent())
- //{
- // TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
- // SetProperties (new TreeModel_ItemPropertiesStream (anItem));
- //}
-
- m_bInitialized = true;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant TreeModel_ItemBase::initValue (const int theItemRole) const
-{
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- switch (Column())
- {
- case 1: { return rowCount(); }
- //case 2: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
- case 3: { return Row(); }
- }
-
- return QVariant();
-}
-
-// =======================================================================
-// function : RowCountWithoutProperties
-// purpose :
-// =======================================================================
-int TreeModel_ItemBase::RowCountWithoutProperties (const TreeModel_ItemBasePtr& theItem)
-{
- if (!theItem->GetProperties())
- return theItem->rowCount();
-
- return theItem->rowCount() - theItem->GetProperties()->ChildItemCount();
-}
#include <Standard.hxx>
#include <Standard_Macro.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_OStream.hxx>
-
#include <inspector/TreeModel_ItemRole.hxx>
#include <Standard_WarningsDisable.hxx>
#include <Standard_WarningsRestore.hxx>
class TreeModel_ItemBase;
-class TreeModel_ItemProperties;
typedef QExplicitlySharedDataPointer<TreeModel_ItemBase> TreeModel_ItemBasePtr;
//! Sets the item internal initialized state to the true. If the item has internal values,
//! there should be initialized here.
- Standard_EXPORT virtual void Init();
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { return NULL; }
+ virtual void Init() { m_bInitialized = true; }
//! Resets the item and the child items content. Sets the initialized state to false.
//! If the item has internal values, there should be reseted here.
//! \param theRole an item role
Standard_EXPORT virtual void Reset(int theRole);
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- virtual void GetStream (Standard_OStream& OS) const { (void)OS; }
-
//! Gets the parent of the item, or TreeModel_ItemBasePtr() if it has no parent.
//! \return pointer to the item
TreeModel_ItemBasePtr Parent() const { return m_pParent; };
//! \return the row count
int rowCount() const { return cachedValue(TreeModel_ItemRole_RowCountRole).toInt(); }
- //! Sets item table properties builder
- Standard_EXPORT void SetProperties (const Handle(TreeModel_ItemProperties)& theProperties);
-
- //! Returns item table properties builder
- Standard_EXPORT Handle(TreeModel_ItemProperties) GetProperties() const;
-
- //! Dumps the content of me on the stream <OS>.
- virtual Standard_Boolean Dump (Standard_OStream& OS) const { (void)OS; return Standard_False; }
-
- //! Returns number of item rows only
- static Standard_EXPORT int RowCountWithoutProperties (const TreeModel_ItemBasePtr& theItem);
-
-
protected:
//! \param theParent the parent item
//! \param theColumn the item column positition in the parent item
Standard_EXPORT TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
- //! Initialize the current item. It creates a backup of the specific item information
- virtual void initItem() const {}
-
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! Return data value for the role. It should be reimplemented in child
//! \param theItemRole a value role
//! \return the value
- Standard_EXPORT virtual QVariant initValue (const int theItemRole) const;
+ virtual QVariant initValue (const int theItemRole) const = 0;
private:
int m_iRow; //!< the item row position in the parent item
int m_iColumn; //!< the item column position in the parent item
bool m_bInitialized; //!< the state whether the item content is already initialized
-
- Handle(TreeModel_ItemProperties) myProperties; //!< item properties
};
//! Returns an explicitly shared pointer to the pointer held by other, using a
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient)
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void TreeModel_ItemProperties::Reset()
-{
- m_bInitialized = false;
- myCachedValues.clear();
-
- myCachedDimValues.clear();
- myCachedPresentations.clear();
-}
-
-// =======================================================================
-// function : GetTableFlags
-// purpose :
-// =======================================================================
-
-Qt::ItemFlags TreeModel_ItemProperties::GetTableFlags (const int, const int theColumn) const
-{
- Qt::ItemFlags aFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-
- if (theColumn == 1)
- aFlags = aFlags | Qt::ItemIsEditable;
-
- return aFlags;
-}
-
-// =======================================================================
-// function : cachedValueRowCount
-// purpose :
-// =======================================================================
-
-int TreeModel_ItemProperties::cachedDimValue (const TreeModel_DimType theDimType) const
-{
- if (myCachedDimValues.contains (theDimType))
- return myCachedDimValues[theDimType].toInt();
-
- QVariant aValueToCache;
- switch (theDimType)
- {
- case TreeModel_DimType_Rows: aValueToCache = GetTableRowCount(); break;
- case TreeModel_DimType_Columns: aValueToCache = GetTableColumnCount(); break;
- }
-
- const_cast<TreeModel_ItemProperties*>(this)->myCachedDimValues.insert (theDimType, aValueToCache);
- return myCachedDimValues.contains (theDimType) ? myCachedDimValues[theDimType].toInt() : 0;
-}
-
-// =======================================================================
-// function : cachedValue
-// purpose :
-// =======================================================================
-
-QVariant TreeModel_ItemProperties::cachedValue (const int theRow, const int theColumn, int theRole) const
-{
- QPair<int, int> aPos = qMakePair (theRow, theColumn);
- if (myCachedValues.contains (aPos) && myCachedValues[aPos].contains (theRole))
- return myCachedValues[aPos][theRole];
-
- QVariant aValueToCache = GetTableData (theRow, theColumn, theRole);
-
- QMap<int, QVariant> aValuesToCache;
- if (myCachedValues.contains(aPos))
- aValuesToCache = myCachedValues[aPos];
- aValuesToCache.insert (theRole, aValueToCache);
-
- const_cast<TreeModel_ItemProperties*>(this)->myCachedValues.insert (aPos, aValuesToCache);
- return aValueToCache;
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TreeModel_ItemProperties_H
-#define TreeModel_ItemProperties_H
-
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-
-#include <NCollection_List.hxx>
-
-#include <inspector/TreeModel_ItemBase.hxx>
-#include <inspector/ViewControl_EditType.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-DEFINE_STANDARD_HANDLE (TreeModel_ItemProperties, Standard_Transient)
-
-//! \class TreeModel_ItemProperties
-//! Class to manipulate properties of tree item. The properties are organized in table structure
-class TreeModel_ItemProperties : public Standard_Transient
-{
- //! enum defined the dimension type
- enum TreeModel_DimType
- {
- TreeModel_DimType_Rows, //! defines number of rows
- TreeModel_DimType_Columns //! defines number of columns
- };
-
-public:
- //! Constructor
- TreeModel_ItemProperties (const TreeModel_ItemBasePtr& theItem) : myItem (theItem), m_bInitialized (Standard_False) {}
-
- //! Destructor
- ~TreeModel_ItemProperties() {}
-
- //! Returns number of table rows. It uses cached value of GetTableRowCount(), Reset() to reinit it.
- //! \return an integer value
- int RowCount() const { return cachedDimValue (TreeModel_DimType_Rows); }
-
- //! Returns number of table columns. It uses cached value of GetTableColumnCount(), Reset() to reinit it.
- //! \return an integer value
- int ColumnCount() const { return cachedDimValue (TreeModel_DimType_Columns); }
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It uses cached value of GetTableData(), Reset() to reinit it.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const
- { return cachedValue (theRow, theColumn, theRole); }
-
- //! Gets whether the item is already initialized.The initialized state is thrown down
- //! by the reset method and get back after the method Init().
- //! \return if the item is initialized
- bool IsInitialized() const { return m_bInitialized; }
-
- //! If me has internal values, it should be initialized here.
- virtual void Init() { m_bInitialized = true; }
-
- //! If the item has internal values, there should be reseted here.
- Standard_EXPORT virtual void Reset();
-
- //! Returns number of item children
- //! \return an integer value, ZERO by default
- virtual int ChildItemCount() const { return 0; }
-
- //! 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 CreateChildItem (int theRow, int theColumn) const
- { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
-
- //! Returns number of table columns. Default value is two columns: title to value
- //! \return an integer value
- virtual int GetTableColumnCount() const { return 2; }
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const { return 0; }
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const
- { (void)theRow; (void)theColumn; (void)theRole; return QVariant(); }
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const
- { (void)theRow; (void)theColumn; return ViewControl_EditType_None; }
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const
- { (void)theRow; (void)theColumn; return QList<QVariant>(); }
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue)
- { (void)theRow; (void)theColumn; (void)theValue; return false; }
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \thePresentations [out] container of presentation handles to be visualized
- virtual void GetPresentations (const int theRow, const int theColumn,
- NCollection_List<Handle(Standard_Transient)>& thePresentations)
- { (void)theRow; (void)theColumn; (void)thePresentations; }
-
- //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable.
- //! Additional flag for the column 1 is Qt::ItemIsEditable.
- //! \param theIndex a model index
- //! \return flags
- Standard_EXPORT virtual Qt::ItemFlags GetTableFlags (const int theRow, const int theColumn) const;
-
- DEFINE_STANDARD_RTTIEXT (TreeModel_ItemProperties, Standard_Transient)
-
-protected:
- //! Returns current item
- TreeModel_ItemBasePtr getItem() const { return myItem; }
-
-private:
- //! Returns the cached value for number of rows. Init the value if it is requested the first time.
- //! \param theDimType dimension type
- //! \return the value
- Standard_EXPORT int cachedDimValue (const TreeModel_DimType theDimType) const;
-
- //! Returns the cached value for the role. Init the value if it is requested the first time
- //! By default, it calls initRowCount(TreeModel_ItemRole_RowCountRole) or initValue for the item role
- //! \param theItemRole a value role
- //! \return the value
- Standard_EXPORT QVariant cachedValue (const int theRow, const int theColumn, int theRole) const;
-
-private:
- TreeModel_ItemBasePtr myItem; //! current item
-
- QMap<TreeModel_DimType, QVariant> myCachedDimValues; //!< cached values, should be cleared by reset
- QMap<QPair<int, int>, QMap<int, QVariant> > myCachedValues; //!< cached values, should be cleared by reset
- QMap<QPair<int, int>, NCollection_List<Handle(Standard_Transient)> > myCachedPresentations; //!< cached values, should be cleared by reset
-
- bool m_bInitialized; //!< the state whether the item content is already initialized
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-// Created on: 2019-04-12
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemPropertiesCreator, Standard_Transient)
+++ /dev/null
-// Created on: 2019-04-12
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TreeModel_ItemPropertiesCreator_H
-#define TreeModel_ItemPropertiesCreator_H
-
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-
-class TreeModel_ItemProperties;
-
-DEFINE_STANDARD_HANDLE (TreeModel_ItemPropertiesCreator, Standard_Transient)
-
-//! \class TreeModel_ItemPropertiesCreator
-//! \brief An interface to create custom panes by transient object name.
-class TreeModel_ItemPropertiesCreator : public Standard_Transient
-{
-public:
-
- //! Constructor
- TreeModel_ItemPropertiesCreator() {}
-
- //! Destructor
- virtual ~TreeModel_ItemPropertiesCreator() {}
-
- //! Creates pane for type
- //! \param theName a type name
- //! \return a pane if it can be created for this type or NULL
- virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) = 0;
-
- DEFINE_STANDARD_RTTIEXT (TreeModel_ItemPropertiesCreator, Standard_Transient)
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/TreeModel_ItemPropertiesStream.hxx>
-#include <inspector/TreeModel_ItemStream.hxx>
-
-#include <inspector/Convert_TransientShape.hxx>
-#include <inspector/Convert_Tools.hxx>
-
-#include <Bnd_Box.hxx>
-#include <gp_XYZ.hxx>
-#include <TCollection.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemPropertiesStream, TreeModel_ItemProperties)
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void TreeModel_ItemPropertiesStream::Init (const Standard_SStream& theStream)
-{
- myStream << theStream.str();
-
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aValues;
- TCollection::Split (theStream, aValues, myKey);
-
- TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(getItem());
- if (!aStreamParent)
- myKey = "Dump";
-
- for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++)
- {
- TCollection_AsciiString aValue = aValues.FindFromIndex (anIndex);
- if (TCollection::HasBracketKey (aValue))
- myChildren.Add (aValues.FindKey (anIndex), aValue);
- else
- myValues.Add (aValues.FindKey (anIndex), aValue);
- }
- TreeModel_ItemProperties::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void TreeModel_ItemPropertiesStream::Reset()
-{
- myKey = "";
- myStream.str (std::string());
- myValues.Clear();
- myChildren.Clear();
-
- TreeModel_ItemProperties::Reset();
-}
-
-// =======================================================================
-// function : GetChildKey
-// purpose :
-// =======================================================================
-TCollection_AsciiString TreeModel_ItemPropertiesStream::GetChildKey (const Standard_Integer theRow) const
-{
- return GetChildrenValues().FindKey (theRow + 1).ToCString();
-}
-
-// =======================================================================
-// function : GetChildStream
-// purpose :
-// =======================================================================
-
-void TreeModel_ItemPropertiesStream::GetChildStream (const Standard_Integer theRow, Standard_OStream& OS) const
-{
- TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(getItem());
- if (!aStreamParent)
- OS << myStream.str();
- else
- OS << GetChildrenValues().FindFromIndex (theRow + 1);
-}
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int TreeModel_ItemPropertiesStream::GetTableRowCount() const
-{
- const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& aValues = GetValues();
- return aValues.Size();
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant TreeModel_ItemPropertiesStream::GetTableData (const int theRow, const int theColumn, int theRole) const
-{
- const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& aValues = GetValues();
-
- if (theRole == Qt::DisplayRole || theRole == Qt::ToolTipRole)
- {
- if (theColumn == 0) return aValues.FindKey (theRow + 1).ToCString();
- else if (theColumn == 1) return aValues.FindFromIndex (theRow + 1).ToCString();
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType TreeModel_ItemPropertiesStream::GetTableEditType (const int /*theRow*/, const int) const
-{
- //switch (theRow)
- //{
- // case 0: return ViewControl_EditType_Spin;
- // default: return ViewControl_EditType_None;
- //}
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool TreeModel_ItemPropertiesStream::SetTableData (const int /*theRow*/, const int /*theColumn*/, const QVariant& /*theValue*/)
-{
- //Handle(Message_Report) aReport = getItemReport();
- //switch (theRow)
- //{
- // case 0: aReport->SetLimit (theValue.toInt()); break;
- // default: break;
- //}
- return true;
-}
-
-// =======================================================================
-// function : GetPresentations
-// purpose :
-// =======================================================================
-
-void TreeModel_ItemPropertiesStream::GetPresentations (const int theRow, const int theColumn,
- NCollection_List<Handle(Standard_Transient)>& thePresentations)
-{
- if (theColumn == 0)
- return;
-
- if (theRow < 0) // full presentation
- {
- Bnd_Box aBox;
- if (aBox.Init (myStream))
- thePresentations.Append (new Convert_TransientShape (Convert_Tools::CreateShape (aBox)));
- }
-
-
- //QVariant aValue = GetTableData (theRow, theColumn, Qt::DisplayRole);
- //TCollection_AsciiString aStrValue = aValue.toString().toStdString().c_str();
-
- //gp_XYZ aPoint;
- //if (!aPoint.Init (Standard_SStream (aStrValue.ToCString())))
- // return;
-
- //thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint)));
-}
-
-// =======================================================================
-// function : ChildItemCount
-// purpose :
-// =======================================================================
-int TreeModel_ItemPropertiesStream::ChildItemCount() const
-{
- TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(getItem());
- if (!aStreamParent && (GetChildrenValues().Size() || GetValues().Size()))
- return 1; // "Dump" item
-
- return GetChildrenValues().Size();
-}
-
-// =======================================================================
-// function : CreateChildItem
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr TreeModel_ItemPropertiesStream::CreateChildItem (int theRow, int theColumn) const
-{
- return TreeModel_ItemStream::CreateItem (getItem(), theRow, theColumn);
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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 MessageModel_ItemReportProperties_H
-#define MessageModel_ItemReportProperties_H
-
-#include <Standard.hxx>
-#include <Message_AttributeStream.hxx>
-#include <NCollection_IndexedDataMap.hxx>
-#include <TCollection_AsciiString.hxx>
-
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-DEFINE_STANDARD_HANDLE (TreeModel_ItemPropertiesStream, TreeModel_ItemProperties)
-
-//! \class TreeModel_ItemPropertiesStream
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class TreeModel_ItemPropertiesStream : public TreeModel_ItemProperties
-{
-public:
-
- //! Constructor
- Standard_EXPORT TreeModel_ItemPropertiesStream (TreeModel_ItemBasePtr theItem)
- : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- virtual ~TreeModel_ItemPropertiesStream() {}
-
- //! Returns Key of the current stream
- const TCollection_AsciiString& GetKey() const { return myKey; }
-
- //! Returns Key of the current stream
- Standard_EXPORT TCollection_AsciiString GetChildKey (const Standard_Integer theRow) const;
-
- //! Returns sub stream inside the current stream
- Standard_EXPORT void GetChildStream (const Standard_Integer theRow, Standard_OStream& OS) const;
-
- //! If me has internal values, it should be initialized here.
- Standard_EXPORT virtual void Init (const Standard_SStream& theStream);
-
- //! If the item has internal values, there should be reseted here.
- Standard_EXPORT virtual void Reset();
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- Standard_EXPORT virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- Standard_EXPORT virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \thePresentations [out] container of presentation handles to be visualized
- Standard_EXPORT virtual void GetPresentations (const int theRow, const int theColumn,
- NCollection_List<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE;
-
- //! Returns number of item children
- //! \return an integer value, ZERO by default
- Standard_EXPORT virtual int ChildItemCount() 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
- Standard_EXPORT virtual TreeModel_ItemBasePtr CreateChildItem (int theRow, int theColumn) const;
-
- DEFINE_STANDARD_RTTIEXT (TreeModel_ItemPropertiesStream, TreeModel_ItemProperties)
-
-protected:
- //! Returns attribute with stream value
- const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& GetChildrenValues() const
- {
- return myChildren;
- }
-
- //! Returns attribute with stream value
- const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& GetValues() const
- {
- return myValues;
- }
-
-protected:
- TCollection_AsciiString myKey;
- Standard_SStream myStream;
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> myValues;
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> myChildren;
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/TreeModel_ItemStream.hxx>
-
-#include <inspector/TreeModel_ItemPropertiesStream.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant TreeModel_ItemStream::initValue (const int theItemRole) const
-{
- QVariant aParentValue = TreeModel_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (Column() != 0)
- return QVariant();
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- TreeModel_ItemBasePtr aParentItem = Parent();
- if (!aParentItem)
- return QVariant();
-
- TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(aParentItem);
- if (!aStreamParent)
- return "Dump";
-
- Handle(TreeModel_ItemPropertiesStream) aStreamProperties = Handle(TreeModel_ItemPropertiesStream)::DownCast (aParentItem->GetProperties());
- if (aStreamProperties.IsNull())
- return QVariant();
-
- return aStreamProperties->GetChildKey (Row()).ToCString();
-}
-
-// =======================================================================
-// function : GetStream
-// purpose :
-// =======================================================================
-void TreeModel_ItemStream::GetStream (Standard_OStream& OS) const
-{
- TreeModel_ItemBasePtr aParentItem = Parent();
- if (!aParentItem)
- return;
-
- Handle(TreeModel_ItemPropertiesStream) aStreamProperties = Handle(TreeModel_ItemPropertiesStream)::DownCast (aParentItem->GetProperties());
- if (aStreamProperties.IsNull())
- return;
-
- aStreamProperties->GetChildStream (Row(), OS);
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr TreeModel_ItemStream::createChild (int, int)
-{
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-02-25
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TreeModel_ItemStream_H
-#define TreeModel_ItemStream_H
-
-#include <Standard.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-class TreeModel_ItemStream;
-typedef QExplicitlySharedDataPointer<TreeModel_ItemStream> TreeModel_ItemStreamPtr;
-
-//! \class TreeModel_ItemStream
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class TreeModel_ItemStream : public TreeModel_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static TreeModel_ItemStreamPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return TreeModel_ItemStreamPtr (new TreeModel_ItemStream (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~TreeModel_ItemStream() Standard_OVERRIDE {};
-
- //! Returns number of displayed presentations
- //! \return rows count
- 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;
-
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE {}
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- TreeModel_ItemStream(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : TreeModel_ItemBase(theParent, theRow, theColumn) {}
-};
-
-#endif
#include <inspector/TreeModel_ModelBase.hxx>
#include <inspector/TreeModel_ItemBase.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/TreeModel_VisibilityState.hxx>
-#include <Standard_Transient.hxx>
-
#include <Standard_WarningsDisable.hxx>
#include <QIcon>
#include <Standard_WarningsRestore.hxx>
: QAbstractItemModel (theParent), m_pRootItem (0), m_pUseVisibilityColumn (false),
myVisibilityState (0)
{
- myVisibleIcon = QIcon (":/icons/item_visible.png");
- myInvisibleIcon = QIcon (":/icons/item_invisible.png");
}
// =======================================================================
if (!myVisibilityState || !myVisibilityState->CanBeVisible (theIndex))
return QVariant();
- QVariant aValue = myVisibilityState->IsVisible (theIndex) ? myVisibleIcon : myInvisibleIcon;
+ QVariant aValue = QIcon (myVisibilityState->IsVisible (theIndex) ? ":/icons/item_visible.png"
+ : ":/icons/item_invisible.png");
anItem->SetCustomData (aValue, theRole);
return aValue;
}
TreeModel_ItemBasePtr anItem = GetItemByIndex (theIndex);
- QVariant anItemData = anItem->data (theIndex, theRole);
-
- if (anItemData.isNull() && theRole == Qt::BackgroundRole && myHighlightedIndices.contains (theIndex))
- anItemData = TreeModel_Tools::LightHighlightColor();
-
- return anItemData;
+ return anItem->data (theIndex, theRole);
}
// =======================================================================
else
aParentItem = GetItemByIndex (theParent);
- if (!aParentItem)
- return 0;
- if (!aParentItem->IsInitialized())
- {
- TreeModel_ItemProperties* aProperties = 0;
- if (!myPropertiesCreators.IsEmpty())
- {
- for (NCollection_List<Handle(TreeModel_ItemPropertiesCreator)>::Iterator anIterator (myPropertiesCreators); anIterator.More(); anIterator.Next())
- {
- Handle(TreeModel_ItemPropertiesCreator) aCreator = anIterator.Value();
- aProperties = aCreator->GetProperties (aParentItem);
- if (aProperties)
- break;
- }
- // TODO: dump properties should be united with properties created by the creator
- aParentItem->SetProperties (aProperties);
- }
- }
-
return aParentItem ? aParentItem->rowCount() : 0;
}
#endif
}
-// =======================================================================
-// function : SetPropertiesCreator
-// purpose :
-// =======================================================================
-void TreeModel_ModelBase::AddPropertiesCreator (const Handle(TreeModel_ItemPropertiesCreator)& theCreator)
-{
- if (myPropertiesCreators.Contains (theCreator))
- return;
- myPropertiesCreators.Append (theCreator);
-}
-
-// =======================================================================
-// function : GetProperties
-// purpose :
-// =======================================================================
-const NCollection_List<Handle(TreeModel_ItemPropertiesCreator)>& TreeModel_ModelBase::GetPropertiesCreators() const
-{
- return myPropertiesCreators;
-}
-
-// =======================================================================
-// function : GetSelected
-// purpose :
-// =======================================================================
-QModelIndexList TreeModel_ModelBase::GetSelected (const QModelIndexList& theIndices, const int theCellId,
- const Qt::Orientation theOrientation)
-{
- QModelIndexList aSelected;
- for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
- {
- QModelIndex anIndex = *anIndicesIt;
- if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
- (theOrientation == Qt::Vertical && anIndex.row() == theCellId))
- aSelected.append (anIndex);
- }
- return aSelected;
-}
-
// =======================================================================
// function : SingleSelected
// purpose :
QModelIndex TreeModel_ModelBase::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
const Qt::Orientation theOrientation)
{
- QModelIndexList aSelected = GetSelected (theIndices, theCellId, theOrientation);
- return aSelected.size() == 1 ? aSelected.first() : QModelIndex();
-}
-
-// =======================================================================
-// function : GetSelectedItems
-// purpose :
-// =======================================================================
-QList<TreeModel_ItemBasePtr> TreeModel_ModelBase::GetSelectedItems (const QModelIndexList& theIndices)
-{
- QList<TreeModel_ItemBasePtr> anItems;
-
+ QModelIndexList aFirstColumnSelectedIndices;
for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
{
- TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
- if (!anItem || anItems.contains (anItem))
- continue;
- anItems.append (anItem);
+ QModelIndex anIndex = *anIndicesIt;
+ if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
+ (theOrientation == Qt::Vertical && anIndex.row() == theCellId))
+ aFirstColumnSelectedIndices.append (anIndex);
}
- return anItems;
+ return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
}
// =======================================================================
#include <inspector/TreeModel_ItemBase.hxx>
#include <inspector/TreeModel_HeaderSection.hxx>
-#include <NCollection_List.hxx>
-
#include <Standard_WarningsDisable.hxx>
#include <QAbstractItemModel>
#include <QExplicitlySharedDataPointer>
#include <QVector>
#include <Standard_WarningsRestore.hxx>
-class TreeModel_ItemPropertiesCreator;
class TreeModel_VisibilityState;
//! \class TreeModel_ModelBase
//!< \return the checker interface
TreeModel_VisibilityState* GetVisibilityState () const { return myVisibilityState; }
- //! Returns true if the tree view model contains highlighted items. This highlight is set manually.
- bool HasHighlighted() { return !myHighlightedIndices.isEmpty(); }
-
- //! Sets items of the indices highlighted in the model.
- //! \param theIndices a list of tree model indices
- void SetHighlighted (const QModelIndexList& theIndices = QModelIndexList()) { myHighlightedIndices = theIndices; }
-
//! Returns the index of the item in the model specified by the given row, column and parent index.
//! Saves an internal pointer at the createIndex. This pointer is a shared pointer to the class,
//! that realizes a base item interface. If the parent is invalid, a root item is used, otherwise a new item
virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return myHeaderValues.size(); }
- //! Sets item table properties builder
- Standard_EXPORT void AddPropertiesCreator (const Handle(TreeModel_ItemPropertiesCreator)& theCreator);
-
- //! Returns item table properties builder
- Standard_EXPORT const NCollection_List<Handle(TreeModel_ItemPropertiesCreator)>& GetPropertiesCreators() const;
-
//! Returns default value of the visibility column
//! \return integer value
static int ColumnVisibilityWidth() { return 20; }
- //! Returns selected items in the cell of given orientation.
- //! \param theIndices a container of selected indices
- //! \param theCellId column index if orientation is horizontal, row index otherwise
- //! \param theOrientation an orientation to apply the cell index
- //! \return model indices from the list
- Standard_EXPORT static QModelIndexList GetSelected (const QModelIndexList& theIndices, const int theCellId,
- const Qt::Orientation theOrientation = Qt::Horizontal);
-
//! Returns single selected item in the cell of given orientation. If the orientation is Horizontal,
//! in the cell id colum, one row should be selected.
//! \param theIndices a container of selected indices
Standard_EXPORT static QModelIndex SingleSelected (const QModelIndexList& theIndices, const int theCellId,
const Qt::Orientation theOrientation = Qt::Horizontal);
-
- //! Returns selected tree model items for indices.
- //! \param theIndices a container of selected indices
- //! \return model items from the list
- Standard_EXPORT static QList<TreeModel_ItemBasePtr> GetSelectedItems (const QModelIndexList& theIndices);
-
protected:
//! Creates root item
//! \param theColumnId index of a column
bool m_pUseVisibilityColumn; //!< the state whether column=0 is reserved for Visibility state
TreeModel_VisibilityState* myVisibilityState; //!< the interface of item visibility
- QIcon myVisibleIcon; //!< icon of visible state
- QIcon myInvisibleIcon; //!< icon of invisible state
-
- QModelIndexList myHighlightedIndices; //!< tree model indices that should be visualized as highlighted
-
- NCollection_List<Handle(TreeModel_ItemPropertiesCreator)> myPropertiesCreators; //!< property pane creators for items
};
#endif
return aLength < theText.length() ? theText.mid (0, aLength) + theTail : theText;
}
-
-// =======================================================================
-// function : LightHighlightColor
-// purpose :
-// =======================================================================
-QColor TreeModel_Tools::LightHighlightColor()
-{
- QWidget aWidget;
- QPalette aPalette = aWidget.palette();
- return aPalette.highlight().color().lighter();
-}
-
-// =======================================================================
-// function : SetExpandedTo
-// purpose :
-// =======================================================================
-void TreeModel_Tools::SetExpandedTo (QTreeView* theTreeView, const QModelIndex& theIndex)
-{
- QAbstractItemModel* aModel = theTreeView->model();
-
- QModelIndex aParent = aModel->parent (theIndex);
- while (aParent.isValid())
- {
- theTreeView->setExpanded (aParent, true);
- aParent = aModel->parent (aParent);
- }
-}
-
-// =======================================================================
-// function : setExpanded
-// purpose :
-// =======================================================================
-void TreeModel_Tools::SetExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
- int& theLevels)
-{
- bool isToExpand = theLevels == -1 || theLevels > 0;
- if (!isToExpand)
- return;
-
- theTreeView->setExpanded (theIndex, isExpanded);
- if (theLevels != -1)
- theLevels--;
-
- QAbstractItemModel* aModel = theTreeView->model();
- for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
- {
- int aLevels = theLevels;
- SetExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
- }
-}
#include <Standard_WarningsDisable.hxx>
#include <QApplication>
#include <QByteArray>
-#include <QColor>
#include <QMap>
#include <QString>
#include <QStyle>
//! \param theWidth width value, if -1, default value is used
//! \param theTail symbols added to the end of the cut string
Standard_EXPORT static QString CutString (const QString& theText, const int theWidth = -1, const QString& theTail = "...");
-
- //! Returns light highlight color
- //! \returns Qt color
- Standard_EXPORT static QColor LightHighlightColor();
-
- //! Makes the view expanded fron the root till the index
- Standard_EXPORT static void SetExpandedTo (QTreeView* theTreeView, const QModelIndex& theIndex);
-
- //! Recursive items expanding in tree view staring from the index
- //! \param theTreeView an OCAF tree view
- //! \param theParentIndex an index which children should be expanded
- //! \param isExpanded a boolean state if the item should be expanded or collapsed
- //! \param theLevels a number of levels to be expanded, or -1 for all levels
- Standard_EXPORT static void SetExpanded (QTreeView* theTreeView,
- const QModelIndex& theIndex,
- const bool isExpanded,
- int& theLevels);
-
};
#endif
VInspector_CallBackMode.hxx
VInspector_Communicator.cxx
VInspector_Communicator.hxx
-VInspector_ItemAspectWindow.cxx
-VInspector_ItemAspectWindow.hxx
VInspector_ItemBase.cxx
VInspector_ItemBase.hxx
-VInspector_ItemBVHTree.cxx
-VInspector_ItemBVHTree.hxx
-VInspector_ItemBVHTreeNode.cxx
-VInspector_ItemBVHTreeNode.hxx
-VInspector_ItemContainer.cxx
-VInspector_ItemContainer.hxx
-VInspector_ItemContainerAPI.hxx
VInspector_ItemContext.cxx
VInspector_ItemContext.hxx
VInspector_ItemFolderObject.cxx
VInspector_ItemFolderObject.hxx
-VInspector_ItemGraphic3dCamera.cxx
-VInspector_ItemGraphic3dCamera.hxx
-VInspector_ItemGraphic3dClipPlane.cxx
-VInspector_ItemGraphic3dClipPlane.hxx
-VInspector_ItemGraphic3dCStructure.cxx
-VInspector_ItemGraphic3dCStructure.hxx
-VInspector_ItemGraphic3dCView.cxx
-VInspector_ItemGraphic3dCView.hxx
-VInspector_ItemGraphic3dGroup.cxx
-VInspector_ItemGraphic3dGroup.hxx
-VInspector_ItemGraphic3dTransformPers.cxx
-VInspector_ItemGraphic3dTransformPers.hxx
+VInspector_ItemEntityOwner.cxx
+VInspector_ItemEntityOwner.hxx
VInspector_ItemHistoryElement.cxx
VInspector_ItemHistoryElement.hxx
VInspector_ItemHistoryRoot.cxx
VInspector_ItemHistoryType.cxx
VInspector_ItemHistoryType.hxx
VInspector_ItemHistoryTypeInfo.hxx
-VInspector_ItemOpenGlContext.cxx
-VInspector_ItemOpenGlContext.hxx
-VInspector_ItemOpenGlLayer.cxx
-VInspector_ItemOpenGlLayer.hxx
-VInspector_ItemOpenGlLayerList.cxx
-VInspector_ItemOpenGlLayerList.hxx
-VInspector_ItemOpenGlWindow.cxx
-VInspector_ItemOpenGlWindow.hxx
VInspector_ItemPresentableObject.cxx
VInspector_ItemPresentableObject.hxx
-VInspector_ItemPresentations.cxx
-VInspector_ItemPresentations.hxx
-VInspector_ItemPrs3dAspect.cxx
-VInspector_ItemPrs3dAspect.hxx
-VInspector_ItemPrs3dDrawer.cxx
-VInspector_ItemPrs3dDrawer.hxx
-VInspector_ItemPrs3dPresentation.cxx
-VInspector_ItemPrs3dPresentation.hxx
-VInspector_ItemSelect3DSensitiveSetItem.hxx
-VInspector_ItemSelect3DSensitiveSetItem.cxx
-VInspector_ItemSelectBasicsEntityOwner.cxx
-VInspector_ItemSelectBasicsEntityOwner.hxx
-VInspector_ItemSelectBasicsSensitiveEntity.cxx
-VInspector_ItemSelectBasicsSensitiveEntity.hxx
-VInspector_ItemSelectMgrViewerSelector.cxx
-VInspector_ItemSelectMgrViewerSelector.hxx
-VInspector_ItemSelectMgrViewerSelectorPicked.cxx
-VInspector_ItemSelectMgrViewerSelectorPicked.hxx
-VInspector_ItemSelectMgrBaseFrustum.cxx
-VInspector_ItemSelectMgrBaseFrustum.hxx
+VInspector_ItemSelection.cxx
+VInspector_ItemSelection.hxx
VInspector_ItemSelectMgrFilter.cxx
VInspector_ItemSelectMgrFilter.hxx
-VInspector_ItemSelectMgrSelectableObjectSet.cxx
-VInspector_ItemSelectMgrSelectableObjectSet.hxx
-VInspector_ItemSelectMgrSelectingVolumeManager.cxx
-VInspector_ItemSelectMgrSelectingVolumeManager.hxx
-VInspector_ItemSelectMgrSelection.cxx
-VInspector_ItemSelectMgrSelection.hxx
-VInspector_ItemSelectMgrSensitiveEntity.cxx
-VInspector_ItemSelectMgrSensitiveEntity.hxx
-VInspector_ItemSelectMgrSensitiveEntitySet.cxx
-VInspector_ItemSelectMgrSensitiveEntitySet.hxx
-VInspector_ItemV3dView.cxx
-VInspector_ItemV3dView.hxx
-VInspector_ItemV3dViewer.cxx
-VInspector_ItemV3dViewer.hxx
-VInspector_PropertiesCreator.cxx
-VInspector_PropertiesCreator.hxx
+VInspector_ItemSensitiveEntity.cxx
+VInspector_ItemSensitiveEntity.hxx
VInspector_SelectionType.hxx
-VInspector_TableModelValues.cxx
-VInspector_TableModelValues.hxx
VInspector_ToolActionType.hxx
VInspector_ToolBar.cxx
VInspector_ToolBar.hxx
// =======================================================================
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 ("");
- }
+ QList<QVariant> anInfo = VInspector_Tools::GetInfo (thePrs);
anInfo[0] = QString ("%1: %2").arg (anInfo[0].toString()).arg (theMode);
myHistoryModel->AddElement (VInspector_CallBackMode_Activate, anInfo);
}
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues;
aValues.append (""); // Name
aValues.append (""); // Pointer
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs)
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs);
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues);
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner)
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues;
aValues.append (""); // Name
aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer
// =======================================================================
void VInspector_CallBack::ClearSelected()
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues;
myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues);
}
// =======================================================================
void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/)
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetHighlightInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues);
// =======================================================================
void VInspector_CallBack::Select()
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetSelectedInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues);
// =======================================================================
void VInspector_CallBack::ShiftSelect()
{
- if (!myHistoryModel)
- return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetSelectedInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues);
//! 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)); }
+ { 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)); }
+ { 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)); }
+ { 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)); }
+ { myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about modes activation
//! \param thePrs the presentation
//! Appends information about modes deactivation
//! \param thePrs the presentation
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+ { 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)); }
+ { (void)theMode; myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about selection change
//! \param theShape the selected shape
//! Appends information about selection clear
//! \param thePrs the selected presentation
virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
+ { myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about moving to point
//! \param theXPix a pixels on horizontal
//! Appends information about setting selection
//! \param thePrs the selected presentation
virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
+ { myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about select
Standard_EXPORT virtual void Select() Standard_OVERRIDE;
+++ /dev/null
-// Created on: 2018-12-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/VInspector_ItemAspectWindow.hxx>
-
-#include <Select3D_SensitiveSet.hxx>
-#include <Aspect_Window.hxx>
-#include <inspector/VInspector_ItemV3dView.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <V3d_View.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemAspectWindow::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Aspect_Window) aWindow = GetAspectWindow();
- if (aWindow.IsNull())
- return Column() == 0 ? "Empty Aspect_Window" : "";
-
- switch (Column())
- {
- case 0: return theItemRole == Qt::DisplayRole ? aWindow->DynamicType()->Name()
- : STANDARD_TYPE (Aspect_Window)->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemAspectWindow::Init()
-{
- VInspector_ItemV3dViewPtr aParentItem = itemDynamicCast<VInspector_ItemV3dView>(Parent());
- if (aParentItem)
- myWindow = aParentItem->GetView()->Window();
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemAspectWindow::Reset()
-{
- myWindow = NULL;
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemAspectWindow::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemAspectWindow*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemAspectWindow::GetTableRowCount() const
-{
- return 30;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemAspectWindow::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(Aspect_Window) aWindow = GetAspectWindow();
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Background") : QVariant ();
- case 1: return isFirstColumn ? QVariant ("BackgroundFillMethod") : QVariant ();
- case 2: return isFirstColumn ? QVariant ("GradientBackground") : QVariant ();
- case 3: return isFirstColumn ? QVariant ("IsMapped") : QVariant (aWindow->IsMapped());
- case 4: return isFirstColumn ? QVariant ("IsVirtual") : QVariant (aWindow->IsVirtual());
- case 5: return isFirstColumn ? QVariant ("Ratio") : QVariant (aWindow->Ratio());
- case 6:
- {
- if (isFirstColumn)
- return QVariant ("Position");
- Standard_Integer aX1, aY1, aX2, aY2;
- aWindow->Position (aX1, aY1, aX2, aY2);
- return QString ("X1 = %1, Y1 = %2, X2 = %3, Y2 = %4").arg (aX1).arg (aY1).arg (aX2).arg (aY2);
- }
- case 7:
- {
- if (isFirstColumn)
- return QVariant ("Size");
- Standard_Integer aWidth, aHeight;
- aWindow->Size (aWidth, aHeight);
- return QString ("width = %1, height = %2").arg (aWidth).arg (aHeight);
- }
- case 8: return isFirstColumn ? QVariant ("NativeHandle") : QVariant ();
- case 9: return isFirstColumn ? QVariant ("NativeParentHandle") : QVariant ();
- case 10: return isFirstColumn ? QVariant ("NativeFBConfig") : QVariant ();
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemAspectWindow::buildPresentationShape()
-{
- return TopoDS_Shape();
-}
+++ /dev/null
-// Created on: 2018-12-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemAspectWindow_H
-#define VInspector_ItemAspectWindow_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <Aspect_Window.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class QItemSelectionModel;
-class VInspector_ItemAspectWindow;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemAspectWindow> VInspector_ItemAspectWindowPtr;
-
-//! \class VInspector_ItemAspectWindow
-//! The item shows information about SelectBasics_EntityOwner.
-//! The parent is item selection, children are item entity owners
-class VInspector_ItemAspectWindow : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemAspectWindowPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemAspectWindowPtr (new VInspector_ItemAspectWindow (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemAspectWindow() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myWindow; }
-
- //! \return the current sensitive entity
- Standard_EXPORT Handle(Aspect_Window) GetAspectWindow() const
- { return Handle(Aspect_Window)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE { return 0; }
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
- { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
-
- //! Returns table value for the row in form: <function name> <function value> depending on the aspect kind
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theEntityKind kind or kind of entity
- QVariant getTableData (const int theRow,
- const int theColumn,
- const int theRole,
- const TCollection_AsciiString& theEntityKind) const;
-
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemAspectWindow(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
- Handle(Aspect_Window) myWindow; //!< aspect window
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-04-29
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemBVHTree.hxx>
-
-#include <inspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx>
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx>
-#include <inspector/VInspector_ItemBVHTreeNode.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_PropertiesStream.hxx>
-
-#include <inspector/Convert_Tools.hxx>
-
-#include <Bnd_Box.hxx>
-#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-VInspector_ItemBVHTree::VInspector_ItemBVHTree (TreeModel_ItemBasePtr theParent,
- const int theRow, const int theColumn)
-: VInspector_ItemBase(theParent, theRow, theColumn)
-{
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemBVHTree::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- opencascade::handle<BVH_Tree<Standard_Real, 3> > aTree = GetTree();
- if (aTree.IsNull())
- return 0;
-
- return aTree->Length();
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemBVHTree::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- if (GetTree().IsNull())
- return Column() == 0 ? "Empty BVH tree" : "";
-
- switch (Column())
- {
- case 0:
- {
- TCollection_AsciiString aName = TCollection_AsciiString (GetTree()->DynamicType()->Name()) +
- TCollection_AsciiString (" (") + myName.ToCString() + ")";
- return aName.ToCString();
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemBVHTree::Init()
-{
- VInspector_ItemSelectMgrSelectableObjectSetPtr anObjectParent = itemDynamicCast<VInspector_ItemSelectMgrSelectableObjectSet>(Parent());
- opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree;
- if (anObjectParent)
- {
- aBVHTree = anObjectParent->GetBVHTree (Row(), myName);
- }
- else
- {
- VInspector_ItemSelectMgrSensitiveEntitySetPtr anEntityParent = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntitySet>(Parent());
- if (anEntityParent)
- aBVHTree = anEntityParent->GetBVHTree (Row(), myName);
- }
-
- setTree (aBVHTree);
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemBVHTree::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setTree (NULL);
- myName = TCollection_AsciiString();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemBVHTree::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemBVHTree*>(this)->Init();
-}
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) const
-{
- opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
- if (aBVHTree.IsNull())
- return Standard_False;
-
- aBVHTree->Dump (OS);
- return Standard_True;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemBVHTree::buildPresentationShape()
-{
- return TopoDS_Shape();
- /*opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = myTree;
- if (aBVHTree.IsNull())
- return TopoDS_Shape();
-
- Standard_SStream OS;
- //aBVHTree->DumpNode (Row(), OS);
- aBVHTree->Dump (OS);
-
- Standard_Integer aColumnCount;
- NCollection_Vector<TCollection_AsciiString> aValues;
- Message::ConvertStream (OS, aColumnCount, aValues);
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- for (int aValueId = 0; aValueId < aValues.Size(); )
- {
- for (int aColumnId = 0; aColumnId < aColumnCount; aColumnId++, aValueId++)
- {
- if (aColumnId != 1)
- continue;
-
- TCollection_AsciiString aValue = aValues.Value (aValueId);
- Bnd_Box aBox;
- if (!aBox.Init (Standard_SStream (aValue.ToCString())))
- continue;
-
- TopoDS_Shape aShape = Convert_Tools::CreateShape (aBox);
- aBuilder.Add (aCompound, aShape);
- }
- }
- return aCompound;*/
-}
+++ /dev/null
-// Created on: 2019-04-29
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemBVHTree_H
-#define VInspector_ItemBVHTree_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <BVH_Tree.hxx>
-#include <Standard_OStream.hxx>
-
-class VInspector_ItemBVHTree;
-typedef QExplicitlySharedDataPointer<VInspector_ItemBVHTree> VInspector_ItemBVHTreePtr;
-
-//! \class VInspector_ItemBVHTree
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemBVHTree : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemBVHTreePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemBVHTreePtr (new VInspector_ItemBVHTree (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemBVHTree() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myTree; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const
- { return opencascade::handle<BVH_Tree<Standard_Real, 3> >::DownCast (GetObject()); }
-
- //! Dumps the content of me on the stream <OS>.
- virtual Standard_Boolean Dump (Standard_OStream& OS) const;
-
-protected:
- //! Initialize 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;
-
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() 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:
-
- //! Set V3d viewer selector into the current field
- //! \param theTree a viewer selector
- void setTree (const opencascade::handle<BVH_Tree<Standard_Real, 3> >& theTree) { myTree = theTree; }
-
-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_ItemBVHTree(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
-
-private:
-
- opencascade::handle<BVH_Tree<Standard_Real, 3> > myTree; //!< the current tree
- TCollection_AsciiString myName; //!< the name
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-04-29
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemBVHTreeNode.hxx>
-
-#include <inspector/VInspector_ItemBVHTree.hxx>
-//#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
-//
-#include <inspector/VInspector_Tools.hxx>
-
-#include <inspector/Convert_Tools.hxx>
-
-#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemBVHTreeNode::initRowCount() const
-{
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemBVHTreeNode::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- switch (Column())
- {
- case 0: return QString ("TreeNode_%1").arg (Row()); break;
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemBVHTreeNode::Init()
-{
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemBVHTreeNode::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : GetTree
-// purpose :
-// =======================================================================
-
-opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemBVHTreeNode::GetTree() const
-{
- VInspector_ItemBVHTreePtr anObjectParent = itemDynamicCast<VInspector_ItemBVHTree>(Parent());
-
- return anObjectParent->GetTree();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemBVHTreeNode::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemBVHTreeNode*>(this)->Init();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemBVHTreeNode::createChild (int, int)
-{
- return TreeModel_ItemBasePtr();
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemBVHTreeNode::buildPresentationShape()
-{
- opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
- if (aBVHTree.IsNull())
- return TopoDS_Shape();
-
- Standard_SStream OS;
- aBVHTree->DumpNode (Row(), OS);
-
- Standard_Integer aColumnCount;
- NCollection_Vector<TCollection_AsciiString> aValues;
- Message::ConvertStream (OS, aColumnCount, aValues);
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- for (int aValueId = 0; aValueId < aValues.Size(); )
- {
- for (int aColumnId = 0; aColumnId < aColumnCount; aColumnId++, aValueId++)
- {
- if (aColumnId != 1)
- continue;
-
- TCollection_AsciiString aValue = aValues.Value (aValueId);
- Bnd_Box aBox;
- if (!aBox.Init (Standard_SStream (aValue.ToCString())))
- continue;
-
- TopoDS_Shape aShape = Convert_Tools::CreateShape (aBox);
- aBuilder.Add (aCompound, aShape);
- }
- }
- return aCompound;
-}
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemBVHTreeNode::Dump (Standard_OStream& OS) const
-{
- opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
- if (aBVHTree.IsNull())
- return Standard_False;
-
- aBVHTree->DumpNode (Row(), OS);
- return Standard_True;
-}
+++ /dev/null
-// Created on: 2019-04-29
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemBVHTreeNode_H
-#define VInspector_ItemBVHTreeNode_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-//#include <TopoDS_Shape.hxx>
-//#include <SelectMgr_SelectingVolumeManager.hxx>
-
-class SelectMgr_BaseFrustum;
-
-class VInspector_ItemBVHTreeNode;
-typedef QExplicitlySharedDataPointer<VInspector_ItemBVHTreeNode> VInspector_ItemBVHTreeNodePtr;
-
-//! \class VInspector_ItemBVHTreeNode
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemBVHTreeNode : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemBVHTreeNodePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemBVHTreeNodePtr (new VInspector_ItemBVHTreeNode (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemBVHTreeNode() 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 Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
-
- //! Returns parent tree, the node information is obtained from the tree by the given index
- Standard_EXPORT opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const;
-
- //! Dumps the content of me on the stream <OS>.
- virtual Standard_Boolean Dump (Standard_OStream& OS) const;
-
-protected:
- //! Initialize 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;
-
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() 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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemBVHTreeNode(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-};
-
-#endif
#include <inspector/VInspector_ItemBase.hxx>
#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemBase::Reset()
-{
- myPresentationShape = TopoDS_Shape();
- TreeModel_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemBase::initValue (const int theItemRole) const
-{
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- switch (Column())
- {
- case 1: { return rowCount(); }
- case 2: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
- case 3: { return Row(); }
- }
-
- return QVariant();
-}
-
// =======================================================================
// function : GetContext
// purpose :
return myContext;
}
-
-// =======================================================================
-// function : GetContext
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemBase::GetPresentationShape() const
-{
- if (Column() != TreeModel_ColumnType_Name)
- return TopoDS_Shape();
-
- initItem();
- return myPresentationShape;
-}
#include <AIS_InteractiveContext.hxx>
#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ItemBase.hxx>
-#include <inspector/ViewControl_EditType.hxx>
-
-class Graphic3d_TransformPers;
class VInspector_ItemBase;
typedef QExplicitlySharedDataPointer<VInspector_ItemBase> VInspector_ItemBasePtr;
{
public:
//! Resets cached values
- virtual void Reset() Standard_OVERRIDE;
+ virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
//! Sets the context
//! \param theLabel an object where the child items structure is found
//! \return a context
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \thePresentations [out] container of presentation handles to be visualized
- virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
- { (void)thePresentations; }
-
- //! Returns transform persistent of the item or NULL
- Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
-
- //! Returns shape of the item parameters
- //! \return generated shape of the item parameters
- Standard_EXPORT virtual TopoDS_Shape GetPresentationShape() const;
-
- //! Rebuild presentation shape if the item use it
- //! \return generated shape of the item parameters
- void UpdatePresentationShape() { myPresentationShape = buildPresentationShape(); }
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const { return 0; }
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const
- { (void)theRow; (void)theColumn; return ViewControl_EditType_None; }
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const
- { (void)theRow; (void)theColumn; return QList<QVariant>(); }
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const
- { (void)theRow; (void)theColumn; (void)theRole; return QVariant(); }
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue)
- { (void)theRow; (void)theColumn; (void)theValue; return false; }
-
protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() { return TopoDS_Shape(); }
+ //! Initialize the current item. It creates a backup of the specific item information
+ virtual void initItem() const {}
protected:
protected:
Handle(AIS_InteractiveContext) myContext; //!< the current context
- TopoDS_Shape myPresentationShape; //!< item presentation shape
- Handle(Graphic3d_TransformPers) myTransformPersistence; //!< item cached persistent
};
#endif
\ No newline at end of file
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemContainer.hxx>
-
-#include <inspector/VInspector_ItemContainerAPI.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemContainer::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
- return QVariant();
-
- VInspector_ItemContainerAPI* aContainerItem = dynamic_cast<VInspector_ItemContainerAPI*>(Parent().data());
-
- if (!aContainerItem)
- return "Empty item container";
-
- return aContainerItem->GetContainerValue (Row(), theItemRole);
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemContainer::initRowCount() const
-{
- VInspector_ItemContainerAPI* aContainerItem = dynamic_cast<VInspector_ItemContainerAPI*>(Parent().data());
-
- if (!aContainerItem)
- return 0;
-
- return aContainerItem->GetContainerRowCount (Row());
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemContainer::createChild (int theRow, int theColumn)
-{
- VInspector_ItemContainerAPI* aContainerItem = dynamic_cast<VInspector_ItemContainerAPI*>(Parent().data());
-
- if (!aContainerItem)
- return TreeModel_ItemBasePtr();
-
- return aContainerItem->CreateContainerChild (currentItem(), Row(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemContainer::Init()
-{
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemContainer::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemContainer::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemContainer*> (this)->Init();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemContainer_H
-#define VInspector_ItemContainer_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <AIS_InteractiveObject.hxx>
-#include <NCollection_List.hxx>
-#include <TCollection_AsciiString.hxx>
-
-class Prs3d_Drawer;
-
-class QItemSelectionModel;
-
-class VInspector_ItemContainer;
-typedef QExplicitlySharedDataPointer<VInspector_ItemContainer> VInspector_ItemContainerPtr;
-
-//! \class VInspector_ItemContainer
-//! Item presents additional level of information in the tree model.
-//! Parent is item context, children are either folder item or Selection filter item.
-class VInspector_ItemContainer : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemContainerPtr CreateItem (TreeModel_ItemBasePtr theParent,
- const int theRow, const int theColumn)
- { return VInspector_ItemContainerPtr (new VInspector_ItemContainer (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemContainer() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { return NULL; }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemContainer (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase (theParent, theRow, theColumn) {}
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemContainerAPI_H
-#define VInspector_ItemContainerAPI_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-//! \class VInspector_ItemContainerAPI
-class VInspector_ItemContainerAPI
-{
-
-public:
- //! Constructor
- VInspector_ItemContainerAPI () {}
-
- //! Destructor
- virtual ~VInspector_ItemContainerAPI() {};
-
- //! Returns number of item selected
- //! \return rows count
- virtual int GetContainerRowCount (const int theContainerRow) const = 0;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant GetContainerValue (const int theContainerRow, const int theItemRole) const = 0;
-
- //! 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 CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) = 0;
-
-};
-
-#endif
#include <inspector/VInspector_ItemContext.hxx>
-#include <AIS.hxx>
#include <AIS_ListOfInteractive.hxx>
-#include <SelectMgr.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#ifdef DEBUG_FREE_OWNERS
int aRows = 0;
// only local context is processed: TODO for global context
- NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
aContext->MainSelector()->ActiveOwners(anActiveOwners);
Handle(SelectMgr_EntityOwner) anOwner;
- for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(anActiveOwners);
- anOwnersIt.More(); anOwnersIt.Next())
+ for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt(anActiveOwners); anOwnersIt.More(); anOwnersIt.Next())
{
- anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+ anOwner = anOwnersIt.Value();
if (anOwner.IsNull())
continue;
Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
aRows++;
}
// owners in Global Context
- NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
aContext->MainSelector()->ActiveOwners(anActiveOwners);
if (aRows > 0)
aNbPresentations += aRows;
- NCollection_List<Handle(SelectBasics_EntityOwner)> anEmptySelectableOwners;
- NCollection_List<Handle(SelectBasics_EntityOwner)> anOwners =
+ NCollection_List<Handle(SelectMgr_EntityOwner)> anEmptySelectableOwners;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> anOwners =
VInspector_Tools::ActiveOwners (aContext, anEmptySelectableOwners);
if (anEmptySelectableOwners.Size() > 0)
aNbPresentations += 1;
// =======================================================================
QVariant VInspector_ItemContext::initValue (const int theItemRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return GetContext()->DynamicType()->Name();
+ case 1: return rowCount();
case 4:
{
Handle(AIS_InteractiveObject) anEmptyIO;
return QVariant();
}
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemContext::GetTableRowCount() const
-{
- return 11;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemContext::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- case 0: return ViewControl_EditType_Spin;
- case 1: return ViewControl_EditType_Combo;
- case 2: return ViewControl_EditType_Bool;
- case 3: return ViewControl_EditType_Bool;
- case 4: return ViewControl_EditType_Bool;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemContext::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 1:
- {
- for (int i = 0; i <= SelectMgr_PickingStrategy_OnlyTopmost; i++)
- aValues.append (SelectMgr::PickingStrategyToString ((SelectMgr_PickingStrategy)i));
- }
- break;
- default: break;
- }
-
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemContext::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("PixelTolerance") : QVariant (myContext->PixelTolerance());
- case 1: return isFirstColumn ? QVariant ("PickingStrategy") : QVariant (SelectMgr::PickingStrategyToString (myContext->PickingStrategy()));
- case 2: return isFirstColumn ? QVariant ("AutomaticHilight") : QVariant (myContext->AutomaticHilight());
- case 3: return isFirstColumn ? QVariant ("ToHilightSelected") : QVariant (myContext->ToHilightSelected());
- case 4: return isFirstColumn ? QVariant ("AutoActivateSelection") : QVariant (myContext->GetAutoActivateSelection());
- case 5:
- case 6:
- case 7:
- {
- AIS_DisplayStatus aDisplayStatus = (AIS_DisplayStatus)(theRow - 5);
- if (isFirstColumn)
- return QString ("ObjectsByDisplayStatus: %1").arg (AIS::DisplayStatusToString (aDisplayStatus));
- AIS_ListOfInteractive anObjects;
- myContext->ObjectsByDisplayStatus(aDisplayStatus, anObjects);
- return QVariant (anObjects.Extent());
- }
- break;
- case 8: return isFirstColumn ? QVariant ("DetectedOwner") : QVariant (VInspector_Tools::GetPointerInfo (myContext->DetectedOwner()).ToCString());
- case 9:
- {
- if (isFirstColumn)
- return QVariant ("DetectedOwners");
- int aNbOfDetected = 0;
- for (myContext->InitDetected(); myContext->MoreDetected(); myContext->NextDetected())
- aNbOfDetected++;
- return aNbOfDetected;
- }
- case 10: return isFirstColumn ? QVariant ("NbSelected") : QVariant (myContext->NbSelected());
- default: return QVariant();
- }
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemContext::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- switch (theRow)
- {
- case 0: myContext->SetPixelTolerance (theValue.toInt()); break;
- case 1: myContext->SetPickingStrategy (SelectMgr::PickingStrategyFromString (theValue.toString().toStdString().c_str())); break;
- case 2: myContext->SetAutomaticHilight (theValue.toBool()); break;
- case 3: myContext->SetToHilightSelected (theValue.toBool()); break;
- case 4: myContext->SetAutoActivateSelection (theValue.toBool()); break;
- default: return false;
- }
- return true;
-}
-
// =======================================================================
// function : createChild
// purpose :
//! Destructor
virtual ~VInspector_ItemContext() Standard_OVERRIDE {};
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myContext; }
-
//! Returns number of displayed presentations
//! \return rows count
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
//! \return the value
Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
protected:
//! Initialize the current item. It creates a backup of the specific item information
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/VInspector_ItemEntityOwner.hxx>
+#include <inspector/VInspector_ItemSensitiveEntity.hxx>
+#include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <inspector/VInspector_Tools.hxx>
+
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <Select3D_SensitiveEntity.hxx>
+#include <Standard_Version.hxx>
+#include <StdSelect_BRepOwner.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QItemSelectionModel>
+#include <QColor>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemEntityOwner::initValue(int theItemRole) const
+{
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = getEntityOwner();
+ if (anOwner.IsNull())
+ return QVariant();
+
+ switch (Column())
+ {
+ case 0: return anOwner->DynamicType()->Name();
+ case 2: return VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
+ case 3:
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (BROwnr.IsNull())
+ return QVariant();
+
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (aShape.IsNull())
+ return QVariant();
+
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ case 17:
+ case 18:
+ case 19:
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (BROwnr.IsNull())
+ return QVariant();
+
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (aShape.IsNull())
+ return QVariant();
+
+ return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
+ : Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
+ : /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
+ }
+ default: break;
+ }
+ break;
+ }
+ case Qt::BackgroundRole:
+ case Qt::ForegroundRole:
+ {
+ if (Column() == 2)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (!aContext.IsNull())
+ {
+ if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
+ return (theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white);
+ }
+ }
+ VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
+ if (aParentItem)
+ return aParentItem->data(QModelIndex(), theItemRole);
+ break;
+ }
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemEntityOwner::Init()
+{
+ Handle(SelectMgr_EntityOwner) anOwner;
+
+ VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
+ if (aParentItem)
+ {
+ Handle(SelectMgr_SensitiveEntity) anEntity = aParentItem->GetSensitiveEntity();
+ anOwner = anEntity->BaseSensitive()->OwnerId();
+ }
+ else
+ {
+ VInspector_ItemPresentableObjectPtr aPOItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
+ if (aPOItem)
+ {
+ Handle(AIS_InteractiveObject) anIO = aPOItem->GetInteractiveObject();
+
+ int aRowId = Row();
+ int aCurrentIndex = 0;
+#if OCC_VERSION_HEX < 0x070201
+ for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
+ {
+ const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
+ for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
+ {
+ Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
+#else
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next())
+ {
+ Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
+#endif
+ const Handle(Select3D_SensitiveEntity)& aBase = anEntity->BaseSensitive();
+ if (!aBase.IsNull())
+ {
+ if (aRowId == aCurrentIndex)
+ anOwner = aBase->OwnerId();
+ aCurrentIndex++;
+ }
+ }
+ }
+ }
+ }
+ myOwner = anOwner;
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemEntityOwner::Reset()
+{
+ VInspector_ItemBase::Reset();
+ SetContext (NULL);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemEntityOwner::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemEntityOwner*>(this)->Init();
+}
+
+// =======================================================================
+// function : getEntityOwner
+// purpose :
+// =======================================================================
+Handle(SelectMgr_EntityOwner) VInspector_ItemEntityOwner::getEntityOwner() const
+{
+ initItem();
+ return myOwner;
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemEntityOwner_H
+#define VInspector_ItemEntityOwner_H
+
+#include <AIS_InteractiveObject.hxx>
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+class QItemSelectionModel;
+
+class VInspector_ItemEntityOwner;
+typedef QExplicitlySharedDataPointer<VInspector_ItemEntityOwner> VInspector_ItemEntityOwnerPtr;
+
+//! \class VInspector_ItemPresentableObject
+//! Item for selection entity owner. The parent is sensitive entity item, there are no children
+class VInspector_ItemEntityOwner : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemEntityOwnerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemEntityOwnerPtr (new VInspector_ItemEntityOwner (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemEntityOwner() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns the current entity owner
+ Handle(SelectMgr_EntityOwner) EntityOwner() const { return myOwner; }
+
+protected:
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE{ return 0; }
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
+ { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemEntityOwner(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ //! Returns the current entity owner. Initializes the item if it was not initialized yet
+ Handle(SelectMgr_EntityOwner) getEntityOwner() const;
+
+private:
+
+ Handle(SelectMgr_EntityOwner) myOwner; //!< the current entity owner
+};
+
+#endif
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemGraphic3dTransformPers.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemPrs3dDrawer.hxx>
#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
-#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
-#include <inspector/VInspector_ItemV3dViewer.hxx>
-
-#include <AIS_InteractiveObject.hxx>
-#include <Prs3d.hxx>
// =======================================================================
// function : initValue
// =======================================================================
QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
- return QVariant();
-
- ParentKind aParentKind = GetParentItemKind();
- switch (aParentKind)
+ if (Column() == 0 && (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole))
{
- case ParentKind_ContextItem: return "Properties";
- case ParentKind_PresentationItem: return "Properties";
- case ParentKind_FolderItem: return Row() == 0 ? "Filters" : QVariant();
- default: return QVariant();
+ if (parentItemIsContext()) return "Properties";
+ else if (Row() == 0) return "Filters";
+ else return QVariant();
}
+ return QVariant();
}
// =======================================================================
// =======================================================================
int VInspector_ItemFolderObject::initRowCount() const
{
- ParentKind aParentKind = GetParentItemKind();
- switch (aParentKind)
- {
- case ParentKind_ContextItem:
- {
- int aNbChildren = 3; // Filters, Viewer, MainSelector
- aNbChildren++; // DefaultDrawer
- for (int aTypeId = 0; aTypeId < Prs3d_TypeOfHighlight_NB; aTypeId++)
- {
- const Handle(Prs3d_Drawer)& aStyle = GetContext()->HighlightStyle ((Prs3d_TypeOfHighlight)aTypeId);
- if (!aStyle.IsNull())
- aNbChildren++;
- }
- return aNbChildren;
- }
- case ParentKind_PresentationItem:
- {
- return 4; // TransformPers, Attributes, HilightAttributes and DynamicHilightAttributes
- }
- case ParentKind_FolderItem:
- return (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
- default:
- return 0;
- }
+ return parentItemIsContext() ? 1 : (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
}
// =======================================================================
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int theColumn)
{
- ParentKind aParentKind = GetParentItemKind();
- switch (aParentKind)
- {
- case ParentKind_ContextItem:
- {
- if (theRow == 0)
- return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 1)
- return VInspector_ItemV3dViewer::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 2)
- return VInspector_ItemSelectMgrViewerSelector::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemPrs3dDrawer::CreateItem (currentItem(), theRow, theColumn);
- }
- case ParentKind_PresentationItem:
- {
- if (theRow == 0)
- return VInspector_ItemGraphic3dTransformPers::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemPrs3dDrawer::CreateItem (currentItem(), theRow, theColumn);
- }
- case ParentKind_FolderItem:
- return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
- default: return TreeModel_ItemBasePtr();
- }
+ if (parentItemIsContext())
+ return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
+ else
+ return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
}
// =======================================================================
VInspector_ItemBase::Reset();
}
-// =======================================================================
-// function : GetPrs3dDrawer
-// purpose :
-// =======================================================================
-Handle(Prs3d_Drawer) VInspector_ItemFolderObject::GetPrs3dDrawer (const int theRow,
- TCollection_AsciiString& theName) const
-{
- ParentKind aParentKind = GetParentItemKind();
- switch (aParentKind)
- {
- case ParentKind_ContextItem:
- {
- if (theRow == 0 || theRow == 1 || theRow == 2) // "Filters", "Viewer", "Viewer Selector"
- return 0;
-
- if (theRow == 3)
- {
- theName = "DefaultDrawer";
- return GetContext()->DefaultDrawer();
- }
-
- for (int aTypeId = 0, aCurId = 0; aTypeId < Prs3d_TypeOfHighlight_NB; aTypeId++)
- {
- Prs3d_TypeOfHighlight aType = (Prs3d_TypeOfHighlight)aTypeId;
- const Handle(Prs3d_Drawer)& aDrawer = GetContext()->HighlightStyle (aType);
- if (aDrawer.IsNull())
- continue;
- if (aCurId == theRow - 4)
- {
- theName = TCollection_AsciiString ("HighlightStyle: ") + Prs3d::TypeOfHighlightToString (aType);
- return aDrawer;
- }
- aCurId++;
- }
- }
- case ParentKind_PresentationItem:
- {
- VInspector_ItemPresentableObjectPtr aParentPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- Handle(AIS_InteractiveObject) aPrs = aParentPrsItem->GetInteractiveObject();
- switch (theRow)
- {
- case 0: return 0; // "TransformPers"
- case 1: theName = "Attributes"; return aPrs->Attributes();
- case 2: theName = "HilightAttributes"; return aPrs->HilightAttributes();
- case 3: theName = "DynamicHilightAttributes"; return aPrs->DynamicHilightAttributes();
- default: break;
- }
- }
- case ParentKind_FolderItem:
- default: break;
- }
-
- theName = "None";
- return Handle(Prs3d_Drawer)();
-}
-
// =======================================================================
// function : initItem
// purpose :
}
// =======================================================================
-// function : GetParentItemKind
+// function : parentItemIsContext
// purpose :
// =======================================================================
-VInspector_ItemFolderObject::ParentKind VInspector_ItemFolderObject::GetParentItemKind() const
+bool VInspector_ItemFolderObject::parentItemIsContext() const
{
- VInspector_ItemPresentableObjectPtr aParentPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- if (aParentPrsItem)
- return ParentKind_PresentationItem;
-
- VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(Parent());
- if (aParentContextItem)
- return ParentKind_ContextItem;
-
- return ParentKind_FolderItem;
+ return itemDynamicCast<VInspector_ItemContext> (Parent());
}
#include <inspector/VInspector_ItemBase.hxx>
#include <AIS_InteractiveObject.hxx>
+#include <NCollection_List.hxx>
#include <TCollection_AsciiString.hxx>
-class Prs3d_Drawer;
-
class QItemSelectionModel;
class VInspector_ItemFolderObject;
//! Destructor
virtual ~VInspector_ItemFolderObject() Standard_OVERRIDE {};
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { return NULL; }
-
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
- //! Returns drawer of the row if possible
- //! \param theRow child row index
- //! \param theName [out] drawer name
- Standard_EXPORT Handle(Prs3d_Drawer) GetPrs3dDrawer (const int theRow,
- TCollection_AsciiString& theName) const;
-
- enum ParentKind
- {
- ParentKind_ContextItem, //!< "Properties" item under an interactive context
- ParentKind_PresentationItem, //!< "Properties" item under an interactive presentation
- ParentKind_FolderItem //!< "Filters" item under an interactive context
- };
-
- //! Finds kind of the parent item
- //! \return item kind
- ParentKind GetParentItemKind() const;
-
protected:
//! Initialize the current item. It is empty because Reset() is also empty.
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+private:
+ //! Returns whether the parent item is context item
+ //! \returns bolean value
+ bool parentItemIsContext() const;
+
private:
//! Constructor
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemGraphic3dCStructure.hxx>
-#include <inspector/VInspector_ItemGraphic3dGroup.hxx>
-
-#include <inspector/VInspector_ItemPrs3dPresentation.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Graphic3d.hxx>
-#include <Graphic3d_CStructure.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : GetGroup
-// purpose :
-// =======================================================================
-Handle(Graphic3d_Group) VInspector_ItemGraphic3dCStructure::GetGroup (const int theRowId) const
-{
- Handle(Graphic3d_CStructure) aCStructure = GetCStructure();
- if (aCStructure.IsNull())
- return Handle(Graphic3d_Group)();
-
- const Graphic3d_SequenceOfGroup& aGroups = aCStructure->Groups();
- int aCurrentIndex = 0;
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
- {
- if (theRowId == aCurrentIndex)
- return aGroupIter.Value();
-
- aCurrentIndex++;
- }
- return Handle(Graphic3d_Group)();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCStructure::Init()
-{
- VInspector_ItemPrs3dPresentationPtr aParentItem = itemDynamicCast<VInspector_ItemPrs3dPresentation>(Parent());
-
- Handle(Prs3d_Presentation) aPresentation = aParentItem->GetPresentation();
- myCStructure = aPresentation->CStructure();
- if (!myCStructure.IsNull())
- myTransformPersistence = myCStructure->TransformPersistence();
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCStructure::Reset()
-{
- VInspector_ItemBase::Reset();
- myCStructure = NULL;
- myTransformPersistence = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCStructure::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemGraphic3dCStructure*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dCStructure::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- Handle(Graphic3d_CStructure) aCStructure = GetCStructure();
- return !aCStructure.IsNull() ? aCStructure->Groups().Length() : 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dCStructure::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Graphic3d_CStructure) aCStructure = GetCStructure();
- if (aCStructure.IsNull())
- return Column() == 0 ? "Empty CStructure" : "";
-
- switch (Column())
- {
- case 0: return theItemRole == Qt::DisplayRole ? aCStructure->DynamicType()->Name()
- : STANDARD_TYPE (Graphic3d_CStructure)->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dCStructure::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemGraphic3dCStructure::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 8:
- {
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_UNKNOWN));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Default));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Top));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Topmost));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_TopOSD));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_BotOSD));
- }
- break;
- default: break;
- }
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dCStructure::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(Graphic3d_CStructure) aCStructure = GetCStructure();
- if (aCStructure.IsNull())
- return QVariant();
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("GraphicDriver")
- : QVariant (ViewControl_Tools::GetPointerInfo (aCStructure->GraphicDriver()).ToCString());
- case 1: return isFirstColumn ? QVariant ("Groups") : QVariant (aCStructure->Groups().Length());
- case 2: return isFirstColumn ? QVariant ("Transformation")
- : QVariant (ViewControl_Tools::ToString (aCStructure->Transformation()).ToCString());
- case 3: return isFirstColumn ? QVariant ("TransformPersistence")
- : QVariant (ViewControl_Tools::GetPointerInfo (aCStructure->TransformPersistence()).ToCString());
- case 4: return isFirstColumn ? QVariant ("ClipPlanes")
- : (!aCStructure->ClipPlanes().IsNull() ? QVariant (aCStructure->ClipPlanes()->Size()) : QVariant());
- //case 5: return isFirstColumn ? QVariant ("BoundingBox")
- // : QVariant (ViewControl_Tools::ToString (aCStructure->BoundingBox()).ToCString());
- case 6: return isFirstColumn ? QVariant ("HighlightStyle")
- : QVariant (ViewControl_Tools::GetPointerInfo (aCStructure->HighlightStyle()).ToCString());
-
- case 7: return isFirstColumn ? QVariant ("Id") : QVariant (aCStructure->Id);
- case 8: return isFirstColumn ? QVariant ("ZLayer")
- : QVariant (Graphic3d::ZLayerIdToString(aCStructure->ZLayer()));
- case 9: return isFirstColumn ? QVariant ("Priority") : QVariant (aCStructure->Priority);
- case 10: return isFirstColumn ? QVariant ("PreviousPriority") : QVariant (aCStructure->PreviousPriority);
- case 11: return isFirstColumn ? QVariant ("ContainsFacet") : QVariant (aCStructure->ContainsFacet);
- case 12: return isFirstColumn ? QVariant ("IsInfinite") : QVariant (aCStructure->IsInfinite);
-
- case 13: return isFirstColumn ? QVariant ("stick") : QVariant (aCStructure->stick);
- case 14: return isFirstColumn ? QVariant ("highlight") : QVariant (aCStructure->highlight);
- case 15: return isFirstColumn ? QVariant ("visible") : QVariant (aCStructure->visible);
- case 16: return isFirstColumn ? QVariant ("HLRValidation") : QVariant (aCStructure->HLRValidation);
- case 17: return isFirstColumn ? QVariant ("IsForHighlight") : QVariant (aCStructure->IsForHighlight);
- case 18: return isFirstColumn ? QVariant ("IsMutable") : QVariant (aCStructure->IsMutable);
- case 19: return isFirstColumn ? QVariant ("Is2dText") : QVariant (aCStructure->Is2dText);
-
- default: return QVariant();
- }
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemGraphic3dCStructure::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(Graphic3d_CStructure) aCStructure = GetCStructure();
- switch (theRow)
- {
- case 8: aCStructure->SetZLayer (Graphic3d::ZLayerIdFromString (theValue.toString().toStdString().c_str()));
- default: return false;
- }
- return true;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemGraphic3dCStructure::createChild (int theRow, int theColumn)
-{
- Handle(Graphic3d_CStructure) aCStructure = GetCStructure();
- //Handle(Prs3d_Presentation) aPresentation = GetPresentation();
- //Standard_EXPORT const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const;
-
- if (theRow >= 0 && theRow < GetCStructure()->Groups().Length())
- return VInspector_ItemGraphic3dGroup::CreateItem (currentItem(), theRow, theColumn);
- //else
- // return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
-
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemGraphic3dCStructure_H
-#define VInspector_ItemGraphic3dCStructure_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class Graphic3d_CStructure;
-
-class VInspector_ItemGraphic3dCStructure;
-typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dCStructure> VInspector_ItemGraphic3dCStructurePtr;
-
-//! \class VInspector_ItemGraphic3dCStructure
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemGraphic3dCStructure : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemGraphic3dCStructurePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemGraphic3dCStructurePtr (new VInspector_ItemGraphic3dCStructure (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemGraphic3dCStructure() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myCStructure; }
-
- //! Returns the current C structure, init item if it was not initialized yet
- //! \return graphic C structure object
- Standard_EXPORT Handle(Graphic3d_CStructure) GetCStructure() const
- { return Handle(Graphic3d_CStructure)::DownCast (GetObject()); }
-
- //! Returns group of the C structure
- //! \param theRowId a group index
- //! \return graphical group
- Standard_EXPORT Handle(Graphic3d_Group) GetGroup (const int theRowId) const;
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of displayed presentations
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemGraphic3dCStructure(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(Graphic3d_CStructure) myCStructure;
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemGraphic3dCView.hxx>
-
-#include <inspector/VInspector_ItemV3dView.hxx>
-#include <inspector/VInspector_ItemGraphic3dCamera.hxx>
-#include <inspector/VInspector_ItemGraphic3dClipPlane.hxx>
-#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <Graphic3d_CView.hxx>
-#include <OpenGl_View.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : GetLayerList
-// purpose :
-// =======================================================================
-const OpenGl_LayerList& VInspector_ItemGraphic3dCView::GetLayerList (Standard_Boolean& isDefault) const
-{
- isDefault = Standard_True;
-
- Handle(Graphic3d_CView) aCView = GetCView();
- if (aCView.IsNull())
- return myDefaultLayer;
-
- Handle(OpenGl_View) aOpenGlView = Handle(OpenGl_View)::DownCast (aCView);
- if (aOpenGlView.IsNull())
- return myDefaultLayer;
-
- isDefault = Standard_False;
- return aOpenGlView->LayerList();
-}
-
-// =======================================================================
-// function : GetClipPlane
-// purpose :
-// =======================================================================
-Handle(Graphic3d_ClipPlane) VInspector_ItemGraphic3dCView::GetClipPlane(const int theRow)
-{
- //Handle(V3d_View) aView = GetView();
-
- //const Handle(Graphic3d_SequenceOfHClipPlane)& aClipPlanes = aView->ClipPlanes();
-
- //Standard_Integer aPlaneId = 0;
- //for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aClipPlanes); aPlaneIt.More(); aPlaneIt.Next(), ++aPlaneId)
- //{
- // if (aPlaneId == theRow)
- // return aPlaneIt.Value();
- //}
- return 0;
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCView::Init()
-{
- VInspector_ItemV3dViewPtr aParentItem = itemDynamicCast<VInspector_ItemV3dView>(Parent());
-
- myCView = aParentItem->GetView()->View();
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCView::Reset()
-{
- VInspector_ItemBase::Reset();
- myCView = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCView::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemGraphic3dCView*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dCView::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- int aNbElements = 2; // Camera, OpenGl_LayerList
-
- Handle(Graphic3d_CView) aCView = GetCView();
- const Handle(Graphic3d_SequenceOfHClipPlane)& aClipPlanes = aCView->ClipPlanes();
- if (!aClipPlanes.IsNull())
- aNbElements += aClipPlanes->Size();
-
- return aNbElements;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dCView::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Graphic3d_CView) aCView = GetCView();
- if (aCView.IsNull())
- return Column() == 0 ? "Empty Graphic3d_CView" : "";
-
- switch (Column())
- {
- case 0: return theItemRole == Qt::DisplayRole ? aCView->DynamicType()->Name()
- : STANDARD_TYPE (Graphic3d_CView)->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dCView::GetTableRowCount() const
-{
- return 10;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemGraphic3dCView::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- /*case 4: return ViewControl_EditType_Line;
- case 5: return ViewControl_EditType_Combo;
- case 6: return ViewControl_EditType_Bool;
- case 12: return ViewControl_EditType_Bool;
- case 17: return ViewControl_EditType_Combo;
- case 18: return ViewControl_EditType_Bool;
- case 22: return ViewControl_EditType_Bool;*/
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemGraphic3dCView::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- /*switch (theRow)
- {
- case 5:
- {
- for (int i = 0; i <= Aspect_TOFM_FRONT_SIDE; i++)
- aValues.append (Aspect::TypeOfFacingModelToString((Aspect_TypeOfFacingModel)i));
- }
- break;
- case 17:
- {
- for (int i = 0; i <= PrsMgr_TOP_ProjectorDependant; i++)
- aValues.append (PrsMgr::TypeOfPresentation3dToString ((PrsMgr_TypeOfPresentation3d)i));
- }
- break;
- default: break;
- }*/
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dCView::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(Graphic3d_CView) aCView = GetCView();
- if (aCView.IsNull())
- return QVariant();
-
- //bool isFirstColumn = theColumn == 0;
- //switch (theRow)
- //{
- // case 0: return isFirstColumn ? QVariant ("LineAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->LineAspect()).ToCString());
- // case 1: return isFirstColumn ? QVariant ("FillAreaAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->FillAreaAspect()).ToCString());
- // case 2: return isFirstColumn ? QVariant ("TextAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->TextAspect()).ToCString());
- // case 3: return isFirstColumn ? QVariant ("MarkerAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->MarkerAspect()).ToCString());
- // case 4: return isFirstColumn ? QVariant ("ContainsFacet") : QVariant (aGroup->ContainsFacet());
- // case 5: return isFirstColumn ? QVariant ("IsDeleted") : QVariant (aGroup->IsDeleted());
- // case 6: return isFirstColumn ? QVariant ("IsEmpty") : QVariant (aGroup->IsEmpty());
- // case 7: return isFirstColumn ? QVariant ("IsClosed") : QVariant (aGroup->IsClosed());
- // case 8:
- // {
- // if (isFirstColumn)
- // return QVariant ("MinMaxValues");
- // Standard_Real aXMin, anYMin, aZMin, aXMax, anYMax, aZMax;
- // aGroup->MinMaxValues (aXMin, anYMin, aZMin, aXMax, anYMax, aZMax);
- // Bnd_Box aBox;
- // aBox.Update(aXMin, anYMin, aZMin, aXMax, anYMax, aZMax);
- // return QVariant (ViewControl_Tools::ToString (aBox).ToCString());
- // }
- // case 9:
- // {
- // if (isFirstColumn)
- // return QVariant ("BoundingBox");
- // const Graphic3d_BndBox4f& aBndBox = aGroup->BoundingBox();
- // Bnd_Box aBox;
- // aBox.Update((Standard_Real )aBndBox.CornerMin().x(),
- // (Standard_Real )aBndBox.CornerMin().y(),
- // (Standard_Real )aBndBox.CornerMin().z(),
- // (Standard_Real )aBndBox.CornerMax().x(),
- // (Standard_Real )aBndBox.CornerMax().y(),
- // (Standard_Real )aBndBox.CornerMax().z());
- // return QVariant (ViewControl_Tools::ToString (aBox).ToCString());
- // }
- //}
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemGraphic3dCView::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- /*Handle(AIS_InteractiveObject) aPrs = GetInteractiveObject();
- switch (theRow)
- {
- case 4:
- {
- double aValue = theValue.toDouble();
- if (aValue > 0) aPrs->SetWidth (aValue);
- else aPrs->UnsetWidth();
- }
- break;
- case 5: aPrs->SetCurrentFacingModel (Aspect::TypeOfFacingModelFromString (theValue.toString().toStdString().c_str()));
- case 6: aPrs->SetInfiniteState (theValue.toBool());
- case 12: aPrs->SetAutoHilight(theValue.toBool());
- case 17: aPrs->SetTypeOfPresentation (PrsMgr::TypeOfPresentation3dFromString (theValue.toString().toStdString().c_str()));
- case 18: aPrs->SetMutable (theValue.toBool());
- case 22: if (!theValue.toBool()) aPrs->ResetTransformation();
- default: return false;
- }*/
- return true;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemGraphic3dCView::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 1)
- return VInspector_ItemOpenGlLayerList::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemGraphic3dClipPlane::CreateItem (currentItem(), theRow, theColumn);
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemGraphic3dCView_H
-#define VInspector_ItemGraphic3dCView_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <OpenGl_LayerList.hxx>
-
-class Graphic3d_CView;
-
-class VInspector_ItemGraphic3dCView;
-typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dCView> VInspector_ItemGraphic3dCViewPtr;
-
-//! \class VInspector_ItemGraphic3dCView
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemGraphic3dCView : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemGraphic3dCViewPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemGraphic3dCViewPtr (new VInspector_ItemGraphic3dCView (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemGraphic3dCView() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myCView; }
-
- //! Returns current clip plane, initialize if it was not initialized yet
- Standard_EXPORT Handle(Graphic3d_CView) GetCView() const
- { return Handle(Graphic3d_CView)::DownCast (GetObject()); }
-
- //! Returns layer list if the View is OpenGl_View
- //! \param isDefault flag is true if the layer is absent and the default value of this class is used
- Standard_EXPORT const OpenGl_LayerList& GetLayerList (Standard_Boolean& isDefault) const;
-
- //! Returns clip plane of the row if possible
- //! \param theRow child row index
- Standard_EXPORT Handle(Graphic3d_ClipPlane) GetClipPlane(const int theRow);
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemGraphic3dCView(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn), myDefaultLayer (1) {}
-
-private:
- Handle(Graphic3d_CView) myCView; //! current graphical CView
- OpenGl_LayerList myDefaultLayer; //! default layer if the view is not OpenGl
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemGraphic3dCamera.hxx>
-
-#include <inspector/VInspector_ItemGraphic3dCView.hxx>
-#include <inspector/VInspector_ItemV3dView.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <Graphic3d.hxx>
-#include <Graphic3d_Camera.hxx>
-#include <TopoDS_Compound.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCamera::Init()
-{
- VInspector_ItemV3dViewPtr aParentItem = itemDynamicCast<VInspector_ItemV3dView>(Parent());
- if (aParentItem)
- myCamera = aParentItem->GetView()->DefaultCamera();
- else
- {
- VInspector_ItemGraphic3dCViewPtr aParentItem = itemDynamicCast<VInspector_ItemGraphic3dCView>(Parent());
- if (aParentItem)
- myCamera = aParentItem->GetCView()->Camera();
- }
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCamera::Reset()
-{
- VInspector_ItemBase::Reset();
- myCamera = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dCamera::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemGraphic3dCamera*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dCamera::initRowCount() const
-{
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dCamera::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Graphic3d_Camera) aCamera = GetCamera();
- if (aCamera.IsNull())
- return Column() == 0 ? "Empty Graphic3d_Camera" : "";
-
- switch (Column())
- {
- case 0: return theItemRole == Qt::DisplayRole ? aCamera->DynamicType()->Name()
- : STANDARD_TYPE (Graphic3d_Camera)->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dCamera::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemGraphic3dCamera::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- //case 0: return ViewControl_EditType_DoubleVec3;
- //case 1: return ViewControl_EditType_DoubleVec3;
- //case 2: return ViewControl_EditType_DoubleVec3;
- //case 3: return ViewControl_EditType_DoubleVec3;
- case 4: return ViewControl_EditType_Double;
- case 5: return ViewControl_EditType_Combo;
- case 6: return ViewControl_EditType_Double;
- case 7: return ViewControl_EditType_Double;
- case 8: return ViewControl_EditType_Double;
- case 9: return ViewControl_EditType_Double;
- case 10: return ViewControl_EditType_Combo;
- case 11: return ViewControl_EditType_Combo;
- case 12: return ViewControl_EditType_Double;
- // calculated
- //case 13: return ViewControl_EditType_DoubleVec3;
- //case 14: return ViewControl_EditType_DoubleVec3;
- //case 15: return ViewControl_EditType_DoubleVec3;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemGraphic3dCamera::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 5:
- {
- for (int i = 0; i <= Graphic3d_Camera::Projection_MonoRightEye; i++)
- aValues.append (Graphic3d::CameraProjectionToString((Graphic3d_Camera::Projection)i));
- }
- break;
- case 10:
- {
- for (int i = 0; i <= Graphic3d_Camera::FocusType_Relative; i++)
- aValues.append (Graphic3d::CameraFocusTypeToString((Graphic3d_Camera::FocusType)i));
- }
- break;
- case 11:
- {
- for (int i = 0; i <= Graphic3d_Camera::IODType_Relative; i++)
- aValues.append (Graphic3d::CameraIODTypeToString((Graphic3d_Camera::IODType)i));
- }
- break;
- default: break;
- }
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dCamera::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Graphic3d_Camera) aCamera = GetCamera();
- if (aCamera.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- bool isToolTip = theRole == Qt::ToolTipRole;
- switch (theRow)
- {
- case 0: return isFirstColumn ? (!isToolTip ? QVariant("Eye") : QVariant ("Camera Eye position"))
- : QVariant (ViewControl_Tools::ToString (aCamera->Eye()).ToCString());
- case 1: return isFirstColumn ? (!isToolTip ? QVariant("Center") : QVariant ("Center of the camera"))
- : QVariant (ViewControl_Tools::ToString (aCamera->Center()).ToCString());
- case 2: return isFirstColumn ? (!isToolTip ? QVariant("Up") : QVariant ("Camera Up direction vector, orthogonal to camera direction"))
- : QVariant (ViewControl_Tools::ToString (aCamera->Up()).ToCString());
-
- case 3: return isFirstColumn ? (!isToolTip ? QVariant ("AxialScale") : QVariant ("Camera axial scale vector"))
- : QVariant (ViewControl_Tools::ToString (aCamera->AxialScale()).ToCString());
- case 4: return isFirstColumn ? (!isToolTip ? QVariant ("Scale") : QVariant ("Camera scale (depend on Projection, see sources doc)"))
- : ViewControl_Tools::ToVariant (aCamera->Scale());
- case 5: return isFirstColumn ? (!isToolTip ? QVariant ("ProjectionType") : QVariant ("Camera projection type"))
- : QVariant (Graphic3d::CameraProjectionToString (aCamera->ProjectionType()));
-
- case 6: return isFirstColumn ? (!isToolTip ? QVariant ("FOVy") : QVariant ("Field Of View (FOV) in y axis for perspective projection"))
- : ViewControl_Tools::ToVariant (aCamera->FOVy());
- case 7: return isFirstColumn ? (!isToolTip ? QVariant ("ZNear") : QVariant ("Near Z-clipping plane position: distance of the plane from the Eye"))
- : ViewControl_Tools::ToVariant (aCamera->ZNear());
- case 8: return isFirstColumn ? (!isToolTip ? QVariant ("ZFar") : QVariant ("Far Z-clipping plane position: distance of the plane from the Eye"))
- : ViewControl_Tools::ToVariant (aCamera->ZFar());
- case 9: return isFirstColumn ? (!isToolTip ? QVariant ("Aspect") : QVariant ("Camera width / height display ratio"))
- : ViewControl_Tools::ToVariant (aCamera->Aspect());
-
- case 10: return isFirstColumn ? (!isToolTip ? QVariant ("ZFocusType") : QVariant ("Type used for stereographic focus"))
- : QVariant (Graphic3d::CameraFocusTypeToString (aCamera->ZFocusType()));
- case 11: return isFirstColumn ? (!isToolTip ? QVariant ("ZFocus") : QVariant ("Stereographic focus value"))
- : ViewControl_Tools::ToVariant (aCamera->ZFocus());
-
- case 12: return isFirstColumn ? (!isToolTip ? QVariant ("GetIODType") : QVariant ("Intraocular distance definition type"))
- : QVariant (Graphic3d::CameraIODTypeToString (aCamera->GetIODType()));
- case 13: return isFirstColumn ? (!isToolTip ? QVariant ("IOD") : QVariant ("Intraocular distance value"))
- : ViewControl_Tools::ToVariant (aCamera->IOD());
-
- case 14: return ViewControl_Table::SeparatorData();
- case 15: return isFirstColumn ? QVariant ("Calculated values:") : QVariant();
- case 16: return ViewControl_Table::SeparatorData();
-
- case 17: return isFirstColumn ? (!isToolTip ? QVariant ("Distance") : QVariant ("Distance of Eye from camera Center"))
- : ViewControl_Tools::ToVariant (aCamera->Distance());
- case 18: return isFirstColumn ? (!isToolTip ? QVariant ("Direction") : QVariant ("Camera look direction"))
- : QVariant (ViewControl_Tools::ToString (aCamera->Direction()).ToCString());
- case 19: return isFirstColumn ? (!isToolTip ? QVariant ("ViewDimensions") : QVariant ("View plane size at center (target) point and distance between ZFar and ZNear planes"))
- : ViewControl_Tools::ToString (aCamera->ViewDimensions()).ToCString();
-
- case 20: return ViewControl_Table::SeparatorData();
- case 21: return isFirstColumn ? QVariant ("TransformMatrices (D):") : QVariant();
- case 22: return ViewControl_Table::SeparatorData();
-
- case 23: return isFirstColumn ? QVariant ("OrientationMatrix") : VInspector_Tools::ToVariant (aCamera->OrientationMatrix());
- case 24: return isFirstColumn ? QVariant ("ProjectionMatrix") : VInspector_Tools::ToVariant (aCamera->ProjectionMatrix());
- case 25: return isFirstColumn ? QVariant ("ProjectionStereoLeft") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoLeft());
- case 26: return isFirstColumn ? QVariant ("ProjectionStereoRight") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoRight());
-
- case 27: return ViewControl_Table::SeparatorData();
- case 28: return isFirstColumn ? QVariant ("TransformMatrices (F):") : QVariant();
- case 29: return ViewControl_Table::SeparatorData();
-
- case 30: return isFirstColumn ? QVariant ("OrientationMatrixF") : VInspector_Tools::ToVariant (aCamera->OrientationMatrixF());
- case 31: return isFirstColumn ? QVariant ("ProjectionMatrixF") : VInspector_Tools::ToVariant (aCamera->ProjectionMatrixF());
- case 32: return isFirstColumn ? QVariant ("ProjectionStereoLeftF") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoLeftF());
- case 33: return isFirstColumn ? QVariant ("ProjectionStereoRightF") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoRightF());
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemGraphic3dCamera::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(Graphic3d_Camera) aCamera = GetCamera();
- if (aCamera.IsNull())
- return false;
-
- switch (theRow)
- {
- //case 0: return isFirstColumn ? (!isToolTip ? QVariant("Eye") : QVariant ("Camera Eye position"))
- // : QVariant (ViewControl_Tools::ToString (aCamera->Eye()).ToCString());
- //case 1: return isFirstColumn ? (!isToolTip ? QVariant("Center") : QVariant ("Center of the camera"))
- // : QVariant (ViewControl_Tools::ToString (aCamera->Center()).ToCString());
- //case 2: return isFirstColumn ? (!isToolTip ? QVariant("Up") : QVariant ("Camera Up direction vector, orthogonal to camera direction"))
- // : QVariant (ViewControl_Tools::ToString (aCamera->Up()).ToCString());
- //case 3: return isFirstColumn ? (!isToolTip ? QVariant ("AxialScale") : QVariant ("Camera axial scale vector"))
- // : QVariant (ViewControl_Tools::ToString (aCamera->AxialScale()).ToCString());
- case 4: aCamera->SetScale (ViewControl_Tools::ToRealValue (theValue)); break;
- case 5: aCamera->SetProjectionType (Graphic3d::CameraProjectionFromString(theValue.toString().toStdString().c_str())); break;
-
- case 6: aCamera->SetFOVy (ViewControl_Tools::ToRealValue (theValue)); break;
- case 7: aCamera->SetZRange (ViewControl_Tools::ToRealValue (theValue), aCamera->ZFar()); break;
- case 8: aCamera->SetZRange (aCamera->ZNear(), ViewControl_Tools::ToRealValue (theValue)); break;
- case 9: aCamera->SetAspect (ViewControl_Tools::ToRealValue (theValue)); break;
-
- case 10: aCamera->SetZFocus (Graphic3d::CameraFocusTypeFromString(theValue.toString().toStdString().c_str()),
- aCamera->ZFocus()); break;
- case 11: aCamera->SetZFocus (aCamera->ZFocusType(), ViewControl_Tools::ToRealValue (theValue)); break;
-
- case 12: aCamera->SetIOD (Graphic3d::CameraIODTypeFromString(theValue.toString().toStdString().c_str()),
- aCamera->IOD()); break;
- case 13: aCamera->SetIOD (aCamera->GetIODType(),
- ViewControl_Tools::ToRealValue (theValue)); break;
-
- //case 14: return ViewControl_Table::SeparatorData();
- //case 15: return isFirstColumn ? QVariant ("Calculated values:") : QVariant();
- //case 16: return ViewControl_Table::SeparatorData();
-
- case 17: aCamera->SetDistance (ViewControl_Tools::ToRealValue (theValue)); break;
- //case 18: return isFirstColumn ? (!isToolTip ? QVariant ("Direction") : QVariant ("Camera look direction"))
- // : QVariant (ViewControl_Tools::ToString (aCamera->Direction()).ToCString());
- default: return false;
- }
- return true;
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemGraphic3dCamera::buildPresentationShape (const Handle(Graphic3d_Camera)& theCamera)
-{
- if (theCamera.IsNull())
- return TopoDS_Shape();
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
-
- const gp_Pnt& aCenter = theCamera->Center ();
- const gp_Pnt& anEye = theCamera->Eye ();
- const gp_Dir& anUp = theCamera->Up();
- const gp_Dir& aCameraDirection = theCamera->Direction();
-
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (aCenter));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (anEye));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Lin (anEye, anUp)));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Lin (anEye, aCameraDirection)));
-
- return aCompound;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemGraphic3dCamera::createChild (int, int)
-{
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemGraphic3dCamera_H
-#define VInspector_ItemGraphic3dCamera_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class Graphic3d_Camera;
-
-class VInspector_ItemGraphic3dCamera;
-typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dCamera> VInspector_ItemGraphic3dCameraPtr;
-
-//! \class VInspector_ItemGraphic3dCamera
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemGraphic3dCamera : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemGraphic3dCameraPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemGraphic3dCameraPtr (new VInspector_ItemGraphic3dCamera (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemGraphic3dCamera() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myCamera; }
-
- //! Returns the current graphic3d camera, init item if it was not initialized yet
- //! \return graphic camera
- Standard_EXPORT Handle(Graphic3d_Camera) GetCamera() const { return Handle(Graphic3d_Camera)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE { return buildPresentationShape (myCamera); }
-
- //! Creates shape for the 3d view parameters
- //! \param theView current view
- //! \return shape or NULL
- static TopoDS_Shape buildPresentationShape (const Handle(Graphic3d_Camera)& theView);
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemGraphic3dCamera(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(Graphic3d_Camera) myCamera; //! current graphic group
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemGraphic3dClipPlane.hxx>
-
-#include <AIS.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemGraphic3dClipPlane.hxx>
-#include <inspector/VInspector_ItemV3dView.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dClipPlane::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- VInspector_ItemV3dViewPtr aParentViewItem = itemDynamicCast<VInspector_ItemV3dView>(Parent());
- if (aParentViewItem)
- return aParentViewItem->GetView()->ClipPlanes()->Size();
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dClipPlane::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- if (GetClipPlane().IsNull())
- return Column() == 0 ? "Clip Planes" : "";
-
- switch (Column())
- {
- case 0: return GetClipPlane()->DynamicType()->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemGraphic3dClipPlane::Init()
-{
- //VInspector_ItemV3dViewPtr aParentViewItem = itemDynamicCast<VInspector_ItemV3dView>(Parent());
- //Handle(Graphic3d_ClipPlane) aClipPlane;
- //if (!aParentViewItem) // ClipPlanes
- //{
- // aParentViewItem = itemDynamicCast<VInspector_ItemV3dView>(Parent()->Parent());
- // aClipPlane = aParentViewItem->GetClipPlane(Row());
- //}
- //setClipPlane (aClipPlane);
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemGraphic3dClipPlane::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setClipPlane (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemGraphic3dClipPlane::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemGraphic3dClipPlane*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dClipPlane::GetTableRowCount() const
-{
- return 0;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemGraphic3dClipPlane::GetTableEditType (const int theRow, const int) const
-{
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemGraphic3dClipPlane::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dClipPlane::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemGraphic3dClipPlane::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- return true;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemGraphic3dClipPlane::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- return VInspector_ItemGraphic3dClipPlane::CreateItem (currentItem(), theRow, theColumn);
-
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemGraphic3dClipPlane_H
-#define VInspector_ItemGraphic3dClipPlane_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Graphic3d_ClipPlane.hxx>
-
-class VInspector_ItemGraphic3dClipPlane;
-typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dClipPlane> VInspector_ItemGraphic3dClipPlanePtr;
-
-//! \class VInspector_ItemGraphic3dClipPlane
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemGraphic3dClipPlane : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemGraphic3dClipPlanePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemGraphic3dClipPlanePtr (new VInspector_ItemGraphic3dClipPlane (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemGraphic3dClipPlane() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myClipPlane; }
-
- //! Returns current clip plane, initialize if it was not initialized yet
- Standard_EXPORT Handle(Graphic3d_ClipPlane) GetClipPlane() const
- { return Handle(Graphic3d_ClipPlane)::DownCast (GetObject()); }
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) 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:
-
- //! Set Clip Plane into the current field
- //! \param theViewer a viewer
- void setClipPlane (const Handle(Graphic3d_ClipPlane)& theClipPlane) { myClipPlane = theClipPlane; }
-
-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_ItemGraphic3dClipPlane(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(Graphic3d_ClipPlane) myClipPlane; //!< the current ClipPlane
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemGraphic3dGroup.hxx>
-
-#include <inspector/VInspector_ItemGraphic3dCStructure.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <OpenGl_Group.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dGroup::Init()
-{
- VInspector_ItemGraphic3dCStructurePtr aParentItem = itemDynamicCast<VInspector_ItemGraphic3dCStructure>(Parent());
- myGroup = aParentItem->GetGroup (Row());
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dGroup::Reset()
-{
- VInspector_ItemBase::Reset();
- myGroup = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dGroup::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemGraphic3dGroup*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dGroup::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- Handle(Graphic3d_Group) aGroup = GetGroup();
- Handle(OpenGl_Group) anOpenGlGroup = Handle(OpenGl_Group)::DownCast(aGroup);
- if (anOpenGlGroup.IsNull())
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dGroup::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Graphic3d_Group) aGroup = GetGroup();
- if (aGroup.IsNull())
- return Column() == 0 ? "Empty group" : "";
-
- switch (Column())
- {
- case 0: return theItemRole == Qt::DisplayRole ? aGroup->DynamicType()->Name()
- : STANDARD_TYPE (Graphic3d_Group)->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dGroup::GetTableRowCount() const
-{
- return 10;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dGroup::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(Graphic3d_Group) aGroup = GetGroup();
- if (aGroup.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- //case 0: return isFirstColumn ? QVariant ("LineAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->LineAspect()).ToCString());
- //case 1: return isFirstColumn ? QVariant ("FillAreaAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->FillAreaAspect()).ToCString());
- //case 2: return isFirstColumn ? QVariant ("TextAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->TextAspect()).ToCString());
- //case 3: return isFirstColumn ? QVariant ("MarkerAspect") : QVariant (ViewControl_Tools::GetPointerInfo (aGroup->MarkerAspect()).ToCString());
- case 4: return isFirstColumn ? QVariant ("ContainsFacet") : QVariant (aGroup->ContainsFacet());
- case 5: return isFirstColumn ? QVariant ("IsDeleted") : QVariant (aGroup->IsDeleted());
- case 6: return isFirstColumn ? QVariant ("IsEmpty") : QVariant (aGroup->IsEmpty());
- case 7: return isFirstColumn ? QVariant ("IsClosed") : QVariant (aGroup->IsClosed());
- case 8:
- {
- if (isFirstColumn)
- return QVariant ("MinMaxValues");
- Standard_Real aXMin, anYMin, aZMin, aXMax, anYMax, aZMax;
- aGroup->MinMaxValues (aXMin, anYMin, aZMin, aXMax, anYMax, aZMax);
- Bnd_Box aBox;
- aBox.Update(aXMin, anYMin, aZMin, aXMax, anYMax, aZMax);
- return QVariant (ViewControl_Tools::ToString (aBox).ToCString());
- }
- case 9:
- {
- if (isFirstColumn)
- return QVariant ("BoundingBox");
- const Graphic3d_BndBox4f& aBndBox = aGroup->BoundingBox();
- Bnd_Box aBox;
- aBox.Update((Standard_Real )aBndBox.CornerMin().x(),
- (Standard_Real )aBndBox.CornerMin().y(),
- (Standard_Real )aBndBox.CornerMin().z(),
- (Standard_Real )aBndBox.CornerMax().x(),
- (Standard_Real )aBndBox.CornerMax().y(),
- (Standard_Real )aBndBox.CornerMax().z());
- return QVariant (ViewControl_Tools::ToString (aBox).ToCString());
- }
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetStream
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dGroup::GetStream (Standard_OStream& OS) const
-{
- Handle(Graphic3d_Group) aGroup = GetGroup();
- if (aGroup.IsNull())
- return;
-
- aGroup->Dump (OS);
-}
-
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemGraphic3dGroup::createChild (int theRow, int theColumn)
-{
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemGraphic3dGroup_H
-#define VInspector_ItemGraphic3dGroup_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class Graphic3d_Group;
-class OpenGl_Element;
-
-class VInspector_ItemGraphic3dGroup;
-typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dGroup> VInspector_ItemGraphic3dGroupPtr;
-
-//! \class VInspector_ItemGraphic3dGroup
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemGraphic3dGroup : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemGraphic3dGroupPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemGraphic3dGroupPtr (new VInspector_ItemGraphic3dGroup (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemGraphic3dGroup() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myGroup; }
-
- //! Returns the current graphic3d group, init item if it was not initialized yet
- //! \return graphic group
- Standard_EXPORT Handle(Graphic3d_Group) GetGroup() const
- { return Handle(Graphic3d_Group)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemGraphic3dGroup(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(Graphic3d_Group) myGroup; //! current graphic group
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemGraphic3dTransformPers.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-
-#include <inspector/VInspector_ItemPrs3dPresentation.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Aspect.hxx>
-#include <Graphic3d.hxx>
-#include <Graphic3d_TransformPers.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dTransformPers::Init()
-{
- VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
- if (aParentItem)
- {
- VInspector_ItemPresentableObjectPtr aParentPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(aParentItem->Parent());
- if (aParentPrsItem)
- {
- Handle(AIS_InteractiveObject) anObject = aParentPrsItem->GetInteractiveObject();
- myTransformPers = anObject->TransformPersistence();
- }
- }
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dTransformPers::Reset()
-{
- VInspector_ItemBase::Reset();
- myTransformPers = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemGraphic3dTransformPers::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemGraphic3dTransformPers*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dTransformPers::initRowCount() const
-{
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dTransformPers::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(Graphic3d_TransformPers) aTransformPers = GetTransformPers();
- if (aTransformPers.IsNull())
- return Column() == 0 ? "Graphic3d_TransformPers" : "";
-
- switch (Column())
- {
- case 0: return aTransformPers->DynamicType()->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemGraphic3dTransformPers::GetTableRowCount() const
-{
- return 5;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemGraphic3dTransformPers::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(Graphic3d_TransformPers) aTransformPers = GetTransformPers();
- if (aTransformPers.IsNull())
- return QVariant();
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Mode")
- : QVariant (Graphic3d::TransModeFlagsToString (aTransformPers->Mode()));
- case 1: return isFirstColumn ? QVariant ("AnchorPoint")
- : aTransformPers->IsZoomOrRotate() ? QVariant (ViewControl_Tools::ToString (aTransformPers->AnchorPoint()).ToCString()) : QVariant();
- case 2: return isFirstColumn ? QVariant ("Corner2d")
- : aTransformPers->IsTrihedronOr2d() ? QVariant (Aspect::TypeOfTriedronPositionToString (aTransformPers->Corner2d())) : QVariant();
- case 3: return isFirstColumn ? QVariant ("OffsetX")
- : aTransformPers->IsTrihedronOr2d() ? QVariant (aTransformPers->Offset2d().x()) : QVariant();
- case 4: return isFirstColumn ? QVariant ("OffsetY")
- : aTransformPers->IsTrihedronOr2d() ? QVariant (aTransformPers->Offset2d().y()) : QVariant();
-
- default: return QVariant();
- }
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemGraphic3dTransformPers::createChild (int, int)
-{
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemGraphic3dTransformPers_H
-#define VInspector_ItemGraphic3dTransformPers_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class Graphic3d_TransformPers;
-
-class VInspector_ItemGraphic3dTransformPers;
-typedef QExplicitlySharedDataPointer<VInspector_ItemGraphic3dTransformPers> VInspector_ItemGraphic3dTransformPersPtr;
-
-//! \class VInspector_ItemGraphic3dTransformPers
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemGraphic3dTransformPers : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemGraphic3dTransformPersPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemGraphic3dTransformPersPtr (new VInspector_ItemGraphic3dTransformPers (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemGraphic3dTransformPers() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myTransformPers; }
-
- //! Returns the current C structure, init item if it was not initialized yet
- //! \return graphic C structure object
- Standard_EXPORT Handle(Graphic3d_TransformPers) GetTransformPers() const
- { return Handle(Graphic3d_TransformPers)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of displayed presentations
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemGraphic3dTransformPers(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(Graphic3d_TransformPers) myTransformPers;
-};
-
-#endif
// =======================================================================
QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return getName();
- case 2: return QVariant();
- case 3: return GetPointerInfo();
- case 4: return GetShapeTypeInfo();
+ case 1: return QVariant();
+ case 2: return GetPointerInfo();
+ case 3: return GetShapeTypeInfo();
default: break;
}
return QVariant();
const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (const int theChildRowIndex)
{
int anInfoMapIndex = theChildRowIndex + myFirstIndex;
-
- bool aReversed = true;
- if (aReversed)
- anInfoMapIndex = (myInfoMap.size() - myFirstIndex) - 1 - anInfoMapIndex;
-
return myInfoMap[anInfoMapIndex];
}
// =======================================================================
QVariant VInspector_ItemHistoryRoot::initValue (const int theRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return "History";
- case 2: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
+ case 1: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
default:
break;
}
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
- if (aTypeInfo.myElements.size() < rowCount())
- return QString();
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
return anElements.size() > 1 ? anElements[1].toString() : QString();
}
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
- if ( aTypeInfo.myElements.size() < rowCount())
- return QString();
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
return anElements.size() > 3 ? anElements[3].toString() : QString();
}
// =======================================================================
QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
- if (aParentValue.isValid())
- return aParentValue;
-
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
- int aRowCount = rowCount();
- if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount)
- return QVariant();
-
QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
int anInfoSize = anElements.size();
switch (Column())
{
case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode);
- case 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
+ case 1: return rowCount();
+ case 2: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
+ case 3: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
+ case 4: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
+ case 5: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
default: break;
}
return QVariant();
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlContext.hxx>
-
-//#include <inspector/VInspector_ItemOpenGlContextList.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <Aspect.hxx>
-#include <Graphic3d.hxx>
-#include <OpenGl_Layer.hxx>
-#include <OpenGl_Group.hxx>
-#include <OpenGl_PrimitiveArray.hxx>
-#include <OpenGl_Text.hxx>
-#include <SelectMgr.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlContext::Init()
-{
- //VInspector_ItemOpenGlContextListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlContextList>(Parent());
- //myLayer = aParentItem->GetLayer (Row(), myLayerId);
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlContext::Reset()
-{
- VInspector_ItemBase::Reset();
- myLayer = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlContext::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemOpenGlContext*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlContext::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlContext::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return Column() == 0 ? "Empty element" : "";
-
- switch (Column())
- {
- case 0:
- {
- TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId);
- if (aLayerId.IsEmpty())
- aLayerId = TCollection_AsciiString (myLayerId);
- return theItemRole == Qt::ToolTipRole ? QVariant ("")
- : QVariant (QString("%1 (%2)")
- .arg(aLayer->DynamicType()->Name())
- .arg (aLayerId.ToCString()));
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlContext::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlContext::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures());
- case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled());
- case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities());
-
- case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size());
- case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled());
- case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects());
-
- case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size());
- case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size());
- case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size());
-
- default:
- break;
- }
-
- Standard_Integer aRow = theRow - 9;
- return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings());
-}
-
-// =======================================================================
-// function : getLayerSettingsTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlContext::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const
-{
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant();
- case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString());
- case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString());
-
- case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString());
- case 4: return isFirstColumn ? QVariant ("OriginTransformation")
- : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString());
-
- case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance());
- case 6: return isFirstColumn ? QVariant ("CullingDistance")
- : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0);
-
- case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize());
- case 8: return isFirstColumn ? QVariant ("CullingSize")
- : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0);
-
- case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate());
- case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture());
- case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest());
- case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite());
- case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth());
- case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass());
-
- case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
- : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode));
- case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor);
- case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units);
-
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemOpenGlContext::createChild (int theRow, int theColumn)
-{
- (void)theRow;
- (void)theColumn;
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlContext_H
-#define VInspector_ItemOpenGlContext_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Graphic3d_ZLayerSettings.hxx>
-#include <OpenGl_Layer.hxx>
-
-class Graphic3d_Group;
-
-class VInspector_ItemOpenGlContext;
-typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlContext> VInspector_ItemOpenGlContextPtr;
-
-//! \class VInspector_ItemOpenGlContext
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemOpenGlContext : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemOpenGlContextPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemOpenGlContextPtr (new VInspector_ItemOpenGlContext (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemOpenGlContext() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; }
-
- //! Returns the current graphic3d group, init item if it was not initialized yet
- //! \return graphic group
- Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const
- { return Handle(OpenGl_Layer)::DownCast (GetObject());}
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-protected:
- //! Returns table presentation of layer settings
- QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) 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_ItemOpenGlContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(OpenGl_Layer) myLayer; //! current layer
- Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlLayer.hxx>
-
-#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <Aspect.hxx>
-#include <Graphic3d.hxx>
-#include <OpenGl_Layer.hxx>
-#include <OpenGl_Group.hxx>
-#include <OpenGl_PrimitiveArray.hxx>
-#include <OpenGl_Text.hxx>
-#include <SelectMgr.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayer::Init()
-{
- VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlLayerList>(Parent());
- myLayer = aParentItem->GetLayer (Row(), myLayerId);
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayer::Reset()
-{
- VInspector_ItemBase::Reset();
- myLayer = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayer::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemOpenGlLayer*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlLayer::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayer::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return Column() == 0 ? "Empty element" : "";
-
- switch (Column())
- {
- case 0:
- {
- TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId);
- if (aLayerId.IsEmpty())
- aLayerId = TCollection_AsciiString (myLayerId);
- return theItemRole == Qt::ToolTipRole ? QVariant ("")
- : QVariant (QString("%1 (%2)")
- .arg(aLayer->DynamicType()->Name())
- .arg (aLayerId.ToCString()));
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlLayer::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayer::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures());
- case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled());
- case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities());
-
- case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size());
- case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled());
- case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects());
-
- case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size());
- case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size());
- case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size());
-
- default:
- break;
- }
-
- Standard_Integer aRow = theRow - 9;
- return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings());
-}
-
-// =======================================================================
-// function : getLayerSettingsTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayer::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const
-{
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant();
- case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString());
- case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString());
-
- case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString());
- case 4: return isFirstColumn ? QVariant ("OriginTransformation")
- : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString());
-
- case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance());
- case 6: return isFirstColumn ? QVariant ("CullingDistance")
- : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0);
-
- case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize());
- case 8: return isFirstColumn ? QVariant ("CullingSize")
- : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0);
-
- case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate());
- case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture());
- case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest());
- case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite());
- case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth());
- case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass());
-
- case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
- : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode));
- case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor);
- case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units);
-
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemOpenGlLayer::createChild (int theRow, int theColumn)
-{
- (void)theRow;
- (void)theColumn;
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlLayer_H
-#define VInspector_ItemOpenGlLayer_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Graphic3d_ZLayerSettings.hxx>
-#include <OpenGl_Layer.hxx>
-
-class Graphic3d_Group;
-
-class VInspector_ItemOpenGlLayer;
-typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayer> VInspector_ItemOpenGlLayerPtr;
-
-//! \class VInspector_ItemOpenGlLayer
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemOpenGlLayer : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemOpenGlLayerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemOpenGlLayerPtr (new VInspector_ItemOpenGlLayer (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemOpenGlLayer() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; }
-
- //! Returns the current graphic3d group, init item if it was not initialized yet
- //! \return graphic group
- Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const
- { return Handle(OpenGl_Layer)::DownCast (GetObject());}
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-protected:
- //! Returns table presentation of layer settings
- QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) 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_ItemOpenGlLayer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(OpenGl_Layer) myLayer; //! current layer
- Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlLayerList.hxx>
-
-#include <inspector/VInspector_ItemGraphic3dGroup.hxx>
-#include <inspector/VInspector_ItemGraphic3dCView.hxx>
-#include <inspector/VInspector_ItemOpenGlLayer.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <OpenGl_Element.hxx>
-#include <OpenGl_Group.hxx>
-#include <OpenGl_PrimitiveArray.hxx>
-#include <OpenGl_Text.hxx>
-#include <SelectMgr.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayerList::Init()
-{
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayerList::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : GetLayerList
-// purpose :
-// =======================================================================
-const OpenGl_LayerList& VInspector_ItemOpenGlLayerList::GetLayerList (Standard_Boolean& isDefault) const
-{
- VInspector_ItemGraphic3dCViewPtr aParentItem = itemDynamicCast<VInspector_ItemGraphic3dCView>(Parent());
- return aParentItem->GetLayerList (isDefault);
-}
-
-// =======================================================================
-// function : GetLayer
-// purpose :
-// =======================================================================
-Handle(OpenGl_Layer) VInspector_ItemOpenGlLayerList::GetLayer (const int theRow, Graphic3d_ZLayerId& theLayerId) const
-{
- return NULL;
- /*
- Standard_Boolean isDefault;
- const OpenGl_LayerList& aLayerList = GetLayerList (isDefault);
-
- if (isDefault)
- return NULL;
-
- Standard_Integer aLayerIndex = (int)theRow + 1;
- Handle(OpenGl_Layer) aLayer = aLayerList.Layers().Value (aLayerIndex); // OpenGl_LayerSeqIds range is in [1...N]
- if (aLayer.IsNull())
- return NULL;
-
- const OpenGl_LayerSeqIds& aLayerIDs = aLayerList.LayerIDs();
- for (OpenGl_LayerSeqIds::Iterator aMapIt (aLayerIDs); aMapIt.More(); aMapIt.Next())
- {
- Standard_Integer anIndex = aMapIt.Value();
- if (anIndex != aLayerIndex)
- continue;
-
- theLayerId = aMapIt.Key();
- }
-
- return aLayer;
- */
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayerList::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemOpenGlLayerList*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlLayerList::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- Standard_Boolean isDefault;
- const OpenGl_LayerList& aListOfLayers = GetLayerList (isDefault);
- if (isDefault)
- return 0;
-
- //return aListOfLayers.Layers().Length();
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayerList::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
-
- switch (Column())
- {
- case 0:
- {
- Standard_Boolean isDefault;
- GetLayerList (isDefault);
- if (isDefault)
- return 0;
-
- return isDefault ? "Empty layer list" : "OpenGl_LayerList";
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlLayerList::GetTableRowCount() const
-{
- return 3;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayerList::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Standard_Boolean isDefault;
- const OpenGl_LayerList& aListOfLayers = GetLayerList (isDefault);
- if (isDefault)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aListOfLayers.NbPriorities());
- case 1: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aListOfLayers.NbStructures());
- case 2: return isFirstColumn ? QVariant ("NbImmediateStructures") : QVariant (aListOfLayers.NbImmediateStructures());
-
- default: return QVariant();
- }
-
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemOpenGlLayerList::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemOpenGlLayer::CreateItem (currentItem(), theRow, theColumn);
-}
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlLayerList_H
-#define VInspector_ItemOpenGlLayerList_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <OpenGl_LayerList.hxx>
-
-class VInspector_ItemOpenGlLayerList;
-typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayerList> VInspector_ItemOpenGlLayerListPtr;
-
-//! \class VInspector_ItemOpenGlLayerList
-//! Parent item, that corresponds to OpenGl_LayerList
-//! Children of the item are:
-//! - OpenGl_Layer items
-class VInspector_ItemOpenGlLayerList : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemOpenGlLayerListPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemOpenGlLayerListPtr (new VInspector_ItemOpenGlLayerList (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemOpenGlLayerList() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns layer list if the View is OpenGl_View
- //! \param isDefault flag is true if the layer is absent and the default value of this class is used
- Standard_EXPORT const OpenGl_LayerList& GetLayerList (Standard_Boolean& isDefault) const;
-
- //! Returns layer list if the View is OpenGl_View
- //! \param theLayerId index of the layer
- Standard_EXPORT Handle(OpenGl_Layer) GetLayer (const int theRow, Graphic3d_ZLayerId& theLayerId) const;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemOpenGlLayerList(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlLayer.hxx>
-
-#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <Aspect.hxx>
-#include <Graphic3d.hxx>
-#include <OpenGl_Layer.hxx>
-#include <OpenGl_Group.hxx>
-#include <OpenGl_PrimitiveArray.hxx>
-#include <OpenGl_Text.hxx>
-#include <SelectMgr.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayer::Init()
-{
- VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlLayerList>(Parent());
- myLayer = aParentItem->GetLayer (Row(), myLayerId);
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayer::Reset()
-{
- VInspector_ItemBase::Reset();
- myLayer = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlLayer::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemOpenGlLayer*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlLayer::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayer::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return Column() == 0 ? "Empty element" : "";
-
- switch (Column())
- {
- case 0:
- {
- TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId);
- if (aLayerId.IsEmpty())
- aLayerId = TCollection_AsciiString (myLayerId);
- return theItemRole == Qt::ToolTipRole ? QVariant ("")
- : QVariant (QString("%1 (%2)")
- .arg(aLayer->DynamicType()->Name())
- .arg (aLayerId.ToCString()));
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlLayer::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayer::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures());
- case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled());
- case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities());
-
- case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size());
- case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled());
- case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects());
-
- case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size());
- case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size());
- case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size());
-
- default:
- break;
- }
-
- Standard_Integer aRow = theRow - 9;
- return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings());
-}
-
-// =======================================================================
-// function : getLayerSettingsTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlLayer::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const
-{
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant();
- case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString());
- case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString());
-
- case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString());
- case 4: return isFirstColumn ? QVariant ("OriginTransformation")
- : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString());
-
- case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance());
- case 6: return isFirstColumn ? QVariant ("CullingDistance")
- : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0);
-
- case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize());
- case 8: return isFirstColumn ? QVariant ("CullingSize")
- : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0);
-
- case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate());
- case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture());
- case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest());
- case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite());
- case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth());
- case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass());
-
- case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
- : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode));
- case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor);
- case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units);
-
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemOpenGlLayer::createChild (int theRow, int theColumn)
-{
- (void)theRow;
- (void)theColumn;
-
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlLayer_H
-#define VInspector_ItemOpenGlLayer_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Graphic3d_ZLayerSettings.hxx>
-#include <OpenGl_Layer.hxx>
-
-class Graphic3d_Group;
-
-class VInspector_ItemOpenGlLayer;
-typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayer> VInspector_ItemOpenGlLayerPtr;
-
-//! \class VInspector_ItemOpenGlLayer
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemOpenGlLayer : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemOpenGlLayerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemOpenGlLayerPtr (new VInspector_ItemOpenGlLayer (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemOpenGlLayer() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; }
-
- //! Returns the current graphic3d group, init item if it was not initialized yet
- //! \return graphic group
- Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const
- { return Handle(OpenGl_Layer)::DownCast (GetObject());}
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-protected:
- //! Returns table presentation of layer settings
- QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) 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_ItemOpenGlLayer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(OpenGl_Layer) myLayer; //! current layer
- Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlWindow.hxx>
-
-//#include <inspector/VInspector_ItemOpenGlWindowList.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <Aspect.hxx>
-#include <Graphic3d.hxx>
-#include <OpenGl_Layer.hxx>
-#include <OpenGl_Group.hxx>
-#include <OpenGl_PrimitiveArray.hxx>
-#include <OpenGl_Text.hxx>
-#include <SelectMgr.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlWindow::Init()
-{
- //VInspector_ItemOpenGlWindowListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlWindowList>(Parent());
- //myLayer = aParentItem->GetLayer (Row(), myLayerId);
-
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlWindow::Reset()
-{
- VInspector_ItemBase::Reset();
- myLayer = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemOpenGlWindow::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemOpenGlWindow*>(this)->Init();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlWindow::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlWindow::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return Column() == 0 ? "Empty element" : "";
-
- switch (Column())
- {
- case 0:
- {
- TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId);
- if (aLayerId.IsEmpty())
- aLayerId = TCollection_AsciiString (myLayerId);
- return theItemRole == Qt::ToolTipRole ? QVariant ("")
- : QVariant (QString("%1 (%2)")
- .arg(aLayer->DynamicType()->Name())
- .arg (aLayerId.ToCString()));
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemOpenGlWindow::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlWindow::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(OpenGl_Layer) aLayer = GetLayer();
- if (aLayer.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures());
- case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled());
- case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities());
-
- case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size());
- case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled());
- case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects());
-
- case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size());
- case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size());
- case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size());
-
- default:
- break;
- }
-
- Standard_Integer aRow = theRow - 9;
- return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings());
-}
-
-// =======================================================================
-// function : getLayerSettingsTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemOpenGlWindow::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const
-{
- bool isFirstColumn = theColumn == 0;
-
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant();
- case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString());
- case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString());
-
- case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString());
- case 4: return isFirstColumn ? QVariant ("OriginTransformation")
- : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString());
-
- case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance());
- case 6: return isFirstColumn ? QVariant ("CullingDistance")
- : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0);
-
- case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize());
- case 8: return isFirstColumn ? QVariant ("CullingSize")
- : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0);
-
- case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate());
- case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture());
- case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest());
- case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite());
- case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth());
- case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass());
-
- case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
- : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode));
- case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor);
- case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units);
-
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemOpenGlWindow::createChild (int theRow, int theColumn)
-{
- (void)theRow;
- (void)theColumn;
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-03-15
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemOpenGlWindow_H
-#define VInspector_ItemOpenGlWindow_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Graphic3d_ZLayerSettings.hxx>
-#include <OpenGl_Layer.hxx>
-
-class Graphic3d_Group;
-
-class VInspector_ItemOpenGlWindow;
-typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlWindow> VInspector_ItemOpenGlWindowPtr;
-
-//! \class VInspector_ItemOpenGlWindow
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemOpenGlWindow : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemOpenGlWindowPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemOpenGlWindowPtr (new VInspector_ItemOpenGlWindow (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemOpenGlWindow() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; }
-
- //! Returns the current graphic3d group, init item if it was not initialized yet
- //! \return graphic group
- Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const
- { return Handle(OpenGl_Layer)::DownCast (GetObject());}
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It creates a backup of the specific item information
- //! Do nothing as context has been already set into item
- virtual void initItem() const Standard_OVERRIDE;
-
- //! 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;
-
-protected:
- //! Returns table presentation of layer settings
- QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
- const Graphic3d_ZLayerSettings& theSettings) const;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) 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_ItemOpenGlWindow(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
- Handle(OpenGl_Layer) myLayer; //! current layer
- Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View
-};
-
-#endif
#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <AIS.hxx>
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <Aspect.hxx>
-
#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_ItemPresentations.hxx>
-#include <inspector/VInspector_ItemSelectMgrSelection.hxx>
+#include <inspector/VInspector_ItemEntityOwner.hxx>
+#include <inspector/VInspector_ItemSelection.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
-#include <inspector/ViewControl_ColorSelector.hxx>
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Graphic3d.hxx>
#include <NCollection_List.hxx>
#include <Prs3d.hxx>
#include <Prs3d_Drawer.hxx>
-#include <PrsMgr.hxx>
-#include <SelectBasics_EntityOwner.hxx>
+#include <SelectMgr_EntityOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <Standard_Version.hxx>
// =======================================================================
QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
+ if (Column() == 20 && theItemRole == Qt::BackgroundRole) {
+ Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
+ if (!anIO.IsNull() && anIO->HasColor())
+ {
+ Quantity_Color aColor;
+ anIO->Color(aColor);
+ return QColor ((int)(aColor.Red()*255.), (int)(aColor.Green()*255.), (int)(aColor.Blue()*255.));
+ }
+ }
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (anIO->DynamicType()->Name());
}
+ case 1:
+ return rowCount();
+ case 2:
+ {
+ if (!aNullIO)
+ return VInspector_Tools::GetPointerInfo (anIO, true).ToCString();
+ break;
+ }
+ case 3:
+ {
+ Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
+ if (!aShapeIO.IsNull())
+ {
+ const TopoDS_Shape& aShape = aShapeIO->Shape();
+ if (!aShape.IsNull())
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ break;
+ }
case 4:
{
int aNbSelected = VInspector_Tools::SelectedOwners (GetContext(), anIO, false);
return aNbSelected > 0 ? QString::number (aNbSelected) : "";
}
+ case 5:
+ {
+ TColStd_ListOfInteger aModes;
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ aContext->ActivatedModes(anIO, aModes);
+ TCollection_AsciiString aModesInfo;
+ for (TColStd_ListIteratorOfListOfInteger itr (aModes); itr.More(); itr.Next())
+ {
+ if (!aModesInfo.IsEmpty())
+ aModesInfo += ", ";
+ aModesInfo += VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType(itr.Value()));
+ }
+ return aModesInfo.ToCString();
+ }
+ break;
case 6:
{
double aDeviationCoefficient = 0;
}
return QString::number(aDeviationCoefficient);
}
+ case 7:
+ {
+ double aShapeDeflection = 0;
+ Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
+ if (!aShapeIO.IsNull())
+ {
+ const TopoDS_Shape& aShape = aShapeIO->Shape();
+ if (!aShape.IsNull())
+ aShapeDeflection = Prs3d::GetDeflection(aShape, anIO->Attributes());
+ }
+ return QString::number (aShapeDeflection);
+ }
case 8:
{
double aDeviationCoefficient = 0;
bool anIsAutoTriangulation = aNullIO ? false : anIO->Attributes()->IsAutoTriangulation();
return anIsAutoTriangulation ? QString ("true") : QString ("false");
}
+ case 17:
+ case 18:
+ case 19:
+ {
+ Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
+ if (aShapeIO.IsNull())
+ return QVariant();
+ const TopoDS_Shape& aShape = aShapeIO->Shape();
+ if (aShape.IsNull())
+ return QVariant();
+
+ return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
+ : Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
+ : /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
+ }
default: break;
}
}
// =======================================================================
int VInspector_ItemPresentableObject::initRowCount() const
{
- if (Column() != 0)
- return 0;
-
- int aNbProperties = 2; // "Properties", "Presentations"
-
Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
#if OCC_VERSION_HEX < 0x070201
int aRows = 0;
// iteration through sensitive privitives
for (anIO->Init(); anIO->More(); anIO->Next())
aRows++;
- int aNbSelected = aRows;
+ return aRows;
#else
- int aNbSelected = !anIO.IsNull() ? anIO->Selections().Size() : 0;
+ return !anIO.IsNull()
+ ? anIO->Selections().Size()
+ : 0;
#endif
-
- return aNbProperties + aNbSelected;
}
// =======================================================================
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemPresentableObject::createChild (int theRow, int theColumn)
{
- if (theRow == 0)
- return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
- if (theRow == 1)
- return VInspector_ItemPresentations::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemSelectMgrSelection::CreateItem(currentItem(), theRow, theColumn);
+ return VInspector_ItemSelection::CreateItem(currentItem(), theRow, theColumn);
}
// =======================================================================
}
setInteractiveObject (anIO);
- myTransformPersistence = anIO->TransformPersistence();
- UpdatePresentationShape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
SetContext (NULL);
setInteractiveObject (NULL);
- myTransformPersistence = NULL;
}
// =======================================================================
}
// =======================================================================
-// function : buildPresentationShape
+// function : GetInteractiveObject
// purpose :
// =======================================================================
-TopoDS_Shape VInspector_ItemPresentableObject::buildPresentationShape()
+Handle(AIS_InteractiveObject) VInspector_ItemPresentableObject::GetInteractiveObject() const
{
- Handle(AIS_InteractiveObject) aPrs = myIO;
- if (aPrs.IsNull())
- return TopoDS_Shape();
-
- Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs);
- if (!aShapePrs.IsNull())
- return aShapePrs->Shape();
-
- return TopoDS_Shape();
+ initItem();
+ return myIO;
}
// =======================================================================
}
// =======================================================================
-// function : GetPresentations
-// purpose :
-// =======================================================================
-void VInspector_ItemPresentableObject::GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
-{
- if (Column() != 0)
- return;
-
- thePresentations.Append (GetInteractiveObject());
-}
-
-// =======================================================================
-// function : GetStream
-// purpose :
-// =======================================================================
-void VInspector_ItemPresentableObject::GetStream (Standard_OStream& OS) const
-{
- Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
- if (anIO.IsNull())
- return;
-
- anIO->Dump (OS);
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemPresentableObject::GetTableRowCount() const
-{
- return 36;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemPresentableObject::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- case 3: return ViewControl_EditType_Combo;
- case 6: return ViewControl_EditType_Combo;
- case 8: return ViewControl_EditType_Bool;
- case 13: return ViewControl_EditType_Color;
- case 15: return ViewControl_EditType_Line;
- case 17: return ViewControl_EditType_Combo;
- case 18: return ViewControl_EditType_Line;
-
- case 29: return ViewControl_EditType_Combo;
- case 30: return ViewControl_EditType_Bool;
- case 32: return ViewControl_EditType_Combo;
- case 35: return ViewControl_EditType_Bool;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemPresentableObject::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 3:
- {
- for (int i = 0; i <= AIS_KOI_Dimension; i++)
- aValues.append (AIS::KindOfInteractiveToString((AIS_KindOfInteractive)i));
- }
- break;
- case 6:
- {
- for (int i = 0; i <= Aspect_TOFM_FRONT_SIDE; i++)
- aValues.append (Aspect::TypeOfFacingModelToString((Aspect_TypeOfFacingModel)i));
- }
- break;
- case 17:
- {
- for (int i = 0; i <= Graphic3d_NOM_UserDefined; i++)
- aValues.append (Graphic3d::NameOfMaterialToString ((Graphic3d_NameOfMaterial)i));
- }
- break;
- case 29:
- {
- for (int i = 0; i <= PrsMgr_TOP_ProjectorDependant; i++)
- aValues.append (PrsMgr::TypeOfPresentation3dToString ((PrsMgr_TypeOfPresentation3d)i));
- }
- break;
- case 32:
- {
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_UNKNOWN));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Default));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Top));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Topmost));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_TopOSD));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_BotOSD));
- }
- break;
- default: break;
- }
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
+// function : GetSelectedPresentations
// purpose :
// =======================================================================
-QVariant VInspector_ItemPresentableObject::GetTableData (const int theRow, const int theColumn, const int theRole) const
+NCollection_List<Handle(AIS_InteractiveObject)> VInspector_ItemPresentableObject::GetSelectedPresentations
+ (QItemSelectionModel* theSelectionModel)
{
- bool isFirstColumn = theColumn == 0;
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || theRow != 13)))
- return QVariant();
-
- Handle(AIS_InteractiveObject) aPrs = GetInteractiveObject();
- switch (theRow)
+ NCollection_List<Handle(AIS_InteractiveObject)> aResultList;
+ if (!theSelectionModel)
+ return aResultList;
+
+ QList<TreeModel_ItemBasePtr> anItems;
+
+ QModelIndexList anIndices = theSelectionModel->selectedIndexes();
+ for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
{
- case 0: return ViewControl_Table::SeparatorData();
- case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (AIS_InteractiveObject)->Name())
- : ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
- case 2: return ViewControl_Table::SeparatorData();
- case 3: return isFirstColumn ? QVariant("Type")
- : QVariant (AIS::KindOfInteractiveToString (aPrs->Type()));
- case 4: return isFirstColumn ? QVariant("Signature") : QVariant (aPrs->Signature());
-
- case 5: return isFirstColumn ? QVariant("AcceptShapeDecomposition") : QVariant (aPrs->AcceptShapeDecomposition());
- case 6: return isFirstColumn ? QVariant ("CurrentFacingModel")
- : QVariant (Aspect::TypeOfFacingModelToString (aPrs->CurrentFacingModel()));
- case 7: return isFirstColumn ? QVariant ("DefaultDisplayMode") : QVariant (aPrs->DefaultDisplayMode());
- case 8: return isFirstColumn ? QVariant ("IsInfinite") : QVariant (aPrs->IsInfinite());
- case 9: return isFirstColumn ? QVariant ("Owner")
- : (aPrs->GetOwner().IsNull() ? QVariant("") : ViewControl_Tools::GetPointerInfo (aPrs).ToCString());
- case 10: return isFirstColumn ? QVariant ("DisplayMode") : QVariant (aPrs->DisplayMode());
- case 11: return isFirstColumn ? QVariant ("HilightMode") : QVariant (aPrs->HilightMode());
-
- case 12: return isFirstColumn ? QVariant ("HasColor") : QVariant (aPrs->HasColor());
- case 13:
- {
- if (isFirstColumn)
- return QVariant ("Color");
- Quantity_Color aColor;
- aPrs->Color(aColor);
- return ViewControl_ColorSelector::ColorToQColor (aColor);
- }
- case 14: return isFirstColumn ? QVariant ("HasWidth") : QVariant (aPrs->HasWidth());
- case 15: return isFirstColumn ? QVariant ("Width") : QVariant (aPrs->Width());
- case 16: return isFirstColumn ? QVariant ("HasMaterial") : QVariant (aPrs->HasMaterial());
- case 17: return isFirstColumn ? QVariant ("Material")
- : QVariant (Graphic3d::NameOfMaterialToString (aPrs->Material()));
- case 18: return isFirstColumn ? QVariant ("Transparency") : QVariant (aPrs->Transparency());
- case 19:
- {
- if (isFirstColumn)
- return QVariant ("PolygonOffsets");
- Standard_Integer aMode;
- Standard_ShortReal aFactor, aUnits;
- aPrs->PolygonOffsets (aMode, aFactor, aUnits);
- return QString("Mode: %1, Factor: %2, Units: %3").arg (aMode).arg (aFactor).arg (aUnits);
- }
- case 20: return ViewControl_Table::SeparatorData();
- case 21: return isFirstColumn ? QVariant (STANDARD_TYPE (SelectMgr_SelectableObject)->Name())
- : ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
- case 22: return ViewControl_Table::SeparatorData();
- case 23: return isFirstColumn ? QVariant ("IsAutoHilight") : QVariant (aPrs->IsAutoHilight());
- case 24: return isFirstColumn ? QVariant ("GlobalSelectionMode") : QVariant (aPrs->GlobalSelectionMode());
- case 25:
- {
- if (isFirstColumn)
- return QVariant ("BoundingBox");
- Bnd_Box aBndBox;
- aPrs->BoundingBox (aBndBox);
- return ViewControl_Tools::ToString (aBndBox).ToCString();
- }
- case 26: return ViewControl_Table::SeparatorData();
- case 27: return isFirstColumn ? QVariant (STANDARD_TYPE (PrsMgr_PresentableObject)->Name())
- : ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
- case 28: return ViewControl_Table::SeparatorData();
- case 29: return isFirstColumn ? QVariant ("TypeOfPresentation3d")
- : QVariant (PrsMgr::TypeOfPresentation3dToString (aPrs->TypeOfPresentation3d()));
- case 30: return isFirstColumn ? QVariant ("IsMutable") : QVariant (aPrs->IsMutable());
- case 31: return isFirstColumn ? QVariant ("HasOwnPresentations") : QVariant (aPrs->HasOwnPresentations());
- case 32: return isFirstColumn ? QVariant ("ZLayer") : QVariant (Graphic3d::ZLayerIdToString (aPrs->ZLayer()));
- case 33: return isFirstColumn ? QVariant ("TransformationGeom")
- : QVariant (ViewControl_Tools::ToString(aPrs->TransformationGeom()).ToCString());
- case 34: return isFirstColumn ? QVariant ("LocalTransformationGeom")
- : (!aPrs->LocalTransformationGeom().IsNull()
- ? QVariant (ViewControl_Tools::ToString(aPrs->LocalTransformationGeom()->Trsf()).ToCString()) : QVariant());
- case 35: return isFirstColumn ? QVariant ("ResetTransformation") : (!aPrs->LocalTransformationGeom().IsNull());
- default: return QVariant();
+ TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
+ if (!anItem || anItems.contains (anItem))
+ continue;
+ anItems.append (anItem);
}
-}
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemPresentableObject::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(AIS_InteractiveObject) aPrs = GetInteractiveObject();
- switch (theRow)
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
{
- case 6: aPrs->SetCurrentFacingModel (Aspect::TypeOfFacingModelFromString (theValue.toString().toStdString().c_str())); break;
- case 8: aPrs->SetInfiniteState (theValue.toBool()); break;
- case 15:
- {
- double aValue = theValue.toDouble();
- if (aValue > 0) aPrs->SetWidth (aValue);
- else aPrs->UnsetWidth();
- }
- break;
- case 13:
- {
- float anAlpha;
- aPrs->SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString(), anAlpha));
- }
- break;
- case 17: aPrs->SetMaterial (Graphic3d::NameOfMaterialFromString (theValue.toString().toStdString().c_str())); break;
- case 18:
- {
- double aValue = theValue.toDouble();
- if (aValue > 0 && aValue < 1)
- aPrs->SetTransparency(theValue.toDouble());
- }
- break;
- case 23: aPrs->SetAutoHilight(theValue.toBool()); break;
- case 29: aPrs->SetTypeOfPresentation (PrsMgr::TypeOfPresentation3dFromString (theValue.toString().toStdString().c_str())); break;
- case 30: aPrs->SetMutable (theValue.toBool()); break;
- case 32: aPrs->SetZLayer (Graphic3d::ZLayerIdFromString (theValue.toString().toStdString().c_str())); break;
- case 35: if (!theValue.toBool()) aPrs->ResetTransformation(); break;
- default: return false;
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ VInspector_ItemPresentableObjectPtr aPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(anItem);
+ if (!aPrsItem)
+ continue;
+ Handle(AIS_InteractiveObject) aPresentation = aPrsItem->GetInteractiveObject();
+ if (aSelectedIds.contains ((size_t)aPresentation.operator->()))
+ continue;
+ aSelectedIds.append ((size_t)aPresentation.operator->());
+ if (!aPresentation.IsNull())
+ aResultList.Append (aPresentation);
}
- return true;
+ return aResultList;
}
//! Destructor
virtual ~VInspector_ItemPresentableObject() Standard_OVERRIDE {};
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myIO; }
-
//! Returns the current interactive object, init item if it was not initialized yet
//! \return interactive object
- Standard_EXPORT Handle(AIS_InteractiveObject) GetInteractiveObject() const
- { return Handle(AIS_InteractiveObject)::DownCast (GetObject()); }
+ Standard_EXPORT Handle(AIS_InteractiveObject) GetInteractiveObject() const;
//! Returns pointer information for the current interactive object, init item if it was not initialized yet
//! \return string value
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
- //! Returns presentation of the attribute to be visualized in the view
- //! \thePresentations [out] container of presentation handles to be visualized
- Standard_EXPORT virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
-
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
+ //! Returns presentations, which items are selected in tree view
+ //! \param theSelectionModel a selection model
+ //! \return container of presentations
+ Standard_EXPORT static NCollection_List<Handle(AIS_InteractiveObject)> GetSelectedPresentations
+ (QItemSelectionModel* theSelectionModel);
protected:
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
+private:
//! Set interactive object into the current field
//! \param theIO a presentation
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemPresentations.hxx>
-
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemPrs3dPresentation.hxx>
-
-#include <AIS_InteractiveObject.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPresentations::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
- return QVariant();
-
- return "Presentations";
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemPresentations::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- VInspector_ItemPresentableObjectPtr aParentPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- if (!aParentPrsItem)
- return 0;
-
- Handle(AIS_InteractiveObject) aPresentation = aParentPrsItem->GetInteractiveObject();
-
- int aNbProperties = 0;
- if (!aPresentation->GetSelectPresentation (GetContext()->MainPrsMgr()).IsNull())
- aNbProperties++;
-
- if (!aPresentation->GetHilightPresentation (GetContext()->MainPrsMgr()).IsNull())
- aNbProperties++;
-
- for (PrsMgr_Presentations::Iterator aPrsIter (aPresentation->Presentations()); aPrsIter.More(); aPrsIter.Next())
- {
- const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
- if (!aPrs3d.IsNull())
- aNbProperties++;
- }
- return aNbProperties;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemPresentations::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemPrs3dPresentation::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemPresentations::Init()
-{
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemPresentations::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemPresentations::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemPresentations*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetPresentation
-// purpose :
-// =======================================================================
-Handle(Prs3d_Presentation) VInspector_ItemPresentations::GetPresentation (const int theRowId,
- TCollection_AsciiString& theName) const
-{
- VInspector_ItemPresentableObjectPtr aParentPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- if (!aParentPrsItem)
- return 0;
-
- Handle(AIS_InteractiveObject) aPresentation = aParentPrsItem->GetInteractiveObject();
-
- bool aHasSelectedPresentation = !aPresentation->GetSelectPresentation (NULL).IsNull();
- if (aHasSelectedPresentation && theRowId == 0)
- {
- theName = "SelectPresentation";
- return aPresentation->GetSelectPresentation (NULL);
- }
-
- bool aHasHilightPresentation = !aPresentation->GetHilightPresentation (NULL).IsNull();
- if (aHasHilightPresentation && ((aHasSelectedPresentation && theRowId == 1) || !aHasSelectedPresentation && theRowId == 0))
- {
- theName = "HilightPresentation";
- return aPresentation->GetHilightPresentation (NULL);
- }
-
- int aNextPresentationIndex = aHasSelectedPresentation ? 1 : 0;
- if (aHasHilightPresentation)
- aNextPresentationIndex++;
-
- int aCurrentIndex = 0;
- for (PrsMgr_Presentations::Iterator aPrsIter (aPresentation->Presentations()); aPrsIter.More(); aPrsIter.Next())
- {
- const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue();
- if (aPrs3d.IsNull())
- continue;
- if (theRowId - aNextPresentationIndex == aCurrentIndex)
- {
- theName = "Prs3d_Presentation";
- return aPrs3d;
- }
- aCurrentIndex++;
- }
- return Handle(Prs3d_Presentation)();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemPresentations_H
-#define VInspector_ItemPresentations_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <Prs3d_Presentation.hxx>
-
-class VInspector_ItemPresentations;
-typedef QExplicitlySharedDataPointer<VInspector_ItemPresentations> VInspector_ItemPresentationsPtr;
-
-//! \class VInspector_ItemPresentations
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspector_ItemPresentations : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemPresentationsPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemPresentationsPtr (new VInspector_ItemPresentations (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemPresentations() Standard_OVERRIDE {};
-
- //! Returns presentation of the parent interactive object
- //! \return presentation object
- Standard_EXPORT Handle(Prs3d_Presentation) GetPresentation (const int theRowId, TCollection_AsciiString& theName) const;
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemPresentations(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-26
-// 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_ItemPrs3dAspect.hxx>
-#include <inspector/VInspector_ItemPrs3dDrawer.hxx>
-#include <inspector/ViewControl_ColorSelector.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Aspect.hxx>
-#include <Font.hxx>
-#include <Graphic3d.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-#include <Prs3d.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DatumAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_IsoAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_PlaneAspect.hxx>
-#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Prs3d_TextAspect.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-int GetMaterialRows() { return 25; }
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-
-QVariant VInspector_ItemPrs3dAspect::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
- {
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- bool aNullAspect = anAspect.IsNull();
- switch (Column())
- {
- case 0:
- {
- return theItemRole == Qt::ToolTipRole
- ? (aNullAspect ? QVariant("Prs3d_BasicAspect is empty") : QVariant (anAspect->DynamicType()->Name()))
- : QVariant (myName.ToCString());
- }
- default: break;
- }
- }
- if (theItemRole == Qt::ForegroundRole)
- {
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- bool aNullAspect = anAspect.IsNull();
- if (aNullAspect) return QColor (Qt::lightGray);
-
- VInspector_ItemPrs3dDrawerPtr aParentItem = itemDynamicCast<VInspector_ItemPrs3dDrawer>(Parent());
- if (aParentItem)
- {
- Handle(Prs3d_Drawer) aDrawer = aParentItem->GetDrawer();
- if (aDrawer->Link().IsNull())
- return QVariant(); // default color
-
- TCollection_AsciiString aName;
- Standard_Boolean isOwnAspect;
- aParentItem->GetPrs3dAspect(Row(), aName, isOwnAspect);
- if (!isOwnAspect)
- return QColor (Qt::lightGray);
- }
- else
- {
- VInspector_ItemPrs3dAspectPtr aParentAspectItem = itemDynamicCast<VInspector_ItemPrs3dAspect>(Parent());
- if (aParentAspectItem)
- return aParentAspectItem->initValue (theItemRole);
- }
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-
-int VInspector_ItemPrs3dAspect::initRowCount() const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return 0;
-
- Standard_CString anAspectKind = anAspect->DynamicType()->Name();
- if (anAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- return 3 + 2 * (int) Prs3d_DP_None;
- else if (anAspectKind == STANDARD_TYPE (Prs3d_PlaneAspect)->Name())
- return 3;
- else if (anAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- return 3;
-
- return 0;
-}
-
-// =======================================================================
-// function : GetStream
-// purpose :
-// =======================================================================
-void VInspector_ItemPrs3dAspect::GetStream (Standard_OStream& OS) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return;
-
- anAspect->Dump (OS);
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-
-TreeModel_ItemBasePtr VInspector_ItemPrs3dAspect::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemPrs3dAspect::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemPrs3dAspect::Init()
-{
- TCollection_AsciiString aName;
- Handle(Prs3d_BasicAspect) anAspect;
- VInspector_ItemPrs3dDrawerPtr aParentItem = itemDynamicCast<VInspector_ItemPrs3dDrawer>(Parent());
-
- if (aParentItem)
- {
- Standard_Boolean isOwnAspect;
- anAspect = aParentItem->GetPrs3dAspect(Row(), aName, isOwnAspect);
- }
- else
- {
- VInspector_ItemPrs3dAspectPtr aParentAspectItem = itemDynamicCast<VInspector_ItemPrs3dAspect>(Parent());
- Standard_Boolean isOwnAspect;
- anAspect = aParentAspectItem->GetPrs3dAspect(Row(), aName, isOwnAspect);
- }
-
- setAspect(anAspect, aName);
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemPrs3dAspect::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setAspect (NULL, TCollection_AsciiString());
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemPrs3dAspect::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemPrs3dAspect*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetPrs3dAspect
-// purpose :
-// =======================================================================
-
-Handle(Prs3d_BasicAspect) VInspector_ItemPrs3dAspect::GetPrs3dAspect (const int theRow,
- TCollection_AsciiString& theName,
- Standard_Boolean& theOwnAspect) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return 0;
-
- Standard_CString anAspectKind = anAspect->DynamicType()->Name();
- theOwnAspect = true;
- if (anAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- {
- Handle(Prs3d_DatumAspect) aCustomAspect = Handle(Prs3d_DatumAspect)::DownCast (anAspect);
- switch (theRow) {
- case 0: theName = "TextAspect"; return aCustomAspect->TextAspect();
- case 1: theName = "PointAspect"; return aCustomAspect->PointAspect();
- case 2: theName = "ArrowAspect"; return aCustomAspect->ArrowAspect();
- default:
- {
- if (theRow >= 3 && theRow < 3 + Prs3d_DP_None)
- {
- Prs3d_DatumParts aParts = (Prs3d_DatumParts)(theRow - 3);
- theName = TCollection_AsciiString ("LineAspect: ") + Prs3d::DatumPartsToString (aParts);
- return aCustomAspect->LineAspect (aParts);
- }
-
- if (theRow >= 3 + Prs3d_DP_None && theRow < 3 + 2 * Prs3d_DP_None)
- {
- Prs3d_DatumParts aParts = (Prs3d_DatumParts)(theRow - (3+ Prs3d_DP_None));
- theName = TCollection_AsciiString ("ShadingAspect: ") + Prs3d::DatumPartsToString (aParts);
- return aCustomAspect->ShadingAspect (aParts);
- }
- }
- break;
- }
- }
- else if (anAspectKind == STANDARD_TYPE (Prs3d_PlaneAspect)->Name())
- {
- Handle(Prs3d_PlaneAspect) aCustomAspect = Handle(Prs3d_PlaneAspect)::DownCast (anAspect);
- switch (theRow)
- {
- case 0: theName = "EdgesAspect"; return aCustomAspect->EdgesAspect();
- case 1: theName = "IsoAspect"; return aCustomAspect->IsoAspect();
- case 2: theName = "ArrowAspect"; return aCustomAspect->ArrowAspect();
- }
- }
- else if (anAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- {
- Handle(Prs3d_DimensionAspect) aCustomAspect = Handle(Prs3d_DimensionAspect)::DownCast (anAspect);
- switch (theRow)
- {
- case 0: theName = "LineAspect"; return aCustomAspect->LineAspect();
- case 1: theName = "TextAspect"; return aCustomAspect->TextAspect();
- case 2: theName = "ArrowAspect"; return aCustomAspect->ArrowAspect();
- }
- }
-
- theName = "None";
- return Handle(Prs3d_BasicAspect)();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemPrs3dAspect::GetTableRowCount() const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return 0;
-
- return getTableRowCount (anAspect->DynamicType()->Name());
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemPrs3dAspect::GetTableEditType (const int theRow, const int) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return ViewControl_EditType_None;
-
- return getTableEditType (theRow, anAspect->DynamicType()->Name(), 0);
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemPrs3dAspect::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return aValues;
-
- return getTableEnumValues (theRow, anAspect->DynamicType()->Name(), 0);
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dAspect::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return QVariant();
-
- return getTableData (theRow, theColumn, theRole, anAspect->DynamicType()->Name(), 0);
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemPrs3dAspect::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return false;
-
- return setTableData (theRow, anAspect->DynamicType()->Name(), 0, theValue);
-}
-
-
-// =======================================================================
-// function : getTableRowCount
-// purpose :
-// =======================================================================
-
-int VInspector_ItemPrs3dAspect::getTableRowCount (const TCollection_AsciiString& theAspectKind) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return 0;
-
- if (theAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- return 3 + (Prs3d_DP_ShadingNumberOfFacettes + 1);
- else if (theAspectKind == STANDARD_TYPE (Prs3d_IsoAspect)->Name())
- return 1 + getTableRowCount (STANDARD_TYPE (Prs3d_LineAspect)->Name());
- else if (theAspectKind == STANDARD_TYPE (Prs3d_LineAspect)->Name())
- return 4; // TODO: add Graphic3d_ShaderProgram
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PointAspect)->Name())
- return 3; // TODO: add Graphic3d_ShaderProgram, Graphic3d_MarkerImage
- else if (theAspectKind == STANDARD_TYPE (Prs3d_TextAspect)->Name())
- return 15; // TODO: add Graphic3d_ShaderProgram
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PlaneAspect)->Name())
- return 10;
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ArrowAspect)->Name())
- return 2 + 3; // TODO: add Graphic3d_ShaderProgram
- else if (theAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- return 10;
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ShadingAspect)->Name())
- return 17 + 2 * GetMaterialRows(); // TODO: Graphic3d_ShaderProgram, Graphic3d_TextureSet, Graphic3d_MaterialAspect
-
- return 0;
-}
-
-// =======================================================================
-// function : getTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemPrs3dAspect::getTableEditType (const int theRow,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return ViewControl_EditType_None;
-
- int aRow = theRow - theStartRow;
- if (theAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Combo;
- case 1: return ViewControl_EditType_Bool;
- case 2: return ViewControl_EditType_Bool;
- default:
- {
- if (theRow >= 3 && theRow <= 3 + Prs3d_DP_ShadingNumberOfFacettes)
- return ViewControl_EditType_Double;
- break;
- }
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_IsoAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Spin;
- default: return getTableEditType (theRow, STANDARD_TYPE (Prs3d_LineAspect)->Name(), 1);
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_LineAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_None;
- case 1: return ViewControl_EditType_Color;
- case 2: return ViewControl_EditType_Combo;
- case 3: return ViewControl_EditType_Double;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PointAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Color;
- case 1: return ViewControl_EditType_Combo;
- case 2: return ViewControl_EditType_Double;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_TextAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Double;
- case 1: return ViewControl_EditType_Double;
- case 2: return ViewControl_EditType_Combo;
- case 3: return ViewControl_EditType_Combo;
- case 4: return ViewControl_EditType_Combo;
- case 5: return ViewControl_EditType_Line;
- case 6: return ViewControl_EditType_Color;
- case 7: return ViewControl_EditType_Double;
- case 8: return ViewControl_EditType_Double;
- case 9: return ViewControl_EditType_Combo;
- case 10: return ViewControl_EditType_Combo;
- case 11: return ViewControl_EditType_Color;
- case 12: return ViewControl_EditType_Bool;
- case 13: return ViewControl_EditType_Double;
- case 14: return ViewControl_EditType_Combo;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PlaneAspect)->Name())
- {
- if (aRow >= 0 && aRow < 6 ) return ViewControl_EditType_Double;
- if (aRow >= 6 && aRow < 16 ) return ViewControl_EditType_Bool;
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ArrowAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Double;
- case 1: return ViewControl_EditType_Double;
-
- case 2: return ViewControl_EditType_Color;
- case 3: return ViewControl_EditType_Combo;
- case 4: return ViewControl_EditType_Double;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Line;
- case 1: return ViewControl_EditType_Double;
- case 2: return ViewControl_EditType_Double;
-
- case 3: return ViewControl_EditType_Combo;
- case 4: return ViewControl_EditType_Combo;
- case 5: return ViewControl_EditType_Combo;
-
- case 6: return ViewControl_EditType_Bool;
- case 7: return ViewControl_EditType_Bool;
- case 8: return ViewControl_EditType_Bool;
- case 9: return ViewControl_EditType_Bool;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ShadingAspect)->Name())
- {
- switch (aRow)
- {
- case 0: return ViewControl_EditType_Color;
- case 1: return ViewControl_EditType_Color;
- case 2: return ViewControl_EditType_Color;
-
- case 3: return ViewControl_EditType_Combo;
- case 4: return ViewControl_EditType_Combo;
- case 5: return ViewControl_EditType_Combo;
-
- case 6: return ViewControl_EditType_Double;
- case 7: return ViewControl_EditType_Combo;
- case 8: return ViewControl_EditType_Double;
- case 9: return ViewControl_EditType_Combo; // Graphic3d_HatchStyle is not modified
- case 10: return ViewControl_EditType_Combo;
- case 11: return ViewControl_EditType_Double;
- case 12: return ViewControl_EditType_Double;
-
- case 13: return ViewControl_EditType_Bool;
- case 14: return ViewControl_EditType_Bool;
- case 15: return ViewControl_EditType_Bool;
- case 16: return ViewControl_EditType_Bool;
- default: break;
- }
-
- Handle(Prs3d_ShadingAspect) aCustomAspect = Handle(Prs3d_ShadingAspect)::DownCast (anAspect);
- Handle(Graphic3d_AspectFillArea3d) aFillAreaAspect = aCustomAspect->Aspect();
-
- ViewControl_EditType aType = ViewControl_EditType_None;
- // front material
- aRow = aRow - 17;
- if (getTableEditTypeMaterial (aRow, aType))
- return aType;
-
- // back material
- aRow = aRow - GetMaterialRows();
- if (getTableEditTypeMaterial (aRow, aType))
- return aType;
- }
-
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : getTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemPrs3dAspect::getTableEnumValues (const int theRow,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow) const
-{
- QList<QVariant> aValues;
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return aValues;
-
- int aRow = theRow - theStartRow;
- if (theAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- {
- Handle(Prs3d_DatumAspect) aCustomAspect = Handle(Prs3d_DatumAspect)::DownCast (anAspect);
- if (aRow == 0)
- {
- for (int i = 0; i <= Prs3d_DA_XYZAxis; i++)
- aValues.append (Prs3d::DatumAxesToString ((Prs3d_DatumAxes)i));
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_IsoAspect)->Name())
- {
- Handle(Prs3d_IsoAspect) aCustomAspect = Handle(Prs3d_IsoAspect)::DownCast (anAspect);
- if (aRow > 0)
- return getTableEnumValues (theRow, STANDARD_TYPE (Prs3d_LineAspect)->Name(), 1);
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_LineAspect)->Name())
- {
- if (aRow == 2)
- {
- for (int i = 0; i <= Aspect_TOL_USERDEFINED; i++)
- aValues.append (Aspect::TypeOfLineToString ((Aspect_TypeOfLine)i));
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PointAspect)->Name())
- {
- if (aRow == 1)
- {
- for (int i = Aspect_TOM_EMPTY; i <= Aspect_TOM_USERDEFINED; i++)
- aValues.append (Aspect::TypeOfMarkerToString ((Aspect_TypeOfMarker)i));
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_TextAspect)->Name())
- {
- if (theRow == 2)
- {
- for (int i = Graphic3d_HTA_LEFT; i <= Graphic3d_HTA_RIGHT; i++)
- aValues.append (Graphic3d::HorizontalTextAlignmentToString ((Graphic3d_HorizontalTextAlignment)i));
- }
- else if (theRow == 3)
- {
- for (int i = Graphic3d_VTA_BOTTOM; i <= Graphic3d_VTA_TOPFIRSTLINE; i++)
- aValues.append (Graphic3d::VerticalTextAlignmentToString ((Graphic3d_VerticalTextAlignment)i));
- }
- else if (theRow == 4)
- {
- for (int i = Graphic3d_TP_UP; i <= Graphic3d_TP_RIGHT; i++)
- aValues.append (Graphic3d::TextPathToString ((Graphic3d_TextPath)i));
- }
- else if (theRow == 9)
- {
- for (int i = Aspect_TOST_NORMAL; i <= Aspect_TOST_ANNOTATION; i++)
- aValues.append (Aspect::TypeOfStyleTextToString ((Aspect_TypeOfStyleText)i));
- }
- else if (theRow == 10)
- {
- for (int i = Aspect_TODT_NORMAL; i <= Aspect_TODT_SHADOW; i++)
- aValues.append (Aspect::TypeOfDisplayTextToString ((Aspect_TypeOfDisplayText)i));
- }
- else if (theRow == 14)
- {
- for (int i = Font_FA_Undefined; i <= Font_FA_BoldItalic; i++)
- aValues.append (Font::FontAspectToString ((Font_FontAspect)i));
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ArrowAspect)->Name())
- {
- if (theRow == 0)
- {
- QList<QVariant> aValues;
- aValues << 0 << M_PI / 2.0 << 6;
- return aValues;
- }
- else if (aRow == 3)
- {
- for (int i = 0; i <= Aspect_TOL_USERDEFINED; i++)
- aValues.append (Aspect::TypeOfLineToString ((Aspect_TypeOfLine)i));
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- {
- if (aRow == 3)
- {
- for (int i = 0; i <= Prs3d_DAO_Fit; i++)
- aValues.append (Prs3d::DimensionArrowOrientationToString ((Prs3d_DimensionArrowOrientation)i));
- }
- if (aRow == 4)
- {
- for (int i = 0; i <= Prs3d_DTHP_Fit; i++)
- aValues.append (Prs3d::DimensionTextHorizontalPositionToString ((Prs3d_DimensionTextHorizontalPosition)i));
- }
- if (aRow == 5)
- {
- for (int i = 0; i <= Prs3d_DTVP_Center; i++)
- aValues.append (Prs3d::DimensionTextVerticalPositionToString ((Prs3d_DimensionTextVerticalPosition)i));
- }
- }
-
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ShadingAspect)->Name())
- {
- if (aRow == 3)
- {
- for (int i = 0; i <= Aspect_IS_POINT; i++)
- aValues.append (Aspect::InteriorStyleToString ((Aspect_InteriorStyle)i));
- }
- else if (aRow == 4)
- {
- for (int i = Graphic3d_TOSM_DEFAULT; i <= Graphic3d_TOSM_FRAGMENT; i++)
- aValues.append (Graphic3d::TypeOfShadingModelToString ((Graphic3d_TypeOfShadingModel)i));
- }
- else if (aRow == 5)
- {
- for (int i = Graphic3d_AlphaMode_BlendAuto; i <= Graphic3d_AlphaMode_Blend; i++)
- aValues.append (Graphic3d::AlphaModeToString ((Graphic3d_AlphaMode)i));
- }
- else if (aRow == 7)
- {
- for (int i = 0; i <= Aspect_TOL_USERDEFINED; i++)
- aValues.append (Aspect::TypeOfLineToString ((Aspect_TypeOfLine)i));
- }
- else if (aRow == 9) //Aspect_HatchStyle
- {
- for (int i = 0; i <= Aspect_HS_NB; i++)
- aValues.append (Aspect::HatchStyleToString ((Aspect_HatchStyle)i));
- }
- else if (aRow == 10) //Aspect_PolygonOffsetMode
- {
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_Off));
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_Fill));
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_Line));
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_Point));
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_All));
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_None));
- aValues.append (Aspect::PolygonOffsetModeToString (Aspect_POM_Mask));
- }
- }
-
- return aValues;
-}
-
-// =======================================================================
-// function : getTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dAspect::getTableData (const int theRow,
- const int theColumn,
- const int theRole,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- int aRow = theRow - theStartRow;
-
- if (theAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- {
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(Prs3d_DatumAspect) aCustomAspect = Handle(Prs3d_DatumAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("DatumAxes") : QVariant (Prs3d::DatumAxesToString (aCustomAspect->DatumAxes()));
- case 1: return isFirstColumn ? QVariant ("DrawLabels") : QVariant (aCustomAspect->ToDrawLabels());
- case 2: return isFirstColumn ? QVariant ("DrawArrows") : QVariant (aCustomAspect->ToDrawArrows());
- default:
- {
- if (theRow >= 3 && theRow <= 3 + Prs3d_DP_ShadingNumberOfFacettes)
- {
- Prs3d_DatumAttribute aType = (Prs3d_DatumAttribute)(theRow - 3);
- return isFirstColumn ? QVariant (Prs3d::DatumAttributeToString (aType))
- : ViewControl_Tools::ToVariant (aCustomAspect->Attribute (aType));
- }
- break;
- }
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_IsoAspect)->Name())
- {
- Handle(Prs3d_IsoAspect) aCustomAspect = Handle(Prs3d_IsoAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0:
- {
- if (theRole != Qt::DisplayRole) return QVariant();
- else return isFirstColumn ? QVariant ("Number") : QVariant (aCustomAspect->Number());
- }
- default: return getTableData (theRow, theColumn, theRole, STANDARD_TYPE (Prs3d_LineAspect)->Name(), 1);
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_LineAspect)->Name())
- {
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || aRow != 1)))
- return QVariant();
-
- Handle(Prs3d_LineAspect) aCustomAspect = Handle(Prs3d_LineAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("Aspect") :
- QVariant (ViewControl_Tools::GetPointerInfo (aCustomAspect->Aspect()).ToCString());
- case 1: return getColorData("ColorRGBA", aCustomAspect->Aspect()->ColorRGBA(), isFirstColumn, theRole);
- case 2: return isFirstColumn ? QVariant ("Type")
- : QVariant (Aspect::TypeOfLineToString (aCustomAspect->Aspect()->Type()));
- case 3: return isFirstColumn ? QVariant ("Width") : ViewControl_Tools::ToVariant (aCustomAspect->Aspect()->Width());
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PointAspect)->Name())
- {
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || aRow != 0)))
- return QVariant();
-
- Handle(Prs3d_PointAspect) aCustomAspect = Handle(Prs3d_PointAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return getColorData("ColorRGBA", aCustomAspect->Aspect()->ColorRGBA(), isFirstColumn, theRole);
- case 1: return isFirstColumn ? QVariant ("Type")
- : QVariant (Aspect::TypeOfMarkerToString (aCustomAspect->Aspect()->Type()));
- case 2: return isFirstColumn ? QVariant ("Scale") : ViewControl_Tools::ToVariant (aCustomAspect->Aspect()->Scale());
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_TextAspect)->Name())
- {
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || (aRow != 6 && theRow != 11))))
- return QVariant();
-
- Handle(Prs3d_TextAspect) aCustomAspect = Handle(Prs3d_TextAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("Angle") : ViewControl_Tools::ToVariant (aCustomAspect->Angle());
- case 1: return isFirstColumn ? QVariant ("Height") : ViewControl_Tools::ToVariant (aCustomAspect->Height());
- case 2: return isFirstColumn ? QVariant ("HorizontalJustification")
- : QVariant (Graphic3d::HorizontalTextAlignmentToString (aCustomAspect->HorizontalJustification()));
- case 3: return isFirstColumn ? QVariant ("VerticalJustification")
- : QVariant (Graphic3d::VerticalTextAlignmentToString (aCustomAspect->VerticalJustification()));
- case 4: return isFirstColumn ? QVariant ("Orientation") : QVariant (Graphic3d::TextPathToString (aCustomAspect->Orientation()));
- // Graphic3d_AspectText3d attributes
- case 5: return isFirstColumn ? QVariant ("Font") : QVariant (aCustomAspect->Aspect()->Font().ToCString());
- case 6: return getColorData("ColorRGBA", aCustomAspect->Aspect()->ColorRGBA(), isFirstColumn, theRole);
- //case 7: return isFirstColumn ? QVariant ("ExpansionFactor")
- // : ViewControl_Tools::ToVariant (aCustomAspect->Aspect()->ExpansionFactor());
- //case 8: return isFirstColumn ? QVariant ("Space")
- // : ViewControl_Tools::ToVariant (aCustomAspect->Aspect()->Space());
- case 9: return isFirstColumn ? QVariant ("Style")
- : QVariant (Aspect::TypeOfStyleTextToString (aCustomAspect->Aspect()->Style()));
- case 10: return isFirstColumn ? QVariant ("DisplayType")
- : QVariant (Aspect::TypeOfDisplayTextToString (aCustomAspect->Aspect()->DisplayType()));
- case 11: return getColorData("ColorSubTitleRGBA", aCustomAspect->Aspect()->ColorSubTitleRGBA(), isFirstColumn, theRole);
- case 12: return isFirstColumn ? QVariant ("TextZoomable") : QVariant (aCustomAspect->Aspect()->GetTextZoomable());
- case 13: return isFirstColumn ? QVariant ("TextAngle")
- : ViewControl_Tools::ToVariant (aCustomAspect->Aspect()->GetTextAngle());
- case 14: return isFirstColumn ? QVariant ("TextFontAspect")
- : QVariant (Font::FontAspectToString (aCustomAspect->Aspect()->GetTextFontAspect()));
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PlaneAspect)->Name())
- {
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(Prs3d_PlaneAspect) aCustomAspect = Handle(Prs3d_PlaneAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("ArrowsLength") : ViewControl_Tools::ToVariant (aCustomAspect->ArrowsLength());
- case 1: return isFirstColumn ? QVariant ("ArrowsSize") : ViewControl_Tools::ToVariant (aCustomAspect->ArrowsSize());
- case 2: return isFirstColumn ? QVariant ("ArrowsAngle") : ViewControl_Tools::ToVariant (aCustomAspect->ArrowsAngle());
- case 3: return isFirstColumn ? QVariant ("PlaneXLength") : ViewControl_Tools::ToVariant (aCustomAspect->PlaneXLength());
- case 4: return isFirstColumn ? QVariant ("PlaneYLength") : ViewControl_Tools::ToVariant (aCustomAspect->PlaneYLength());
- case 5: return isFirstColumn ? QVariant ("IsoDistance") : ViewControl_Tools::ToVariant (aCustomAspect->IsoDistance());
-
- case 6: return isFirstColumn ? QVariant ("DisplayCenterArrow") : aCustomAspect->DisplayCenterArrow();
- case 7: return isFirstColumn ? QVariant ("DisplayEdgesArrows") : aCustomAspect->DisplayEdgesArrows();
- case 8: return isFirstColumn ? QVariant ("DisplayEdges") : aCustomAspect->DisplayEdges();
- case 9: return isFirstColumn ? QVariant ("DisplayIso") : aCustomAspect->DisplayIso();
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ArrowAspect)->Name())
- {
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || aRow != 2)))
- return QVariant();
-
- Handle(Prs3d_ArrowAspect) aCustomAspect = Handle(Prs3d_ArrowAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("Angle") : ViewControl_Tools::ToVariant (aCustomAspect->Angle());
- case 1: return isFirstColumn ? QVariant ("Length") : ViewControl_Tools::ToVariant (aCustomAspect->Length());
- case 2: return getColorData("ColorRGBA", aCustomAspect->Aspect()->ColorRGBA(), isFirstColumn, theRole);
- case 3: return isFirstColumn ? QVariant ("Type")
- : QVariant (Aspect::TypeOfLineToString (aCustomAspect->Aspect()->Type()));
- case 4: return isFirstColumn ? QVariant ("Width") : ViewControl_Tools::ToVariant (aCustomAspect->Aspect()->Width());
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- {
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(Prs3d_DimensionAspect) aCustomAspect = Handle(Prs3d_DimensionAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("ValueStringFormat") : QVariant (aCustomAspect->ValueStringFormat().ToCString());
- case 1: return isFirstColumn ? QVariant ("ExtensionSize") : ViewControl_Tools::ToVariant (aCustomAspect->ExtensionSize());
- case 2: return isFirstColumn ? QVariant ("ArrowTailSize") : ViewControl_Tools::ToVariant (aCustomAspect->ArrowTailSize());
-
- case 3: return isFirstColumn ? QVariant ("ArrowOrientation")
- : QVariant (Prs3d::DimensionArrowOrientationToString (aCustomAspect->ArrowOrientation()));
- case 4: return isFirstColumn ? QVariant ("TextHorizontalPosition")
- : QVariant (Prs3d::DimensionTextHorizontalPositionToString (aCustomAspect->TextHorizontalPosition()));
- case 5: return isFirstColumn ? QVariant ("TextVerticalPosition")
- : QVariant (Prs3d::DimensionTextVerticalPositionToString (aCustomAspect->TextVerticalPosition()));
-
- case 6: return isFirstColumn ? QVariant ("IsUnitsDisplayed") : aCustomAspect->IsUnitsDisplayed();
- case 7: return isFirstColumn ? QVariant ("IsText3d") : aCustomAspect->IsText3d();
- case 8: return isFirstColumn ? QVariant ("IsTextShaded") : aCustomAspect->IsTextShaded();
- case 9: return isFirstColumn ? QVariant ("IsArrows3d") : aCustomAspect->IsArrows3d();
-
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ShadingAspect)->Name())
- {
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || (aRow != 0 && theRow != 1 && theRow != 2
- && !isColorMaterialRow (theRow)))))
- return QVariant();
-
- Handle(Prs3d_ShadingAspect) aCustomAspect = Handle(Prs3d_ShadingAspect)::DownCast (anAspect);
- Handle(Graphic3d_AspectFillArea3d) anAspect = aCustomAspect->Aspect();
- switch (aRow)
- {
- case 0: return getColorData("InteriorColorRGBA", anAspect->InteriorColorRGBA(), isFirstColumn, theRole);
- case 1: return getColorData("BackInteriorColorRGBA", anAspect->BackInteriorColorRGBA(), isFirstColumn, theRole);
- case 2: return getColorData("EdgeColorRGBA", anAspect->EdgeColorRGBA(), isFirstColumn, theRole);
- case 3: return isFirstColumn ? QVariant ("InteriorStyle")
- : QVariant (Aspect::InteriorStyleToString (anAspect->InteriorStyle()));
- case 4: return isFirstColumn ? QVariant ("ShadingModel")
- : QVariant (Graphic3d::TypeOfShadingModelToString (anAspect->ShadingModel()));
- case 5: return isFirstColumn ? QVariant ("AlphaMode")
- : QVariant (Graphic3d::AlphaModeToString (anAspect->AlphaMode()));
- case 6: return isFirstColumn ? QVariant ("AlphaCutoff") : ViewControl_Tools::ToVariant (anAspect->AlphaCutoff());
- case 7: return isFirstColumn ? QVariant ("EdgeLineType")
- : QVariant (Aspect::TypeOfLineToString (anAspect->EdgeLineType()));
- case 8: return isFirstColumn ? QVariant ("EdgeWidth") : ViewControl_Tools::ToVariant (anAspect->EdgeWidth());
- case 9: return isFirstColumn ? QVariant ("HatchStyle: Type")
- : (!anAspect->HatchStyle().IsNull() ? QVariant (Aspect::HatchStyleToString
- ((Aspect_HatchStyle)anAspect->HatchStyle()->HatchType())) : QVariant());
- case 10: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
- : QVariant (Aspect::PolygonOffsetModeToString (anAspect->PolygonOffset().Mode));
- case 11: return isFirstColumn ? QVariant ("PolygonOffset: Factor")
- : ViewControl_Tools::ToVariant (anAspect->PolygonOffset().Factor);
- case 12: return isFirstColumn ? QVariant ("PolygonOffset: Units")
- : ViewControl_Tools::ToVariant (anAspect->PolygonOffset().Units);
- case 13: return isFirstColumn ? QVariant ("Distinguish") : anAspect->Distinguish();
- case 14: return isFirstColumn ? QVariant ("ToDrawEdges") : anAspect->ToDrawEdges();
- case 15: return isFirstColumn ? QVariant ("ToSuppressBackFaces") : anAspect->ToSuppressBackFaces();
- case 16: return isFirstColumn ? QVariant ("ToMapTexture") : anAspect->ToMapTexture();
- default: break;
- }
- // front material
- aRow = aRow - 17;
- const Graphic3d_MaterialAspect& aFrontMaterial = anAspect->FrontMaterial();
- QVariant aValue = getMaterialValue (aRow, theColumn, theRole, aFrontMaterial, "FrontMaterial");
- if (aValue.isValid())
- return aValue;
-
- // back material
- aRow = aRow - GetMaterialRows();
- const Graphic3d_MaterialAspect& aBackMaterial = anAspect->BackMaterial();
- aValue = getMaterialValue (aRow, theColumn, theRole, aBackMaterial, "BackMaterial");
- if (aValue.isValid())
- return aValue;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : setTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemPrs3dAspect::setTableData (const int theRow,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow,
- const QVariant& theValue) const
-{
- Handle(Prs3d_BasicAspect) anAspect = GetAspect();
- if (anAspect.IsNull())
- return false;
-
- int aRow = theRow - theStartRow;
- if (theAspectKind == STANDARD_TYPE (Prs3d_DatumAspect)->Name())
- {
- Handle(Prs3d_DatumAspect) aCustomAspect = Handle(Prs3d_DatumAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: aCustomAspect->SetDrawDatumAxes (Prs3d::DatumAxesFromString (theValue.toString().toStdString().c_str())); break;
- case 1: aCustomAspect->SetDrawLabels (theValue.toBool()); break;
- case 2: aCustomAspect->SetDrawArrows (theValue.toBool()); break;
- default:
- {
- if (theRow >= 3 && theRow <= 3 + Prs3d_DP_ShadingNumberOfFacettes)
- {
- Prs3d_DatumAttribute aType = (Prs3d_DatumAttribute)(theRow - 3);
- aCustomAspect->SetAttribute (aType, ViewControl_Tools::ToRealValue (theValue));
- }
- break;
- }
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_IsoAspect)->Name())
- {
- Handle(Prs3d_IsoAspect) aCustomAspect = Handle(Prs3d_IsoAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: aCustomAspect->SetNumber(theValue.toInt()); break;
- default: setTableData (theRow, STANDARD_TYPE (Prs3d_LineAspect)->Name(), 1, theValue); break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_LineAspect)->Name())
- {
- Handle(Prs3d_LineAspect) aCustomAspect = Handle(Prs3d_LineAspect)::DownCast (anAspect);
- Handle(Graphic3d_AspectLine3d) anAspect = aCustomAspect->Aspect();
- switch (aRow)
- {
- case 0: break;
- case 1: anAspect->SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 2: anAspect->SetType (Aspect::TypeOfLineFromString (theValue.toString().toStdString().c_str())); break;
- case 3: anAspect->SetWidth (ViewControl_Tools::ToShortRealValue (theValue)); break;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PointAspect)->Name())
- {
- Handle(Prs3d_PointAspect) aCustomAspect = Handle(Prs3d_PointAspect)::DownCast (anAspect);
- Handle(Graphic3d_AspectMarker3d) anAspect = aCustomAspect->Aspect();
- switch (aRow)
- {
- case 0: anAspect->SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 1: anAspect->SetType (Aspect::TypeOfMarkerFromString (theValue.toString().toStdString().c_str())); break;
- case 2: anAspect->SetScale (ViewControl_Tools::ToShortRealValue (theValue)); break;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_TextAspect)->Name())
- {
- Handle(Prs3d_TextAspect) aCustomAspect = Handle(Prs3d_TextAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: aCustomAspect->SetAngle (ViewControl_Tools::ToRealValue (theValue)); break;
- case 1: aCustomAspect->SetHeight (ViewControl_Tools::ToRealValue (theValue)); break;
- case 2: aCustomAspect->SetHorizontalJustification (Graphic3d::HorizontalTextAlignmentFromString
- (theValue.toString().toStdString().c_str())); break;
- case 3: aCustomAspect->SetVerticalJustification (Graphic3d::VerticalTextAlignmentFromString
- (theValue.toString().toStdString().c_str())); break;
- case 4: aCustomAspect->SetOrientation (Graphic3d::TextPathFromString (theValue.toString().toStdString().c_str())); break;
- // Graphic3d_AspectText3d attributes
- case 5: aCustomAspect->Aspect()->SetFont (theValue.toString().toStdString().c_str()); break;
- case 6: aCustomAspect->Aspect()->SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- //case 7: aCustomAspect->Aspect()->SetExpansionFactor (ViewControl_Tools::ToRealValue (theValue)); break;
- //case 8: aCustomAspect->Aspect()->SetSpace (ViewControl_Tools::ToRealValue (theValue)); break;
- case 9: aCustomAspect->Aspect()->SetStyle (Aspect::TypeOfStyleTextFromString (theValue.toString().toStdString().c_str())); break;
- case 10: aCustomAspect->Aspect()->SetDisplayType (Aspect::TypeOfDisplayTextFromString (theValue.toString().toStdString().c_str())); break;
- case 11: aCustomAspect->Aspect()->SetColorSubTitle (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 12: aCustomAspect->Aspect()->SetTextZoomable (theValue.toBool()); break;
- case 13: aCustomAspect->Aspect()->SetTextAngle (ViewControl_Tools::ToRealValue (theValue)); break;
- case 14: aCustomAspect->Aspect()->SetTextFontAspect (Font::FontAspectFromString (theValue.toString().toStdString().c_str())); break;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_PlaneAspect)->Name())
- {
- Handle(Prs3d_PlaneAspect) aCustomAspect = Handle(Prs3d_PlaneAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: aCustomAspect->SetArrowsLength (ViewControl_Tools::ToRealValue (theValue)); break;
- case 1: aCustomAspect->SetArrowsSize (ViewControl_Tools::ToRealValue (theValue)); break;
- case 2: aCustomAspect->SetArrowsAngle (ViewControl_Tools::ToRealValue (theValue)); break;
- case 3: aCustomAspect->SetPlaneLength (ViewControl_Tools::ToRealValue (theValue),
- aCustomAspect->PlaneYLength()); break;
- case 4: aCustomAspect->SetPlaneLength (aCustomAspect->PlaneXLength(),
- ViewControl_Tools::ToRealValue (theValue)); break;
- case 5: aCustomAspect->SetIsoDistance (ViewControl_Tools::ToRealValue (theValue)); break;
- case 6: aCustomAspect->SetDisplayCenterArrow (theValue.toBool()); break;
- case 7: aCustomAspect->SetDisplayEdgesArrows (theValue.toBool()); break;
- case 8: aCustomAspect->SetDisplayEdges (theValue.toBool()); break;
- case 9: aCustomAspect->SetDisplayIso (theValue.toBool()); break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ArrowAspect)->Name())
- {
- Handle(Prs3d_ArrowAspect) aCustomAspect = Handle(Prs3d_ArrowAspect)::DownCast (anAspect);
- Handle(Graphic3d_AspectLine3d) anAspect = aCustomAspect->Aspect();
- switch (aRow)
- {
- case 0: aCustomAspect->SetAngle (ViewControl_Tools::ToRealValue (theValue)); break;
- case 1: aCustomAspect->SetLength (ViewControl_Tools::ToRealValue (theValue)); break;
-
- case 2: anAspect->SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 3: anAspect->SetType (Aspect::TypeOfLineFromString (theValue.toString().toStdString().c_str())); break;
- case 4: anAspect->SetWidth (ViewControl_Tools::ToShortRealValue (theValue)); break;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_DimensionAspect)->Name())
- {
- Handle(Prs3d_DimensionAspect) aCustomAspect = Handle(Prs3d_DimensionAspect)::DownCast (anAspect);
- switch (aRow)
- {
- case 0: aCustomAspect->SetValueStringFormat (theValue.toString().toStdString().c_str()); break;
- case 1: aCustomAspect->SetExtensionSize (ViewControl_Tools::ToRealValue (theValue)); break;
- case 2: aCustomAspect->SetArrowTailSize (ViewControl_Tools::ToRealValue (theValue)); break;
-
- case 3: aCustomAspect->SetArrowOrientation (Prs3d::DimensionArrowOrientationFromString (
- theValue.toString().toStdString().c_str())); break;
- case 4: aCustomAspect->SetTextHorizontalPosition (Prs3d::DimensionTextHorizontalPositionFromString (
- theValue.toString().toStdString().c_str())); break;
- case 5: aCustomAspect->SetTextVerticalPosition (Prs3d::DimensionTextVerticalPositionFromString (
- theValue.toString().toStdString().c_str())); break;
- case 6: aCustomAspect->MakeUnitsDisplayed (theValue.toBool()); break;
- case 7: aCustomAspect->MakeText3d (theValue.toBool()); break;
- case 8: aCustomAspect->MakeTextShaded (theValue.toBool()); break;
- case 9: aCustomAspect->MakeArrows3d (theValue.toBool()); break;
- default: break;
- }
- }
- else if (theAspectKind == STANDARD_TYPE (Prs3d_ShadingAspect)->Name())
- {
- Handle(Prs3d_ShadingAspect) aCustomAspect = Handle(Prs3d_ShadingAspect)::DownCast (anAspect);
- Handle(Graphic3d_AspectFillArea3d) anAspect = aCustomAspect->Aspect();
- switch (aRow)
- {
- case 0: anAspect->SetInteriorColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 1: anAspect->SetBackInteriorColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 2: anAspect->SetEdgeColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 3: anAspect->SetInteriorStyle (Aspect::InteriorStyleFromString (
- theValue.toString().toStdString().c_str())); break;
- case 4: anAspect->SetShadingModel (Graphic3d::TypeOfShadingModelFromString (
- theValue.toString().toStdString().c_str())); break;
- case 5:
- case 6:
- {
- Graphic3d_AlphaMode aMode = anAspect->AlphaMode();
- Standard_ShortReal aCutoff = anAspect->AlphaCutoff();
- if (aRow == 5)
- aMode = Graphic3d::AlphaModeFromString (theValue.toString().toStdString().c_str());
- else
- aCutoff = ViewControl_Tools::ToShortRealValue (theValue);
- anAspect->SetAlphaMode (aMode, aCutoff);
- break;
- }
- case 7: anAspect->SetEdgeLineType (Aspect::TypeOfLineFromString (
- theValue.toString().toStdString().c_str())); break;
- case 8: anAspect->SetEdgeWidth (ViewControl_Tools::ToShortRealValue (theValue)); break;
- case 9: break; // Graphic3d_HatchStyle is not modified
-
- case 10:
- case 11:
- case 12:
- {
- Standard_Integer aMode;
- Standard_ShortReal aFactor, aUnits;
- anAspect->PolygonOffsets (aMode, aFactor, aUnits);
- if (aRow == 10)
- aMode = Aspect::PolygonOffsetModeFromString (theValue.toString().toStdString().c_str());
- else if (aRow == 11)
- aFactor = ViewControl_Tools::ToShortRealValue (theValue);
- else if (aRow == 12)
- aUnits = ViewControl_Tools::ToShortRealValue (theValue);
-
- anAspect->SetPolygonOffsets (aMode, aFactor, aUnits);
- break;
- }
- case 13: anAspect->SetDistinguish (theValue.toBool()); break;
- case 14: anAspect->SetDrawEdges (theValue.toBool()); break;
- case 15: anAspect->SetSuppressBackFaces (theValue.toBool()); break;
- case 16: anAspect->SetTextureMapOn (theValue.toBool()); break;
- default: break;
- }
-
- // front material
- aRow = aRow - 17;
- Graphic3d_MaterialAspect& aFrontMaterial = anAspect->ChangeFrontMaterial();
- if (setMaterialValue (aRow, aFrontMaterial, theValue))
- return true;
-
- // back material
- aRow = aRow - GetMaterialRows();
- Graphic3d_MaterialAspect& aBackMaterial = anAspect->ChangeBackMaterial();
- if (setMaterialValue (aRow, aBackMaterial, theValue))
- return true;
- }
- return true;
-}
-
-// =======================================================================
-// function : isColorMaterialRow
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemPrs3dAspect::isColorMaterialRow (const int theRow) const
-{
- // front material
- int aRow = theRow - 17;
- if (aRow >= 8 && aRow <= 12)
- return Standard_True;
-
- // back material
- aRow = aRow - GetMaterialRows();
- if (aRow >= 8 && aRow <= 12)
- return Standard_True;
-
- return Standard_False;
-}
-
-// =======================================================================
-// function : getTableEditTypeMaterial
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemPrs3dAspect::getTableEditTypeMaterial (const int theRow,
- ViewControl_EditType& theType) const
-{
- theType = ViewControl_EditType_None;
-
- switch (theRow)
- {
- case 6:
- case 7: theType = ViewControl_EditType_Line; break;
-
- case 8:
- case 9:
- case 10:
- case 11:
- case 12: theType = ViewControl_EditType_Color; break;
-
- case 13:
- case 14:
- case 15:
- case 16:
- case 17: theType = ViewControl_EditType_Line; break;
-
- case 18:
- case 19:
- case 20:
- case 21: theType = ViewControl_EditType_Bool; break;
-
- default: break;
- }
-
- return theRow < GetMaterialRows();
-}
-
-// =======================================================================
-// function : getMaterialValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dAspect::getMaterialValue (const int theRow,
- const int theColumn,
- const int theRole,
- const Graphic3d_MaterialAspect& theMaterial,
- const TCollection_AsciiString& theInfo) const
-{
- bool isFirstColumn = theColumn == 0;
-
- if ((theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole) ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || (theRow < 8 || theRow > 12))))
- return QVariant();
-
- switch (theRow)
- {
- case 0: return ViewControl_Tools::TableSeparator();
- case 1: return isFirstColumn ? QVariant (theInfo.ToCString()) : QVariant ("");
- case 2: return ViewControl_Tools::TableSeparator();
-
- case 3: return isFirstColumn ? QVariant ("Name") : QVariant (theMaterial.Name()); //TODO
- case 4: return isFirstColumn ? QVariant ("RequestedName") : QVariant (theMaterial.RequestedName()); // TODO
- case 5: return isFirstColumn ? QVariant ("MaterialName") : QVariant (theMaterial.MaterialName());
-
- case 6: return isFirstColumn ? QVariant ("Transparency") : QVariant (theMaterial.Transparency());
- case 7: return isFirstColumn ? QVariant ("Alpha") : QVariant (theMaterial.Alpha());
-
- case 8: return getColorData("Color", Quantity_ColorRGBA (theMaterial.Color()), isFirstColumn, theRole);
- case 9: return getColorData("AmbientColor", Quantity_ColorRGBA (theMaterial.AmbientColor()), isFirstColumn, theRole);
- case 10: return getColorData("DiffuseColor", Quantity_ColorRGBA (theMaterial.DiffuseColor()), isFirstColumn, theRole);
- case 11: return getColorData("SpecularColor", Quantity_ColorRGBA (theMaterial.SpecularColor()), isFirstColumn, theRole);
- case 12: return getColorData("EmissiveColor", Quantity_ColorRGBA (theMaterial.EmissiveColor()), isFirstColumn, theRole);
-
- case 13: return isFirstColumn ? QVariant ("Ambient") : QVariant (theMaterial.Ambient());
- case 14: return isFirstColumn ? QVariant ("Diffuse") : QVariant (theMaterial.Diffuse());
- case 15: return isFirstColumn ? QVariant ("Specular") : QVariant (theMaterial.Specular());
- case 16: return isFirstColumn ? QVariant ("Emissive") : QVariant (theMaterial.Emissive());
-
- case 17: return isFirstColumn ? QVariant ("Shininess") : QVariant (theMaterial.Shininess());
-
- case 18: return isFirstColumn ? QVariant ("ReflectionMode (Ambient)") : QVariant (theMaterial.ReflectionMode (Graphic3d_TOR_AMBIENT));
- case 19: return isFirstColumn ? QVariant ("ReflectionMode (Diffuse)") : QVariant (theMaterial.ReflectionMode (Graphic3d_TOR_DIFFUSE));
- case 20: return isFirstColumn ? QVariant ("ReflectionMode (Specular)") : QVariant (theMaterial.ReflectionMode (Graphic3d_TOR_SPECULAR));
- case 21: return isFirstColumn ? QVariant ("ReflectionMode (Emissive)") : QVariant (theMaterial.ReflectionMode (Graphic3d_TOR_EMISSION));
-
- case 22: return isFirstColumn ? QVariant ("RefractionIndex") : QVariant (theMaterial.RefractionIndex());
- case 23: return isFirstColumn ? QVariant ("BSDF.FresnelCoat.FresnelType()") : QVariant (theMaterial.BSDF().FresnelCoat.FresnelType()); // TODO
- case 24: return isFirstColumn ? QVariant ("BSDF.FresnelBase.FresnelType()") : QVariant (theMaterial.BSDF().FresnelBase.FresnelType()); // TODO
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : setMaterialValue
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemPrs3dAspect::setMaterialValue (const int theRow,
- Graphic3d_MaterialAspect& theMaterial,
- const QVariant& theValue) const
-{
- switch (theRow)
- {
- case 6: theMaterial.SetTransparency (ViewControl_Tools::ToShortRealValue (theValue)); break;
- case 7: theMaterial.SetAlpha (ViewControl_Tools::ToShortRealValue (theValue)); break;
-
- case 8: theMaterial.SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 9: theMaterial.SetAmbientColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 10: theMaterial.SetDiffuseColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 11: theMaterial.SetSpecularColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
- case 12: theMaterial.SetEmissiveColor (ViewControl_ColorSelector::StringToColor (theValue.toString())); break;
-
- case 13: theMaterial.SetAmbient (ViewControl_Tools::ToShortRealValue (theValue)); break;
- case 14: theMaterial.SetDiffuse (ViewControl_Tools::ToShortRealValue (theValue)); break;
- case 15: theMaterial.SetSpecular (ViewControl_Tools::ToShortRealValue (theValue)); break;
- case 16: theMaterial.SetEmissive (ViewControl_Tools::ToShortRealValue (theValue)); break;
- case 17: theMaterial.SetShininess (ViewControl_Tools::ToShortRealValue (theValue)); break;
-
- case 18: theMaterial.SetReflectionMode (Graphic3d_TOR_AMBIENT, theValue.toBool()); break;
- case 19: theMaterial.SetReflectionMode (Graphic3d_TOR_DIFFUSE, theValue.toBool()); break;
- case 20: theMaterial.SetReflectionMode (Graphic3d_TOR_SPECULAR, theValue.toBool()); break;
- case 21: theMaterial.SetReflectionMode (Graphic3d_TOR_EMISSION, theValue.toBool()); break;
- }
- return theRow < GetMaterialRows();
-}
-
-// =======================================================================
-// function : getColorData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dAspect::getColorData(const TCollection_AsciiString& theInfo,
- const Quantity_ColorRGBA& theColor,
- const Standard_Boolean isFirstColumn,
- const int theRole) const
-{
- if (isFirstColumn)
- return theInfo.ToCString();
-
- if (theRole == Qt::BackgroundRole)
- return ViewControl_ColorSelector::ColorToQColor (theColor);
-
- else if (theRole == Qt::DisplayRole)
- return ViewControl_ColorSelector::ColorToString (theColor);
-
- return QVariant();
-}
+++ /dev/null
-// Created on: 2018-08-26
-// 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_ItemPrs3dAspect_H
-#define VInspector_ItemPrs3dAspect_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Prs3d_BasicAspect.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemPrs3dAspect;
-typedef QExplicitlySharedDataPointer<VInspector_ItemPrs3dAspect> VInspector_ItemPrs3dAspectPtr;
-
-//! \class VInspector_ItemPrs3dAspect
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspector_ItemPrs3dAspect : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemPrs3dAspectPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemPrs3dAspectPtr (new VInspector_ItemPrs3dAspect (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemPrs3dAspect() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myAspect; }
-
- //! Returns the current aspect, init item if it was not initialized yet
- //! \return interactive object
- Standard_EXPORT Handle(Prs3d_BasicAspect) GetAspect() const
- { return Handle(Prs3d_BasicAspect)::DownCast (GetObject()); }
-
- //! Returns sub aspect of the row if possible, e.g. Datum/Dimension aspect
- //! \param theRow child row index
- //! \param theName [out] drawer name
- Standard_EXPORT Handle(Prs3d_BasicAspect) GetPrs3dAspect (const int theRow,
- TCollection_AsciiString& theName,
- Standard_Boolean& theOwnAspect) const;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
- //! Set interactive object into the current field
- //! \param theIO a presentation
- //! \param theName item display data value
- void setAspect (Handle(Prs3d_BasicAspect) theAspect, const TCollection_AsciiString& theName)
- { myAspect = theAspect; myName = theName; }
-
-private:
-
- //! Returns number of table rows depending on the aspect kind
- //! \param theAspectKind kind or parent kind of aspect
- int getTableRowCount (const TCollection_AsciiString& theAspectKind) const;
-
- //! Returns number of table rows depending on the aspect kind
- //! \param theRow a model index row
- //! \param theAspectKind kind or parent kind of aspect
- //! \param theStartRow number of rows following before the parameter row, use sum of row and start row
- ViewControl_EditType getTableEditType (const int theRow,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow) const;
-
- //! Returns container of string values for enumeration in the model row depending on the aspect kind
- //! \param theRow table model row index
- //! \param theAspectKind kind or parent kind of aspect
- //! \param theStartRow number of rows following before the parameter row, use sum of row and start row
- //! \return string values for the enumeration presented in the row or an empty container
- QList<QVariant> getTableEnumValues (const int theRow,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow) const;
-
- //! Returns table value for the row in form: <function name> <function value> depending on the aspect kind
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theAspectKind kind or parent kind of aspect
- //! \param theStartRow number of rows following before the parameter row, use sum of row and start row
- QVariant getTableData (const int theRow,
- const int theColumn,
- const int theRole,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow) const;
-
- //! Sets the value into the table cell depending on the aspect kind
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- bool setTableData (const int theRow,
- const TCollection_AsciiString& theAspectKind,
- const int theStartRow,
- const QVariant& theValue) const;
-
- //! Returns true if the table value in the row is a color of a material
- Standard_Boolean isColorMaterialRow (const int theRow) const;
-
- //! Returns type of edit control for the material row
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- Standard_Boolean getTableEditTypeMaterial (const int theRow,
- ViewControl_EditType& theType) const;
-
- //! Returns value of Graphic3d_MaterialAspect for the row
- QVariant getMaterialValue (const int theRow,
- const int theColumn,
- const int theRole,
- const Graphic3d_MaterialAspect& theMaterial,
- const TCollection_AsciiString& theInfo) const;
-
- Standard_Boolean setMaterialValue (const int theRow,
- Graphic3d_MaterialAspect& theMaterial,
- const QVariant& theValue) const;
-
- //! Returns color data depending on parameters
- //! \param theInfo information value if column is the first one
- //! \param theColor color value
- //! \param isFirstColumn true if the column id is zero, return info value
- //! \param theRole if background, returns color or text parameters of color
- QVariant getColorData (const TCollection_AsciiString& theInfo,
- const Quantity_ColorRGBA& theColor,
- const Standard_Boolean isFirstColumn,
- const int theRole) const;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemPrs3dAspect(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(Prs3d_BasicAspect) myAspect; //!< the current interactive context
- TCollection_AsciiString myName; //!< the item display data value
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-10
-// 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_ItemPrs3dDrawer.hxx>
-#include <inspector/VInspector_ItemPrs3dAspect.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/ViewControl_ColorSelector.hxx>
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Aspect.hxx>
-#include <Graphic3d.hxx>
-#include <Prs3d.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DatumAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_IsoAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_PlaneAspect.hxx>
-#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-
-QVariant VInspector_ItemPrs3dDrawer::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- bool aNullDrawer = aDrawer.IsNull();
- if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
- {
- switch (Column())
- {
- case 0:
- {
- return theItemRole == Qt::ToolTipRole
- ? (aNullDrawer ? QVariant("Prs3d_Drawer is empty") : QVariant (aDrawer->DynamicType()->Name()))
- : QVariant (myName.ToCString());
- }
- default: break;
- }
- }
- if (theItemRole == Qt::ForegroundRole)
- return !aNullDrawer ? QColor (Qt::black) : QColor (Qt::lightGray);
-
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-
-int VInspector_ItemPrs3dDrawer::initRowCount() const
-{
- VInspector_ItemPrs3dDrawerPtr aParentDrawerItem = itemDynamicCast<VInspector_ItemPrs3dDrawer>(Parent());
- if (aParentDrawerItem)
- return 0;
-
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return 0;
-
- int aChildCount = 1; // Link
- aChildCount += 18; // Prs3d_Drawer aspects
- return aChildCount;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-
-TreeModel_ItemBasePtr VInspector_ItemPrs3dDrawer::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- {
- return VInspector_ItemPrs3dDrawer::CreateItem (currentItem(), theRow, theColumn); // "Link"
- }
- else
- return VInspector_ItemPrs3dAspect::CreateItem (currentItem(), theRow, theColumn); // "Aspects"
-
- return TreeModel_ItemBasePtr();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemPrs3dDrawer::Init()
-{
- VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
- Handle(Prs3d_Drawer) aDrawer;
- TCollection_AsciiString aName;
- if (aParentItem)
- aDrawer = aParentItem->GetPrs3dDrawer(Row(), aName);
- else
- {
- VInspector_ItemPrs3dDrawerPtr aParentDrawerItem = itemDynamicCast<VInspector_ItemPrs3dDrawer>(Parent());
- if (aParentDrawerItem)
- {
- aDrawer = aParentDrawerItem->GetDrawer()->Link();
- aName = "Link";
- }
- }
- setDrawer (aDrawer, aName);
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemPrs3dDrawer::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setDrawer (NULL, "None");
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemPrs3dDrawer::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemPrs3dDrawer*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetPrs3dAspect
-// purpose :
-// =======================================================================
-
-Handle(Prs3d_BasicAspect) VInspector_ItemPrs3dDrawer::GetPrs3dAspect (const int theRow,
- TCollection_AsciiString& theName,
- Standard_Boolean& theOwnAspect) const
-{
- if (theRow == 0) // "Link" driver, there is no aspect
- return 0;
-
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return 0;
-
- // do not create a new instance of the aspect
- switch (theRow)
- {
- case 1: theName = "UIsoAspect"; theOwnAspect = aDrawer->HasOwnUIsoAspect(); return aDrawer->UIsoAspect();
- case 2: theName = "VIsoAspect"; theOwnAspect = aDrawer->HasOwnVIsoAspect(); return aDrawer->VIsoAspect();
- case 3: theName = "WireAspect"; theOwnAspect = aDrawer->HasOwnWireAspect(); return aDrawer->WireAspect();
- case 4: theName = "PointAspect"; theOwnAspect = aDrawer->HasOwnPointAspect(); return aDrawer->PointAspect();
- case 5: theName = "LineAspect"; theOwnAspect = aDrawer->HasOwnLineAspect(); return aDrawer->LineAspect();
- case 6: theName = "TextAspect"; theOwnAspect = aDrawer->HasOwnTextAspect(); return aDrawer->TextAspect();
- case 7: theName = "ShadingAspect"; theOwnAspect = aDrawer->HasOwnShadingAspect(); return aDrawer->ShadingAspect();
- case 8: theName = "PlaneAspect"; theOwnAspect = aDrawer->HasOwnPlaneAspect(); return aDrawer->PlaneAspect();
- case 9: theName = "SeenLineAspect"; theOwnAspect = aDrawer->HasOwnSeenLineAspect(); return aDrawer->SeenLineAspect();
- case 10: theName = "ArrowAspect"; theOwnAspect = aDrawer->HasOwnArrowAspect(); return aDrawer->ArrowAspect();
- case 11: theName = "HiddenLineAspect"; theOwnAspect = aDrawer->HasOwnHiddenLineAspect(); return aDrawer->HiddenLineAspect();
- case 12: theName = "VectorAspect"; theOwnAspect = aDrawer->HasOwnVectorAspect(); return aDrawer->VectorAspect();
- case 13: theName = "DatumAspect"; theOwnAspect = aDrawer->HasOwnDatumAspect(); return aDrawer->DatumAspect();
- case 14: theName = "SectionAspect"; theOwnAspect = aDrawer->HasOwnSectionAspect(); return aDrawer->SectionAspect();
- case 15: theName = "FreeBoundaryAspect"; theOwnAspect = aDrawer->HasOwnFreeBoundaryAspect(); return aDrawer->FreeBoundaryAspect();
- case 16: theName = "UnFreeBoundaryAspect"; theOwnAspect = aDrawer->HasOwnUnFreeBoundaryAspect(); return aDrawer->UnFreeBoundaryAspect();
- case 17: theName = "FaceBoundaryAspect"; theOwnAspect = aDrawer->HasOwnFaceBoundaryAspect(); return aDrawer->FaceBoundaryAspect();
- case 18: theName = "DimensionAspect"; theOwnAspect = aDrawer->HasOwnDimensionAspect(); return aDrawer->DimensionAspect();
- default: break;
- }
-
- theName = "None";
- return Handle(Prs3d_BasicAspect)();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemPrs3dDrawer::GetTableRowCount() const
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return 0;
-
- return 76;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemPrs3dDrawer::GetTableEditType (const int theRow, const int) const
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return ViewControl_EditType_None;
-
- switch (theRow)
- {
- case 4: return ViewControl_EditType_Spin;
- case 6: return ViewControl_EditType_Line;
- case 8: return ViewControl_EditType_Line;
- case 10: return ViewControl_EditType_Combo;
- case 12: return ViewControl_EditType_Combo;
- case 13: return ViewControl_EditType_Bool;
- case 14: return ViewControl_EditType_Line;
- case 15: return ViewControl_EditType_Bool;
- case 16: return ViewControl_EditType_Line;
- case 18: return ViewControl_EditType_Line;
- case 21: return ViewControl_EditType_Line;
- case 24: return ViewControl_EditType_Bool;
- case 26: return ViewControl_EditType_Bool;
- case 28: return ViewControl_EditType_Bool;
- // aspects
- case 30:
- case 31:
- case 32:
- case 34:
- case 35:
- case 36:
- case 37:
- case 38:
- case 39:
- case 40:
- case 41:
- case 43:
- case 44:
- case 46:
- case 47: return ViewControl_EditType_Bool;
-
- case 48: return ViewControl_EditType_Combo;
-
- case 49:
- case 50:
- case 51:
- case 53:
- case 54:
- case 56:
- case 57:
- case 59:
- case 60: return ViewControl_EditType_Bool;
-
- case 62:
- case 64:
- case 66:
- case 68: return ViewControl_EditType_Line;
- case 72: return ViewControl_EditType_Color;
-
- case 73: return ViewControl_EditType_Combo;
- case 74: return ViewControl_EditType_Combo;
- case 75: return ViewControl_EditType_Spin;
-
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemPrs3dDrawer::GetTableEnumValues (const int theRow, const int) const
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return QList<QVariant>();
-
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 10:
- {
- for (int i = 0; i <= Aspect_TOD_ABSOLUTE; i++)
- aValues.append (Aspect::TypeOfDeflectionToString ((Aspect_TypeOfDeflection)i));
- }
- break;
- case 12:
- {
- for (int i = 0; i <= Prs3d_TOH_Algo; i++)
- aValues.append (Prs3d::TypeOfHLRToString ((Prs3d_TypeOfHLR)i));
- }
- break;
- case 48:
- {
- for (int i = 0; i <= Prs3d_VDM_Inherited; i++)
- aValues.append (Prs3d::VertexDrawModeToString ((Prs3d_VertexDrawMode)i));
- }
- break;
- case 73:
- {
- for (int i = 0; i <= Aspect_TOHM_BOUNDBOX; i++)
- aValues.append (Aspect::TypeOfHighlightMethodToString ((Aspect_TypeOfHighlightMethod)i));
- }
- break;
- case 74:
- {
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_UNKNOWN));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Default));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Top));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Topmost));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_TopOSD));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_BotOSD));
- }
- break;
- default: break;
- }
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dDrawer::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- if (theRole != Qt::DisplayRole && theRole != Qt::BackgroundRole ||
- (theRole == Qt::BackgroundRole && (isFirstColumn || theRow != 72)))
- return QVariant();
-
- switch (theRow)
- {
- case 0: return ViewControl_Table::SeparatorData();
- case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (Prs3d_Drawer)->Name())
- : ViewControl_Tools::GetPointerInfo (aDrawer).ToCString();
- case 2: return ViewControl_Table::SeparatorData();
- case 3: return isFirstColumn ? QVariant ("HasOwnDiscretisation") : QVariant (aDrawer->HasOwnDiscretisation());
- case 4: return isFirstColumn ? QVariant ("Discretisation") : QVariant (aDrawer->Discretisation());
- case 5: return isFirstColumn ? QVariant ("HasOwnMaximalParameterValue") : QVariant (aDrawer->HasOwnMaximalParameterValue());
- case 6: return isFirstColumn ? QVariant ("MaximalParameterValue") : QVariant (aDrawer->MaximalParameterValue());
- case 7: return isFirstColumn ? QVariant ("HasOwnMaximalChordialDeviation") : QVariant (aDrawer->HasOwnMaximalChordialDeviation());
- case 8: return isFirstColumn ? QVariant ("MaximalChordialDeviation") : QVariant (aDrawer->MaximalChordialDeviation());
- case 9: return isFirstColumn ? QVariant ("HasOwnTypeOfDeflection") : QVariant (aDrawer->HasOwnTypeOfDeflection());
- case 10: return isFirstColumn ? QVariant ("TypeOfDeflection")
- : QVariant (Aspect::TypeOfDeflectionToString (aDrawer->TypeOfDeflection()));
- case 11: return isFirstColumn ? QVariant ("HasOwnTypeOfHLR") : QVariant (aDrawer->HasOwnTypeOfHLR());
- case 12: return isFirstColumn ? QVariant ("TypeOfHLR")
- : QVariant (Prs3d::TypeOfHLRToString (aDrawer->TypeOfHLR()));
-
- case 13: return isFirstColumn ? QVariant ("HasOwnDeviationCoefficient") : QVariant (aDrawer->HasOwnDeviationCoefficient());
- case 14: return isFirstColumn ? QVariant ("DeviationCoefficient") : QVariant (aDrawer->DeviationCoefficient());
- case 15: return isFirstColumn ? QVariant ("HasOwnHLRDeviationCoefficient") : QVariant (aDrawer->HasOwnHLRDeviationCoefficient());
- case 16: return isFirstColumn ? QVariant ("HLRDeviationCoefficient") : QVariant (aDrawer->HLRDeviationCoefficient());
-
- case 17: return isFirstColumn ? QVariant ("HasOwnDeviationAngle") : QVariant (aDrawer->HasOwnDeviationAngle());
- case 18: return isFirstColumn ? QVariant ("DeviationAngle") : QVariant (aDrawer->DeviationAngle());
- case 19: return isFirstColumn ? QVariant ("PreviousDeviationAngle") : QVariant (aDrawer->PreviousDeviationAngle());
-
- case 20: return isFirstColumn ? QVariant ("HasOwnHLRDeviationAngle") : QVariant (aDrawer->HasOwnHLRDeviationAngle());
- case 21: return isFirstColumn ? QVariant ("HLRAngle") : QVariant (aDrawer->HLRAngle());
- case 22: return isFirstColumn ? QVariant ("PreviousHLRDeviationAngle") : QVariant (aDrawer->PreviousHLRDeviationAngle());
-
- case 23: return isFirstColumn ? QVariant ("HasOwnIsoOnPlane") : QVariant (aDrawer->HasOwnIsoOnPlane());
- case 24: return isFirstColumn ? QVariant ("IsoOnPlane") : QVariant (aDrawer->IsoOnPlane());
- case 25: return isFirstColumn ? QVariant ("HasOwnIsoOnTriangulation") : QVariant (aDrawer->HasOwnIsoOnTriangulation());
- case 26: return isFirstColumn ? QVariant ("IsoOnTriangulation") : QVariant (aDrawer->IsoOnTriangulation());
- case 27: return isFirstColumn ? QVariant ("HasOwnIsAutoTriangulation") : QVariant (aDrawer->HasOwnIsAutoTriangulation());
- case 28: return isFirstColumn ? QVariant ("IsAutoTriangulation") : QVariant (aDrawer->IsAutoTriangulation());
- case 29: return ViewControl_Table::SeparatorData(); // aspects separation
-
- case 30: return isFirstColumn ? QVariant ("HasOwnUIsoAspect") : QVariant (aDrawer->HasOwnUIsoAspect());
- case 31: return isFirstColumn ? QVariant ("HasOwnVIsoAspect") : QVariant (aDrawer->HasOwnVIsoAspect());
- case 32: return isFirstColumn ? QVariant ("HasOwnWireAspect") : QVariant (aDrawer->HasOwnWireAspect());
- case 33: return isFirstColumn ? QVariant ("HasOwnWireDraw") : QVariant (aDrawer->HasOwnWireDraw());
- case 34: return isFirstColumn ? QVariant ("WireDraw") : QVariant (aDrawer->WireDraw());
- case 35: return isFirstColumn ? QVariant ("HasOwnPointAspect") : QVariant (aDrawer->HasOwnPointAspect());
- case 36: return isFirstColumn ? QVariant ("HasOwnLineAspect") : QVariant (aDrawer->HasOwnLineAspect());
- case 37: return isFirstColumn ? QVariant ("HasOwnTextAspect") : QVariant (aDrawer->HasOwnTextAspect());
- case 38: return isFirstColumn ? QVariant ("HasOwnShadingAspect") : QVariant (aDrawer->HasOwnShadingAspect());
- case 39: return isFirstColumn ? QVariant ("HasOwnPlaneAspect") : QVariant (aDrawer->HasOwnPlaneAspect());
- case 40: return isFirstColumn ? QVariant ("HasOwnSeenLineAspect") : QVariant (aDrawer->HasOwnSeenLineAspect());
-
- case 41: return isFirstColumn ? QVariant ("HasOwnArrowAspect") : QVariant (aDrawer->HasOwnArrowAspect());
- case 42: return isFirstColumn ? QVariant ("HasOwnLineArrowDraw") : QVariant (aDrawer->HasOwnLineArrowDraw());
- case 43: return isFirstColumn ? QVariant ("LineArrowDraw") : QVariant (aDrawer->LineArrowDraw());
-
- case 44: return isFirstColumn ? QVariant ("HasOwnHiddenLineAspect") : QVariant (aDrawer->HasOwnHiddenLineAspect());
- case 45: return isFirstColumn ? QVariant ("HasOwnDrawHiddenLine") : QVariant (aDrawer->HasOwnDrawHiddenLine());
- case 46: return isFirstColumn ? QVariant ("DrawHiddenLine") : QVariant (aDrawer->DrawHiddenLine());
-
- case 47: return isFirstColumn ? QVariant ("HasOwnVectorAspect") : QVariant (aDrawer->HasOwnVectorAspect());
- case 48: return isFirstColumn ? QVariant ("VertexDrawMode")
- : QVariant (Prs3d::VertexDrawModeToString (aDrawer->VertexDrawMode()));
-
- case 49: return isFirstColumn ? QVariant ("HasOwnDatumAspect") : QVariant (aDrawer->HasOwnDatumAspect());
-
- case 50: return isFirstColumn ? QVariant ("HasOwnSectionAspect") : QVariant (aDrawer->HasOwnSectionAspect());
-
- case 51: return isFirstColumn ? QVariant ("HasOwnFreeBoundaryAspect") : QVariant (aDrawer->HasOwnFreeBoundaryAspect());
- case 52: return isFirstColumn ? QVariant ("HasOwnFreeBoundaryDraw") : QVariant (aDrawer->HasOwnFreeBoundaryDraw());
- case 53: return isFirstColumn ? QVariant ("FreeBoundaryDraw") : QVariant (aDrawer->FreeBoundaryDraw());
-
- case 54: return isFirstColumn ? QVariant ("HasOwnUnFreeBoundaryAspect") : QVariant (aDrawer->HasOwnUnFreeBoundaryAspect());
- case 55: return isFirstColumn ? QVariant ("HasOwnUnFreeBoundaryDraw") : QVariant (aDrawer->HasOwnUnFreeBoundaryDraw());
- case 56: return isFirstColumn ? QVariant ("UnFreeBoundaryDraw") : QVariant (aDrawer->UnFreeBoundaryDraw());
-
- case 57: return isFirstColumn ? QVariant ("HasOwnFaceBoundaryAspect") : QVariant (aDrawer->HasOwnFaceBoundaryAspect());
- case 58: return isFirstColumn ? QVariant ("HasOwnFaceBoundaryDraw") : QVariant (aDrawer->HasOwnFaceBoundaryDraw());
- case 59: return isFirstColumn ? QVariant ("FaceBoundaryDraw") : QVariant (aDrawer->FaceBoundaryDraw());
-
- case 60: return isFirstColumn ? QVariant ("HasOwnDimensionAspect") : QVariant (aDrawer->HasOwnDimensionAspect());
-
- case 61: return isFirstColumn ? QVariant ("HasOwnDimLengthModelUnits") : QVariant (aDrawer->HasOwnDimLengthModelUnits());
- case 62: return isFirstColumn ? QVariant ("DimLengthModelUnits") : QVariant (aDrawer->DimLengthModelUnits().ToCString());
- case 63: return isFirstColumn ? QVariant ("HasOwnDimLengthModelUnits") : QVariant (aDrawer->HasOwnDimLengthModelUnits());
- case 64: return isFirstColumn ? QVariant ("DimAngleModelUnits") : QVariant (aDrawer->DimAngleModelUnits().ToCString());
-
- case 65: return isFirstColumn ? QVariant ("HasOwnDimLengthDisplayUnits") : QVariant (aDrawer->HasOwnDimLengthDisplayUnits());
- case 66: return isFirstColumn ? QVariant ("DimLengthDisplayUnits") : QVariant (aDrawer->DimLengthDisplayUnits().ToCString());
- case 67: return isFirstColumn ? QVariant ("HasOwnDimAngleDisplayUnits") : QVariant (aDrawer->HasOwnDimAngleDisplayUnits());
- case 68: return isFirstColumn ? QVariant ("DimAngleDisplayUnits") : QVariant (aDrawer->DimAngleDisplayUnits().ToCString());
-
- // Graphic3d_PresentationAttributes
- case 69: return ViewControl_Table::SeparatorData();
- case 70: return isFirstColumn ? QVariant (STANDARD_TYPE (Graphic3d_PresentationAttributes)->Name())
- : ViewControl_Tools::GetPointerInfo (aDrawer).ToCString();
- case 72:
- {
- if (isFirstColumn) return QVariant ("ColorRGBA");
- else if (theRole == Qt::BackgroundRole) return ViewControl_ColorSelector::ColorToQColor (aDrawer->ColorRGBA());
- else if (theRole == Qt::DisplayRole) return ViewControl_ColorSelector::ColorToString (aDrawer->ColorRGBA());
- }
- case 71: return ViewControl_Table::SeparatorData();
- case 73: return isFirstColumn ? QVariant ("Method")
- : QVariant (Aspect::TypeOfHighlightMethodToString (aDrawer->Method()));
- case 74: return isFirstColumn ? QVariant ("ZLayer")
- : QVariant (Graphic3d::ZLayerIdToString (aDrawer->ZLayer()));
- case 75: return isFirstColumn ? QVariant ("DisplayMode") : QVariant (aDrawer->DisplayMode());
-
-
- default: return QVariant();
- }
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemPrs3dDrawer::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return false;
-
- switch (theRow)
- {
- case 4: aDrawer->SetDiscretisation (theValue.toInt()); break;
- case 6: aDrawer->SetMaximalParameterValue (theValue.toDouble()); break;
- case 8: aDrawer->SetMaximalChordialDeviation (theValue.toDouble()); break;
- case 10: aDrawer->SetTypeOfDeflection (Aspect::TypeOfDeflectionFromString (theValue.toString().toStdString().c_str())); break;
- case 12: aDrawer->SetTypeOfHLR (Prs3d::TypeOfHLRFromString (theValue.toString().toStdString().c_str())); break;
- case 13: aDrawer->SetDeviationCoefficient(); break;
- case 14: aDrawer->SetDeviationCoefficient (theValue.toDouble()); break;
- case 15: aDrawer->SetHLRDeviationCoefficient(); break;
- case 16: aDrawer->SetHLRDeviationCoefficient (theValue.toDouble()); break;
- case 18: aDrawer->SetDeviationAngle (theValue.toDouble()); break;
- case 21: aDrawer->SetHLRAngle (theValue.toDouble()); break;
- case 24: aDrawer->SetIsoOnPlane (theValue.toBool()); break;
- case 26: aDrawer->SetIsoOnTriangulation (theValue.toBool()); break;
- case 28: aDrawer->SetAutoTriangulation (theValue.toBool()); break;
- // aspects
- case 30:
- case 31:
- case 32:
- case 35:
- case 36:
- case 37:
- case 38:
- case 39:
- case 40:
- case 41:
- case 44:
- case 47:
- case 49:
- case 50:
- case 51:
- case 54:
- case 57:
- case 60:
- {
- Standard_Boolean isOwnAspect = (Standard_Boolean)theValue.toBool();
- if (!isOwnAspect)
- aDrawer->SetUIsoAspect (NULL);
- Handle(Prs3d_Drawer) aLink = aDrawer->Link(); // copy link drawer to restore it
- aDrawer->SetLink(NULL);
- // creates and sets default aspect
- // TODO: suggest to fill myHasOwnUIsoAspect in UIsoAspect
- if (theRow == 30) aDrawer->SetUIsoAspect (isOwnAspect ? aDrawer->UIsoAspect() : NULL);
- if (theRow == 31) aDrawer->SetVIsoAspect (isOwnAspect ? aDrawer->VIsoAspect() : NULL);
- if (theRow == 32) aDrawer->SetWireAspect (isOwnAspect ? aDrawer->WireAspect() : NULL);
- if (theRow == 35) aDrawer->SetPointAspect (isOwnAspect ? aDrawer->PointAspect() : NULL);
- if (theRow == 36) aDrawer->SetLineAspect (isOwnAspect ? aDrawer->LineAspect() : NULL);
- if (theRow == 37) aDrawer->SetTextAspect (isOwnAspect ? aDrawer->TextAspect() : NULL);
- if (theRow == 38) aDrawer->SetShadingAspect (isOwnAspect ? aDrawer->ShadingAspect() : NULL);
- if (theRow == 39) aDrawer->SetPlaneAspect (isOwnAspect ? aDrawer->PlaneAspect() : NULL);
- if (theRow == 40) aDrawer->SetSeenLineAspect (isOwnAspect ? aDrawer->SeenLineAspect() : NULL);
- if (theRow == 41) aDrawer->SetArrowAspect (isOwnAspect ? aDrawer->ArrowAspect() : NULL);
- if (theRow == 44) aDrawer->SetHiddenLineAspect (isOwnAspect ? aDrawer->HiddenLineAspect() : NULL);
- if (theRow == 47) aDrawer->SetVectorAspect (isOwnAspect ? aDrawer->VectorAspect() : NULL);
- if (theRow == 49) aDrawer->SetDatumAspect (isOwnAspect ? aDrawer->DatumAspect() : NULL);
- if (theRow == 50) aDrawer->SetSectionAspect (isOwnAspect ? aDrawer->SectionAspect() : NULL);
- if (theRow == 51) aDrawer->SetFreeBoundaryAspect (isOwnAspect ? aDrawer->FreeBoundaryAspect() : NULL);
- if (theRow == 54) aDrawer->SetUnFreeBoundaryAspect (isOwnAspect ? aDrawer->UnFreeBoundaryAspect() : NULL);
- if (theRow == 57) aDrawer->SetFaceBoundaryAspect (isOwnAspect ? aDrawer->FaceBoundaryAspect() : NULL);
- if (theRow == 60) aDrawer->SetDimensionAspect (isOwnAspect ? aDrawer->DimensionAspect() : NULL);
-
- aDrawer->SetLink(aLink);
- }
- break;
- case 34: aDrawer->SetWireDraw (theValue.toBool()); break;
- case 43: aDrawer->SetLineArrowDraw (theValue.toBool()); break;
- case 46: { if (theValue.toBool()) aDrawer->EnableDrawHiddenLine(); else aDrawer->DisableDrawHiddenLine(); } break;
- case 48: aDrawer->SetVertexDrawMode (Prs3d::VertexDrawModeFromString (theValue.toString().toStdString().c_str())); break;
- case 53: aDrawer->SetFreeBoundaryDraw (theValue.toBool()); break;
- case 56: aDrawer->SetUnFreeBoundaryDraw (theValue.toBool()); break;
- case 59: aDrawer->SetFaceBoundaryDraw (theValue.toBool()); break;
-
- case 62: aDrawer->SetDimLengthModelUnits (theValue.toString().toStdString().c_str()); break;
- case 64: aDrawer->SetDimAngleModelUnits (theValue.toString().toStdString().c_str()); break;
- case 66: aDrawer->SetDimLengthDisplayUnits (theValue.toString().toStdString().c_str()); break;
- case 68: aDrawer->SetDimAngleDisplayUnits (theValue.toString().toStdString().c_str()); break;
-
- case 72:
- {
- float anAlpha;
- aDrawer->SetColor (ViewControl_ColorSelector::StringToColor (theValue.toString(), anAlpha));
- aDrawer->SetTransparency (anAlpha);
- }
- case 73: aDrawer->SetMethod (Aspect::TypeOfHighlightMethodFromString (theValue.toString().toStdString().c_str())); break;
- case 74: aDrawer->SetZLayer (Graphic3d::ZLayerIdFromString (theValue.toString().toStdString().c_str())); break;
- case 75: aDrawer->SetDisplayMode (theValue.toInt()); break;
-
- default: return false;
- }
- return true;
-}
+++ /dev/null
-// Created on: 2018-08-10
-// 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_ItemPrs3dDrawer_H
-#define VInspector_ItemPrs3dDrawer_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <Prs3d_Drawer.hxx>
-
-class Prs3d_BasicAspect;
-
-class QItemSelectionModel;
-
-class VInspector_ItemPrs3dDrawer;
-typedef QExplicitlySharedDataPointer<VInspector_ItemPrs3dDrawer> VInspector_ItemPrs3dDrawerPtr;
-
-//! \class VInspector_ItemPrs3dDrawer
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspector_ItemPrs3dDrawer : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemPrs3dDrawerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemPrs3dDrawerPtr (new VInspector_ItemPrs3dDrawer (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemPrs3dDrawer() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myDrawer; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Handle(Prs3d_Drawer) GetDrawer() const
- { return Handle(Prs3d_Drawer)::DownCast (GetObject()); }
-
- //! Returns drawer of the row if possible
- //! \param theRow child row index
- //! \param theName [out] drawer name
- Standard_EXPORT Handle(Prs3d_BasicAspect) GetPrs3dAspect (const int theRow,
- TCollection_AsciiString& theName,
- Standard_Boolean& theOwnAspect) const;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-protected:
-
- //! Set interactive object into the current field
- //! \param theIO a presentation
- //! \param theName item display data value
- void setDrawer (const Handle(Prs3d_Drawer)& theDrawer, const TCollection_AsciiString& theName)
- { myDrawer = theDrawer; myName = theName; }
-
-protected:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemPrs3dDrawer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(Prs3d_Drawer) myDrawer; //!< the current drawer
- TCollection_AsciiString myName; //!< the item display data value
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemPrs3dPresentation.hxx>
-#include <inspector/VInspector_ItemGraphic3dCStructure.hxx>
-#include <inspector/VInspector_ItemPresentations.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <inspector/Convert_Tools.hxx>
-
-#include <Graphic3d.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dPresentation::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
- return QVariant();
-
- Handle(Prs3d_Presentation) aPresentation = GetPresentation();
- bool aNullPresentation = aPresentation.IsNull();
-
- switch (Column())
- {
- case 0:
- {
- return theItemRole == Qt::ToolTipRole
- ? (aNullPresentation ? QVariant("Prs3d_Presentation is empty") : QVariant (aPresentation->DynamicType()->Name()))
- : QVariant (myName.ToCString());
- }
- }
-
- return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemPrs3dPresentation::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- //Handle(Prs3d_Presentation) aPresentation = GetPresentation();
-
- //Standard_EXPORT const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const;
-
- return 1; //aPresentation->NumberOfGroups();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemPrs3dPresentation::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- return VInspector_ItemGraphic3dCStructure::CreateItem (currentItem(), theRow, theColumn);
- //if (theRow == 1)
- // return VInspector_ItemPrs3dPresentation::CreateItem (currentItem(), theRow, theColumn);
- //else
- // return VInspector_ItemSelectMgrSelection::CreateItem(currentItem(), theRow, theColumn);
- return TreeModel_ItemBasePtr();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemPrs3dPresentation::Init()
-{
- VInspector_ItemPresentationsPtr aParentItem = itemDynamicCast<VInspector_ItemPresentations>(Parent());
-
- TCollection_AsciiString aName;
- Handle(Prs3d_Presentation) aPresentation = aParentItem->GetPresentation (Row(), aName);
- setPresentation (aPresentation, aName);
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemPrs3dPresentation::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setPresentation (NULL, "None");
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemPrs3dPresentation::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemPrs3dPresentation*>(this)->Init();
-}
-
-// =======================================================================
-// function : setPresentation
-// purpose :
-// =======================================================================
-void VInspector_ItemPrs3dPresentation::setPresentation (const Handle(Prs3d_Presentation)& thePresentation,
- const TCollection_AsciiString& theName)
-{
- myPresentation = thePresentation;
- myName = theName;
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemPrs3dPresentation::GetTableRowCount() const
-{
- return 14;
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemPrs3dPresentation::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- switch (theRow)
- {
- case 4:
- {
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_UNKNOWN));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Default));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Top));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Topmost));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_TopOSD));
- aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_BotOSD));
- }
- break;
- default: break;
- }
- return aValues;
-}
-
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemPrs3dPresentation::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(Prs3d_Presentation) aPrs = GetPresentation();
- switch (theRow)
- {
- case 0: return ViewControl_Table::SeparatorData();
- case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (Prs3d_Presentation)->Name())
- : ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
- case 2: return ViewControl_Table::SeparatorData();
- case 3: return isFirstColumn ? QVariant ("DisplayPriority") : QVariant (aPrs->DisplayPriority());
- case 4: return isFirstColumn ? QVariant ("GetZLayer")
- : QVariant (Graphic3d::ZLayerIdToString (aPrs->GetZLayer()));
- case 5: return isFirstColumn ? QVariant ("MinMaxValues")
- : QVariant (ViewControl_Tools::ToString (aPrs->MinMaxValues()).ToCString());
- case 6: return isFirstColumn ? QVariant ("ContainsFacet") : QVariant (aPrs->ContainsFacet());
- case 7: return isFirstColumn ? QVariant ("IsDeleted") : QVariant (aPrs->IsDeleted());
- case 8: return isFirstColumn ? QVariant ("IsDisplayed") : QVariant (aPrs->IsDisplayed());
- case 9: return isFirstColumn ? QVariant ("IsEmpty") : QVariant (aPrs->IsEmpty());
- case 10: return isFirstColumn ? QVariant ("IsInfinite") : QVariant (aPrs->IsInfinite());
- case 11: return isFirstColumn ? QVariant ("IsHighlighted") : QVariant (aPrs->IsHighlighted());
- case 12: return isFirstColumn ? QVariant ("IsTransformed") : QVariant (aPrs->IsTransformed());
- case 13: return isFirstColumn ? QVariant ("IsVisible") : QVariant (aPrs->IsVisible());
- default: return QVariant();
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemPrs3dPresentation::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(Prs3d_Presentation) aPrs = GetPresentation();
- switch (theRow)
- {
- case 8: aPrs->SetZLayer (Graphic3d::ZLayerIdFromString (theValue.toString().toStdString().c_str()));
- default: return false;
- }
- return true;
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemPrs3dPresentation::buildPresentationShape()
-{
- if (!myPresentation.IsNull())
- myPresentationShape = Convert_Tools::CreateShape (myPresentation->MinMaxValues());
-
- return TopoDS_Shape();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemPrs3dPresentation_H
-#define VInspector_ItemPrs3dPresentation_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <AIS_InteractiveObject.hxx>
-#include <NCollection_List.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemPrs3dPresentation;
-typedef QExplicitlySharedDataPointer<VInspector_ItemPrs3dPresentation> VInspector_ItemPrs3dPresentationPtr;
-
-//! \class VInspector_ItemPrs3dPresentation
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspector_ItemPrs3dPresentation : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemPrs3dPresentationPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemPrs3dPresentationPtr (new VInspector_ItemPrs3dPresentation (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspector_ItemPrs3dPresentation() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myPresentation; }
-
- //! Returns the current presentation, init item if it was not initialized yet
- //! \return presentation object
- Standard_EXPORT Handle(Prs3d_Presentation) GetPresentation() const
- { return Handle(Prs3d_Presentation)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Returns number of item selected
- //! \return rows count
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
-
-private:
-
- //! Set presentation into the current field
- //! \param thePresentation a presentation
- //! \param theName the item name
- void setPresentation (const Handle(Prs3d_Presentation)& thePresentation,
- const TCollection_AsciiString& theName);
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemPrs3dPresentation(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(Prs3d_Presentation) myPresentation; //!< the current presentation
- TCollection_AsciiString myName; //!< the item display data value
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/VInspector_ItemSelect3DSensitiveSetItem.hxx>
-
-//#include <AIS_ListOfInteractive.hxx>
-//#include <AIS_Shape.hxx>
-//#include <BRep_Builder.hxx>
-//#include <BRepBuilderAPI_MakeEdge.hxx>
-//#include <BRepBuilderAPI_MakeVertex.hxx>
-//#include <SelectBasics_SensitiveEntity.hxx>
-//#include <Select3D_SensitiveBox.hxx>
-//#include <Select3D_SensitiveCircle.hxx>
-//#include <Select3D_SensitiveCurve.hxx>
-//#include <Select3D_SensitiveFace.hxx>
-//#include <Select3D_SensitivePoint.hxx>
-//#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveSet.hxx>
-//#include <Select3D_SensitiveTriangle.hxx>
-//#include <Select3D_InteriorSensitivePointSet.hxx> // child of Select3D_SensitiveSet
-//#include <Select3D_SensitiveGroup.hxx>
-//#include <Select3D_SensitivePoly.hxx>
-//#include <Select3D_SensitivePrimitiveArray.hxx>
-//#include <Select3D_SensitiveTriangulation.hxx>
-//#include <Select3D_SensitiveWire.hxx>
-//#include <SelectMgr_EntityOwner.hxx>
-//#include <SelectMgr_Selection.hxx>
-//#include <SelectMgr_SensitiveEntity.hxx>
-//#include <Standard_Version.hxx>
-//#include <StdSelect_BRepOwner.hxx>
-//#include <TColgp_HArray1OfPnt.hxx>
-//#include <TopoDS_Edge.hxx>
-//#include <TopoDS_Face.hxx>
-//#include <TopoDS_Shape.hxx>
-//#include <TopoDS_Vertex.hxx>
-//
-//#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectBasicsSensitiveEntity.hxx>
-//#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
-#include <inspector/VInspector_Tools.hxx>
-//#include <inspector/ViewControl_Table.hxx>
-//#include <inspector/ViewControl_Tools.hxx>
-//
-
-#include <inspector/Convert_Tools.hxx>
-#include <Standard_WarningsDisable.hxx>
-//#include <QStringList>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : GetSensitiveEntity
-// purpose :
-// =======================================================================
-Handle(Standard_Transient) VInspector_ItemSelect3DSensitiveSetItem::GetObject() const
-{
- //initItem(); // to update presentation shapes
- VInspector_ItemSelectBasicsSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSelectBasicsSensitiveEntity>(Parent());
- if (aParentItem)
- return aParentItem->GetSensitiveEntity();
- return Handle(Standard_Transient)();
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelect3DSensitiveSetItem::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
- if (anEntity.IsNull())
- return QVariant();
-
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return QString ("Index = %1").arg (Row());
- default:
- break;
- }
- break;
- }
- case Qt::BackgroundRole:
- case Qt::ForegroundRole:
- {
- VInspector_ItemSelectBasicsSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSelectBasicsSensitiveEntity>(Parent());
- if (aParentItem)
- return aParentItem->data(QModelIndex(), theItemRole);
- break;
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelect3DSensitiveSetItem::Init()
-{
- UpdatePresentationShape();
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelect3DSensitiveSetItem::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelect3DSensitiveSetItem::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelect3DSensitiveSetItem*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelect3DSensitiveSetItem::GetTableRowCount() const
-{
- return 1;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelect3DSensitiveSetItem::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(Select3D_SensitiveSet) aSensitiveSet = Handle(Select3D_SensitiveSet)::DownCast (GetSensitiveEntity());
- if (aSensitiveSet.IsNull() || aSensitiveSet->Size() <= Row())
- return "Empty Select3D_SensitiveSet item";
-
- Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Box") : QVariant (VInspector_Tools::ToVariant (aSensitiveSet->Box (Row())));
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelect3DSensitiveSetItem::buildPresentationShape()
-{
- Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
- if (anEntity.IsNull())
- return TopoDS_Shape();
-
- Handle(Select3D_SensitiveSet) aSensitiveSet = Handle(Select3D_SensitiveSet)::DownCast (GetSensitiveEntity());
- if (aSensitiveSet.IsNull() || aSensitiveSet->Size() < Row())
- return TopoDS_Shape();
-
- Select3D_BndBox3d aBndBox = aSensitiveSet->Box (Row());
- return VInspector_Tools::CreateShape (aBndBox);
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelect3DSensitiveSetItem_H
-#define VInspector_ItemSelect3DSensitiveSetItem_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <SelectBasics_EntityOwner.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class QItemSelectionModel;
-class VInspector_ItemSelect3DSensitiveSetItem;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelect3DSensitiveSetItem> VInspector_ItemSelect3DSensitiveSetItemPtr;
-
-//! \class VInspector_ItemSelect3DSensitiveSetItem
-//! The item shows information about SelectBasics_EntityOwner.
-//! The parent is item selection, children are item entity owners
-class VInspector_ItemSelect3DSensitiveSetItem : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelect3DSensitiveSetItemPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelect3DSensitiveSetItemPtr (new VInspector_ItemSelect3DSensitiveSetItem (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelect3DSensitiveSetItem() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const;
-
- //! \return the current sensitive entity
- Standard_EXPORT Handle(SelectBasics_SensitiveEntity) GetSensitiveEntity() const
- { return Handle(SelectBasics_SensitiveEntity)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \thePresentations [out] container of presentation handles to be visualized
- //Standard_EXPORT virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- //virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- //virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE { return 0; }
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
- { (void)theRow, (void)theColumn; return TreeModel_ItemBasePtr(); }
-
- //! Returns owner of the current sensitive entity
- //! \return owner
- //Handle(SelectBasics_EntityOwner) getEntityOwner() const;
-
- //! Returns table value for the row in form: <function name> <function value> depending on the aspect kind
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theEntityKind kind or kind of entity
- QVariant getTableData (const int theRow,
- const int theColumn,
- const int theRole,
- const TCollection_AsciiString& theEntityKind) const;
-
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelect3DSensitiveSetItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <SelectBasics_EntityOwner.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QItemSelectionModel>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectBasicsEntityOwner::initValue(int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- Handle(SelectBasics_EntityOwner) anOwner = getEntityOwner();
- if (anOwner.IsNull())
- return QVariant();
-
- switch (Column())
- {
- case 0: return anOwner->DynamicType()->Name();
- default: break;
- }
- break;
- }
- case Qt::BackgroundRole:
- case Qt::ForegroundRole:
- {
- if (Column() == 2)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
- if (!aContext.IsNull())
- {
- if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
- return (theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white);
- }
- }
- VInspector_ItemSelectMgrSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntity>(Parent());
- if (aParentItem)
- return aParentItem->data(QModelIndex(), theItemRole);
- break;
- }
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsEntityOwner::Init()
-{
- Handle(SelectBasics_EntityOwner) anOwner;
-
- VInspector_ItemSelectMgrSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntity>(Parent());
- if (aParentItem)
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aParentItem->GetSensitiveEntity();
- if (!anEntity.IsNull() && !anEntity->BaseSensitive().IsNull())
- anOwner = anEntity->BaseSensitive()->OwnerId();
- }
- else
- {
- VInspector_ItemPresentableObjectPtr aPOItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- if (aPOItem)
- {
- Handle(AIS_InteractiveObject) anIO = aPOItem->GetInteractiveObject();
-
- int aRowId = Row();
- int aCurrentIndex = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
- {
- const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
- for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
-#else
- for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next())
- {
- const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next())
- {
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
-#endif
- const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
- if (!aBase.IsNull())
- {
- if (aRowId == aCurrentIndex)
- anOwner = aBase->OwnerId();
- aCurrentIndex++;
- }
- }
- }
- }
- }
- myOwner = anOwner;
- UpdatePresentationShape();
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsEntityOwner::Reset()
-{
- VInspector_ItemBase::Reset();
- SetContext (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsEntityOwner::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectBasicsEntityOwner*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetStream
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsEntityOwner::GetStream (Standard_OStream& OS) const
-{
- Handle(SelectMgr_EntityOwner) anEntityOwner = Handle(SelectMgr_EntityOwner)::DownCast (getEntityOwner());
- if (anEntityOwner.IsNull())
- return;
-
- anEntityOwner->Dump (OS);
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectBasicsEntityOwner::GetTableRowCount() const
-{
- return 20;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemSelectBasicsEntityOwner::GetTableEditType(const int theRow, const int) const
-{
- switch (theRow)
- {
- case 0: return ViewControl_EditType_Spin;
- default: return ViewControl_EditType_None;
- }
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemSelectBasicsEntityOwner::GetTableEnumValues(const int theRow, const int) const
-{
- QList<QVariant> aValues;
- /*switch (theRow)
- {
- case 5:
- {
- for (int i = 0; i <= Aspect_TOFM_FRONT_SIDE; i++)
- aValues.append (Aspect::TypeOfFacingModelToString((Aspect_TypeOfFacingModel)i));
- }
- break;
- case 17:
- {
- for (int i = 0; i <= PrsMgr_TOP_ProjectorDependant; i++)
- aValues.append (PrsMgr::TypeOfPresentation3dToString ((PrsMgr_TypeOfPresentation3d)i));
- }
- break;
- default: break;
- }*/
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectBasicsEntityOwner::GetTableData(const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(SelectBasics_EntityOwner) anOwner = getEntityOwner();
- Handle(SelectMgr_EntityOwner) anEntityOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwner);
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Priority") : QVariant (anOwner->Priority());
- case 1: return isFirstColumn ? QVariant ("HasLocation") : QVariant (anOwner->HasLocation());
- case 2: return isFirstColumn ? QVariant ("Location") :
- (anOwner->HasLocation() ? QVariant (ViewControl_Tools::ToString (anOwner->Location()).ToCString()) : QVariant());
- case 3: return isFirstColumn ? QVariant ("IsSelected") : QVariant (!anEntityOwner.IsNull() ? anEntityOwner->IsSelected() : "");
- default: break;
- }
-
-
- Handle(StdSelect_BRepOwner) aBROwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
- if (aBROwner.IsNull())
- return QVariant();
-
- int aBRepOwnerRow = theRow - 4;
- switch (aBRepOwnerRow)
- {
- case 0: return ViewControl_Table::SeparatorData();
- case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (StdSelect_BRepOwner)->Name())
- : ViewControl_Tools::GetPointerInfo (aBROwner).ToCString();
- case 2: return ViewControl_Table::SeparatorData();
- case 3: return isFirstColumn ? QVariant ("HilightMode") : QVariant (aBROwner->HilightMode());
- case 4: return isFirstColumn ? QVariant ("Shape") :
- (!aBROwner->Shape().IsNull() ? ViewControl_Tools::GetPointerInfo (aBROwner->Shape().TShape()).ToCString() : QVariant());
- case 5: return isFirstColumn ? QVariant ("ShapeType") :
- (!aBROwner->Shape().IsNull() ? VInspector_Tools::GetShapeTypeInfo (aBROwner->Shape().ShapeType()).ToCString() : QVariant());
- default: return QVariant();
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemSelectBasicsEntityOwner::SetTableData(const int theRow, const int, const QVariant& theValue)
-{
- Handle(SelectBasics_EntityOwner) anOwner = getEntityOwner();
- switch (theRow)
- {
- case 0: anOwner->SetPriority (theValue.toInt());
- default: return false;
- }
- return true;
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelectBasicsEntityOwner::buildPresentationShape()
-{
- Handle(StdSelect_BRepOwner) aBROwner = Handle(StdSelect_BRepOwner)::DownCast (myOwner);
- if (aBROwner.IsNull())
- return TopoDS_Shape();
-
- return aBROwner->Shape();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelectBasicsEntityOwner_H
-#define VInspector_ItemSelectBasicsEntityOwner_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemSelectBasicsEntityOwner;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectBasicsEntityOwner> VInspector_ItemSelectBasicsEntityOwnerPtr;
-
-//! \class VInspector_ItemPresentableObject
-//! Item for selection entity owner. The parent is sensitive entity item, there are no children
-class VInspector_ItemSelectBasicsEntityOwner : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectBasicsEntityOwnerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectBasicsEntityOwnerPtr (new VInspector_ItemSelectBasicsEntityOwner (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectBasicsEntityOwner() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myOwner; }
-
- //! Returns the current entity owner
- Handle(SelectBasics_EntityOwner) EntityOwner() const { return myOwner; }
-
- //! Returns stream value of the item to fulfill property panel.
- //! \return stream value or dummy
- Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType(const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues(const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData(const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData(const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE{ return 0; }
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape();
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
- { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelectBasicsEntityOwner(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- //! Returns the current entity owner. Initializes the item if it was not initialized yet
- Handle(SelectBasics_EntityOwner) getEntityOwner() const
- { return Handle(SelectBasics_EntityOwner)::DownCast (GetObject()); }
-
-private:
-
- Handle(SelectBasics_EntityOwner) myOwner; //!< the current entity owner
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/VInspector_ItemSelectBasicsSensitiveEntity.hxx>
-#include <inspector/VInspector_ItemSelect3DSensitiveSetItem.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_Shape.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveCircle.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <Select3D_SensitiveFace.hxx>
-#include <Select3D_SensitivePoint.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveSet.hxx>
-#include <Select3D_SensitiveTriangle.hxx>
-#include <Select3D_InteriorSensitivePointSet.hxx> // child of Select3D_SensitiveSet
-#include <Select3D_SensitiveGroup.hxx>
-#include <Select3D_SensitivePoly.hxx>
-#include <Select3D_SensitivePrimitiveArray.hxx>
-#include <Select3D_SensitiveTriangulation.hxx>
-#include <Select3D_SensitiveWire.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-
-#include <inspector/Convert_Tools.hxx>
-
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectBasicsSensitiveEntity::initRowCount() const
-{
- Handle(Select3D_SensitiveSet) aSensitiveSet = Handle(Select3D_SensitiveSet)::DownCast (GetSensitiveEntity());
- if (!aSensitiveSet.IsNull())
- return aSensitiveSet->Size();
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectBasicsSensitiveEntity::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
- if (anEntity.IsNull())
- return QVariant();
-
- Handle(SelectBasics_EntityOwner) anOwner = anEntity->OwnerId();
-
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return anEntity->DynamicType()->Name();
- default:
- break;
- }
- break;
- }
- case Qt::BackgroundRole:
- case Qt::ForegroundRole:
- {
- if (Column() == 2)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
- if (!aContext.IsNull())
- {
- if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
- return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
- }
- }
- VInspector_ItemSelectMgrSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntity>(Parent());
- if (aParentItem)
- return aParentItem->data(QModelIndex(), theItemRole);
- break;
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectBasicsSensitiveEntity::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemSelect3DSensitiveSetItem::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsSensitiveEntity::Init()
-{
- VInspector_ItemSelectMgrSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntity>(Parent());
-
- Handle(SelectMgr_SensitiveEntity) anEntity = aParentItem->GetSensitiveEntity();
-
- myEntity = anEntity->BaseSensitive();
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsSensitiveEntity::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
- myEntity = NULL;
- //if (!myPresentation.IsNull() && !myPresentation->GetContext().IsNull())
- //{
- // myPresentation->GetContext()->Erase (myPresentation, Standard_False);
- // myPresentation = NULL;
- //}
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsSensitiveEntity::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectBasicsSensitiveEntity*>(this)->Init();
-}
-
-// =======================================================================
-// function : getEntityOwner
-// purpose :
-// =======================================================================
-Handle(SelectBasics_EntityOwner) VInspector_ItemSelectBasicsSensitiveEntity::getEntityOwner() const
-{
- initItem();
-
- Handle(SelectBasics_EntityOwner) anOwner;
- const Handle(SelectBasics_SensitiveEntity)& aBase = GetSensitiveEntity();
- if (aBase.IsNull())
- return anOwner;
- return aBase->OwnerId();
-}
-
-// =======================================================================
-// function : GetPresentations
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectBasicsSensitiveEntity::GetPresentations(NCollection_List<Handle(Standard_Transient)>& thePresentations)
-{
- if (Column() != 0)
- return;
-
- if (!myPresentation.IsNull())
- return;
-
- Handle(Select3D_SensitiveEntity) aBaseEntity = GetSensitiveEntity();
- if (aBaseEntity.IsNull())
- return;
-
- TopoDS_Shape aShape = GetPresentationShape();
- if (aShape.IsNull())
- return;
-
- myPresentation = new AIS_Shape (aShape);
- myPresentation->SetColor (Quantity_Color (Quantity_NOC_BLUE1));
- thePresentations.Append (myPresentation);
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectBasicsSensitiveEntity::GetTableRowCount() const
-{
- return 40;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemSelectBasicsSensitiveEntity::GetTableEditType(const int theRow, const int) const
-{
- switch (theRow)
- {
- case 3: return ViewControl_EditType_Spin;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectBasicsSensitiveEntity::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
- if (anEntity.IsNull())
- return QVariant();
-
- switch (theRow)
- {
- case 0: return ViewControl_Table::SeparatorData();
- case 1: return isFirstColumn ? QVariant(STANDARD_TYPE(SelectBasics_SensitiveEntity)->Name())
- : ViewControl_Tools::GetPointerInfo (anEntity).ToCString();
- case 2: return ViewControl_Table::SeparatorData();
-
- case 3: return isFirstColumn ? QVariant ("SensitivityFactor") : QVariant(anEntity->SensitivityFactor());
- case 4: return isFirstColumn ? QVariant ("NbSubElements") : QVariant (anEntity->NbSubElements());
- case 5: return isFirstColumn ? QVariant ("BoundingBox") : QVariant (VInspector_Tools::ToVariant (anEntity->BoundingBox()));
-
- case 6: return isFirstColumn ? QVariant ("HasInitLocation") : QVariant (anEntity->HasInitLocation());
- case 7: return isFirstColumn ? QVariant ("InvInitLocation")
- : QVariant (ViewControl_Tools::ToString (anEntity->InvInitLocation().Trsf()).ToCString());
-
- case 8: return ViewControl_Table::SeparatorData();
- case 9: return isFirstColumn ? QVariant (anEntity->DynamicType()->Name())
- : ViewControl_Tools::GetPointerInfo (anEntity).ToCString();
- case 10: return ViewControl_Table::SeparatorData();
- default: return getTableData (theRow, theColumn, theRole, anEntity->DynamicType()->Name());
- }
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemSelectBasicsSensitiveEntity::SetTableData(const int theRow, const int, const QVariant& theValue)
-{
- Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
- switch (theRow)
- {
- case 3: anEntity->SetSensitivityFactor(theValue.toInt());
- //case 5: aPrs->SetCurrentFacingModel (Aspect::TypeOfFacingModelFromString (theValue.toString().toStdString().c_str()));
- //case 6: aPrs->SetInfiniteState (theValue.toBool());
- //case 12: aPrs->SetAutoHilight(theValue.toBool());
- //case 17: aPrs->SetTypeOfPresentation (PrsMgr::TypeOfPresentation3dFromString (theValue.toString().toStdString().c_str()));
- //case 18: aPrs->SetMutable (theValue.toBool());
- default: return false;
- }
- return true;
-}
-
-// =======================================================================
-// function : getTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectBasicsSensitiveEntity::getTableData (const int theRow,
- const int theColumn,
- const int,
- const TCollection_AsciiString& theEntityKind) const
-{
- Handle(Select3D_SensitiveEntity) aBaseEntity = GetSensitiveEntity();
- if (aBaseEntity.IsNull())
- return QVariant();
-
- int aRow = theRow - 11;
- bool isFirstColumn = theColumn == 0;
-
- if (aRow == 0)
- return isFirstColumn ? QVariant ("CenterOfGeometry")
- : QVariant (ViewControl_Tools::ToString (aBaseEntity->CenterOfGeometry()).ToCString());
- aRow = aRow - 1; // for Select3D_SensitiveEntity common value
-
- Handle(Select3D_SensitiveSet) aSetEntity = Handle(Select3D_SensitiveSet)::DownCast (aBaseEntity);
- if (!aSetEntity.IsNull())
- {
- if (aRow == 0)
- {
- return isFirstColumn ? QVariant ("Size") : QVariant (aSetEntity->Size());
- }
- aRow = aRow - 1; // for Select3D_SensitiveSet common value
- }
- //if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveBox)->Name())
- //{
- //Handle(Select3D_SensitiveBox) anEntity = Handle(Select3D_SensitiveBox)::DownCast (aBaseEntity);
- //}
- if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveCircle)->Name())
- {
- Handle(Select3D_SensitiveCircle) anEntity = Handle(Select3D_SensitiveCircle)::DownCast (aBaseEntity);
- //if (aRow == 0)
- }
- if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveCurve)->Name())
- {
- Handle(Select3D_SensitiveCurve) anEntity = Handle(Select3D_SensitiveCurve)::DownCast (aBaseEntity);
- //if (aRow == 0)
- }
- if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveFace)->Name())
- {
- Handle(Select3D_SensitiveFace) anEntity = Handle(Select3D_SensitiveFace)::DownCast (aBaseEntity);
- if (aRow == 0)
- {
- if (isFirstColumn)
- return "GetPoints";
- else
- {
- Handle(TColgp_HArray1OfPnt) aPoints;
- anEntity->GetPoints (aPoints);
- return ViewControl_Tools::ToString (aPoints).ToCString();
- }
- }
- }
- else if (theEntityKind == STANDARD_TYPE (Select3D_SensitivePoint)->Name())
- {
- Handle(Select3D_SensitivePoint) anEntity = Handle(Select3D_SensitivePoint)::DownCast (aBaseEntity);
- if (aRow == 0)
- return isFirstColumn ? QVariant ("Point") : QVariant (ViewControl_Tools::ToString (anEntity->Point()).ToCString());
- }
- else if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveSegment)->Name())
- {
- Handle(Select3D_SensitiveSegment) anEntity = Handle(Select3D_SensitiveSegment)::DownCast (aBaseEntity);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("StartPoint") : QVariant (ViewControl_Tools::ToString (anEntity->StartPoint()).ToCString());
- case 1: return isFirstColumn ? QVariant ("EndPoint") : QVariant (ViewControl_Tools::ToString (anEntity->EndPoint()).ToCString());
- default: break;
- }
- }
- //Select3D_SensitiveSet
- else if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveTriangle)->Name())
- {
- Handle(Select3D_SensitiveTriangle) anEntity = Handle(Select3D_SensitiveTriangle)::DownCast (aBaseEntity);
- gp_Pnt aPnt0, aPnt1, aPnt2;
- anEntity->Points3D (aPnt0, aPnt1, aPnt2);
- switch (aRow)
- {
- case 0: return isFirstColumn ? QVariant ("Points (0)") : QVariant (ViewControl_Tools::ToString (aPnt0).ToCString());
- case 1: return isFirstColumn ? QVariant ("Points (1)") : QVariant (ViewControl_Tools::ToString (aPnt1).ToCString());
- case 2: return isFirstColumn ? QVariant ("Points (2)") : QVariant (ViewControl_Tools::ToString (aPnt2).ToCString());
- default: break;
- }
- }
- //Select3D_InteriorSensitivePointSet
- //Select3D_SensitiveGroup
- else if (theEntityKind == STANDARD_TYPE (Select3D_SensitivePoly)->Name() ||
- theEntityKind == STANDARD_TYPE (Select3D_SensitiveCircle)->Name() ||
- theEntityKind == STANDARD_TYPE (Select3D_SensitiveCurve)->Name())
- {
- if (aRow == 0)
- {
- if (isFirstColumn)
- return "GetPoints";
- else
- {
- Handle(Select3D_SensitivePoly) anEntity = Handle(Select3D_SensitivePoly)::DownCast (aBaseEntity);
- Handle(TColgp_HArray1OfPnt) aPoints;
- anEntity->Points3D (aPoints);
- return ViewControl_Tools::ToString (aPoints).ToCString();
- }
- }
- }
- else if (theEntityKind == STANDARD_TYPE (Select3D_SensitivePrimitiveArray)->Name())
- {
- // TODO
- }
- else if (theEntityKind == STANDARD_TYPE (Select3D_SensitiveTriangulation)->Name())
- {
- Handle(Select3D_SensitiveTriangulation) anEntity = Handle(Select3D_SensitiveTriangulation)::DownCast (aBaseEntity);
- if (aRow == 0)
- return isFirstColumn ? QVariant ("Triangulation") : QVariant (ViewControl_Tools::GetPointerInfo (anEntity->Triangulation()).ToCString());
- }
- //Select3D_SensitiveWire
- return QVariant();
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelectBasicsSensitiveEntity::buildPresentationShape
- (const Handle(SelectBasics_SensitiveEntity)& theEntity)
-{
- Handle(Select3D_SensitiveEntity) aBaseEntity = theEntity;
- if (aBaseEntity.IsNull())
- return TopoDS_Shape();
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
-
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (aBaseEntity->CenterOfGeometry()));
-
- Select3D_BndBox3d aBoundingBox = aBaseEntity->BoundingBox();
- if (aBoundingBox.IsValid())
- aBuilder.Add (aCompound, VInspector_Tools::CreateShape (aBoundingBox));
-
- Standard_CString aTypeName = aBaseEntity->DynamicType()->Name();
- if (aTypeName == STANDARD_TYPE (Select3D_SensitiveBox)->Name())
- {
- Handle(Select3D_SensitiveBox) anEntity = Handle(Select3D_SensitiveBox)::DownCast (aBaseEntity);
- TopoDS_Shape aShape = Convert_Tools::CreateShape(anEntity->Box());
- aBuilder.Add (aCompound, aShape);
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitiveFace)->Name())
- {
- Handle(Select3D_SensitiveFace) anEntity = Handle(Select3D_SensitiveFace)::DownCast (aBaseEntity);
- Handle(TColgp_HArray1OfPnt) aPoints;
- anEntity->GetPoints (aPoints);
- for (Standard_Integer aPntIter = aPoints->Lower(); aPntIter <= aPoints->Upper(); ++aPntIter)
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(aPoints->Value (aPntIter)));
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitivePoint)->Name())
- {
- Handle(Select3D_SensitivePoint) anEntity = Handle(Select3D_SensitivePoint)::DownCast (aBaseEntity);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(anEntity->Point()));
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitiveSegment)->Name())
- {
- Handle(Select3D_SensitiveSegment) anEntity = Handle(Select3D_SensitiveSegment)::DownCast (aBaseEntity);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge(anEntity->StartPoint(), anEntity->EndPoint()));
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitiveTriangle)->Name())
- {
- Handle(Select3D_SensitiveTriangle) anEntity = Handle(Select3D_SensitiveTriangle)::DownCast (aBaseEntity);
- gp_Pnt aPnt0, aPnt1, aPnt2;
- anEntity->Points3D (aPnt0, aPnt1, aPnt2);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(aPnt0));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(aPnt1));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(aPnt2));
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitivePoly)->Name() ||
- aTypeName == STANDARD_TYPE (Select3D_SensitiveCircle)->Name() ||
- aTypeName == STANDARD_TYPE (Select3D_SensitiveCurve)->Name())
- {
- Handle(Select3D_SensitivePoly) anEntity = Handle(Select3D_SensitivePoly)::DownCast (aBaseEntity);
-
- Handle(TColgp_HArray1OfPnt) aPoints;
- anEntity->Points3D (aPoints);
- for (Standard_Integer aPntIter = aPoints->Lower(); aPntIter <= aPoints->Upper(); ++aPntIter)
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(aPoints->Value (aPntIter)));
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitivePrimitiveArray)->Name())
- {
- }
- else if (aTypeName == STANDARD_TYPE (Select3D_SensitiveTriangulation)->Name())
- {
- Handle(Select3D_SensitiveTriangulation) anEntity = Handle(Select3D_SensitiveTriangulation)::DownCast (aBaseEntity);
- const Handle(Poly_Triangulation)& aPolyTriangulation = anEntity->Triangulation();
- if (!aPolyTriangulation.IsNull())
- {
- TopoDS_Face aFace;
- aBuilder.MakeFace (aFace, aPolyTriangulation);
- aBuilder.Add (aCompound, aFace);
- }
- }
-
- return aCompound;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelectBasicsSensitiveEntity_H
-#define VInspector_ItemSelectBasicsSensitiveEntity_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <SelectBasics_EntityOwner.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class QItemSelectionModel;
-class VInspector_ItemSelectBasicsSensitiveEntity;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectBasicsSensitiveEntity> VInspector_ItemSelectBasicsSensitiveEntityPtr;
-
-//! \class VInspector_ItemSelectBasicsSensitiveEntity
-//! The item shows information about SelectBasics_EntityOwner.
-//! The parent is item selection, children are item entity owners
-class VInspector_ItemSelectBasicsSensitiveEntity : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectBasicsSensitiveEntityPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectBasicsSensitiveEntityPtr (new VInspector_ItemSelectBasicsSensitiveEntity (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectBasicsSensitiveEntity() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myEntity; }
-
- //! \return the current sensitive entity
- Standard_EXPORT Handle(SelectBasics_SensitiveEntity) GetSensitiveEntity() const
- { return Handle(SelectBasics_SensitiveEntity)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \thePresentations [out] container of presentation handles to be visualized
- Standard_EXPORT virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
- //! Returns owner of the current sensitive entity
- //! \return owner
- Handle(SelectBasics_EntityOwner) getEntityOwner() const;
-
- //! Returns table value for the row in form: <function name> <function value> depending on the aspect kind
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theEntityKind kind or kind of entity
- QVariant getTableData (const int theRow,
- const int theColumn,
- const int theRole,
- const TCollection_AsciiString& theEntityKind) const;
-
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE { return buildPresentationShape (myEntity); }
-
- //! Creates shape depending on the entity kind and parameters
- //! \param theEntity current sensitive entity
- //! \return shape or NULL
- static TopoDS_Shape buildPresentationShape (const Handle(SelectBasics_SensitiveEntity)& theEntity);
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelectBasicsSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- Handle(SelectBasics_SensitiveEntity) myEntity; //!< the current sensitive entity
- Handle(AIS_InteractiveObject) myPresentation; //!< the current presentation
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrBaseFrustum.hxx>
-
-#include <inspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrBaseFrustum::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrBaseFrustum::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle (SelectMgr_BaseFrustum) aFrustum = GetFrustum();
- if (aFrustum.IsNull())
- return Column() == 0 ? "Empty frustum" : "";
-
- switch (Column())
- {
- case 0: return aFrustum->DynamicType()->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrBaseFrustum::Init()
-{
- VInspector_ItemSelectMgrSelectingVolumeManagerPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelectingVolumeManager>(Parent());
-
- Handle(SelectMgr_BaseFrustum) aFrustum;
- if (aParentItem)
- {
- SelectMgr_SelectingVolumeManager aVolumeManager;
- if (aParentItem->GetViewerSelector (aVolumeManager))
- {
- aFrustum = aVolumeManager.ActiveVolume();
- }
- }
- setFrustum (aFrustum);
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrBaseFrustum::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setFrustum (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrBaseFrustum::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrBaseFrustum*>(this)->Init();
-}
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemSelectMgrBaseFrustum::Dump (Standard_OStream& OS) const
-{
- Handle(SelectMgr_BaseFrustum) aFrustum = GetFrustum();
-
- if (aFrustum.IsNull())
- return Standard_False;
-
- aFrustum->Dump (OS);
- return Standard_True;
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrBaseFrustum::GetTableRowCount() const
-{
- return 60;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrBaseFrustum::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(SelectMgr_BaseFrustum) aView = GetFrustum();
- if (aView.IsNull())
- return QVariant();
-
- //bool isFirstColumn = theColumn == 0;
- //switch (theRow)
- //{
- // case 0:
- // {
- // if (isFirstColumn)
- // return QVariant ("ImmediateUpdate");
-
- // Standard_Boolean aCurState = aView->SetImmediateUpdate (Standard_False);
- // aView->SetImmediateUpdate (aCurState);
-
- // return aCurState;
- // }
- // break;
- // case 1:
- // {
- // if (isFirstColumn)
- // return QVariant ("ActiveLights");
-
- // V3d_ListOfLightIterator aLightsIt = aView->ActiveLightIterator();
- // Standard_Integer aNbOfLights = 0;
- // while (aLightsIt.More())
- // {
- // aNbOfLights++;
- // aLightsIt.Next();
- // }
- // return aNbOfLights;
- // }
- // case 2:
- // {
- // if (isFirstColumn)
- // return QVariant ("Axis: origin");
-
- // Standard_Real aX, anY, aZ, aVx, aVy, aVz;
- // aView->Axis (aX, anY, aZ, aVx, aVy, aVz);
-
- // return ViewControl_Tools::ToString (gp_Pnt (aX, anY, aZ)).ToCString();
- // }
- // case 3:
- // {
- // if (isFirstColumn)
- // return QVariant ("Axis: direction");
-
- // Standard_Real aX, anY, aZ, aVx, aVy, aVz;
- // aView->Axis (aX, anY, aZ, aVx, aVy, aVz);
-
- // return ViewControl_Tools::ToString (gp_Dir (aVx, aVy, aVz)).ToCString();
- // }
- // case 4: return isFirstColumn ? QVariant ("ComputedMode") : QVariant (aView->ComputedMode());
- // case 5: return isFirstColumn ? QVariant ("AutoZFitMode") : QVariant (aView->AutoZFitMode());
- // case 6: return isFirstColumn ? QVariant ("AutoZFitScaleFactor") : QVariant (aView->AutoZFitScaleFactor());
- //}
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrBaseFrustum::createChild (int theRow, int theColumn)
-{
- //if (theRow == 0)
- // return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn);
- //else if (theRow == 1)
- // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
- //else if (theRow == 2)
- // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
- //
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrBaseFrustum_H
-#define VInspector_ItemSelectMgrBaseFrustum_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <SelectMgr_BaseFrustum.hxx>
-
-class VInspector_ItemSelectMgrBaseFrustum;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrBaseFrustum> VInspector_ItemSelectMgrBaseFrustumPtr;
-
-//! \class VInspector_ItemSelectMgrBaseFrustum
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemSelectMgrBaseFrustum : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrBaseFrustumPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrBaseFrustumPtr (new VInspector_ItemSelectMgrBaseFrustum (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrBaseFrustum() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myFrustum; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Handle(SelectMgr_BaseFrustum) GetFrustum() const
- { return Handle(SelectMgr_BaseFrustum)::DownCast (GetObject()); }
-
- //! Dumps the content of me on the stream <OS>.
- virtual Standard_Boolean Dump (Standard_OStream& OS) const;
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) 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:
-
- //! Set V3d viewer selector into the current field
- //! \param theFrustum a viewer selector
- void setFrustum (const Handle(SelectMgr_BaseFrustum)& theFrustum) { myFrustum = theFrustum; }
-
-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_ItemSelectMgrBaseFrustum(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(SelectMgr_BaseFrustum) myFrustum; //!< the current viewer selector
-};
-
-#endif
// =======================================================================
QVariant VInspector_ItemSelectMgrFilter::initValue (int theItemRole) const
{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
Handle(SelectMgr_Filter) aFilter = GetFilter();
{
case 0: return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (aFilter->DynamicType()->Name());
+ case 1: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
+ case 2: return VInspector_Tools::GetPointerInfo (aFilter, true).ToCString();
default: break;
}
}
const_cast<VInspector_ItemSelectMgrFilter*>(this)->Init();
}
+// =======================================================================
+// function : GetInteractiveObject
+// purpose :
+// =======================================================================
+Handle(SelectMgr_Filter) VInspector_ItemSelectMgrFilter::GetFilter() const
+{
+ initItem();
+ return myFilter;
+}
//! Destructor
virtual ~VInspector_ItemSelectMgrFilter() Standard_OVERRIDE {};
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myFilter; }
-
//! Returns the current filter, init item if it was not initialized yet
//! \return filter object
- Standard_EXPORT Handle(SelectMgr_Filter) GetFilter() const
- { return Handle(SelectMgr_Filter)::DownCast (GetObject()); }
+ Standard_EXPORT Handle(SelectMgr_Filter) GetFilter() const;
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+++ /dev/null
-// Created on: 2019-04-29
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrSelectableObjectSet.hxx>
-
-#include <inspector/VInspector_ItemBVHTree.hxx>
-#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
-#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <SelectMgr.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSelectableObjectSet::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return SelectMgr_SelectableObjectSet::BVHSubsetNb; // VInspector_ItemBVHTree items
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSelectableObjectSet::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- SelectMgr_SelectableObjectSet aSet;
- if (!GetSelectableObjectSet (aSet))
- return Column() == 0 ? "Empty selectable object set" : "";
-
- switch (Column())
- {
- case 0: return "SelectMgr_SelectableObjectSet";
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrSelectableObjectSet::Init()
-{
- //VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
- //Handle(SelectMgr_SelectingVolumeManager) aVolumeMgr;
- //if (aParentItem)
- //{
- // VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
- // if (aParentContextItem)
- // {
- // Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
- // aVolumeMgr = aContext->MainSelector();
- // }
- //}
- //setViewerSelector (aVolumeMgr);
-
- //UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrSelectableObjectSet::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrSelectableObjectSet::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrSelectableObjectSet*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetSelectableObjectSet
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemSelectMgrSelectableObjectSet::GetSelectableObjectSet (SelectMgr_SelectableObjectSet& theSet) const
-{
- VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent());
-
- if (!aParentItem || aParentItem->GetViewerSelector().IsNull())
- return Standard_False;
-
- theSet = aParentItem->GetViewerSelector()->GetSelectableObjects();
- return Standard_True;
-}
-
-// =======================================================================
-// function : GetBVHTree
-// purpose :
-// =======================================================================
-opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemSelectMgrSelectableObjectSet::GetBVHTree (const int theRow,
- TCollection_AsciiString& theName) const
-{
- SelectMgr_SelectableObjectSet aSet;
- if (!GetSelectableObjectSet (aSet))
- return NULL;
-
- if (theRow >= SelectMgr_SelectableObjectSet::BVHSubsetNb)
- return NULL;
-
- SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = (SelectMgr_SelectableObjectSet::BVHSubset)theRow;
- theName = TCollection_AsciiString ("BVH_Tree_") + SelectMgr::BVHSubsetToString (aBVHSubset);
-
- return aSet.BVH (aBVHSubset);
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSelectableObjectSet::GetTableRowCount() const
-{
- return 60;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSelectableObjectSet::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- //SelectMgr_SelectingVolumeManager aVolumeMgr;
- //if (!GetViewerSelector (aVolumeMgr))
- // return QVariant();
-
- //bool isFirstColumn = theColumn == 0;
- //switch (theRow)
- //{
- // case 0: return isFirstColumn ? QVariant ("GetActiveSelectionType") : QVariant (aVolumeMgr.GetActiveSelectionType());
- // case 1: return isFirstColumn ? QVariant ("IsOverlapAllowed()") : QVariant (aVolumeMgr.IsOverlapAllowed());
- // case 2: return isFirstColumn ? "GetNearPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetNearPickedPnt()).ToCString();
- // case 3: return isFirstColumn ? "GetFarPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetFarPickedPnt()).ToCString();
- // default: break;
- //}
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectableObjectSet::createChild (int theRow, int theColumn)
-{
- if (theRow == 0 || theRow == 1 || theRow == 2)
- return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn);
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-04-29
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrSelectableObjectSet_H
-#define VInspector_ItemSelectMgrSelectableObjectSet_H
-
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <BVH_Tree.hxx>
-#include <Standard.hxx>
-#include <SelectMgr_SelectableObjectSet.hxx>
-#include <TCollection_AsciiString.hxx>
-
-class SelectMgr_BaseFrustum;
-
-class VInspector_ItemSelectMgrSelectableObjectSet;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelectableObjectSet> VInspector_ItemSelectMgrSelectableObjectSetPtr;
-
-//! \class VInspector_ItemSelectMgrSelectableObjectSet
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemSelectMgrSelectableObjectSet : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrSelectableObjectSetPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrSelectableObjectSetPtr (new VInspector_ItemSelectMgrSelectableObjectSet (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrSelectableObjectSet() 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 Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Standard_Boolean GetSelectableObjectSet (SelectMgr_SelectableObjectSet& theSet) const;
-
- //! Returns child BVH tree of the row
- opencascade::handle<BVH_Tree<Standard_Real, 3> > GetBVHTree (const int theRow, TCollection_AsciiString& theName) const;
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) 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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemSelectMgrSelectableObjectSet(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrSelectingVolumeManager.hxx>
-
-#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
-#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSelectingVolumeManager::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 2;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSelectingVolumeManager::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- SelectMgr_SelectingVolumeManager aVolumeManager;
- if (!GetViewerSelector (aVolumeManager))
- return Column() == 0 ? "Empty volume manager" : "";
-
- switch (Column())
- {
- case 0: return "SelectMgr_SelectingVolumeManager";
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrSelectingVolumeManager::Init()
-{
- //VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
- //Handle(SelectMgr_SelectingVolumeManager) aVolumeMgr;
- //if (aParentItem)
- //{
- // VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
- // if (aParentContextItem)
- // {
- // Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
- // aVolumeMgr = aContext->MainSelector();
- // }
- //}
- //setViewerSelector (aVolumeMgr);
-
- //UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrSelectingVolumeManager::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrSelectingVolumeManager::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrSelectingVolumeManager*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemSelectMgrSelectingVolumeManager::GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const
-{
- VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent());
-
- if (!aParentItem || aParentItem->GetViewerSelector().IsNull())
- return Standard_False;
-
- theVolumeManager = aParentItem->GetViewerSelector()->GetManager();
- return Standard_True;
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-Handle(SelectMgr_BaseFrustum) VInspector_ItemSelectMgrSelectingVolumeManager::GetFrustum (const int theRow) const
-{
- SelectMgr_SelectingVolumeManager aVolumeManager;
- if (!GetViewerSelector (aVolumeManager))
- return NULL;
-
- if (theRow == 0)
- return aVolumeManager.GetVolume (SelectBasics_SelectingVolumeManager::Box);
- else if (theRow == 1)
- return aVolumeManager.GetVolume (SelectBasics_SelectingVolumeManager::Polyline);
-
- return NULL;
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSelectingVolumeManager::GetTableRowCount() const
-{
- return 60;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSelectingVolumeManager::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- SelectMgr_SelectingVolumeManager aVolumeMgr;
- if (!GetViewerSelector (aVolumeMgr))
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("GetActiveSelectionType") : QVariant (aVolumeMgr.GetActiveSelectionType());
- case 1: return isFirstColumn ? QVariant ("IsOverlapAllowed()") : QVariant (aVolumeMgr.IsOverlapAllowed());
- case 2: return isFirstColumn ? "GetNearPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetNearPickedPnt()).ToCString();
- case 3: return isFirstColumn ? "GetFarPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetFarPickedPnt()).ToCString();
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectingVolumeManager::createChild (int theRow, int theColumn)
-{
- if (theRow == 0 || theRow == 1)
- return VInspector_ItemSelectMgrBaseFrustum::CreateItem (currentItem(), theRow, theColumn);
- //else if (theRow == 1)
- // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
- //else if (theRow == 2)
- // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
- //
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrSelectingVolumeManager_H
-#define VInspector_ItemSelectMgrSelectingVolumeManager_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <SelectMgr_SelectingVolumeManager.hxx>
-
-class SelectMgr_BaseFrustum;
-
-class VInspector_ItemSelectMgrSelectingVolumeManager;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelectingVolumeManager> VInspector_ItemSelectMgrSelectingVolumeManagerPtr;
-
-//! \class VInspector_ItemSelectMgrSelectingVolumeManager
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemSelectMgrSelectingVolumeManager : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrSelectingVolumeManagerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrSelectingVolumeManagerPtr (new VInspector_ItemSelectMgrSelectingVolumeManager (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrSelectingVolumeManager() 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 Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Standard_Boolean GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const;
-
- //! Returns frustum Frustum for row = 0, FrustumSet for row = 1
- Handle(SelectMgr_BaseFrustum) GetFrustum (const int theRow) const;
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) 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
- //! \param theRow the item row positition in the parent item
- //! \param theColumn the item column positition in the parent item
- VInspector_ItemSelectMgrSelectingVolumeManager(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemSelectMgrSelection.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSelection::initRowCount() const
-{
- Handle(SelectMgr_Selection) aSelection = GetSelection();
-#if OCC_VERSION_HEX < 0x070201
- int aRows = 0;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
- aRows++;
- return aRows;
-#else
- return aSelection->Entities().Size();
-#endif
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSelection::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return GetSelection()->DynamicType()->Name();
- case 3:
- {
- if (theItemRole == Qt::ToolTipRole)
- return "Mode";
- else
- {
- VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- return VInspector_Tools::SelectionModeToName(GetSelection()->Mode(), aParentItem->GetInteractiveObject()).ToCString();
- }
- }
- case 4:
- {
- if (theItemRole == Qt::ToolTipRole)
- return "SelectMgr_StateOfSelection";
- else {
- int aNbSelected = 0;
- SelectMgr_StateOfSelection aState = GetSelection()->GetSelectionState();
- if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
-#if OCC_VERSION_HEX < 0x070201
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
- {
- const Handle(SelectBasics_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
-#else
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
- {
- const Handle(SelectBasics_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
-#endif
- if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
- aNbSelected++;
- }
- }
- return aNbSelected > 0 ? QString::number (aNbSelected) : "";
- }
- }
- case 9:
- {
- SelectMgr_StateOfSelection aState = GetSelection()->GetSelectionState();
- return VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
- }
- case 10: return QString::number (GetSelection()->Sensitivity());
- case 11:
- return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
- GetSelection()->UpdateStatus()).ToCString();
- case 12:
- return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
- GetSelection()->BVHUpdateStatus()).ToCString();
- default:
- break;
- }
- break;
- }
- case Qt::ForegroundRole:
- {
- SelectMgr_StateOfSelection aState = GetSelection()->GetSelectionState();
- return QVariant (aState == SelectMgr_SOS_Activated ? QColor (Qt::black) : QColor (Qt::darkGray));
- }
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelection::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemSelectMgrSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSelection::Init()
-{
- VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
-
- Handle(AIS_InteractiveObject) anIO = aParentItem->GetInteractiveObject();
-
- int aRowId = Row();
- int aDeltaIndex = 2; // properties, presentation items
- int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
-#else
- for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
-#endif
- {
- if (aCurrentId != aRowId - aDeltaIndex)
- continue;
-#if OCC_VERSION_HEX < 0x070201
- mySelection = anIO->CurrentSelection();
-#else
- mySelection = aSelIter.Value();
-#endif
- break;
- }
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSelection::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
-
- mySelection = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSelection::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrSelection*>(this)->Init();
- // an empty method to don't initialize the main label, as it was not cleared in Reset()
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSelection::GetTableRowCount() const
-{
- return 10;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSelection::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
-
- Handle(SelectMgr_Selection) aSelection = GetSelection();
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Mode") : QVariant (aSelection->Mode());
- case 1: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aSelection->Sensitivity());
- case 2: return isFirstColumn ? QVariant ("UpdateStatus")
- : QVariant ((int)aSelection->UpdateStatus()); // TODO! SelectMgr_TypeOfUpdate
- case 3: return isFirstColumn ? QVariant ("BVHUpdateStatus")
- : QVariant ((int)aSelection->BVHUpdateStatus()); // TODO! SelectMgr_TypeOfBVHUpdate
- case 4: return isFirstColumn ? QVariant ("GetSelectionState")
- : QVariant ((int)aSelection->GetSelectionState()); // TODO! SelectMgr_StateOfSelection
-
- default: return QVariant();
- }
- return QVariant();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelectMgrSelection_H
-#define VInspector_ItemSelectMgrSelection_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <SelectMgr_Selection.hxx>
-
-class VInspector_ItemSelectMgrSelection;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelection> VInspector_ItemSelectMgrSelectionPtr;
-
-//! \class VInspector_ItemSelectMgrSelection
-//! Item about SelectMgr_Selection.
-//! Parent is presentable object item, children are sensitive entity items
-class VInspector_ItemSelectMgrSelection : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrSelectionPtr CreateItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrSelectionPtr (new VInspector_ItemSelectMgrSelection (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrSelection() {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return mySelection; }
-
- //! \return current selection value
- Standard_EXPORT Handle(SelectMgr_Selection) GetSelection() const
- { return Handle(SelectMgr_Selection)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initializes the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! Initializes number of children
- //! \return integer value
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelectMgrSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- Handle(SelectMgr_Selection) mySelection; //!< the current selection
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
-#include <inspector/VInspector_ItemSelectBasicsSensitiveEntity.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TopoDS_Shape.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelectMgrSelection.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSensitiveEntity::initRowCount() const
-{
- if (GetSensitiveEntity()->BaseSensitive().IsNull())
- return 0;
-
- return 2;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSensitiveEntity::initValue (int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- Handle(SelectMgr_SensitiveEntity) anEntity = GetSensitiveEntity();
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return anEntity->DynamicType()->Name();
- default:
- break;
- }
- break;
- }
- case Qt::BackgroundRole:
- case Qt::ForegroundRole:
- {
- if (Column() == 2)
- {
- Handle(AIS_InteractiveContext) aContext = GetContext();
- if (!aContext.IsNull())
- {
- if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
- return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
- }
- }
- VInspector_ItemSelectMgrSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelection>(Parent());
- if (aParentItem)
- return aParentItem->data(QModelIndex(), theItemRole);
- break;
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntity::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- return VInspector_ItemSelectBasicsEntityOwner::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 1)
- return VInspector_ItemSelectBasicsSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
-
- return TreeModel_ItemBasePtr();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSensitiveEntity::Init()
-{
- VInspector_ItemSelectMgrSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelection>(Parent());
-
- Handle(SelectMgr_Selection) aSelection = aParentItem->GetSelection();
-
- int aRowId = Row();
- int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
-#else
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++)
-#endif
- {
- if (aCurrentId != aRowId)
- continue;
-#if OCC_VERSION_HEX < 0x070201
- myEntity = aSelection->Sensitive();
-#else
- myEntity = aSelEntIter.Value();
-#endif
- break;
- }
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSensitiveEntity::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
- myEntity = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSensitiveEntity::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrSensitiveEntity*>(this)->Init();
-}
-
-// =======================================================================
-// function : getEntityOwner
-// purpose :
-// =======================================================================
-Handle(SelectBasics_EntityOwner) VInspector_ItemSelectMgrSensitiveEntity::getEntityOwner() const
-{
- initItem();
-
- Handle(SelectBasics_EntityOwner) anOwner;
- const Handle(SelectBasics_SensitiveEntity)& aBase = myEntity->BaseSensitive();
- if (aBase.IsNull())
- return anOwner;
- return aBase->OwnerId();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSensitiveEntity::GetTableRowCount() const
-{
- return 1;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSensitiveEntity::GetTableData(const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- Handle(SelectMgr_SensitiveEntity) anEntity = GetSensitiveEntity();
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("IsActiveForSelection") : QVariant (anEntity->IsActiveForSelection());
- default: return QVariant();
- }
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelectMgrSensitiveEntity_H
-#define VInspector_ItemSelectMgrSensitiveEntity_H
-
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <SelectBasics_EntityOwner.hxx>
-#include <SelectBasics_SensitiveEntity.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class VInspector_ItemSelectMgrSensitiveEntity;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSensitiveEntity> VInspector_ItemSelectMgrSensitiveEntityPtr;
-
-//! \class VInspector_ItemSelectMgrSensitiveEntity
-//! The item shows information about SelectBasics_EntityOwner.
-//! The parent is item selection, children are item entity owners
-class VInspector_ItemSelectMgrSensitiveEntity : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrSensitiveEntityPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrSensitiveEntityPtr (new VInspector_ItemSelectMgrSensitiveEntity (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrSensitiveEntity() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myEntity; }
-
- //! \return the current sensitive entity
- Standard_EXPORT Handle(SelectMgr_SensitiveEntity) GetSensitiveEntity() const
- { return Handle(SelectMgr_SensitiveEntity)::DownCast (GetObject()); }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData(const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
- //! Returns owner of the current sensitive entity
- //! \return owner
- Handle(SelectBasics_EntityOwner) getEntityOwner() const;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelectMgrSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- Handle(SelectMgr_SensitiveEntity) myEntity; //!< the current entity owner
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx>
-#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
-#include <inspector/VInspector_ItemBVHTree.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <SelectMgr_SensitiveEntitySet.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const
-{
- //Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet());
- //if (!aSensitiveSet.IsNull())
- // return aSensitiveSet->Size();
-
- return 1; // for BVH_Tree
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrSensitiveEntitySet::initValue (int theItemRole) const
-{
- if (theItemRole == Qt::DisplayRole && theItemRole == Qt::ToolTipRole && Column() == 2)
- return ViewControl_Tools::GetPointerInfo (GetSelectableObject(), true).ToCString();
-
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Handle(SelectMgr_SensitiveEntitySet) anEntitySet = GetSensitiveEntitySet();
- const Handle(SelectMgr_SelectableObject)& aSelectableObject = GetSelectableObject();
-
- if (anEntitySet.IsNull())
- return Column() == 0 ? "Empty sensitive entity set" : "";
-
- if (aSelectableObject.IsNull())
- return Column() == 0 ? "Empty selectable object for sensitive entity set" : "";
-
- switch (theItemRole)
- {
- case Qt::DisplayRole:
- case Qt::EditRole:
- case Qt::ToolTipRole:
- {
- switch (Column())
- {
- case 0: return aSelectableObject->DynamicType()->Name();
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntitySet::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSensitiveEntitySet::Init()
-{
- VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent()->Parent());
-
- Handle(SelectMgr_SelectableObject) anObject;
- Handle(SelectMgr_SensitiveEntitySet) anEntitySet = aParentItem->GetSensitiveEntitySet (Row(), anObject);
-
- myEntitySet = anEntitySet;
- mySelectableObject = anObject;
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSensitiveEntitySet::Reset()
-{
- // an empty method to don't clear the main label, otherwise the model will be empty
- TreeModel_ItemBase::Reset();
- myEntitySet = NULL;
- mySelectableObject = NULL;
-}
-
-// =======================================================================
-// function : GetBVHTree
-// purpose :
-// =======================================================================
-opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemSelectMgrSensitiveEntitySet::GetBVHTree (const int theRow,
- TCollection_AsciiString& theName) const
-{
- Handle(SelectMgr_SensitiveEntitySet) anEntitySet = GetSensitiveEntitySet();
-
- if (anEntitySet.IsNull())
- return NULL;
-
- return anEntitySet->BVH();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrSensitiveEntitySet::initItem() const
-{
- if (IsInitialized())
- return;
-
- const_cast<VInspector_ItemSelectMgrSensitiveEntitySet*>(this)->Init();
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelectMgrSensitiveEntitySet::buildPresentationShape()
-{
- //mySelectableObject
- return TopoDS_Shape();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemSelectMgrSensitiveEntitySet_H
-#define VInspector_ItemSelectMgrSensitiveEntitySet_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <BVH_Tree.hxx>
-#include <SelectMgr_SensitiveEntitySet.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class SelectMgr_SelectableObject;
-
-class QItemSelectionModel;
-class VInspector_ItemSelectMgrSensitiveEntitySet;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSensitiveEntitySet> VInspector_ItemSelectMgrSensitiveEntitySetPtr;
-
-//! \class VInspector_ItemSelectMgrSensitiveEntitySet
-class VInspector_ItemSelectMgrSensitiveEntitySet : public VInspector_ItemBase
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrSensitiveEntitySetPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrSensitiveEntitySetPtr (new VInspector_ItemSelectMgrSensitiveEntitySet (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrSensitiveEntitySet() Standard_OVERRIDE {};
-
- //! Returns data object of the item.
- //! \return object
- virtual Handle(Standard_Transient) GetObject() const { initItem(); return myEntitySet; }
-
- //! \return the current sensitive entity
- Standard_EXPORT Handle(SelectMgr_SensitiveEntitySet) GetSensitiveEntitySet() const
- { return Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetObject()); }
-
- //! \return the current sensitive entity
- Standard_EXPORT const Handle(SelectMgr_SelectableObject)& GetSelectableObject() const
- { GetObject(); return mySelectableObject; }
-
- //! Inits the item, fills internal containers
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! Resets cached values
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns child BVH tree of the row
- opencascade::handle<BVH_Tree<Standard_Real, 3> > GetBVHTree (const int theRow, TCollection_AsciiString& theName) const;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
- //! \return number of children.
- virtual int initRowCount() const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value> depending on the aspect kind
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theEntityKind kind or kind of entity
- QVariant getTableData (const int theRow,
- const int theColumn,
- const int theRole,
- const TCollection_AsciiString& theEntityKind) const;
-
-protected:
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
-
- //! Constructor
- //! param theParent a parent item
- VInspector_ItemSelectMgrSensitiveEntitySet(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
- Handle(SelectMgr_SensitiveEntitySet) myEntitySet; //!< the current sensitive entity
- Handle(SelectMgr_SelectableObject) mySelectableObject; //!< the current presentation
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrViewerSelector.hxx>
-
-#include <inspector/VInspector_ItemContainer.hxx>
-#include <inspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx>
-#include <inspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx>
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx>
-#include <inspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx>
-
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/View_Tools.hxx>
-
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <TopoDS_Compound.hxx>
-
-#include <StdSelect_ViewerSelector3d.hxx>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-VInspector_ItemSelectMgrViewerSelector::VInspector_ItemSelectMgrViewerSelector (TreeModel_ItemBasePtr theParent,
- const int theRow, const int theColumn)
-: VInspector_ItemBase(theParent, theRow, theColumn),
- myXPix (150), myYPix (350), myXMinPix (150), myYMinPix (350), myXMaxPix (200), myYMaxPix (400)
-{
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrViewerSelector::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- // SelectMgr_SelectingVolumeManager, VInspector_ItemSelectMgrSelectableObjectSet, VInspector_ItemContainer
- Standard_Integer aNbRows = GetFirstChildOfPicked();
-
- Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
- if (!aViewSelector.IsNull())
- {
- for (Standard_Integer aDetIter = 1; aDetIter <= aViewSelector->NbPicked(); ++aDetIter)
- {
- aNbRows++;
- //Handle(SelectMgr_EntityOwner) anOwner = aViewSelector->->Picked (aDetIter);
- }
- }
- return aNbRows;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrViewerSelector::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- if (GetViewerSelector().IsNull())
- return Column() == 0 ? "Empty viewer selector" : "";
-
- switch (Column())
- {
- case 0: return GetViewerSelector()->DynamicType()->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrViewerSelector::Init()
-{
- VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
- Handle(SelectMgr_ViewerSelector) aViewerSelector;
- if (aParentItem)
- {
- VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
- if (aParentContextItem)
- {
- Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
- aViewerSelector = aContext->MainSelector();
- }
- }
- setViewerSelector (aViewerSelector);
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrViewerSelector::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setViewerSelector (NULL);
-}
-
-// =======================================================================
-// function : GetSensitiveEntitySet
-// purpose :
-// =======================================================================
-Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::GetSensitiveEntitySet (const int theRow,
- Handle(SelectMgr_SelectableObject)& theObject)
-{
- Standard_Integer anIndex = 0;
-
- Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
- if (aViewSelector.IsNull())
- return NULL;
-
- for (SelectMgr_MapOfObjectSensitivesIterator anIterator (aViewSelector->GetObjectSensitives()); anIterator.More(); anIterator.Next(), anIndex++)
- {
- if (anIndex != theRow)
- continue;
-
- theObject = anIterator.Key();
- return anIterator.Value();
- }
- return NULL;
-}
-
-// =======================================================================
-// function : GetContainerRowCount
-// purpose :
-// =======================================================================
-
-int VInspector_ItemSelectMgrViewerSelector::GetContainerRowCount (const int theContainerRow) const
-{
- if (theContainerRow != 2)
- return 0;
-
- Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
- if (aViewSelector.IsNull())
- return 0;
-
- return aViewSelector->GetObjectSensitives().Extent();
-}
-
-// =======================================================================
-// function : GetContainerValue
-// purpose :
-// =======================================================================
-
-QVariant VInspector_ItemSelectMgrViewerSelector::GetContainerValue (const int theContainerRow, const int theItemRole) const
-{
- if (theContainerRow != 2)
- return 0;
-
- if (theItemRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
- if (aViewSelector.IsNull())
- return QVariant();
-
- return "SelectMgr_MapOfObjectSensitives";
-}
-
-// =======================================================================
-// function : CreateContainerChild
-// purpose :
-// =======================================================================
-
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn)
-{
- if (theContainerRow != 2)
- return TreeModel_ItemBasePtr();
-
- return VInspector_ItemSelectMgrSensitiveEntitySet::CreateItem (theParent, theRow, theColumn);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrViewerSelector::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrViewerSelector*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrViewerSelector::GetTableRowCount() const
-{
- return 60;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrViewerSelector::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
- if (aViewerSelector.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aViewerSelector->Sensitivity());
- case 1: return isFirstColumn ? QVariant ("IsPickClosest") : QVariant (aViewerSelector->IsPickClosest());
- case 2: return isFirstColumn ? QVariant ("NbPicked") : QVariant (aViewerSelector->NbPicked());
-
- case 3: return ViewControl_Table::SeparatorData();
- case 4: return isFirstColumn ? QVariant ("ClearPicked") : QVariant ("DO");
-
- case 5: return ViewControl_Table::SeparatorData();
- case 6: return isFirstColumn ? QVariant ("X (pixel)") : QVariant (myXPix);
- case 7: return isFirstColumn ? QVariant ("Y (pixel)") : QVariant (myYPix);
- case 8: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO");
-
- case 9: return ViewControl_Table::SeparatorData();
- case 10: return isFirstColumn ? QVariant ("X Min (pixel)") : QVariant (myXMinPix);
- case 11: return isFirstColumn ? QVariant ("Y Min (pixel)") : QVariant (myXMinPix);
- case 12: return isFirstColumn ? QVariant ("X Max (pixel)") : QVariant (myXMaxPix);
- case 13: return isFirstColumn ? QVariant ("Y Max (pixel)") : QVariant (myYMaxPix);
- case 14: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO");
-
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemSelectMgrViewerSelector::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- case 4: return ViewControl_EditType_DoAction;
- case 6: return ViewControl_EditType_Spin;
- case 7: return ViewControl_EditType_Spin;
- case 8: return ViewControl_EditType_DoAction;
- case 10: return ViewControl_EditType_Spin;
- case 11: return ViewControl_EditType_Spin;
- case 12: return ViewControl_EditType_Spin;
- case 13: return ViewControl_EditType_Spin;
- case 14: return ViewControl_EditType_DoAction;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemSelectMgrViewerSelector::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
- if (aViewerSelector.IsNull())
- return Standard_False;
-
- switch (theRow)
- {
- case 4: aViewerSelector->ClearPicked(); break;
- case 6: myXPix = theValue.toInt();
- case 7: myYPix = theValue.toInt();
- case 8:
- {
- Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector);
- if (!aSelector3d.IsNull())
- aSelector3d->Pick (myXPix, myYPix, View_Tools::FindActiveView (GetContext()));
- break;
- }
- case 10: myXMinPix = theValue.toInt();
- case 11: myXMinPix = theValue.toInt();
- case 12: myXMaxPix = theValue.toInt();
- case 13: myYMaxPix = theValue.toInt();
- case 14:
- {
- Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector);
- if (!aSelector3d.IsNull())
- aSelector3d->Pick (myXMinPix, myYMinPix, myXMaxPix, myYMaxPix, View_Tools::FindActiveView (GetContext()));
- break;
- }
- default: break;
- }
- return Standard_True;
-}
-
-// =======================================================================
-// function : Dump
-// purpose :
-// =======================================================================
-Standard_Boolean VInspector_ItemSelectMgrViewerSelector::Dump (Standard_OStream& OS) const
-{
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
- if (aViewerSelector.IsNull())
- return Standard_False;
-
- aViewerSelector->Dump (OS);
- return Standard_True;
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelectMgrViewerSelector::buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewSelector)
-{
- if (theViewSelector.IsNull() || theViewSelector->NbPicked() == 0)
- return TopoDS_Shape();
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
-
- for (Standard_Integer aRankId = 1; aRankId <= theViewSelector->NbPicked(); ++aRankId)
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (theViewSelector->PickedPoint (aRankId)));
-
- return aCompound;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- return VInspector_ItemSelectMgrSelectingVolumeManager::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 1)
- return VInspector_ItemSelectMgrSelectableObjectSet::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 2)
- return VInspector_ItemContainer::CreateItem (currentItem(), theRow, theColumn);
- else
- return VInspector_ItemSelectMgrViewerSelectorPicked::CreateItem (currentItem(), theRow, theColumn);
-}
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrViewerSelector_H
-#define VInspector_ItemSelectMgrViewerSelector_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-#include <inspector/VInspector_ItemContainerAPI.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <SelectMgr_ViewerSelector.hxx>
-#include <Standard_OStream.hxx>
-
-class VInspector_ItemSelectMgrViewerSelector;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelector> VInspector_ItemSelectMgrViewerSelectorPtr;
-
-//! \class VInspector_ItemSelectMgrViewerSelector
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase, public VInspector_ItemContainerAPI
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrViewerSelectorPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrViewerSelectorPtr (new VInspector_ItemSelectMgrViewerSelector (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrViewerSelector() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myViewerSelector; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Handle(SelectMgr_ViewerSelector) GetViewerSelector() const
- { return Handle(SelectMgr_ViewerSelector)::DownCast (GetObject()); }
-
- //! Returns the span from the 0 row to the first item corresponded to the picked item
- //! the 0 item is SelectMgr_SelectingVolumeManager
- //! the 1 item is VInspector_ItemSelectMgrSelectableObjectSet
- //! the 2 item is VInspector_ItemContainer for SelectMgr_MapOfObjectSensitives
- Standard_Integer GetFirstChildOfPicked() const { return 3; }
-
- //! Returns entity set if possible from SelectMgr_MapOfObjectSensitives
- //! \param theRow row index
- //! \param theObject [out] object connected to the sensitive entity set
- Standard_EXPORT Handle(SelectMgr_SensitiveEntitySet) GetSensitiveEntitySet (const int theRow,
- Handle(SelectMgr_SelectableObject)& theObject);
-
- //! Returns number of item selected
- //! \return rows count
- virtual int GetContainerRowCount (const int theContainerRow) const Standard_OVERRIDE;
-
- //! Returns item information for the given role. Fills internal container if it was not filled yet
- //! \param theItemRole a value role
- //! \return the value
- virtual QVariant GetContainerValue (const int theContainerRow, const int theItemRole) const Standard_OVERRIDE;
-
- //! Creates a child item in the given position.
- //! \param theRow the child row position
- //! \param theColumn the child column position
- //! \return the created item
- virtual TreeModel_ItemBasePtr CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) Standard_OVERRIDE;
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
- //! Dumps the content of me on the stream <OS>.
- virtual Standard_Boolean Dump (Standard_OStream& OS) const;
-
-protected:
-
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE { return buildPresentationShape (myViewerSelector); }
-
- //! Creates shape for the 3d viewer selector parameters
- //! \param theViewerSelector current viewer selector
- //! \return shape or NULL
- static TopoDS_Shape buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewerSelector);
-
-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:
-
- //! Set V3d viewer selector into the current field
- //! \param theViewerSelector a viewer selector
- void setViewerSelector (const Handle(SelectMgr_ViewerSelector)& theViewerSelector) { myViewerSelector = theViewerSelector; }
-
-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_ItemSelectMgrViewerSelector(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
-
-private:
-
- Handle(SelectMgr_ViewerSelector) myViewerSelector; //!< the current viewer selector
-
- Standard_Integer myXPix; //!< cached value for picked X
- Standard_Integer myYPix; //!< cached value for picked Y
-
- Standard_Integer myXMinPix; //!< cached value for min value of picked X
- Standard_Integer myYMinPix; //!< cached value for min value of picked Y
-
- Standard_Integer myXMaxPix; //!< cached value for max value of picked X
- Standard_Integer myYMaxPix; //!< cached value for max value of picked Y
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrViewerSelectorPicked.hxx>
-
-#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
-#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrViewerSelectorPicked::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 0;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrViewerSelectorPicked::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- Standard_Integer aRankId;
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
- if (aViewerSelector.IsNull())
- return Column() == 0 ? "Empty viewer selector" : "";
-
- switch (Column())
- {
- case 0:
- {
- TCollection_AsciiString aValue = TCollection_AsciiString (aRankId) + " - " +
- VInspector_Tools::GetPointerInfo (aViewerSelector->Picked (aRankId));
- return aValue.ToCString();
- }
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrViewerSelectorPicked::Init()
-{
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrViewerSelectorPicked::Reset()
-{
- VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemSelectMgrViewerSelectorPicked::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemSelectMgrViewerSelectorPicked*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-Handle(SelectMgr_ViewerSelector) VInspector_ItemSelectMgrViewerSelectorPicked::GetViewerSelector (Standard_Integer& theRankId) const
-{
- VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent());
- if (!aParentItem)
- return NULL;
-
- Handle(SelectMgr_ViewerSelector) aViewerSelector = aParentItem->GetViewerSelector();
- theRankId = Row() + 1 - aParentItem->GetFirstChildOfPicked();
- if (theRankId > aViewerSelector->NbPicked())
- return NULL;
-
- return aViewerSelector;
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrViewerSelectorPicked::GetTableRowCount() const
-{
- return 60;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrViewerSelectorPicked::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole)
- return QVariant();
-
- Standard_Integer aRankId;
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
- if (aViewerSelector.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? "Picked" :
- (theRole == Qt::DisplayRole ? VInspector_Tools::GetPointerInfo (aViewerSelector->Picked (aRankId)).ToCString()
- : aViewerSelector->Picked (aRankId)->DynamicType()->Name());
- case 1: return isFirstColumn ? "PickedEntity" :
- (theRole == Qt::DisplayRole ? VInspector_Tools::GetPointerInfo (aViewerSelector->PickedEntity (aRankId)).ToCString()
- : aViewerSelector->PickedEntity (aRankId)->DynamicType()->Name());
- case 2: return isFirstColumn ? "PickedPoint" : ViewControl_Tools::ToString (aViewerSelector->PickedPoint (aRankId)).ToCString();
-
- default: break;
- }
- Standard_Integer aLastIndex = 2;
-
- if (theRow > aLastIndex)
- return getTableSortCriterionData (theRow - (aLastIndex + 1), theColumn, theRole);
-
- return QVariant();
-}
-
-// =======================================================================
-// function : getTableSortCriterionData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrViewerSelectorPicked::getTableSortCriterionData (const Standard_Integer theIndex,
- const int theColumn, const int theRole) const
-{
- Standard_Integer aRankId;
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
- if (aViewerSelector.IsNull())
- return QVariant();
-
- const SelectMgr_SortCriterion& aCriterion = aViewerSelector->PickedData (aRankId);
- bool isFirstColumn = theColumn == 0;
- switch (theIndex)
- {
- case 0: return isFirstColumn ? QVariant ("Depth") : QVariant (aCriterion.Depth);
- case 1: return isFirstColumn ? QVariant ("MinDist") : QVariant (aCriterion.MinDist);
- case 2: return isFirstColumn ? QVariant ("Tolerance") : QVariant (aCriterion.Tolerance);
- case 3: return isFirstColumn ? QVariant ("Priority") : QVariant (aCriterion.Priority);
- case 4: return isFirstColumn ? QVariant ("ZLayerPosition") : QVariant (aCriterion.ZLayerPosition);
- case 5: return isFirstColumn ? QVariant ("NbOwnerMatches") : QVariant (aCriterion.NbOwnerMatches);
- case 6: return isFirstColumn ? QVariant ("ToPreferClosest") : QVariant (aCriterion.ToPreferClosest);
- default: break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelectMgrViewerSelectorPicked::buildPresentationShape()
-{
- Standard_Integer aRankId;
- Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
- return buildPresentationShape (aViewerSelector, aRankId);
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemSelectMgrViewerSelectorPicked::buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewSelector,
- const Standard_Integer theRowId)
-{
- if (theViewSelector.IsNull() || theRowId + 1 > theViewSelector->NbPicked())
- return TopoDS_Shape();
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
-
- Standard_Integer aRankId = theRowId + 1;
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (theViewSelector->PickedPoint (aRankId)));
-
- return aCompound;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelectorPicked::createChild (int, int)
-{
- //if (theRow == 0)
- // return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn);
- //else if (theRow == 1)
- // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
- //else if (theRow == 2)
- // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
- //
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2019-02-04
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_ItemSelectMgrViewerSelectorPicked_H
-#define VInspector_ItemSelectMgrViewerSelectorPicked_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <SelectMgr_ViewerSelector.hxx>
-
-class VInspector_ItemSelectMgrViewerSelectorPicked;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelectorPicked> VInspector_ItemSelectMgrViewerSelectorPickedPtr;
-
-//! \class VInspector_ItemSelectMgrViewerSelectorPicked
-//! Parent item, that corresponds Folder under the AIS_InteractiveContext
-//! Children of the item are: none
-class VInspector_ItemSelectMgrViewerSelectorPicked : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemSelectMgrViewerSelectorPickedPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemSelectMgrViewerSelectorPickedPtr (new VInspector_ItemSelectMgrViewerSelectorPicked (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemSelectMgrViewerSelectorPicked() 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 Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
-
- //! Returns viewer selector of the parent and index of rank inside the parent
- //! \param theRankId rank of the item inside viewer selector
- Standard_EXPORT Handle(SelectMgr_ViewerSelector) GetViewerSelector (Standard_Integer& theRankId) const;
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
- //! Returns table value of SelectMgr_SortCriterion
- QVariant getTableSortCriterionData (const Standard_Integer theIndex, const int theColumn, const int theRole) const;
-
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
-
- //! Creates shape for the 3d viewer selector parameters
- //! \param theViewerSelector current viewer selector
- //! \param theRowId index of the item row, theRank - 1 value inside viewer selector
- //! \return shape or NULL
- static TopoDS_Shape buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewerSelector,
- const Standard_Integer theRowId);
-
-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:
-
-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_ItemSelectMgrViewerSelectorPicked(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-};
-
-#endif
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/VInspector_ItemSelection.hxx>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <Standard_Version.hxx>
+#include <inspector/VInspector_ItemContext.hxx>
+#include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <inspector/VInspector_ItemSensitiveEntity.hxx>
+#include <inspector/VInspector_Tools.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QStringList>
+
+#include <QColor>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : getSelection
+// purpose :
+// =======================================================================
+Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
+{
+ initItem();
+ return mySelection;
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelection::initRowCount() const
+{
+ Handle(SelectMgr_Selection) aSelection = getSelection();
+#if OCC_VERSION_HEX < 0x070201
+ int aRows = 0;
+ for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ aRows++;
+ return aRows;
+#else
+ return aSelection->Entities().Size();
+#endif
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelection::initValue (int theItemRole) const
+{
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ {
+ switch (Column())
+ {
+ case 0: return getSelection()->DynamicType()->Name();
+ case 1: return rowCount();
+ case 3:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Mode";
+ else
+ {
+ VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
+ return VInspector_Tools::SelectionModeToName(getSelection()->Mode(), aParentItem->GetInteractiveObject()).ToCString();
+ }
+ }
+ case 4:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "SelectMgr_StateOfSelection";
+ else {
+ int aNbSelected = 0;
+ SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
+ if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+#if OCC_VERSION_HEX < 0x070201
+ for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ {
+ const Handle(SelectMgr_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
+#else
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
+#endif
+ if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
+ aNbSelected++;
+ }
+ }
+ return aNbSelected > 0 ? QString::number (aNbSelected) : "";
+ }
+ }
+ case 9:
+ {
+ SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
+ return VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
+ }
+ case 10: return QString::number (getSelection()->Sensitivity());
+ case 11:
+ return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
+ getSelection()->UpdateStatus()).ToCString();
+ case 12:
+ return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
+ getSelection()->BVHUpdateStatus()).ToCString();
+ default:
+ break;
+ }
+ break;
+ }
+ case Qt::ForegroundRole:
+ {
+ SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
+ return QVariant (aState == SelectMgr_SOS_Activated ? QColor (Qt::black) : QColor (Qt::darkGray));
+ }
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSelection::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemSelection::Init()
+{
+ VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
+
+ Handle(AIS_InteractiveObject) anIO = aParentItem->GetInteractiveObject();
+
+ int aRowId = Row();
+ int aCurrentId = 0;
+#if OCC_VERSION_HEX < 0x070201
+ for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
+#else
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
+#endif
+ {
+ if (aCurrentId != aRowId)
+ continue;
+#if OCC_VERSION_HEX < 0x070201
+ mySelection = anIO->CurrentSelection();
+#else
+ mySelection = aSelIter.Value();
+#endif
+ break;
+ }
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemSelection::Reset()
+{
+ // an empty method to don't clear the main label, otherwise the model will be empty
+ TreeModel_ItemBase::Reset();
+
+ mySelection = NULL;
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemSelection::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSelection*>(this)->Init();
+ // an empty method to don't initialize the main label, as it was not cleared in Reset()
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemSelection_H
+#define VInspector_ItemSelection_H
+
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <SelectMgr_Selection.hxx>
+
+class VInspector_ItemSelection;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelection> VInspector_ItemSelectionPtr;
+
+//! \class VInspector_ItemSelection
+//! Item about SelectMgr_Selection.
+//! Parent is presentable object item, children are sensitive entity items
+class VInspector_ItemSelection : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSelectionPtr CreateItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSelectionPtr (new VInspector_ItemSelection (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSelection() {};
+
+ //! \return current selection value
+ Standard_EXPORT Handle(SelectMgr_Selection) getSelection() const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+protected:
+
+ //! Initializes the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Initializes number of children
+ //! \return integer value
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ Handle(SelectMgr_Selection) mySelection; //!< the current selection
+};
+
+#endif
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <inspector/VInspector_ItemSensitiveEntity.hxx>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <Select3D_SensitiveEntity.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <Standard_Version.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS_Shape.hxx>
+#include <inspector/VInspector_ItemContext.hxx>
+#include <inspector/VInspector_ItemEntityOwner.hxx>
+#include <inspector/VInspector_ItemSelection.hxx>
+#include <inspector/VInspector_Tools.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QStringList>
+#include <QColor>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : GetSensitiveEntity
+// purpose :
+// =======================================================================
+Handle(SelectMgr_SensitiveEntity) VInspector_ItemSensitiveEntity::GetSensitiveEntity() const
+{
+ initItem();
+ return myEntity;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
+{
+ Handle(SelectMgr_SensitiveEntity) aBase = GetSensitiveEntity();
+ Handle(SelectMgr_EntityOwner) anOwner = aBase->BaseSensitive()->OwnerId();
+
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ {
+ switch (Column())
+ {
+ case 0: return myEntity->DynamicType()->Name();
+ case 2: return VInspector_Tools::GetPointerInfo (GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
+ case 3:
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (BROwnr.IsNull())
+ return QVariant();
+
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (aShape.IsNull())
+ return QVariant();
+
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ case 13: return
+#if OCC_VERSION_HEX <= 0x060901
+ ("none");
+#else
+ myEntity->IsActiveForSelection() ? QString ("true") : QString ("false");
+#endif
+ case 14: return QString::number (GetSensitiveEntity()->BaseSensitive()->SensitivityFactor());
+ case 15: return QString::number (GetSensitiveEntity()->BaseSensitive()->NbSubElements());
+ case 16:
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (BROwnr.IsNull())
+ return QVariant();
+ return anOwner->Priority();
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ case Qt::BackgroundRole:
+ case Qt::ForegroundRole:
+ {
+ if (Column() == 2)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (!aContext.IsNull())
+ {
+ if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
+ return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
+ }
+ }
+ VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
+ if (aParentItem)
+ return aParentItem->data(QModelIndex(), theItemRole);
+ break;
+ }
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSensitiveEntity::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemEntityOwner::CreateItem (currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemSensitiveEntity::Init()
+{
+ VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
+
+ Handle(SelectMgr_Selection) aSelection = aParentItem->getSelection();
+
+ int aRowId = Row();
+ int aCurrentId = 0;
+#if OCC_VERSION_HEX < 0x070201
+ for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
+#else
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++)
+#endif
+ {
+ if (aCurrentId != aRowId)
+ continue;
+#if OCC_VERSION_HEX < 0x070201
+ myEntity = aSelection->Sensitive();
+#else
+ myEntity = aSelEntIter.Value();
+#endif
+ break;
+ }
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemSensitiveEntity::Reset()
+{
+ // an empty method to don't clear the main label, otherwise the model will be empty
+ TreeModel_ItemBase::Reset();
+ myEntity = NULL;
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemSensitiveEntity::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSensitiveEntity*>(this)->Init();
+}
+
+// =======================================================================
+// function : getEntityOwner
+// purpose :
+// =======================================================================
+Handle(SelectMgr_EntityOwner) VInspector_ItemSensitiveEntity::getEntityOwner() const
+{
+ initItem();
+
+ Handle(SelectMgr_EntityOwner) anOwner;
+ const Handle(Select3D_SensitiveEntity)& aBase = myEntity->BaseSensitive();
+ if (aBase.IsNull())
+ return anOwner;
+ return aBase->OwnerId();
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemSensitiveEntity_H
+#define VInspector_ItemSensitiveEntity_H
+
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <Select3D_SensitiveEntity.hxx>
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+class SelectMgr_EntityOwner;
+class VInspector_ItemSensitiveEntity;
+
+typedef QExplicitlySharedDataPointer<VInspector_ItemSensitiveEntity> VInspector_ItemSensitiveEntityPtr;
+
+//! \class VInspector_ItemSensitiveEntity
+//! The item shows information about SelectMgr_EntityOwner.
+//! The parent is item selection, children are item entity owners
+class VInspector_ItemSensitiveEntity : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSensitiveEntityPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSensitiveEntityPtr (new VInspector_ItemSensitiveEntity (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSensitiveEntity() Standard_OVERRIDE {};
+
+ //! \return the current sensitive entity
+ Standard_EXPORT Handle(SelectMgr_SensitiveEntity) GetSensitiveEntity() const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+protected:
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE { return !GetSensitiveEntity()->BaseSensitive().IsNull() ? 1 : 0; }
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+ //! Returns owner of the current sensitive entity
+ //! \return owner
+ Handle(SelectMgr_EntityOwner) getEntityOwner() const;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ Handle(SelectMgr_SensitiveEntity) myEntity; //!< the current entity owner
+};
+
+#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemV3dView.hxx>
-
-#include <AIS.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <TopoDS_Compound.hxx>
-#include <V3d_ListOfLight.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/ViewControl_TableDoubleVector.hxx>
-#include <inspector/VInspector_ItemAspectWindow.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemGraphic3dCamera.hxx>
-#include <inspector/VInspector_ItemGraphic3dCView.hxx>
-#include <inspector/VInspector_ItemV3dViewer.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemV3dView::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- return 3; // 0 - Default Camera, 1 - Aspect_Window, 2 - CView
- // TODO: V3d_ListOfLight, V3d_Trihedron,
- //Aspect_Grid-MyPlane-MyTrsf-MyGridEchoStructure-MyGridEchoGroup
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemV3dView::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- if (GetView().IsNull())
- return Column() == 0 ? "Empty view" : "";
-
- switch (Column())
- {
- case 0: return GetView()->DynamicType()->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemV3dView::Init()
-{
- VInspector_ItemV3dViewerPtr aParentItem = itemDynamicCast<VInspector_ItemV3dViewer>(Parent());
- Handle(V3d_View) aView;
- if (aParentItem)
- {
- aView = aParentItem->GetView (Row());
- }
- setView (aView);
-
- UpdatePresentationShape();
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemV3dView::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setView (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemV3dView::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemV3dView*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemV3dView::GetTableRowCount() const
-{
- return 60;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemV3dView::GetTableEditType (const int theRow, const int) const
-{
- switch (theRow)
- {
- case 2: return ViewControl_EditType_DoubleVector;
- }
-
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemV3dView::GetTableEnumValues (const int, const int) const
-{
- QList<QVariant> aValues;
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemV3dView::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- Handle(V3d_View) aView = GetView();
- if (aView.IsNull())
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0:
- {
- if (isFirstColumn)
- return QVariant ("ImmediateUpdate");
-
- Standard_Boolean aCurState = aView->SetImmediateUpdate (Standard_False);
- aView->SetImmediateUpdate (aCurState);
-
- return aCurState;
- }
- break;
- case 1:
- {
- if (isFirstColumn)
- return QVariant ("ActiveLights");
-
- V3d_ListOfLightIterator aLightsIt = aView->ActiveLightIterator();
- Standard_Integer aNbOfLights = 0;
- while (aLightsIt.More())
- {
- aNbOfLights++;
- aLightsIt.Next();
- }
- return aNbOfLights;
- }
- case 2:
- {
- if (isFirstColumn)
- return QVariant ("Axis: origin");
-
- Standard_Real aX, anY, aZ, aVx, aVy, aVz;
- aView->Axis (aX, anY, aZ, aVx, aVy, aVz);
-
- return ViewControl_Tools::ToString (gp_Pnt (aX, anY, aZ)).ToCString();
- }
- case 3:
- {
- if (isFirstColumn)
- return QVariant ("Axis: direction");
-
- Standard_Real aX, anY, aZ, aVx, aVy, aVz;
- aView->Axis (aX, anY, aZ, aVx, aVy, aVz);
-
- return ViewControl_Tools::ToString (gp_Dir (aVx, aVy, aVz)).ToCString();
- }
- case 4: return isFirstColumn ? QVariant ("ComputedMode") : QVariant (aView->ComputedMode());
- case 5: return isFirstColumn ? QVariant ("AutoZFitMode") : QVariant (aView->AutoZFitMode());
- case 6: return isFirstColumn ? QVariant ("AutoZFitScaleFactor") : QVariant (aView->AutoZFitScaleFactor());
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemV3dView::SetTableData (const int theRow, const int theColumn, const QVariant& theValue)
-{
- Handle(V3d_View) aView = GetView();
- if (aView.IsNull())
- return false;
-
- if (theColumn == 0)
- return false;
-
- switch (theRow)
- {
- case 2:
- {
- QString aValue = theValue.toString();
- Standard_Real aX, anY, aZ, aVx, aVy, aVz;
- QList<QVariant> aValues = ViewControl_TableDoubleVector::GetListVector(aValue);
-
- if (aValues.size() == 3)
- {
- aX = aValues[0].toFloat();
- anY = aValues[1].toFloat();
- aZ = aValues[2].toFloat();
-
- Standard_Real aTmpX, aTmpY, aTmpZ;
- aView->Axis(aTmpX, aTmpY, aTmpZ, aVx, aVy, aVz);
-
- aView->SetAxis(aX, anY, aZ, aVx, aVy, aVz);
- }
- }
- }
- return true;
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_ItemV3dView::buildPresentationShape (const Handle(V3d_View)& theView)
-{
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
-
- Standard_Real aX, anY, aZ, aVx, aVy, aVz;
- theView->Axis (aX, anY, aZ, aVx, aVy, aVz);
- gp_Pnt anOrigin (aX, anY, aZ);
-
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (anOrigin));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Lin (anOrigin, gp_Dir (aVx, aVy, aVz))));
-
- return aCompound;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemV3dView::createChild (int theRow, int theColumn)
-{
- if (theRow == 0)
- return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 1)
- return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
- else if (theRow == 2)
- return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
-
- return TreeModel_ItemBasePtr();
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemV3dView_H
-#define VInspector_ItemV3dView_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <V3d_View.hxx>
-
-class VInspector_ItemV3dView;
-typedef QExplicitlySharedDataPointer<VInspector_ItemV3dView> VInspector_ItemV3dViewPtr;
-
-//! \class VInspector_ItemV3dView
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemV3dView : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemV3dViewPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemV3dViewPtr (new VInspector_ItemV3dView (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemV3dView() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myView; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Handle(V3d_View) GetView() const
- { return Handle(V3d_View)::DownCast (GetObject()); }
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-protected:
-
- //! Build presentation shape
- //! \return generated shape of the item parameters
- virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE { return buildPresentationShape (myView); }
-
- //! Creates shape for the 3d view parameters
- //! \param theView current view
- //! \return shape or NULL
- static TopoDS_Shape buildPresentationShape (const Handle(V3d_View)& theView);
-
-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:
-
- //! Set V3d view into the current field
- //! \param theViewer a viewer
- void setView (const Handle(V3d_View)& theView) { myView = theView; }
-
-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_ItemV3dView(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(V3d_View) myView; //!< the current view
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_ItemV3dViewer.hxx>
-
-#include <AIS.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_ItemV3dView.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : GetView
-// purpose :
-// =======================================================================
-Handle(V3d_View) VInspector_ItemV3dViewer::GetView (const int theRow) const
-{
- Handle(V3d_Viewer) aViewer = GetViewer();
-
- int aViewId = 0;
- for (V3d_ListOfViewIterator anActiveViewIter (GetViewer()->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- Handle(V3d_View) aView = anActiveViewIter.Value();
- if (aView->View().IsNull())
- continue;
-
- if (theRow == aViewId)
- return aView;
- aViewId++;
- }
-
- return NULL;
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemV3dViewer::initRowCount() const
-{
- if (Column() != 0)
- return 0;
-
- int aNbOfViews = 0;
- for (V3d_ListOfViewIterator anActiveViewIter (GetViewer()->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- if (!anActiveViewIter.Value().IsNull())
- aNbOfViews++;
- }
- return aNbOfViews;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemV3dViewer::initValue (const int theItemRole) const
-{
- QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
- if (aParentValue.isValid())
- return aParentValue;
-
- if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
- return QVariant();
-
- if (GetViewer().IsNull())
- return Column() == 0 ? "Empty viewer" : "";
-
- switch (Column())
- {
- case 0: return GetViewer()->DynamicType()->Name();
- default:
- break;
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspector_ItemV3dViewer::Init()
-{
- VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
- Handle(V3d_Viewer) aViewer;
- if (aParentItem)
- {
- VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
- if (aParentContextItem)
- {
- Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
- aViewer = aContext->CurrentViewer();
- }
- }
- setViewer (aViewer);
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspector_ItemV3dViewer::Reset()
-{
- VInspector_ItemBase::Reset();
-
- setViewer (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspector_ItemV3dViewer::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspector_ItemV3dViewer*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemV3dViewer::GetTableRowCount() const
-{
- return 0;
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemV3dViewer::GetTableEditType (const int theRow, const int) const
-{
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspector_ItemV3dViewer::GetTableEnumValues (const int theRow, const int) const
-{
- QList<QVariant> aValues;
- return aValues;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemV3dViewer::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspector_ItemV3dViewer::SetTableData (const int theRow, const int, const QVariant& theValue)
-{
- return true;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemV3dViewer::createChild (int theRow, int theColumn)
-{
- return VInspector_ItemV3dView::CreateItem (currentItem(), theRow, theColumn);
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_ItemV3dViewer_H
-#define VInspector_ItemV3dViewer_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <V3d_Viewer.hxx>
-
-class VInspector_ItemV3dViewer;
-typedef QExplicitlySharedDataPointer<VInspector_ItemV3dViewer> VInspector_ItemV3dViewerPtr;
-
-//! \class VInspector_ItemV3dViewer
-//! Parent item, that corresponds to AIS_InteractiveContext
-//! Children of the item are:
-//! - "Property" item to show context attributes such as selection filters and drawer properties
-//! - presentation items to show all interactive elements displayed/erased in the context
-class VInspector_ItemV3dViewer : public VInspector_ItemBase
-{
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspector_ItemV3dViewerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspector_ItemV3dViewerPtr (new VInspector_ItemV3dViewer (theParent, theRow, theColumn)); }
-
- //! Destructor
- virtual ~VInspector_ItemV3dViewer() Standard_OVERRIDE {};
-
- //! Returns view by index using active views iterator
- //! \param theRow row index of the view
- //! \return view
- Standard_EXPORT Handle(V3d_View) GetView (const int theRow) const;
-
- //! 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 Handle(Standard_Transient) GetObject() const { initItem(); return myViewer; }
-
- //! Returns current drawer, initialize the drawer if it was not initialized yet
- Standard_EXPORT Handle(V3d_Viewer) GetViewer() const
- { return Handle(V3d_Viewer)::DownCast (GetObject()); }
-
-protected:
- //! Initialize 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) 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:
-
- //! Set V3d viewer into the current field
- //! \param theViewer a viewer
- void setViewer (const Handle(V3d_Viewer)& theViewer) { myViewer = theViewer; }
-
-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_ItemV3dViewer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-protected:
-
- Handle(V3d_Viewer) myViewer; //!< the current viewer
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-04-28
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_PropertiesCreator.hxx>
-#include <inspector/VInspectorPaneAIS_ColoredShape.hxx>
-#include <inspector/ViewControl_PropertiesStream.hxx>
-
-#include <Standard_OStream.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator)
-
-// =======================================================================
-// function : GetProperties
-// purpose :
-// =======================================================================
-TreeModel_ItemProperties* VInspector_PropertiesCreator::GetProperties (const TreeModel_ItemBasePtr& theItem)
-{
- Standard_SStream aSStream;
- if (theItem->Dump (aSStream))
- return new ViewControl_PropertiesStream (theItem);
-
- return NULL;
-}
-
+++ /dev/null
-// Created on: 2019-04-28
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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_PropertiesCreator_H
-#define VInspector_PropertiesCreator_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
-
-DEFINE_STANDARD_HANDLE (VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator)
-
-//! \class VInspector_PropertiesCreator
-//! \brief An interface to create custom panes by transient object name.
-class VInspector_PropertiesCreator : public TreeModel_ItemPropertiesCreator
-{
-public:
-
- //! Constructor
- VInspector_PropertiesCreator() {}
-
- //! Destructor
- virtual ~VInspector_PropertiesCreator() {}
-
- //! Returns pane for the name, creates a new pane if it does not exist and possible to create
- //! \param theName type of the pane
- //! \return a pane instance or NULL
- virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) Standard_OVERRIDE;
-
- DEFINE_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator)
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/VInspector_TableModelValues.hxx>
-
-#include <inspector/ViewControl_Pane.hxx>
-#include <inspector/ViewControl_PaneItem.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <inspector/ViewControl_PaneCreator.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-
-VInspector_TableModelValues::VInspector_TableModelValues (const TreeModel_ItemBasePtr& theItem,
- const NCollection_List<Handle(ViewControl_PaneCreator)>& theCreators)
- : ViewControl_TableModelValues(), myItem (theItem), myCreators (theCreators)
-{
- QList<TreeModel_HeaderSection> aHeaderValues;
- aHeaderValues.append(TreeModel_HeaderSection ("Function", 190));
- aHeaderValues.append(TreeModel_HeaderSection ("Value", -2));
- SetHeaderValues(aHeaderValues, Qt::Horizontal);
-
- SetHeaderVisible(Qt::Horizontal, Standard_False);
- SetHeaderVisible(Qt::Vertical, Standard_False);
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant VInspector_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const
-{
- int aRow = theRow;
- if (!myItem->GetProperties().IsNull())
- {
- int aPropertiesCount = myItem->GetProperties()->GetTableRowCount();
- if (aRow < aPropertiesCount)
- return myItem->GetProperties()->GetTableData (theRow, theColumn, theRole);
- else
- aRow = aRow - aPropertiesCount;
- }
- switch (theRole)
- {
- case Qt::FontRole:
- {
- if (theColumn == 0)
- {
- QFont aFont = qApp->font();
- aFont.setItalic (true);
- return aFont;
- }
- }
- case Qt::ForegroundRole:
- {
- if (theColumn == 0)
- return QColor (Qt::darkGray).darker(150);
- else if (GetEditType (aRow, theColumn) != ViewControl_EditType_None)
- return ViewControl_TableModelValues::EditCellColor();
- }
- default:
- {
- VInspector_ItemBasePtr anItem = GetItem();
- if (!anItem)
- return QVariant();
- Handle(Standard_Transient) anObject = anItem->GetObject();
- if (anObject.IsNull())
- return anItem->GetTableData (aRow, theColumn, theRole);
-
- int aCurrentRow = aRow;
- for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
- {
- Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
- ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
- if (!aPane)
- continue;
- if (aCurrentRow >= aPane->GetTableRowCount (anObject))
- aCurrentRow -= aPane->GetTableRowCount (anObject);
- else
- return aPane->GetTableData (anObject, aCurrentRow, theColumn, theRole);
- }
- return anItem->GetTableData (aCurrentRow, theColumn, theRole);
- }
- }
-}
-
-// =======================================================================
-// function : GetRangeValues
-// purpose :
-// =======================================================================
-
-bool VInspector_TableModelValues::SetData (const int theRow, const int theColumn, const QVariant& theValue, int theRole)
-{
- if (theRole != Qt::EditRole)
- return false;
-
- int aRow = theRow;
- if (!myItem->GetProperties().IsNull())
- {
- int aPropertiesCount = myItem->GetProperties()->GetTableRowCount();
- if (aRow < aPropertiesCount)
- return myItem->GetProperties()->SetTableData (theRow, theColumn, theValue);
- else
- aRow = aRow - aPropertiesCount;
- }
-
- VInspector_ItemBasePtr anItem = GetItem();
- if (!anItem)
- return false;
-
- Handle(Standard_Transient) anObject = anItem->GetObject();
- if (anObject.IsNull())
- return anItem->SetTableData (aRow, theColumn, theValue);
-
- int aCurrentRow = aRow;
- for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
- {
- Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
- ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
- if (!aPane)
- continue;
- if (aCurrentRow >= aPane->GetTableRowCount (anObject))
- aCurrentRow -= aPane->GetTableRowCount (anObject);
- else
- return aPane->SetTableData (anObject, aCurrentRow, theColumn, theValue);
- }
- return anItem->SetTableData (aCurrentRow, theColumn, theValue);
-}
-
-// =======================================================================
-// function : Flags
-// purpose :
-// =======================================================================
-
-Qt::ItemFlags VInspector_TableModelValues::Flags (const QModelIndex& theIndex) const
-{
- Qt::ItemFlags aFlags = ViewControl_TableModelValues::Flags (theIndex);
-
- if (theIndex.column() == 1)
- aFlags = aFlags | Qt::ItemIsEditable;
-
- return aFlags;
-}
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int VInspector_TableModelValues::RowCount (const QModelIndex& theParent) const
-{
- int aRowCount = 0;
- if (!myItem->GetProperties().IsNull())
- aRowCount = myItem->GetProperties()->GetTableRowCount();
-
- VInspector_ItemBasePtr anItem = GetItem();
- if (!anItem)
- return aRowCount;
-
- aRowCount += anItem->GetTableRowCount();
- Handle(Standard_Transient) anObject = anItem->GetObject();
- if (anObject.IsNull())
- return aRowCount;
-
- for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
- {
- Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
- ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
- if (!aPane)
- continue;
- aRowCount += aPane->GetTableRowCount (anObject);
- }
- return aRowCount;
-}
-
-// =======================================================================
-// function : GetEditType
-// purpose :
-// =======================================================================
-
-ViewControl_EditType VInspector_TableModelValues::GetEditType (const int theRow, const int theColumn) const
-{
- int aRow = theRow;
- if (!myItem->GetProperties().IsNull())
- {
- int aPropertiesCount = myItem->GetProperties()->GetTableRowCount();
- if (aRow < aPropertiesCount)
- return myItem->GetProperties()->GetTableEditType (theRow, theColumn);
- else
- aRow = aRow - aPropertiesCount;
- }
-
- if (theColumn == 0)
- return ViewControl_EditType_None;
-
- VInspector_ItemBasePtr anItem = GetItem();
- if (!anItem)
- return ViewControl_EditType_None;
-
- Handle(Standard_Transient) anObject = anItem->GetObject();
- if (anObject.IsNull())
- return anItem->GetTableEditType (aRow, theColumn);
-
- int aCurrentRow = aRow;
- for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
- {
- Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
- ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
- if (!aPane)
- continue;
- if (aCurrentRow >= aPane->GetTableRowCount (anObject))
- aCurrentRow -= aPane->GetTableRowCount (anObject);
- else
- return aPane->GetTableEditType (anObject, aCurrentRow, theColumn);
- }
- return anItem->GetTableEditType (aCurrentRow, theColumn);
-}
-
-// =======================================================================
-// function : GetEnumValues
-// purpose :
-// =======================================================================
-
-QList<QVariant> VInspector_TableModelValues::GetEnumValues (const int theRow, const int theColumn) const
-{
- if (theColumn != 1)
- return QList<QVariant>();
-
- int aRow = theRow;
- if (!myItem->GetProperties().IsNull())
- {
- int aPropertiesCount = myItem->GetProperties()->GetTableRowCount();
- if (aRow < aPropertiesCount)
- return myItem->GetProperties()->GetTableEnumValues (theRow, theColumn);
- else
- aRow = aRow - aPropertiesCount;
- }
-
- VInspector_ItemBasePtr anItem = GetItem();
- if (!anItem)
- return QList<QVariant>();
-
- Handle(Standard_Transient) anObject = anItem->GetObject();
- if (anObject.IsNull())
- return anItem->GetTableEnumValues (aRow, theColumn);
-
- int aCurrentRow = aRow;
- for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
- {
- Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
- ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
- if (!aPane)
- continue;
- if (aCurrentRow >= aPane->GetTableRowCount (anObject))
- aCurrentRow -= aPane->GetTableRowCount (anObject);
- else
- return aPane->GetTableEnumValues (anObject, aCurrentRow, theColumn);
- }
- return anItem->GetTableEnumValues (aCurrentRow, theColumn);
-}
-
-// =======================================================================
-// function : GetPaneShapes
-// purpose :
-// =======================================================================
-
-void VInspector_TableModelValues::GetPaneShapes (const int theRow, const int theColumn, NCollection_List<TopoDS_Shape>& theShapes)
-{
- int aRow = theRow;
- if (!myItem->GetProperties().IsNull())
- {
- int aPropertiesCount = myItem->GetProperties()->GetTableRowCount();
- if (aRow < aPropertiesCount)
- return;// myItem->GetProperties()->GetEnumValues (theRow, theColumn);
- else
- aRow = aRow - aPropertiesCount;
- }
-
- VInspector_ItemBasePtr anItem = GetItem();
- if (!anItem)
- return;
-
- Handle(Standard_Transient) anObject = anItem->GetObject();
- if (anObject.IsNull())
- return;
-
- for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
- {
- Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
- ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
- if (!aPane)
- continue;
-
- ViewControl_PaneItem* anItem = aPane->GetSelected (anObject, aRow, theColumn);
- if (anItem && !anItem->GetShape().IsNull())
- theShapes.Append (anItem->GetShape());
- }
-}
-
-// =======================================================================
-// function : GetItem
-// purpose :
-// =======================================================================
-
-VInspector_ItemBasePtr VInspector_TableModelValues::GetItem() const
-{
- return itemDynamicCast<VInspector_ItemBase>(myItem);
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VInspector_TableModelValues_H
-#define VInspector_TableModelValues_H
-
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-class ViewControl_PaneCreator;
-
-#include <NCollection_List.hxx>
-
-//! \class VInspector_TableModelValues
-//! \brief This is an implementation for ViewControl_TableModel to present tree item values
-class VInspector_TableModelValues : public ViewControl_TableModelValues
-{
-public:
-
- //! Constructor
- Standard_EXPORT VInspector_TableModelValues (const TreeModel_ItemBasePtr& theItem,
- const NCollection_List<Handle(ViewControl_PaneCreator)>& theCreators);
-
- //! Destructor
- virtual ~VInspector_TableModelValues() Standard_OVERRIDE {}
-
- //! Returns number of columns. It has two columns: <funciton name> <function value>
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 2; }
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int RowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Sets content of the model index for the given role, it is applyed to internal container of values
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return true if the value is changed
- Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
- int theRole = Qt::DisplayRole) Standard_OVERRIDE;
-
- //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable.
- //! Additional flag for the column 1 is Qt::ItemIsEditable.
- //! \param theIndex a model index
- //! \return flags
- virtual Qt::ItemFlags Flags (const QModelIndex& theIndex) const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of pane shapes
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \param [out] output container of shapes to add pane new shapes if found
- Standard_EXPORT void GetPaneShapes (const int theRow, const int theColumn, NCollection_List<TopoDS_Shape>& theShapes);
-
-private:
-
- //!< Returns source item base
- VInspector_ItemBasePtr GetItem() const;
-
-private:
- NCollection_List<Handle(ViewControl_PaneCreator)> myCreators; //!< pane creators
- TreeModel_ItemBasePtr myItem; //!< source item base
-};
-
-#endif
#include <inspector/VInspector_Tools.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_TableModelValues.hxx>
-
-#include <inspector/Convert_Tools.hxx>
-
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
-#include <Standard_Version.hxx>
-#if OCC_VERSION_HEX < 0x060901
-#include <AIS_LocalContext.hxx>
-#endif
#include <AIS_Selection.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Trihedron.hxx>
#include <BRep_Builder.hxx>
-#include <BRepPrimAPI_MakeBox.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepTools.hxx>
-#include <Graphic3d.hxx>
-#include <Graphic3d_IndexBuffer.hxx>
-#include <Graphic3d_Buffer.hxx>
-#include <Graphic3d_BoundBuffer.hxx>
-
+#include <gp_Trsf.hxx>
#include <SelectMgr_StateOfSelection.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
#include <SelectMgr_TypeOfBVHUpdate.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
-#include <TopoDS_Compound.hxx>
-
#include <sstream>
// =======================================================================
// =======================================================================
TCollection_AsciiString VInspector_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
{
- if (!thePointer.operator->())
- return "";
-
std::ostringstream aPtrStr;
aPtrStr << thePointer.operator->();
if (!isShortInfo)
// purpose :
// =======================================================================
bool VInspector_Tools::IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
- const Handle(SelectBasics_EntityOwner)& theOwner)
+ const Handle(SelectMgr_EntityOwner)& theOwner)
{
bool anIsSelected = false;
+ Handle(SelectMgr_EntityOwner) anOwner = theOwner;
for (theContext->InitSelected(); theContext->MoreSelected() && !anIsSelected; theContext->NextSelected())
- anIsSelected = theContext->SelectedOwner() == theOwner;
+ anIsSelected = theContext->SelectedOwner() == anOwner;
return anIsSelected;
}
// function : ContextOwners
// purpose :
// =======================================================================
-NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ContextOwners (
+NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ContextOwners (
const Handle(AIS_InteractiveContext)& theContext)
{
- NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> aResultOwners;
if (theContext.IsNull())
return aResultOwners;
#endif
if (anEntity.IsNull())
continue;
- const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
- Handle(SelectBasics_EntityOwner) anOwner = aBase->OwnerId();
+ const Handle(Select3D_SensitiveEntity)& aBase = anEntity->BaseSensitive();
+ Handle(SelectMgr_EntityOwner) anOwner = aBase->OwnerId();
Standard_Transient* anOwnerPtr = anOwner.operator->();
if (aSelectedIds.contains ((size_t)anOwnerPtr))
continue;
// function : ActiveOwners
// purpose :
// =======================================================================
-NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ActiveOwners (
+NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ActiveOwners (
const Handle(AIS_InteractiveContext)& theContext,
- NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners)
+ NCollection_List<Handle(SelectMgr_EntityOwner)>& theEmptySelectableOwners)
{
- NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> aResultOwners;
// only local context is processed: TODO for global context
Handle(AIS_InteractiveContext) aContext = theContext;
if (aContext.IsNull())
return aResultOwners;
- NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
// OCCT BUG:1 - equal pointer owners are appears in the list
#if OCC_VERSION_HEX > 0x060901
aContext->MainSelector()->ActiveOwners (anActiveOwners);
anActiveOwners = aContext->MainSelector()->ActiveOwners();
#endif
QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
- Handle(SelectMgr_EntityOwner) anOwner;
- for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
+ for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
- anOwner = anOwnersIt.Value();
+ const Handle(SelectMgr_EntityOwner)& anOwner = anOwnersIt.Value();
if (anOwner.IsNull())
continue;
// purpose :
// =======================================================================
void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
- const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners)
+ const NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners)
{
// TODO: the next two rows are to be removed later
theContext->UnhilightSelected(false);
theContext->UnhilightSelected(Standard_False);
- //TODO: processing in local context only
-#if OCC_VERSION_HEX < 0x060901
- Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
- TCollection_AsciiString aSelectionName = aLContext->SelectionName();
- aLContext->UnhilightPicked(Standard_False);
-#endif
-
- for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(theOwners);
+ for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt(theOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
Handle(SelectMgr_EntityOwner) anOwner = anOwnersIt.Value();
-#if OCC_VERSION_HEX > 0x060901
theContext->AddOrRemoveSelected (anOwner, Standard_False);
-#else
- AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
- anOwner->SetSelected(Standard_True);
-#endif
}
theContext->UpdateCurrentViewer();
}
{
switch (theValue)
{
- case SelectMgr_SOS_Activated: return "Activated";
- case SelectMgr_SOS_Deactivated: return "Deactivated";
- //case SelectMgr_SOS_Sleeping: return "Sleeping";
case SelectMgr_SOS_Any: return "Any";
case SelectMgr_SOS_Unknown: return "Unknown";
+ case SelectMgr_SOS_Activated: return "Activated";
+ case SelectMgr_SOS_Deactivated: return "Deactivated";
default: break;
}
}
}
// =======================================================================
-// function : ReadShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_Tools::ReadShape (const TCollection_AsciiString& theFileName)
-{
- TopoDS_Shape aShape;
-
- BRep_Builder aBuilder;
- BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
-
- return aShape;
-}
-
-// =======================================================================
-// function : GetPropertyTableValues
+// function : LocationToName
// purpose :
// =======================================================================
-void VInspector_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
- const NCollection_List<Handle(ViewControl_PaneCreator)>& theCreators,
- QList<ViewControl_TableModelValues*>& theTableValues)
-{
- TreeModel_ItemBasePtr anItem = theItem;
- VInspector_ItemFolderObjectPtr aFolderItem = itemDynamicCast<VInspector_ItemFolderObject>(anItem);
- if (aFolderItem)
- {
- VInspector_ItemFolderObject::ParentKind aParentKind = aFolderItem->GetParentItemKind();
- if (aParentKind == VInspector_ItemFolderObject::ParentKind_ContextItem ||
- aParentKind == VInspector_ItemFolderObject::ParentKind_PresentationItem)
- anItem = theItem->Parent();
- }
-
- theTableValues.append (new VInspector_TableModelValues (anItem, theCreators));
-}
-
-namespace
-{
- static Standard_CString VInspector_Table_PrintDisplayActionType[5] =
- {
- "None", "Display", "Redisplay", "Erase", "Remove"
- };
-}
-
-//=======================================================================
-//function : DisplayActionTypeToString
-//purpose :
-//=======================================================================
-Standard_CString VInspector_Tools::DisplayActionTypeToString (View_DisplayActionType theType)
-{
- return VInspector_Table_PrintDisplayActionType[theType];
-}
-
-//=======================================================================
-//function : DisplayActionTypeFromString
-//purpose :
-//=======================================================================
-Standard_Boolean VInspector_Tools::DisplayActionTypeFromString (Standard_CString theTypeString,
- View_DisplayActionType& theType)
-{
- TCollection_AsciiString aName (theTypeString);
- for (Standard_Integer aTypeIter = 0; aTypeIter <= View_DisplayActionType_RemoveId; ++aTypeIter)
- {
- Standard_CString aTypeName = VInspector_Table_PrintDisplayActionType[aTypeIter];
- if (aName == aTypeName)
- {
- theType = View_DisplayActionType (aTypeIter);
- return Standard_True;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : ToVariant
-//purpose :
-//=======================================================================
-QVariant VInspector_Tools::ToVariant (const Select3D_BndBox3d& theBoundingBox)
-{
- return QString ("(%1, %2, %3), (%4, %5, %6)")
- .arg (theBoundingBox.CornerMin().x()).arg (theBoundingBox.CornerMin().y()).arg (theBoundingBox.CornerMin().z())
- .arg (theBoundingBox.CornerMax().x()).arg (theBoundingBox.CornerMax().y()).arg (theBoundingBox.CornerMax().z());
-}
-
-//=======================================================================
-//function : CreateShape
-//purpose :
-//=======================================================================
-TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBoundingBox)
-{
- if (!theBoundingBox.IsValid())
- return TopoDS_Shape();
-
- gp_Pnt aPntMin = gp_Pnt (theBoundingBox.CornerMin().x(), theBoundingBox.CornerMin().y(), theBoundingBox.CornerMin().z());
- gp_Pnt aPntMax = gp_Pnt (theBoundingBox.CornerMax().x(), theBoundingBox.CornerMax().y(), theBoundingBox.CornerMax().z());
-
- return Convert_Tools::CreateBoxShape (aPntMin, aPntMax);
-}
-
-//=======================================================================
-//function : ToVariant
-//purpose :
-//=======================================================================
-QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_IndexBuffer)& theIndexBuffer)
-{
- const Handle(Graphic3d_Buffer)& aBuffer = theIndexBuffer;
- return VInspector_Tools::ToVariant (aBuffer);
-}
-
-//=======================================================================
-//function : ToVariant
-//purpose :
-//=======================================================================
-QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_Buffer)& theBuffer)
-{
- if (theBuffer.IsNull())
- return QVariant();
-
- QString anInfo;
- anInfo = "NbElements = " + QString::number (theBuffer->NbElements) + ",";
- anInfo = "NbAttributes = " + QString::number (theBuffer->NbAttributes) + ",";
- anInfo = "Stride = " + QString::number (theBuffer->Stride) + ",";
- QStringList anAttributes;
- for (Standard_Integer anAttribIter = 0; anAttribIter < theBuffer->NbAttributes; ++anAttribIter)
- {
- const Graphic3d_Attribute& anAttrib = theBuffer->Attribute (anAttribIter);
- anAttributes.append(VInspector_Tools::ToString (anAttrib));
- }
- return anInfo + " (" + anAttributes.join(", ") + ")";
-}
-
-//=======================================================================
-//function : ToVariant
-//purpose :
-//=======================================================================
-QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_BoundBuffer)& /*theBoundBuffer*/)
-{
- //const Handle(Graphic3d_Buffer)& aBuffer = theBoundBuffer;
- //Handle(Graphic3d_Buffer) aBuffer = Handle(Graphic3d_Buffer)::DownCast (theBoundBuffer);
- //return VInspector_Tools::ToVariant (aBuffer);
- return QVariant();
-}
-
-//=======================================================================
-//function : ToVariant
-//purpose :
-//=======================================================================
-QVariant VInspector_Tools::ToVariant (const Graphic3d_Mat4d& theMatrix)
+TCollection_AsciiString VInspector_Tools::LocationToName (const TopLoc_Location& theLocation)
{
- TCollection_AsciiString aValues;
- for (int aRowId = 1; aRowId <= theMatrix.Rows(); aRowId++)
- {
- for (int aColId = 1; aColId <= theMatrix.Cols(); aColId++)
- {
- aValues += TCollection_AsciiString (theMatrix.GetValue (aRowId, aColId));
- if (aColId != theMatrix.Rows())
- aValues += ",";
- }
- if (aRowId != theMatrix.Rows())
- aValues += " ";
- }
-
- return aValues.ToCString();
-}
+ gp_Trsf aTrsf = theLocation.Transformation();
-//=======================================================================
-//function : ToVariant
-//purpose :
-//=======================================================================
-QVariant VInspector_Tools::ToVariant (const Graphic3d_Mat4& theMatrix)
-{
TCollection_AsciiString aValues;
- for (int aRowId = 1; aRowId <= theMatrix.Rows(); aRowId++)
+ for (int aRowId = 1; aRowId <= 3; aRowId++)
{
- for (int aColId = 1; aColId <= theMatrix.Cols(); aColId++)
- {
- aValues += TCollection_AsciiString (theMatrix.GetValue (aRowId, aColId));
- if (aColId != theMatrix.Rows())
+ for (int aColId = 1; aColId <= 4; aColId++) {
+ aValues += TCollection_AsciiString (aTrsf.Value(aRowId, aColId));
+ if (aColId != 4)
aValues += ",";
}
- if (aRowId != theMatrix.Rows())
+ if (aRowId != 3)
aValues += " ";
}
-
- return aValues.ToCString();
+ return aValues;
}
-//=======================================================================
-//function : ToString
-//purpose :
-//=======================================================================
-QString VInspector_Tools::ToString (const Graphic3d_Attribute& theAttribute)
+// =======================================================================
+// function : ReadShape
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_Tools::ReadShape (const TCollection_AsciiString& theFileName)
{
- Graphic3d_TypeOfAttribute anId = theAttribute.Id;
- Graphic3d_TypeOfData aDataType = theAttribute.DataType;
+ TopoDS_Shape aShape;
- QString anInfo = Graphic3d::TypeOfAttributeToString (anId);
- anInfo += ": ";
- anInfo += Graphic3d::TypeOfDataToString (aDataType);
+ BRep_Builder aBuilder;
+ BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
- return anInfo;
+ return aShape;
}
#define VInspector_Tools_H
#include <AIS_InteractiveContext.hxx>
-#include <Bnd_Box.hxx>
-#include <Bnd_OBB.hxx>
-#include <Graphic3d_Buffer.hxx>
-#include <Graphic3d_Mat4.hxx>
-#include <Graphic3d_Mat4d.hxx>
-#include <Select3D_BndBox3d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <inspector/VInspector_CallBackMode.hxx>
-#include <inspector/View_DisplayActionType.hxx>
#include <inspector/VInspector_SelectionType.hxx>
-#include <inspector/ViewControl_PaneCreator.hxx>
-
-#include <inspector/TreeModel_ItemBase.hxx>
-
#include <Standard_WarningsDisable.hxx>
#include <QList>
#include <QVariant>
#include <Standard_WarningsRestore.hxx>
-class ViewControl_TableModelValues;
-
-class Graphic3d_IndexBuffer;
-class Graphic3d_Buffer;
-class Graphic3d_BoundBuffer;
-
//! \class VInspector_Tools
//! The class that gives auxiliary methods for Visualization elements manipulation
class VInspector_Tools
//! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
//! \return the string value
Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo = true);
+ const bool isShortInfo);
//! Returns number of selected owners for presentation
//! \param theContext an interactive context
//! \param theOwner a selectable owner
//! \return boolean value
Standard_EXPORT static bool IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
- const Handle(SelectBasics_EntityOwner)& theOwner);
+ const Handle(SelectMgr_EntityOwner)& theOwner);
//! Returns all owners present in the context
//! \param theContext an interactive context
//! \return container of owners
- Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ContextOwners (
+ Standard_EXPORT static NCollection_List<Handle(SelectMgr_EntityOwner)> ContextOwners (
const Handle(AIS_InteractiveContext)& theContext);
//! Returns active owners in main selector of context
//! \param theContext an interactive context
//! \param theEmptySelectableOwners container of owners with NULL presentation or not displayed presentation
//! \return container of owners
- Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ActiveOwners (
+ Standard_EXPORT static NCollection_List<Handle(SelectMgr_EntityOwner)> ActiveOwners (
const Handle(AIS_InteractiveContext)& theContext,
- NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners);
+ NCollection_List<Handle(SelectMgr_EntityOwner)>& theEmptySelectableOwners);
//! Unhighlight selected, set selected the owners
//! \param theContext an interactive context
//! \param theOwners a container of owners
Standard_EXPORT static void AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
- const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
+ const NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners);
//! Unhighlight selected, set selected presentations
//! \param theContext an interactive context
//! \return text value
Standard_EXPORT static TCollection_AsciiString OrientationToName (const TopAbs_Orientation& theOrientation);
+ //! Returns text of orientation
+ //! \param theLocation a location value
+ //! \return text value
+ Standard_EXPORT static TCollection_AsciiString LocationToName (const TopLoc_Location& theLocation);
+
//! Read Shape using BREP reader
//! \param theFileName a file name
//! \return shape or NULL
Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
-
- //! Fills container of table values
- //! \param theAlert a message alert
- //! \param theTableValue container of values
- Standard_EXPORT static void GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
- const NCollection_List<Handle(ViewControl_PaneCreator)>& theCreators,
- QList<ViewControl_TableModelValues*>& theTableValues);
-
- //! Returns the string name for a given type.
- //! @param theType action type
- //! @return string identifier from the display action type
- Standard_EXPORT static Standard_CString DisplayActionTypeToString (View_DisplayActionType theType);
-
- //! Returns the enumeration type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @return string identifier from the display action type
- static View_DisplayActionType DisplayActionTypeFromString (Standard_CString theTypeString)
- {
- View_DisplayActionType aType = View_DisplayActionType_NoneId;
- DisplayActionTypeFromString (theTypeString, aType);
- return aType;
- }
-
- //! Determines the enumeration type from the given string identifier (using case-insensitive comparison).
- //! @param theTypeString string identifier
- //! @param theType detected action type
- //! @return TRUE if string identifier is known
- Standard_EXPORT static Standard_Boolean DisplayActionTypeFromString (const Standard_CString theTypeString,
- View_DisplayActionType& theType);
-
- //! Build string presentation of bounding box information in form: (xmin, ymin, zmin), (xmax, ymax, zmax)
- //! \param theBoundingBox bounding box
- //! \return string presentation
- Standard_EXPORT static QVariant ToVariant (const Select3D_BndBox3d& theBoundingBox);
-
- //! Creates box shape
- //! \param theBoundingBox box shape parameters
- //! \return created shape
- Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox);
-
- //! Build string presentation of Graphic3D index buffer
- //! \param theIndexBuffer index buffer
- //! \return string presentation
- Standard_EXPORT static QVariant ToVariant (const Handle(Graphic3d_IndexBuffer)& theIndexBuffer);
-
- //! Build string presentation of Graphic3D buffer
- //! \param theBuffer index buffer
- //! \return string presentation
- Standard_EXPORT static QVariant ToVariant (const Handle(Graphic3d_Buffer)& theBuffer);
-
- //! Build string presentation of Graphic3D bound buffer
- //! \param theBoundBuffer index buffer
- //! \return string presentation
- Standard_EXPORT static QVariant ToVariant (const Handle(Graphic3d_BoundBuffer)& theBoundBuffer);
-
- //! Convert matrix values into a text presentation
- //! \param theMatrix a matrix of elements
- //! \return string presentation
- Standard_EXPORT static QVariant ToVariant (const Graphic3d_Mat4d& theMatrix);
-
- //! Convert matrix values into a text presentation
- //! \param theMatrix a matrix of elements
- //! \return string presentation
- Standard_EXPORT static QVariant ToVariant (const Graphic3d_Mat4& theMatrix);
-
- Standard_EXPORT static QString ToString (const Graphic3d_Attribute& theAttribute);
-
};
#endif
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
+#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <SelectBasics_EntityOwner.hxx>
+#include <inspector/VInspector_ItemSensitiveEntity.hxx>
+#include <SelectMgr_EntityOwner.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QItemSelectionModel>
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
- SetHeaderItem (3, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
+ SetHeaderItem (3, TreeModel_HeaderSection ("ShapeType", COLUMN_SHAPE_TYPE_WIDTH)); // ItemPresentableObject, ItemSelection
SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); // ItemContext, ItemPresentableObject, ItemSelection
- //SetHeaderItem (5, TreeModel_HeaderSection ("ActivatedModes", -1)); // ItemPresentableObject
- //SetHeaderItem (6, TreeModel_HeaderSection ("DeviationCoefficient", -1, true)); // ItemContext, ItemPresentableObject
- //SetHeaderItem (7, TreeModel_HeaderSection ("Deflection", -1, true)); // ItemPresentableObject
- //SetHeaderItem (8, TreeModel_HeaderSection ("IsAutoTriangulation", -1, true)); // ItemPresentableObject
-
- //SetHeaderItem (9, TreeModel_HeaderSection ("SelectionState", -1)); // ItemSelection
- //SetHeaderItem (10, TreeModel_HeaderSection ("Sensitivity", -1, true)); // ItemSelection
- //SetHeaderItem (11, TreeModel_HeaderSection ("UpdateStatus", -1, true)); // ItemSelection
- //SetHeaderItem (12, TreeModel_HeaderSection ("BVHUpdateStatus", -1, true)); // ItemSelection
-
- //SetHeaderItem (13, TreeModel_HeaderSection ("IsActiveForSelection", -1, true)); // ItemSensitiveEntity
- //SetHeaderItem (14, TreeModel_HeaderSection ("SensitivityFactor", -1, true)); // ItemSensitiveEntity
- //SetHeaderItem (15, TreeModel_HeaderSection ("NbSubElements", -1, true)); // ItemSensitiveEntity
- //SetHeaderItem (16, TreeModel_HeaderSection ("Priority", -1, true)); // ItemSensitiveEntity
-
- //SetHeaderItem (17, TreeModel_HeaderSection ("TShape", COLUMN_POINTER_WIDTH, true)); // ItemEntityOwner
- //SetHeaderItem (18, TreeModel_HeaderSection ("Orientation", -1, true)); // ItemEntityOwner
- //SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
-
- //SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
-
- //SetHeaderItem (21, TreeModel_HeaderSection ("Owner Location", -1, true)); // ItemEntityOwner
+ SetHeaderItem (5, TreeModel_HeaderSection ("ActivatedModes", -1)); // ItemPresentableObject
+ SetHeaderItem (6, TreeModel_HeaderSection ("DeviationCoefficient", -1, true)); // ItemContext, ItemPresentableObject
+ SetHeaderItem (7, TreeModel_HeaderSection ("Deflection", -1, true)); // ItemPresentableObject
+ SetHeaderItem (8, TreeModel_HeaderSection ("IsAutoTriangulation", -1, true)); // ItemPresentableObject
+
+ SetHeaderItem (9, TreeModel_HeaderSection ("SelectionState", -1)); // ItemSelection
+ SetHeaderItem (10, TreeModel_HeaderSection ("Sensitivity", -1, true)); // ItemSelection
+ SetHeaderItem (11, TreeModel_HeaderSection ("UpdateStatus", -1, true)); // ItemSelection
+ SetHeaderItem (12, TreeModel_HeaderSection ("BVHUpdateStatus", -1, true)); // ItemSelection
+
+ SetHeaderItem (13, TreeModel_HeaderSection ("IsActiveForSelection", -1, true)); // ItemSensitiveEntity
+ SetHeaderItem (14, TreeModel_HeaderSection ("SensitivityFactor", -1, true)); // ItemSensitiveEntity
+ SetHeaderItem (15, TreeModel_HeaderSection ("NbSubElements", -1, true)); // ItemSensitiveEntity
+ SetHeaderItem (16, TreeModel_HeaderSection ("Priority", -1, true)); // ItemSensitiveEntity
+
+ SetHeaderItem (17, TreeModel_HeaderSection ("TShape", COLUMN_POINTER_WIDTH, true)); // ItemEntityOwner
+ SetHeaderItem (18, TreeModel_HeaderSection ("Orientation", -1, true)); // ItemEntityOwner
+ SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
+
+ SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
}
// =======================================================================
// fill root item by the application
for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
itemDynamicCast<VInspector_ItemContext>(myRootItems[aColId])->SetContext (theContext);
-
- UpdateTreeModel();
+ EmitLayoutChanged();
}
// =======================================================================
// function : FindPointers
// purpose :
// =======================================================================
-void VInspector_ViewModel::FindPointers (const QStringList& thePointers,
- const QModelIndex& theParent,
- QModelIndexList& theFoundIndices)
+QModelIndexList VInspector_ViewModel::FindPointers (const QStringList& thePointers)
{
- if (thePointers.isEmpty())
- return;
-
- QModelIndex aParentIndex = theParent.isValid() ? theParent : index (0, 0);
+ QModelIndexList anIndices;
+ QModelIndex aParentIndex = index (0, 0);
TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // context item
for (int aRowId = 0, aCount = aParentItem->rowCount(); aRowId < aCount; aRowId++)
{
QModelIndex anIndex = index (aRowId, 0, aParentIndex);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItemBase);
- if (!aVItem)
+ VInspector_ItemPresentableObjectPtr anItemPrs = itemDynamicCast<VInspector_ItemPresentableObject>(anItemBase);
+ if (!anItemPrs)
continue;
- Handle(Standard_Transient) anObject = aVItem->GetObject();
- TCollection_AsciiString aPointerInfo = ViewControl_Tools::GetPointerInfo (anObject);
- if (thePointers.contains (aPointerInfo.ToCString()))
- theFoundIndices.append (anIndex);
-
- FindPointers (thePointers, anIndex, theFoundIndices);
+ if (thePointers.contains (anItemPrs->PointerInfo()))
+ anIndices.append (anIndex);
}
+ return anIndices;
}
// =======================================================================
// purpose :
// =======================================================================
void VInspector_ViewModel::GetSelectedOwners (QItemSelectionModel* theSelectionModel,
- NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners)
+ NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners)
{
if (!theSelectionModel)
return;
for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
{
TreeModel_ItemBasePtr anItem = *anItemIt;
- Handle(SelectBasics_EntityOwner) anEntityOwner;
- if (VInspector_ItemSelectBasicsEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemSelectBasicsEntityOwner>(anItem))
+ Handle(SelectMgr_EntityOwner) anEntityOwner;
+ if (VInspector_ItemEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemEntityOwner>(anItem))
{
anEntityOwner = anOwnerItem->EntityOwner();
}
- else if (VInspector_ItemSelectMgrSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntity>(anItem))
+ else if (VInspector_ItemSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(anItem))
{
anEntityOwner = aSensItem->GetSensitiveEntity()->BaseSensitive()->OwnerId();
}
#include <AIS_InteractiveContext.hxx>
#include <NCollection_List.hxx>
-#include <SelectBasics_EntityOwner.hxx>
+#include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx>
#include <inspector/TreeModel_ModelBase.hxx>
#include <inspector/VInspector_ItemBase.hxx>
//! Returns tree view indices for the given pointers of presentable object
//! \param thePointers a list of presentation pointers
- //! \param theParent an index of the parent item
- //! \param [out] container of indices
- Standard_EXPORT void FindPointers (const QStringList& thePointers,
- const QModelIndex& theParent,
- QModelIndexList& theFoundIndices);
+ //! \return container of indices
+ Standard_EXPORT QModelIndexList FindPointers (const QStringList& thePointers);
//! Returns tree model index of the presentation item in the tree view.
//! \param thePresentation a presentation
//! \param theSelectionModel a selection model
//! \param theOwners an output list of owners
Standard_EXPORT static void GetSelectedOwners (QItemSelectionModel* theSelectionModel,
- NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
+ NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners);
//! Updates tree model
Standard_EXPORT void UpdateTreeModel();
: TreeModel_ModelBase (theParent)
{
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));
+ SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
+ SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+ SetHeaderItem (3, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
+ SetHeaderItem (4, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
+ SetHeaderItem (5, TreeModel_HeaderSection ("Selected/Highlighted", -1));
for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
{
#include <inspector/VInspector_Window.hxx>
-#include <AIS_ColoredShape.hxx>
#include <AIS_Shape.hxx>
-#include <AIS_Trihedron.hxx>
-//#include <BRep_Builder.hxx>
-//#include <BRepBuilderAPI_MakeVertex.hxx>
-//#include <BRepBuilderAPI_MakeEdge.hxx>
-//#include <BRepBuilderAPI_MakeFace.hxx>
-#include <Geom_Axis2Placement.hxx>
-//#include <TopoDS_Compound.hxx>
-
-#include <TopExp_Explorer.hxx>
-
-#include <inspector/Convert_Tools.hxx>
#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/ViewControl_MessageDialog.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/Convert_TransientShape.hxx>
+#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_CallBack.hxx>
#include <inspector/VInspector_Communicator.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
+#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
-//#include <inspector/VInspector_PropertiesCreator.hxx>
-#include <inspector/VInspector_TableModelValues.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_ViewModelHistory.hxx>
-#include <inspector/VInspectorPaneAIS_PaneCreator.hxx>
-#include <inspector/VInspectorPaneAIS_PropertiesCreator.hxx>
-
-#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_TreeView.hxx>
-#include <inspector/View_Displayer.hxx>
-#include <inspector/View_DisplayPreview.hxx >
-#include <inspector/View_PreviewParameters.hxx>
#include <inspector/View_Widget.hxx>
#include <inspector/View_Window.hxx>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
-//#define DEBUG_TWO_VIEWS
-#ifdef DEBUG_TWO_VIEWS
-#include <inspector/View_CameraPositionPrs.hxx>
-#endif
-
-const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH = 300;//600;
-const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT = 1000;
-
const int VINSPECTOR_DEFAULT_WIDTH = 1250;
const int VINSPECTOR_DEFAULT_HEIGHT = 800;
VInspector_Window::VInspector_Window()
: myParent (0), myExportToShapeViewDialog (0), myViewWindow (0)
{
- myDisplayPreview = new View_DisplayPreview();
-
myMainWindow = new QMainWindow (0);
QWidget* aCentralWidget = new QWidget (myMainWindow);
myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection);
myTreeView->header()->setStretchLastSection (true);
myTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
- //((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_TREE_VIEW_WIDTH,
- // VINSPECTOR_DEFAULT_TREE_VIEW_HEIGHT));
VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView);
- //aTreeModel->AddPropertiesCreator(new VInspector_PropertiesCreator());
myTreeView->setModel (aTreeModel);
// hide Visibility column
TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
myTreeView->setSelectionModel (aSelModel);
connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
aParentLay->addWidget(myTreeView, 1, 0);
aParentLay->setRowStretch (1, 1);
myMainWindow->setCentralWidget (aCentralWidget);
- // property view
- myPaneCreators.Append (new VInspectorPaneAIS_PaneCreator());
- //aTreeModel->AddPropertiesCreator (new VInspectorPaneAIS_PropertiesCreator());
-
- myPropertyView = new ViewControl_PropertyView (myMainWindow,
- QSize(VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH, VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT));
- myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
- myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
- myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
- myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
- myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
- connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool)));
- connect (myPropertyView, SIGNAL (propertyViewSelectionChanged()), this, SLOT (onPropertyViewSelectionChanged ()));
-
myHistoryView = new ViewControl_TreeView (myMainWindow);
myHistoryView->setSelectionBehavior (QAbstractItemView::SelectRows);
((ViewControl_TreeView*)myHistoryView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH,
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
}
-
anItems.clear();
- View_PreviewParameters::SaveState (myDisplayPreview->GetPreviewParameters(), anItems, "preview_parameters_");
+ TreeModel_Tools::SaveState (myHistoryView, anItems, "history_view_");
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
-
- anItems.clear();
- TreeModel_Tools::SaveState (myTreeView, anItems);
- for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
- {
- theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
- }
}
// =======================================================================
else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(),
"history_view_"))
continue;
- else if (View_PreviewParameters::RestoreState (myDisplayPreview->GetPreviewParameters(), anItemIt.Key().ToCString(),
- anItemIt.Value().ToCString(), "preview_parameters_"))
- continue;
}
}
myTreeView->scrollTo (aPresentationIndex);
}
}
-
- if (!myCallBack.IsNull())
- {
- VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
- (myHistoryView->model());
- aHistoryModel->Reset();
- aHistoryModel->EmitLayoutChanged();
- }
-}
-
-// =======================================================================
-// function : GetSelectedPresentations
-// purpose :
-// =======================================================================
-NCollection_List<Handle(AIS_InteractiveObject)> VInspector_Window::GetSelectedPresentations (QItemSelectionModel* theModel)
-{
- NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations;
-
- QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theModel->selectedIndexes());
-
- QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
- NCollection_List<Handle(Standard_Transient)> anItemPresentations;
- for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
- {
- TreeModel_ItemBasePtr anItem = *anItemIt;
- VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
- if (!aVItem)
- continue;
-
- anItemPresentations.Clear();
- aVItem->GetPresentations (anItemPresentations);
-
- for (NCollection_List<Handle(Standard_Transient)>::Iterator anIt (anItemPresentations); anIt.More(); anIt.Next())
- {
- Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (anIt.Value());
- if (aSelectedIds.contains ((size_t)aPresentation.operator->()))
- continue;
- aSelectedIds.append ((size_t)aPresentation.operator->());
- if (!aPresentation.IsNull())
- aSelectedPresentations.Append (aPresentation);
- }
- }
- return aSelectedPresentations;
-}
-
-// =======================================================================
-// function : GetSelectedShapes
-// purpose :
-// =======================================================================
-
-void VInspector_Window::GetSelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations)
-{
- QModelIndexList theIndices = myTreeView->selectionModel()->selectedIndexes();
-
- QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theIndices);
- for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
- {
- TreeModel_ItemBasePtr anItem = *anItemIt;
- VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
- if (!aVItem /*|| aVItem->Row() == 0*/)
- continue;
-
- TopoDS_Shape aShape = aVItem->GetPresentationShape();
- if (aShape.IsNull())
- continue;
-
- theSelPresentations.Append (new Convert_TransientShape (aShape));
- }
-}
-
-// =======================================================================
-// function : GetSelectedShapes
-// purpose :
-// =======================================================================
-NCollection_List<TopoDS_Shape> VInspector_Window::GetSelectedShapes (const QModelIndexList& theIndices)
-{
- NCollection_List<TopoDS_Shape> aSelectedShapes;
-
- QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theIndices);
- for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
- {
- TreeModel_ItemBasePtr anItem = *anItemIt;
- VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
- if (!aVItem /*|| aVItem->Row() == 0*/)
- continue;
-
- TopoDS_Shape aShape = aVItem->GetPresentationShape();
- if (aShape.IsNull())
- continue;
-
- aSelectedShapes.Append (aShape);
- }
-
- // obtain selection from the property panel
- {
- //QList<ViewControl_Table*> aPropertyTables;
- //myPropertyView->GetActiveTables (aPropertyTables);
- //if (!aPropertyTables.isEmpty())
- //{
- // ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables
-
- // Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
-
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
- TreeModel_ItemBasePtr aTreeItem = TreeModel_ModelBase::GetItemByIndex (anIndex);
-
- //QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes();
- GetSelectedPropertyPanelShapes(aTreeItem, aSelectedShapes);
- //}
- }
-
- return aSelectedShapes;
-}
-
-// =======================================================================
-// function : GetSelectedPropertyPanelShapes
-// purpose :
-// =======================================================================
-void VInspector_Window::GetSelectedPropertyPanelShapes (const TreeModel_ItemBasePtr& theTreeItem,
- NCollection_List<TopoDS_Shape>& theShapes)
-{
- QList<ViewControl_Table*> aPropertyTables;
- myPropertyView->GetActiveTables (aPropertyTables);
- if (aPropertyTables.isEmpty())
- return;
-
- ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables
- if (!aFirstTable)
- return;
-
- NCollection_List<Handle(Standard_Transient)> theSelPresentations;
- aFirstTable->GetSelectedPresentations (theTreeItem, theSelPresentations);
-
- for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator (theSelPresentations); anIterator.More(); anIterator.Next())
- {
- Handle(Convert_TransientShape) aShapePrs = Handle(Convert_TransientShape)::DownCast (anIterator.Value());
- if (!aShapePrs.IsNull())
- theShapes.Append (aShapePrs->GetShape());
- }
-
- //QModelIndexList& thePropertyPanelIndices = aFirstTable->GetTableView()->selectionModel()->selectedIndexes(),
-
- //QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices);
- //NCollection_List<Handle(Standard_Transient)> aPropertyPresentations;
- //for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
- //{
- // TreeModel_ItemBasePtr anItem = *anItemIt;
- // if (!anItem || anItem->Column() != 0)
- // continue;
-
- // QList<ViewControl_TableModelValues*> aTableValues;
- // VInspector_Tools::GetPropertyTableValues (anItem, myPaneCreators, aTableValues);
- // if (aTableValues.isEmpty())
- // continue;
-
- // Handle(TreeModel_ItemProperties) anItemProperties = anItem->GetProperties();
- // for (int aTableIt = 0; aTableIt < aTableValues.size(); aTableIt++)
- // {
- // VInspector_TableModelValues* aTableVals = dynamic_cast<VInspector_TableModelValues*>(aTableValues[aTableIt]);
- // if (!aTableVals)
- // continue;
-
- // // default shape by NULL selection
- // aTableVals->GetPaneShapes (-1, -1, theShapes);
-
- // for (QModelIndexList::const_iterator anIndicesIt = thePropertyPanelIndices.begin(); anIndicesIt != thePropertyPanelIndices.end(); anIndicesIt++)
- // {
- // QModelIndex anIndex = *anIndicesIt;
- // aTableVals->GetPaneShapes (anIndex.row(), anIndex.column(), theShapes);
-
- // if (!anItemProperties.IsNull())
- // {
- // anItemProperties->GetPresentations (anIndex.row(), anIndex.column(), aPropertyPresentations);
- // }
- // }
- // }
- //}
-
- //if (!aPropertyPresentations.IsEmpty())
- //{
- // for (NCollection_List<Handle(Standard_Transient)>::Iterator aPrsIterator (aPropertyPresentations); aPrsIterator.More(); aPrsIterator.Next())
- // {
- // Handle(Convert_TransientShape) aShapePrs = Handle(Convert_TransientShape)::DownCast (aPrsIterator.Value());
- // if (!aShapePrs.IsNull())
- // theShapes.Append (aShapePrs->GetShape());
- // }
- //}
-}
-
-// =======================================================================
-// function : GetSelectedTransformPers
-// purpose :
-// =======================================================================
-Handle(Graphic3d_TransformPers) VInspector_Window::GetSelectedTransformPers()
-{
- QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (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;
-
- while (aVItem)
- {
- Handle(Graphic3d_TransformPers) aPers = aVItem->TransformPersistence();
- if (!aPers.IsNull())
- return aPers;
-
- aVItem = itemDynamicCast<VInspector_ItemBase>(aVItem->Parent());
- }
- }
- return Handle(Graphic3d_TransformPers)();
}
// =======================================================================
// =======================================================================
bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
{
- VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aViewModel)
- return Standard_False;
-
Handle(AIS_InteractiveContext) aContext;
Handle(VInspector_CallBack) aCallBack;
- Standard_Boolean isModelUpdated = Standard_False;
for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next())
{
if (aCallBack.IsNull())
aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
-
- if (!Handle(ViewControl_PaneCreator)::DownCast (anObject).IsNull())
- {
- Handle(ViewControl_PaneCreator) aPaneCreator = Handle(ViewControl_PaneCreator)::DownCast (anObject);
- if (!myPaneCreators.Contains (aPaneCreator))
- myPaneCreators.Append (aPaneCreator);
- isModelUpdated = Standard_True;
- }
- if (!Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject).IsNull())
- {
- Handle(TreeModel_ItemPropertiesCreator) aPropCreator = Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject);
- VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*>(myTreeView->model());
- aViewModel->AddPropertiesCreator (aPropCreator);
- isModelUpdated = Standard_True;
- }
}
- if (aViewModel->GetContext() != aContext)
- SetContext(aContext);
+ if (aContext.IsNull())
+ return false;
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (aViewModel && aViewModel->GetContext() == aContext)
+ UpdateTreeModel();
else
- isModelUpdated = Standard_True;
+ SetContext (aContext);
if (!aCallBack.IsNull() && aCallBack != myCallBack)
{
myCallBack->SetContext(aContext);
myCallBack->SetHistoryModel(aHistoryModel);
}
-
- if (isModelUpdated)
- UpdateTreeModel();
-
return true;
}
// =======================================================================
void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theContext)
{
- if (theContext.IsNull())
- return;
-
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- bool isFirst = aViewModel->GetContext().IsNull();
-
aViewModel->SetContext (theContext);
myTreeView->setExpanded (aViewModel->index (0, 0), true);
if (!myCallBack.IsNull())
myCallBack->SetContext (theContext);
-
- myDisplayPreview->SetContext (theContext);
-
- if (isFirst)
- onExportToMessageView();
}
// =======================================================================
if (aShape.IsNull())
return isModelUpdated;
-#ifndef DEBUG_COLORED_SHAPE
Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape);
-#else
- Handle(AIS_ColoredShape) aPresentation = new AIS_ColoredShape (aShape);
-
- TopExp_Explorer expS(aShape, TopAbs_EDGE);
- for (; expS.More(); expS.Next())
- {
- aPresentation->SetCustomColor (expS.Current(), Quantity_Color (Quantity_NOC_GREEN));
- }
-#endif
- View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
- aDisplayer->DisplayPresentation (aPresentation);
-
- //aContext->Display (aPresentation, false);
- //aContext->Load (aPresentation, -1/*selection mode*/);
+ aContext->Display (aPresentation, false);
+ aContext->Load (aPresentation, -1/*selection mode*/);
aContext->UpdateCurrentViewer();
UpdateTreeModel();
{
QMenu* aMenu = new QMenu (GetMainWindow());
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this));
- aMenu->addSeparator();
-
- QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (anItemBase)
- {
- if (itemDynamicCast<VInspector_ItemContext> (anItemBase))
- {
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to MessageView"), SLOT (onExportToMessageView()), GetMainWindow(), this));
- aMenu->addSeparator();
-
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Default preview"), SLOT (onDefaultPreview()), GetMainWindow(), this));
- }
- }
-
- aMenu->addSeparator();
- for (int aTypeId = (int)View_DisplayActionType_DisplayId; aTypeId <= (int)View_DisplayActionType_RemoveId; aTypeId++)
- aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((View_DisplayActionType) aTypeId),
- SLOT (onDisplayActionTypeClicked()), GetMainWindow(), this));
- aMenu->addSeparator();
-
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand"), SLOT (onExpand()), GetMainWindow(), this));
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand All"), SLOT (onExpandAll()), GetMainWindow(), this));
- aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Collapse All"), SLOT (onCollapseAll()), GetMainWindow(), this));
-
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Show"), SLOT (onShow()), GetMainWindow(), this));
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Hide"), SLOT (onHide()), GetMainWindow(), this));
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec(aPoint);
}
}
case VInspector_ToolActionType_SelectPresentationsId:
{
- bool isChecked = myToolBar->GetToolButton ((VInspector_ToolActionType)theActionId)->isChecked();
+ bool isChecked = myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked();
NCollection_List<Handle(AIS_InteractiveObject)> aPresentationsForViewer;
if (isChecked)
- aPresentationsForViewer = GetSelectedPresentations (myTreeView->selectionModel());
+ aPresentationsForViewer = VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
- VInspector_Tools::AddOrRemovePresentations (aContext, aPresentationsForViewer);
+ VInspector_Tools::AddOrRemovePresentations(aContext, aPresentationsForViewer);
UpdateTreeModel();
break;
}
case VInspector_ToolActionType_SelectOwnersId:
{
- NCollection_List<Handle(SelectBasics_EntityOwner)> anOwnersForViewer;
+ NCollection_List<Handle(SelectMgr_EntityOwner)> anOwnersForViewer;
if (myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked())
VInspector_ViewModel::GetSelectedOwners(myTreeView->selectionModel(), anOwnersForViewer);
VInspector_Tools::AddOrRemoveSelectedShapes(aViewModel->GetContext(), anOwnersForViewer);
}
// =======================================================================
-// function : onPropertyPanelShown
-// purpose :
-// =======================================================================
-void VInspector_Window::onPropertyPanelShown (bool isToggled)
-{
- if (!isToggled)
- return;
-
- updatePropertyPanelBySelection();
-}
-
-// =======================================================================
-// function : onPropertyViewSelectionChanged
-// purpose :
-// =======================================================================
-void VInspector_Window::onPropertyViewSelectionChanged()
-{
- QModelIndex aTreeItemIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
- TreeModel_ItemBasePtr aTreeItemSelected = TreeModel_ModelBase::GetItemByIndex (aTreeItemIndex);
- if (!aTreeItemSelected)
- return;
-
- QList<ViewControl_Table*> aPropertyTables;
- myPropertyView->GetActiveTables (aPropertyTables);
- if (aPropertyTables.isEmpty())
- return;
-
- ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables
- NCollection_List<Handle(Standard_Transient)> aSelPresentations;
- aFirstTable->GetSelectedPresentations (aTreeItemSelected, aSelPresentations);
-
- //Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties();
-
-
- //QMap<int, QList<int>> aSelectedIndices;
- //aFirstTable->GetSelectedIndices (aSelectedIndices);
-
- //ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(aFirstTable->GetTableView()->model());
- //ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues();
-
- QStringList aPointers;
- aFirstTable->GetSelectedPointers (aPointers);
-
- //NCollection_List<Handle(Standard_Transient)> aSelPresentations;
- /*for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- int aRowId = aSelIt.key();
- QList<int> aColIds = aSelIt.value();
- for (int aColId = 0; aColId < aColIds.size(); aColId++)
- {
- int aSelectedColId = aColIds[aColId];
- if (aSelectedColId != 1)
- continue;
-
- QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString();
- if (aData.contains (ViewControl_Tools::GetPointerPrefix().ToCString()))
- aPointers.append (aData);
-
- if (anItemProperties)
- anItemProperties->GetPresentations (aRowId, aColId, aSelPresentations);
- }
- }*/
- highlightTreeViewItems (aPointers);
-
- //Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
- //QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes();
- //NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (aTreeViewSelected);
-
- //GetSelectedPropertyPanelShapes(aTreeViewSelected,
- // aFirstTable->GetTableView()->selectionModel()->selectedIndexes(),
- // aSelectedShapes);
- //updatePreviewPresentation(aSelectedShapes, aSelectedPersistent);
-
- myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations);
-}
-
-// =======================================================================
-// function : onTreeViewSelectionChanged
+// function : onSelectionChanged
// purpose :
// =======================================================================
-void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&,
- const QItemSelection&)
+void VInspector_Window::onSelectionChanged (const QItemSelection&,
+ const QItemSelection&)
{
QApplication::setOverrideCursor (Qt::WaitCursor);
else if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectOwnersId)->isChecked())
onToolBarActionClicked(VInspector_ToolActionType_SelectOwnersId);
- if (myPropertyPanelWidget->toggleViewAction()->isChecked())
- updatePropertyPanelBySelection();
-
- QModelIndex aTreeItemIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
- TreeModel_ItemBasePtr aTreeItemSelected = TreeModel_ModelBase::GetItemByIndex (aTreeItemIndex);
- if (!aTreeItemSelected)
- return;
-
- NCollection_List<Handle(Standard_Transient)> aSelPresentations;
- Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties();
- if (anItemProperties)
- anItemProperties->GetPresentations (-1, -1, aSelPresentations);
- //else
- GetSelectedShapes (aSelPresentations);
- myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations);
-
- //Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
-
- //NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes());
-
- //updatePreviewPresentation(aSelectedShapes, aSelectedPersistent);
-
QApplication::restoreOverrideCursor();
}
QModelIndexList aSelectedIndices = theSelected.indexes();
QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first());
- selectTreeViewItems (aPointers);
-}
-// =======================================================================
-// function : onExportToShapeView
-// purpose :
-// =======================================================================
-void VInspector_Window::onExportToMessageView()
-{
- VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aViewModel)
+ VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aTreeModel)
return;
- Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
- TCollection_AsciiString aPluginName ("TKMessageView");
- NCollection_List<Handle(Standard_Transient)> aParameters;
- if (myParameters->FindParameters (aPluginName))
- aParameters = myParameters->Parameters (aPluginName);
-
- QStringList anExportedPointers;
- anExportedPointers.append (VInspector_Tools::GetPointerInfo (aContext, true).ToCString());
- aParameters.Append (aContext);
-
- myParameters->SetParameters (aPluginName, aParameters, false);//myExportToShapeViewDialog->IsAccepted());
+ QModelIndexList anIndices = aTreeModel->FindPointers (aPointers);
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ aSelectionModel->clear();
+ for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+ {
+ QModelIndex anIndex = anIndices[anIndicesId];
+ myTreeView->setExpanded (aTreeModel->parent (anIndex), true);
+ aSelectionModel->select (anIndex, QItemSelectionModel::Select);
+ }
}
// =======================================================================
// =======================================================================
void VInspector_Window::onExportToShapeView()
{
- const QModelIndexList anIndices;
- NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes());
+ NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
+ VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
+ if (aSelectedPresentations.Extent() <= 0)
+ return;
TCollection_AsciiString aPluginName ("TKShapeView");
NCollection_List<Handle(Standard_Transient)> aParameters;
anItemNames = myParameters->GetSelectedNames (aPluginName);
QStringList anExportedPointers;
- if (aSelectedShapes.Extent() > 0)
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt (aSelectedPresentations); anIOIt.More(); anIOIt.Next())
{
- for (NCollection_List<TopoDS_Shape>::Iterator anIOIt (aSelectedShapes); anIOIt.More(); anIOIt.Next())
- {
- const TopoDS_Shape& aShape = anIOIt.Value();
- if (aShape.IsNull())
- continue;
- aParameters.Append (aShape.TShape());
- anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
- anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
- }
- }
-
- // seach for objects to be exported
- QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (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;
-
- Handle(Standard_Transient) anObject = aVItem->GetObject();
- if (anObject.IsNull())
+ Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (anIOIt.Value());
+ if (aShapePresentation.IsNull())
continue;
- aParameters.Append (anObject);
- anItemNames.Append (anObject->DynamicType()->Name());
- anExportedPointers.append (VInspector_Tools::GetPointerInfo (anObject, true).ToCString());
+ const TopoDS_Shape& aShape = aShapePresentation->Shape();
+ if (aShape.IsNull())
+ continue;
+ aParameters.Append (aShape.TShape());
+ anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
+ anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
}
-
- if (anExportedPointers.isEmpty())
+ if (anExportedPointers.empty())
return;
TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
- QString aMessage = QString ("Objects %1 are sent to %2.")
+ QString aMessage = QString ("TShape %1 is sent to %2.")
.arg (anExportedPointers.join(", "))
.arg (aPluginShortName.ToCString());
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
}
// =======================================================================
-// function : onDefaultPreview
+// function : onShow
// purpose :
// =======================================================================
-void VInspector_Window::onDefaultPreview()
+void VInspector_Window::onShow()
{
- myDisplayPreview->DisplayDefaultPreview();
-
- UpdateTreeModel();
+ displaySelectedPresentations (true);
}
// =======================================================================
-// function : onDisplayActionTypeClicked
+// function : onHide
// purpose :
// =======================================================================
-void VInspector_Window::onDisplayActionTypeClicked()
+void VInspector_Window::onHide()
{
- QAction* anAction = (QAction*)sender();
-
- displaySelectedPresentations (VInspector_Tools::DisplayActionTypeFromString (anAction->text().toStdString().c_str()));
+ displaySelectedPresentations (false);
}
-// =======================================================================
-// function : onExpand
-// purpose :
-// =======================================================================
-void VInspector_Window::onExpand()
-{
- QApplication::setOverrideCursor (Qt::WaitCursor);
-
- QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
- QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
- for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
- {
- int aLevels = 2;
- TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
- }
- QApplication::restoreOverrideCursor();
-}
-
-// =======================================================================
-// function : onExpandAll
-// purpose :
-// =======================================================================
-void VInspector_Window::onExpandAll()
-{
- QApplication::setOverrideCursor (Qt::WaitCursor);
-
- QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
- QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
- for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
- {
- int aLevels = -1;
- TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
- }
- QApplication::restoreOverrideCursor();
-}
-
-// =======================================================================
-// function : onCollapseAll
-// purpose :
-// =======================================================================
-void VInspector_Window::onCollapseAll()
-{
- QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
- QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
- for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
- {
- int aLevels = -1;
- TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
- }
-}
-
-#ifdef DEBUG_TWO_VIEWS
-// =======================================================================
-// function : onViewLeftButtonDown
-// purpose :
-// =======================================================================
-void VInspector_Window::onViewLeftButtonDown (const int theX, const int theY)
-{
- myCameraPrs->StartTransformation (theX, theY);
-}
-
-// =======================================================================
-// function : onViewLeftButtonUp
-// purpose :
-// =======================================================================
-void VInspector_Window::onViewLeftButtonUp (const int theX, const int theY)
-{
- myCameraPrs->StopTransformation (theX, theY);
-}
-
-// =======================================================================
-// function : onViewMoveTo
-// purpose :
-// =======================================================================
-void VInspector_Window::onViewMoveTo (const int theX, const int theY)
-{
- View_Widget* aViewWidget = (View_Widget*) sender();
-
- myCameraPrs->Transform (theX, theY, aViewWidget->GetViewer()->GetView());
-
- VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aViewModel)
- return;
- Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
- if (aContext.IsNull())
- return;
- aContext->Redisplay (myCameraPrs, Standard_True);
-}
-
-// =======================================================================
-// function : onViewLeftButtonUp
-// purpose :
-// =======================================================================
-void VInspector_Window::onViewLeftButtonUp()
-{
-
-}
-#endif
-
// =======================================================================
// function : UpdateTreeModel
// purpose :
aViewModel->UpdateTreeModel();
}
-// =======================================================================
-// function : updatePropertyPanelBySelection
-// purpose :
-// =======================================================================
-void VInspector_Window::updatePropertyPanelBySelection()
-{
- QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
-
- QModelIndexList aSelected = TreeModel_ModelBase::GetSelected (aModel->selectedIndexes(), 0);
- QList<ViewControl_TableModelValues*> aTableValues;
-
- if (aSelected.size() == 1)
- {
- TreeModel_ItemBasePtr aSelectedItem = TreeModel_ModelBase::GetItemByIndex(aSelected.first());
- VInspector_Tools::GetPropertyTableValues (aSelectedItem, myPaneCreators, aTableValues);
- }
- myPropertyView->Init (aTableValues);
-}
-
// =======================================================================
// function : displaySelectedPresentations
// purpose :
// =======================================================================
-
-void VInspector_Window::displaySelectedPresentations (const View_DisplayActionType theType)
+void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
{
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (!aViewModel)
if (aContext.IsNull())
return;
- QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
- if (!aSelectionModel)
- return;
-
- NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations = GetSelectedPresentations (aSelectionModel);
- const QModelIndexList& aSelectedIndices = aSelectionModel->selectedIndexes();
-
- bool aPreviewPresentationShown = myDisplayPreview->HasPreview();
- // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
- // Erased to Displayed container or back
- aSelectionModel->clear();
-
- // redisplay preview presentation if exists
- if (aPreviewPresentationShown && theType == View_DisplayActionType_RedisplayId)
- {
- // REDISPLAY preview !
-
- //QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (aSelectedIndices);
- //NCollection_List<Handle(Standard_Transient)> aSelPresentations;
-
- //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;
- // aVItem->UpdatePresentationShape();
-
- // Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties();
- // if (anItemProperties)
- // anItemProperties->GetPresentations (aRowId, aColId, aSelPresentations);
- //}
- //myDisplayPreview->UpdatePreview (theType, aSelPresentations);
-
- //NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (aSelectedIndices);
- //updatePreviewPresentation(aSelectedShapes, GetSelectedTransformPers());
- }
-
- if (aSelectedPresentations.Extent() == 0)
+ NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
+ VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
+ if (aSelectedPresentations.Extent() <= 0)
return;
for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt(aSelectedPresentations); anIOIt.More(); anIOIt.Next())
{
Handle(AIS_InteractiveObject) aPresentation = anIOIt.Value();
- switch (theType)
+ if (theToDisplay)
{
- case View_DisplayActionType_DisplayId:
- {
- aContext->Display(aPresentation, false);
- aContext->Load(aPresentation, -1);
- }
- break;
-
- case View_DisplayActionType_RedisplayId: aContext->Redisplay (aPresentation, false); break;
- case View_DisplayActionType_EraseId: aContext->Erase (aPresentation, false); break;
- case View_DisplayActionType_RemoveId: aContext->Remove (aPresentation, false); break;
- default: break;
+ aContext->Display(aPresentation, false);
+ aContext->Load(aPresentation, -1);
}
+ else
+ aContext->Erase(aPresentation, false);
}
aContext->UpdateCurrentViewer();
- UpdateTreeModel();
-}
-
-// =======================================================================
-// function : highlightTreeViewItems
-// purpose :
-// =======================================================================
-void VInspector_Window::highlightTreeViewItems (const QStringList& thePointers)
-{
- VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aTreeModel)
- return;
-
- QModelIndexList anIndices;
- aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
- for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
- {
- QModelIndex anIndex = anIndices[anIndicesId];
- TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
- }
- aTreeModel->SetHighlighted (anIndices);
-
- if (!anIndices.isEmpty())
- myTreeView->scrollTo (anIndices.last());
-}
-
-// =======================================================================
-// function : selectTreeViewItems
-// purpose :
-// =======================================================================
-void VInspector_Window::selectTreeViewItems (const QStringList& thePointers)
-{
- VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aTreeModel)
- return;
-
- QModelIndexList anIndices;
- aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
+ // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
+ // Erased to Displayed container or back
QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
aSelectionModel->clear();
- for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
- {
- QModelIndex anIndex = anIndices[anIndicesId];
- TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
- aSelectionModel->select (anIndex, QItemSelectionModel::Select);
- }
+
+ UpdateTreeModel();
}
// =======================================================================
// =======================================================================
Handle(AIS_InteractiveContext) VInspector_Window::createView()
{
- // create two view windows
- Handle(AIS_InteractiveContext) aContext = View_Viewer::CreateStandardViewer();
-
- Handle(AIS_Trihedron) aTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY()));
- aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded);
- aContext->Display (aTrihedron, Standard_True);
-
- myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true);
+ myViewWindow = new View_Window (0);
myViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
myViewWindow->show();
-#ifdef DEBUG_TWO_VIEWS
- myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X - 240, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
-
- View_Window* aSecondViewWindow = new View_Window (0, aContext);
- aSecondViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
- aSecondViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X + 220, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
- aSecondViewWindow->show();
-
- myCameraPrs = new View_CameraPositionPrs (aContext, 0);
- aContext->Display (myCameraPrs, Standard_True);
-
- View_Widget* aViewWidget = myViewWindow->GetView();
- connect (aViewWidget, SIGNAL (leftButtonDown (const int, const int)),
- this, SLOT (onViewLeftButtonDown (const int, const int)));
- connect (aViewWidget, SIGNAL (leftButtonUp (const int, const int)),
- this, SLOT (onViewLeftButtonUp (const int, const int)));
- connect (aViewWidget, SIGNAL (moveTo (const int, const int)),
- this, SLOT(onViewMoveTo (const int, const int)));
-#endif
-
- return aContext;
+ return myViewWindow->GetView()->GetViewer()->GetContext();
}
-
-// =======================================================================
-// function : updatePreviewPresentation
-// purpose :
-// =======================================================================
-//void VInspector_Window::updatePreviewPresentation (const NCollection_List<TopoDS_Shape>& theShapes,
-// const Handle(Graphic3d_TransformPers)& thePersistent)
-//{
-// Handle(AIS_InteractiveContext) aContext;
-// VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
-// if (aViewModel)
-// aContext = aViewModel->GetContext();
-//
-// if (theShapes.IsEmpty())
-// {
-// if (!aContext.IsNull())
-// aContext->Remove (myPreviewPresentation, Standard_True);
-// myPreviewPresentation = NULL;
-// return;
-// }
-//
-// BRep_Builder aBuilder;
-// TopoDS_Compound aCompound;
-// aBuilder.MakeCompound (aCompound);
-// for (NCollection_List<TopoDS_Shape>::Iterator anIterator (theShapes); anIterator.More(); anIterator.Next())
-// {
-// aBuilder.Add (aCompound, anIterator.Value());
-// }
-//
-// if (myPreviewPresentation.IsNull())
-// {
-// myPreviewPresentation = new AIS_Shape (aCompound);
-// myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
-//
-// myPreviewPresentation->SetTransformPersistence(thePersistent);
-// if (!aContext.IsNull())
-// aContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
-// }
-// else
-// {
-// Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
-// myPreviewPresentation->SetTransformPersistence(thePersistent);
-// if (!aContext.IsNull())
-// aContext->Redisplay (myPreviewPresentation, Standard_True);
-// }
-//}
#include <AIS_InteractiveContext.hxx>
#include <NCollection_List.hxx>
-#include <SelectBasics_EntityOwner.hxx>
+#include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx>
#include <inspector/TInspectorAPI_PluginParameters.hxx>
#include <inspector/VInspector_CallBack.hxx>
-#include <inspector/View_DisplayActionType.hxx>
-
-#include <inspector/ViewControl_PaneCreator.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QObject>
#include <Standard_WarningsRestore.hxx>
class ViewControl_MessageDialog;
-class ViewControl_PropertyView;
class VInspector_ToolBar;
-
-class View_DisplayPreview;
class View_Window;
class QAbstractItemModel;
class QAction;
-class QDockWidget;
+class QMainWindow;
class QTreeView;
class QWidget;
-//#define DEBUG_TWO_VIEWS
-
-#ifdef DEBUG_TWO_VIEWS
-class View_CameraPositionPrs;
-#endif
-
-
//! \class VInspector_Window
//! Window that unites all VInspector controls.
class VInspector_Window : public QObject
//! Returns main control
QWidget* GetMainWindow() const { return myMainWindow; }
- //! Returns presentations of selected items in tree model
- //! \param theModel selection model
- //! \return container of presentations
- NCollection_List<Handle(AIS_InteractiveObject)> GetSelectedPresentations (QItemSelectionModel* theModel);
-
- void GetSelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations);
-
- //! Returns selected shapes
- //! \param theModel selection model
- //! \return container of shapes
- NCollection_List<TopoDS_Shape> GetSelectedShapes (const QModelIndexList& theIndices);
-
- //! Returns selected shapes
- //! \param theModel selection model
- //! \return container of shapes
- void GetSelectedPropertyPanelShapes (const TreeModel_ItemBasePtr& theTreeItem,
- NCollection_List<TopoDS_Shape>& theShapes);
-
- //! Returns the first not zero transform persistent of selected elements
- Handle(Graphic3d_TransformPers) GetSelectedTransformPers();
-
private:
//! Fills controls of the plugin by parameters:
//! \param theActionId an action identifier in tool bar
void onToolBarActionClicked (const int theActionId);
- //! Display content of selected tree view item if isToggled is true
- //! \param isToggled true if the property dock widget is shown
- void onPropertyPanelShown (bool isToggled);
-
- //! Update presentation of the selected tree view item using information about selection in property view
- //! \param theSelected container of selected table cells
- //! \param theDeselected container of selected table cells
- void onPropertyViewSelectionChanged();
-
//! Synchronization selection between history and tree view. Selection by history view
//! \param theSelected a selected items
//! \param theDeselected a deselected items
//! check box is checked
//! \param theSelected a selected items
//! \param theDeselected a deselected items
- void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
- //! Exports the selected context into MessageView for have preview in the context.
- void onExportToMessageView();
+ void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
//! Exports the first selected shape into ShapeViewer plugin.
void onExportToShapeView();
- //! Displays default preview presentation
- void onDefaultPreview();
-
- //! Apply activated display action
- void onDisplayActionTypeClicked();
-
- //! Expand two next levels for all selected item
- void onExpand();
+ //! Shows selected presentation if it is not shown yet
+ void onShow();
- //! Expand all levels for all selected items
- void onExpandAll();
-
- //! Collapse all levels for all selected items
- void onCollapseAll();
-
-#ifdef DEBUG_TWO_VIEWS
- //! Processing mouse down in the view
- //! \param theX X mouse position in pixels
- //! \param theY Y mouse position in pixels
- void onViewLeftButtonDown (const int theX, const int theY);
-
- //! Processing mouse up in the view
- //! \param theX X mouse position in pixels
- //! \param theY Y mouse position in pixels
- void onViewLeftButtonUp (const int theX, const int theY);
-
- //! Processing move in the view
- //! \param theX X mouse position in pixels
- //! \param theY Y mouse position in pixels
- void onViewMoveTo (const int theX, const int theY);
-
- //! Processing left button up
- void onViewLeftButtonUp();
-#endif
+ //! Erase selected presentation if it is shown
+ void onHide();
private:
//! Updates tree model
void UpdateTreeModel();
- //! Updates property panel content by item selected in tree view.
- void updatePropertyPanelBySelection();
-
//! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
//! still belongs to the current context until Remove is called.
- //! \param theType display action type
- void displaySelectedPresentations (const View_DisplayActionType theType);
-
- //! Set items of the pointers highlighted in tree view
- //! \param theType display action type
- void highlightTreeViewItems (const QStringList& thePointers);
-
- //! Set items of the pointers selected in tree view
- //! \param theType display action type
- void selectTreeViewItems (const QStringList& thePointers);
+ //! \param theToDisplay if true, presentation is displayed otherwise erased
+ void displaySelectedPresentations (const bool theToDisplay);
//! Creates an istance of 3D view to initialize context.
//! \return a context of created view.
QMainWindow* myMainWindow; //!< main control
VInspector_ToolBar* myToolBar; //!< tool bar actions
-
- QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
- ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
-
QTreeView* myTreeView; //!< tree view of AIS content
QTreeView* myHistoryView; //!< history of AIS context calls
Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
- NCollection_List<Handle(ViewControl_PaneCreator)> myPaneCreators; //!< panes for AIS presentations
-
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
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
-
- View_DisplayPreview* myDisplayPreview; //!< class for preview display
-
-#ifdef DEBUG_TWO_VIEWS
- Handle(View_CameraPositionPrs) myCameraPrs;
-#endif
};
#endif
+++ /dev/null
-VInspectorPaneAIS_ColoredShape.cxx
-VInspectorPaneAIS_ColoredShape.hxx
-VInspectorPaneAIS_ItemPrs3dDrawer.cxx
-VInspectorPaneAIS_ItemPrs3dDrawer.hxx
-VInspectorPaneAIS_PaneCreator.cxx
-VInspectorPaneAIS_PaneCreator.hxx
-VInspectorPaneAIS_PropertiesCreator.cxx
-VInspectorPaneAIS_PropertiesCreator.hxx
-VInspectorPaneAIS_Shape.cxx
-VInspectorPaneAIS_Shape.hxx
\ No newline at end of file
+++ /dev/null
-// Created on: 2019-04-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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/VInspectorPaneAIS_ColoredShape.hxx>
-#include <inspector/VInspectorPaneAIS_ItemPrs3dDrawer.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <inspector/VInspector_Tools.hxx>
-
-#include <AIS_ColoredShape.hxx>
-
-// =======================================================================
-// function : ChildItemCount
-// purpose :
-// =======================================================================
-int VInspectorPaneAIS_ColoredShape::ChildItemCount() const
-{
- Handle(AIS_ColoredShape) aPrs = GetPresentation();
- if (aPrs.IsNull())
- return 0;
-
- return aPrs->CustomAspectsMap().Size();
-}
-
-// =======================================================================
-// function : CreateChildItem
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspectorPaneAIS_ColoredShape::CreateChildItem (int theRow, int theColumn) const
-{
- Handle(AIS_ColoredShape) aPrs = GetPresentation();
- if (aPrs.IsNull())
- return TreeModel_ItemBasePtr();
-
- return VInspectorPaneAIS_ItemPrs3dDrawer::CreateItem (getItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : GetPresentation
-// purpose :
-// =======================================================================
-Handle(AIS_ColoredShape) VInspectorPaneAIS_ColoredShape::GetPresentation() const
-{
- return Handle(AIS_ColoredShape)::DownCast (getItem()->GetObject());
-}
+++ /dev/null
-// Created on: 2019-04-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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 VInspectorPaneAIS_ColoredShape_H
-#define VInspectorPaneAIS_ColoredShape_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
-
-class AIS_ColoredShape;
-
-//! \class VInspectorPaneAIS_ColoredShape
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspectorPaneAIS_ColoredShape : public TreeModel_ItemProperties
-{
-public:
- //! Constructor
- VInspectorPaneAIS_ColoredShape (const TreeModel_ItemBasePtr& theItem) : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- ~VInspectorPaneAIS_ColoredShape() {}
-
- //! Returns number of item children
- //! \return an integer value, ZERO by default
- Standard_EXPORT virtual int ChildItemCount() 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
- Standard_EXPORT virtual TreeModel_ItemBasePtr CreateChildItem (int theRow, int theColumn) const Standard_OVERRIDE;
-
-protected:
- //! Converts transient object to custom presentation type
- //! \return custom presentation
- Handle(AIS_ColoredShape) GetPresentation() const;
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-08-10
-// 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/VInspectorPaneAIS_ItemPrs3dDrawer.hxx>
-
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
-
-#include <AIS_ColoredShape.hxx>
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void VInspectorPaneAIS_ItemPrs3dDrawer::Init()
-{
- Handle(Prs3d_Drawer) aDrawer;
- TCollection_AsciiString aName;
- VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
- if (!aParentItem)
- {
- VInspector_ItemPrs3dDrawer::Init();
- return;
- }
-
- Handle(AIS_ColoredShape) aPrs = Handle(AIS_ColoredShape)::DownCast (aParentItem->GetInteractiveObject());
- const AIS_DataMapOfShapeDrawer& anAspectsMap = aPrs->CustomAspectsMap();
-
- int aRowId = Row();
- int anItemRows = TreeModel_ItemBase::RowCountWithoutProperties (aParentItem);
- int aCurrentRow = anItemRows;
- for (AIS_DataMapOfShapeDrawer::Iterator anIter (anAspectsMap); anIter.More(); anIter.Next(), aCurrentRow++)
- {
- if (aRowId != aCurrentRow)
- continue;
-
- aDrawer = anIter.Value();
- break;
- }
- aName = aDrawer.IsNull() ? "NULL" : (TCollection_AsciiString(aDrawer->DynamicType()->Name()) + "_" + (aRowId - anItemRows));
- setDrawer (aDrawer, aName);
- TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void VInspectorPaneAIS_ItemPrs3dDrawer::Reset()
-{
- VInspector_ItemPrs3dDrawer::Reset();
-
- myShape = TopoDS_Shape();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void VInspectorPaneAIS_ItemPrs3dDrawer::initItem() const
-{
- if (IsInitialized())
- return;
- const_cast<VInspectorPaneAIS_ItemPrs3dDrawer*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspectorPaneAIS_ItemPrs3dDrawer::GetTableRowCount() const
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return 0;
-
- return 1 + VInspector_ItemPrs3dDrawer::GetTableRowCount();
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspectorPaneAIS_ItemPrs3dDrawer::GetTableData (const int theRow, const int theColumn, const int theRole) const
-{
- Handle(Prs3d_Drawer) aDrawer = GetDrawer();
- if (aDrawer.IsNull())
- return QVariant();
-
- if (theRow == 0)
- {
- if (theRole == Qt::DisplayRole)
- return theColumn == 0 ? QVariant ("TopoDS_Shape") : QVariant();
- else
- return QVariant();
- }
-
- return VInspector_ItemPrs3dDrawer::GetTableData (theRow, theColumn, theRole);
-}
-
+++ /dev/null
-// Created on: 2018-08-10
-// 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 VInspectorPaneAIS_ItemPrs3dDrawer_H
-#define VInspectorPaneAIS_ItemPrs3dDrawer_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-#include <inspector/VInspector_ItemPrs3dDrawer.hxx>
-
-#include <TopoDS_Shape.hxx>
-
-class Prs3d_BasicAspect;
-class QItemSelectionModel;
-
-class VInspectorPaneAIS_ItemPrs3dDrawer;
-typedef QExplicitlySharedDataPointer<VInspectorPaneAIS_ItemPrs3dDrawer> VInspectorPaneAIS_ItemPrs3dDrawerPtr;
-
-//! \class VInspectorPaneAIS_ItemPrs3dDrawer
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspectorPaneAIS_ItemPrs3dDrawer : public VInspector_ItemPrs3dDrawer
-{
-
-public:
-
- //! Creates an item wrapped by a shared pointer
- static VInspectorPaneAIS_ItemPrs3dDrawerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- { return VInspectorPaneAIS_ItemPrs3dDrawerPtr (new VInspectorPaneAIS_ItemPrs3dDrawer (theParent, theRow, theColumn)); }
- //! Destructor
- virtual ~VInspectorPaneAIS_ItemPrs3dDrawer() 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 number of table rows
- //! \return an integer value
- virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-protected:
-
- //! Initialize the current item. It is empty because Reset() is also empty.
- virtual void initItem() const Standard_OVERRIDE;
-
-private:
-
- //! Constructor
- //! param theParent a parent item
- VInspectorPaneAIS_ItemPrs3dDrawer (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : VInspector_ItemPrs3dDrawer (theParent, theRow, theColumn) {}
-
-protected:
-
- TopoDS_Shape myShape; //!< current shape
-
- friend class VInspectorPaneAIS_ColoredShape;
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-12-08
-// 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/VInspectorPaneAIS_PaneCreator.hxx>
-#include <inspector/VInspectorPaneAIS_Shape.hxx>
-
-#include <AIS_Shape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PaneCreator, ViewControl_PaneCreator)
-
-// =======================================================================
-// function : createPane
-// purpose :
-// =======================================================================
-ViewControl_Pane* VInspectorPaneAIS_PaneCreator::createPane (const Standard_CString& theName)
-{
- if (theName == STANDARD_TYPE (AIS_Shape)->Name())
- return new VInspectorPaneAIS_Shape();
-
- return NULL;
-}
-
-// =======================================================================
-// function : buildPresentationShape
-// purpose :
-// =======================================================================
-ViewControl_Pane* VInspectorPaneAIS_PaneCreator::GetPane (const Standard_CString& theName)
-{
- if (myPanes.IsBound (theName))
- return myPanes.Find (theName);
-
- ViewControl_Pane* aPane = createPane (theName);
- if (aPane)
- myPanes.Bind (theName, aPane);
-
- return aPane;
-}
+++ /dev/null
-// Created on: 2018-12-08
-// 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 VInspectorPaneAIS_PaneCreator_H
-#define VInspectorPaneAIS_PaneCreator_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <inspector/ViewControl_PaneCreator.hxx>
-#include <inspector/ViewControl_Pane.hxx>
-
-#include <NCollection_DataMap.hxx>
-#include <TCollection_AsciiString.hxx>
-
-DEFINE_STANDARD_HANDLE (VInspectorPaneAIS_PaneCreator, ViewControl_PaneCreator)
-
-//! \class VInspectorPaneAIS_PaneCreator
-//! \brief An interface to create custom panes by transient object name.
-class VInspectorPaneAIS_PaneCreator : public ViewControl_PaneCreator
-{
-public:
-
- //! Constructor
- VInspectorPaneAIS_PaneCreator() {}
-
- //! Destructor
- virtual ~VInspectorPaneAIS_PaneCreator() {}
-
- //! Returns pane for the name, creates a new pane if it does not exist and possible to create
- //! \param theName type of the pane
- //! \return a pane instance or NULL
- virtual ViewControl_Pane* GetPane (const Standard_CString& theName);
-
- DEFINE_STANDARD_RTTIEXT(VInspectorPaneAIS_PaneCreator, ViewControl_PaneCreator)
-
-protected:
- //! Creates new pane for the name
- //! \return pane instance or NULL
- ViewControl_Pane* createPane (const Standard_CString& theName);
-
-private:
- NCollection_DataMap<TCollection_AsciiString, ViewControl_Pane*> myPanes; //!< created panes
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-04-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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/VInspectorPaneAIS_PropertiesCreator.hxx>
-#include <inspector/VInspectorPaneAIS_ColoredShape.hxx>
-
-#include <AIS_ColoredShape.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator)
-
-// =======================================================================
-// function : GetProperties
-// purpose :
-// =======================================================================
-TreeModel_ItemProperties* VInspectorPaneAIS_PropertiesCreator::GetProperties (const TreeModel_ItemBasePtr& theItem)
-{
- Handle(Standard_Transient) anObject = theItem->GetObject();
- if (anObject.IsNull())
- return NULL;
-
- if (!Handle(AIS_ColoredShape)::DownCast (anObject).IsNull())
- return new VInspectorPaneAIS_ColoredShape (theItem);
-
- return NULL;
-}
-
+++ /dev/null
-// Created on: 2019-04-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 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 VInspectorPaneAIS_PropertiesCreator_H
-#define VInspectorPaneAIS_PropertiesCreator_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
-
-DEFINE_STANDARD_HANDLE (VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator)
-
-//! \class VInspectorPaneAIS_PropertiesCreator
-//! \brief An interface to create custom panes by transient object name.
-class VInspectorPaneAIS_PropertiesCreator : public TreeModel_ItemPropertiesCreator
-{
-public:
-
- //! Constructor
- VInspectorPaneAIS_PropertiesCreator() {}
-
- //! Destructor
- virtual ~VInspectorPaneAIS_PropertiesCreator() {}
-
- //! Returns pane for the name, creates a new pane if it does not exist and possible to create
- //! \param theName type of the pane
- //! \return a pane instance or NULL
- virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) Standard_OVERRIDE;
-
- DEFINE_STANDARD_RTTIEXT(VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator)
-
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-12-08
-// 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/VInspectorPaneAIS_Shape.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <inspector/ViewControl_PaneItem.hxx>
-
-#include <Prs3d.hxx>
-#include <TopAbs.hxx>
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspectorPaneAIS_Shape::GetTableRowCount(const Handle(Standard_Transient)& theObject) const
-{
- Handle(AIS_Shape) aPrs = GetPresentation (theObject);
- if (aPrs.IsNull())
- return 0;
-
- return 8;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-QVariant VInspectorPaneAIS_Shape::GetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn, const int theRole) const
-{
- Handle(AIS_Shape) aPrs = GetPresentation (theObject);
- if (aPrs.IsNull())
- return QVariant();
-
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return ViewControl_Table::SeparatorData();
- case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (AIS_Shape)->Name())
- : ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
- case 2: return ViewControl_Table::SeparatorData();
- case 3: return isFirstColumn ? QVariant ("TShape")
- : (aPrs->Shape().IsNull() ? QVariant ("") : ViewControl_Tools::GetPointerInfo (aPrs->Shape().TShape()).ToCString());
- case 4: return isFirstColumn ? QVariant ("ShapeType")
- : (aPrs->Shape().IsNull() ? QVariant ("") : TopAbs::ShapeTypeToString (aPrs->Shape().ShapeType()));
- case 5: return isFirstColumn ? QVariant ("Orientation")
- : (aPrs->Shape().IsNull() ? QVariant ("") : VInspector_Tools::OrientationToName (aPrs->Shape().Orientation()).ToCString());
- case 6: return isFirstColumn ? QVariant ("Location")
- : (aPrs->Shape().IsNull() ? QVariant ("") : ViewControl_Tools::ToString (aPrs->Shape().Location()).ToCString());
- case 7: return isFirstColumn ? QVariant ("Deflection")
- : (aPrs->Shape().IsNull() ? QVariant ("") : QVariant (Prs3d::GetDeflection(aPrs->Shape(), aPrs->Attributes())));
-
- default: return QVariant();
- }
-}
-
-// =======================================================================
-// function : GetSelected
-// purpose :
-// =======================================================================
-ViewControl_PaneItem* VInspectorPaneAIS_Shape::GetSelected (const Handle(Standard_Transient)& theObject,
- const int /*theRow*/, const int /*theColumn*/)
-{
- Handle(AIS_Shape) aPrs = GetPresentation (theObject);
- if (aPrs.IsNull())
- return NULL;
-
- ViewControl_PaneItem* aPaneItem = new ViewControl_PaneItem();
- aPaneItem->SetShape (aPrs->Shape());
-
- return aPaneItem;
-}
+++ /dev/null
-// Created on: 2018-12-08
-// 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 VInspectorPaneAIS_Shape_H
-#define VInspectorPaneAIS_Shape_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <inspector/ViewControl_Pane.hxx>
-
-#include <AIS_Shape.hxx>
-
-//! \class VInspectorPaneAIS_Shape
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspectorPaneAIS_Shape : public ViewControl_Pane
-{
-public:
- //! Constructor
- VInspectorPaneAIS_Shape() : ViewControl_Pane() {}
-
- //! Destructor
- ~VInspectorPaneAIS_Shape() {}
-
- //! Returns number of table rows
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount(const Handle(Standard_Transient)& theObject) const Standard_OVERRIDE;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theRow a model index row
- //! \param theColumn a model index column
- Standard_EXPORT virtual QVariant GetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow,
- const int theColumn,
- const int theRole) const Standard_OVERRIDE;
-
- //! Return selected element in the pane cell
- //! \param theObject current pane object
- //! \param theRow a model index row
- //! \param theColumn a model index column
- Standard_EXPORT virtual ViewControl_PaneItem* GetSelected (const Handle(Standard_Transient)& theObject,
- const int theRow,
- const int theColumn) Standard_OVERRIDE;
-
-protected:
- //! Converts transient object to custom presentation type
- //! \return custom presentation
- Handle(AIS_Shape) GetPresentation (const Handle(Standard_Transient)& theObject) const
- { return Handle(AIS_Shape)::DownCast (theObject); };
-};
-
-#endif
View.qrc
-View_CameraPositionPrs.cxx
-View_CameraPositionPrs.hxx
View_ContextType.hxx
-View_DisplayActionType.hxx
View_Displayer.cxx
View_Displayer.hxx
-View_DisplayPreview.cxx
-View_DisplayPreview.hxx
View_PresentationType.hxx
-View_PreviewParameters.cxx
-View_PreviewParameters.hxx
View_ToolActionType.hxx
View_ToolBar.cxx
View_ToolBar.hxx
+++ /dev/null
-// Created on: 2018-12-11
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/View_CameraPositionPrs.hxx>
-
-#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Graphic3d_ArrayOfPoints.hxx>
-
-#include <Prs3d_Root.hxx>
-#include <TColgp_SequenceOfPnt.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-// =======================================================================
-// function : StartTransformation
-// purpose :
-// =======================================================================
-void View_CameraPositionPrs::StartTransformation (const int theX, const int theY)
-{
- myIsTransformationStarted = Standard_True;
- myStartPosition = gp_Pnt2d (theX, theY);
-}
-
-// =======================================================================
-// function : StopTransformation
-// purpose :
-// =======================================================================
-void View_CameraPositionPrs::StopTransformation (const int theX, const int theY)
-{
- myIsTransformationStarted = Standard_False;
- myStartPosition = gp_Pnt2d (0, 0);
-
- int aValue = 9;
-}
-
-// =======================================================================
-// function : Transform
-// purpose :
-// =======================================================================
-void View_CameraPositionPrs::Transform (const int theX, const int theY, const Handle(V3d_View) theView)
-{
- // scale camera symmetry according to the center
- if (!myIsTransformationStarted)
- return;
-
- Standard_Integer aXDiff = theX - myStartPosition.X();
- Standard_Integer anYDiff = theY - myStartPosition.Y();
-
- Handle(V3d_View) aTargetView = GetView();
- if (aTargetView.IsNull())
- return;
- TColgp_SequenceOfPnt aPoints = getCameraPoints(aTargetView->Camera());
- TColgp_SequenceOfPnt2d aPixelPoints = projectToView (aPoints, theView);
- Standard_Real aWidthInPixels = aPixelPoints.Value(2).Distance (aPixelPoints.Value(1));
- Standard_Real aHeightInPixels = aPixelPoints.Value(3).Distance (aPixelPoints.Value(2));
-
- if (aWidthInPixels < Precision::Confusion() ||
- aHeightInPixels < Precision::Confusion())
- return;
-
- Standard_Real aXScaleToMove = aXDiff / aWidthInPixels;
- Standard_Real anYScaleToMove = anYDiff / aHeightInPixels;
-
- TColgp_SequenceOfPnt2d aTargetPixelPoints = projectToView (aPoints, aTargetView);
- Standard_Real aTargetWidthInPixels = aTargetPixelPoints.Value(2).Distance (aTargetPixelPoints.Value(1));
- Standard_Real aTargetHeightInPixels = aTargetPixelPoints.Value(3).Distance (aTargetPixelPoints.Value(2));
- if (aTargetWidthInPixels < Precision::Confusion() ||
- aTargetHeightInPixels < Precision::Confusion())
- return;
-
- gp_XYZ aTargetCameraDimensions = aTargetView->Camera()->ViewDimensions();
- Standard_Real aTargetXDiff = aXScaleToMove * aTargetWidthInPixels;
- Standard_Real aTargetYDiff = anYScaleToMove * aTargetHeightInPixels;
-
- double aRatio = aHeightInPixels / aWidthInPixels;
-
- bool isXScale = true;
- if (aTargetXDiff == 0 && aTargetYDiff == 0)
- return;
- else if (aTargetXDiff == 0)
- isXScale = false;
- else if (aTargetYDiff == 0)
- isXScale = true;
- else // both X, Y are not zero
- {
- double aDiffRatio = aTargetYDiff / aTargetXDiff;
- isXScale = aDiffRatio > aRatio;
- }
-
- Standard_Real aNewScale = 1;
- if (isXScale)
- {
- bool isIncrease = true;
- double aScaleSign = isIncrease ? 1.0 : -1.0;
-
- double aScale = aTargetView->Camera()->Scale();
- Standard_Real aTargetWidthInPixelsNew = aScale + aTargetXDiff * aScaleSign;
- aNewScale = aTargetWidthInPixelsNew;
- }
- else
- {
- std::cout << "Nothing to do" << std::endl;
- myStartPosition = gp_Pnt2d (theX, theY);
- return;
- }
-
- aTargetView->Camera()->SetScale (aNewScale);
- aTargetView->AutoZFit();
- //aTargetView->ImmediateUpdate();
- //aTargetView->Pan (aTargetXDiff, aTargetYDiff);
-
- myStartPosition = gp_Pnt2d (theX, theY);
-
- // move camera center
- //if (!myIsTransformationStarted)
- // return;
-
- //Standard_Integer aXDiff = theX - myStartPosition.X();
- //Standard_Integer anYDiff = theY - myStartPosition.Y();
- //aXDiff = -aXDiff;
-
- //Handle(V3d_View) aTargetView = GetView();
- //if (aTargetView.IsNull())
- // return;
- //TColgp_SequenceOfPnt aPoints = getCameraPoints(aTargetView->Camera());
- //TColgp_SequenceOfPnt2d aPixelPoints = projectToView (aPoints, theView);
- //Standard_Real aWidthInPixels = aPixelPoints.Value(2).Distance (aPixelPoints.Value(1));
- //Standard_Real aHeightInPixels = aPixelPoints.Value(3).Distance (aPixelPoints.Value(2));
-
- //if (aWidthInPixels < Precision::Confusion() ||
- // aHeightInPixels < Precision::Confusion())
- // return;
-
- //Standard_Real aXScaleToMove = aXDiff / aWidthInPixels;
- //Standard_Real anYScaleToMove = anYDiff / aHeightInPixels;
-
- //TColgp_SequenceOfPnt2d aTargetPixelPoints = projectToView (aPoints, aTargetView);
- //Standard_Real aTargetWidthInPixels = aTargetPixelPoints.Value(2).Distance (aTargetPixelPoints.Value(1));
- //Standard_Real aTargetHeightInPixels = aTargetPixelPoints.Value(3).Distance (aTargetPixelPoints.Value(2));
- //if (aTargetWidthInPixels < Precision::Confusion() ||
- // aTargetHeightInPixels < Precision::Confusion())
- // return;
-
- //gp_XYZ aTargetCameraDimensions = aTargetView->Camera()->ViewDimensions();
- //Standard_Real aTargetXDiff = aXScaleToMove * aTargetWidthInPixels;
- //Standard_Real aTargetYDiff = anYScaleToMove * aTargetHeightInPixels;
-
- //aTargetView->Pan (aTargetXDiff, aTargetYDiff);
-
- //myStartPosition = gp_Pnt2d (theX, theY);
-}
-
-// =======================================================================
-// function : CreateView
-// purpose :
-// =======================================================================
-void View_CameraPositionPrs::Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode)
-{
- thePresentation->Clear();
- if (GetView().IsNull())
- return;
-
- Handle (Graphic3d_Camera) aCamera = GetView()->Camera();
-
- Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
- Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d (Quantity_NOC_RED, Aspect_TOL_SOLID, 5);
- aGroup->SetGroupPrimitivesAspect (aLineAspect);
-
- gp_Pnt aCameraCenter = aCamera->Center();
- gp_XYZ aCameraDims = aCamera->ViewDimensions();
- gp_XYZ aCameraHalfDims = 0.5 * aCameraDims;
-
- gp_Dir anEyeDir (gp_Vec (aCameraCenter, aCamera->Eye()));
- gp_Dir anUpVec = aCamera->Up();
-
- gp_Dir aZAxis = anEyeDir;
- gp_Dir anYAxis = anUpVec;
- gp_Dir aXAxis = aZAxis ^ anYAxis;
-
- aZAxis = gp_Dir ((gp_Vec (aCamera->Eye(), aCameraCenter)));
- aZAxis.Reverse();
- double aZValue = 0;//aCamera->Scale();
-
- TColgp_SequenceOfPnt aPoints = getCameraPoints (aCamera);
- {
- //aZValue = aZAxis.Z() * aCamera->Scale();
-
- Handle(Graphic3d_ArrayOfPolylines) aSegments = new Graphic3d_ArrayOfPolylines (aPoints.Size());
- for (Standard_Integer aPointIndex = 1, aPointCount = aPoints.Length(); aPointIndex <= aPointCount; aPointIndex++)
- {
- aSegments->SetVertice (aPointIndex, aPoints (aPointIndex));
- ////aSegments->SetVertice (aPointIndex, gp_Pnt (aPoints (aPointIndex).X(), aPoints (aPointIndex).Y(), aZValue));
- //gp_Pnt aPoint = aPoints (aPointIndex);
- //aPoint.Translate(gp_Vec(aCamera->Eye(), gp::Origin()));
-
- //aSegments->SetVertice (aPointIndex, gp_Pnt (aPoint.X(), aPoint.Y(), aPoint.Z()));
- }
- aGroup->AddPrimitiveArray (aSegments);
- }
-
- {
- aGroup = Prs3d_Root::NewGroup (thePresentation);
- aLineAspect = new Graphic3d_AspectLine3d (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 3);
- aGroup->SetGroupPrimitivesAspect (aLineAspect);
-
- //aZValue = aZAxis.Z() * aCamera->Scale();
- aZValue = 20;//aCamera->ZFar() / aCamera->Scale();
-
- double aDistance = aCameraCenter.Distance (aCamera->Eye());
- Handle (Graphic3d_Camera) aDefCamera = GetView()->DefaultCamera();
- double aDefCameraScale = aDefCamera->Scale();
- double aScale = aCamera->Scale();
-
- double aMoveDistance = -aDistance + aDistance * (1 - aScale / aDefCameraScale);
-
- //std::cout << "aDistance = " << aDistance << "aScale = " << aScale << "1 - aScale / aDefCameraScale = " << 1 - aScale / aDefCameraScale
- // << "aMoveDistance = " << aMoveDistance << std::endl;
-
- Handle(Graphic3d_ArrayOfPolylines) aSegments = new Graphic3d_ArrayOfPolylines (aPoints.Size());
- for (Standard_Integer aPointIndex = 1, aPointCount = aPoints.Length(); aPointIndex <= aPointCount; aPointIndex++)
- {
- //aSegments->SetVertice (aPointIndex, aPoints (aPointIndex));
- //aSegments->SetVertice (aPointIndex, gp_Pnt (aPoints (aPointIndex).X(), aPoints (aPointIndex).Y(), aZValue));
- gp_Pnt aPoint = aPoints (aPointIndex);
- gp_Dir aDir = gp_Dir (gp_Vec(aCamera->Eye(), aCameraCenter));
- gp_Pnt aNewPoint = gp_Pnt(aPoint.XYZ() + aDir.XYZ() * aMoveDistance);
- gp_Vec aVec (aPoint, aNewPoint);
- aPoint.Translate(aVec);
-
- aSegments->SetVertice (aPointIndex, gp_Pnt (aPoint.X(), aPoint.Y(), aPoint.Z()));
-
- }
- aGroup->AddPrimitiveArray (aSegments);
- }
-
- Handle(Graphic3d_ArrayOfPoints) aVertices = new Graphic3d_ArrayOfPoints(1);
- aVertices->SetVertice (1, aCameraCenter);
-
- Handle(Graphic3d_AspectMarker3d) aMarkerAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_PLUS, Quantity_NOC_GREEN, 3);
- aGroup->SetGroupPrimitivesAspect (aMarkerAspect);
- aGroup->AddPrimitiveArray(aVertices);
-}
-
-// =======================================================================
-// function : ComputeSelection
-// purpose :
-// =======================================================================
-void View_CameraPositionPrs::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode)
-{
-}
-
-// =======================================================================
-// function : GetCamera
-// purpose :
-// =======================================================================
-Handle(V3d_View) View_CameraPositionPrs::GetView() const
-{
- Handle(V3d_Viewer) aViewer = myContext->CurrentViewer();
-
- int aViewId = 0;
- for (V3d_ListOfViewIterator anActiveViewIter (aViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- Handle(V3d_View) aView = anActiveViewIter.Value();
- if (aView->View().IsNull())
- continue;
-
- if (myViewId == aViewId)
- return aView;
- aViewId++;
- }
- return Handle(V3d_View)();
-}
-
-// =======================================================================
-// function : getCameraPoints
-// purpose :
-// =======================================================================
-TColgp_SequenceOfPnt View_CameraPositionPrs::getCameraPoints (const Handle (Graphic3d_Camera)& theCamera)
-{
- gp_Pnt aCameraCenter = theCamera->Center();
- gp_XYZ aCameraDims = theCamera->ViewDimensions();
- gp_XYZ aCameraHalfDims = 0.5 * aCameraDims;
-
- gp_Dir anEyeDir (gp_Vec (aCameraCenter, theCamera->Eye()));
- gp_Dir anUpVec = theCamera->Up();
-
- gp_Dir aZAxis = anEyeDir;
- gp_Dir anYAxis = anUpVec;
- gp_Dir aXAxis = aZAxis ^ anYAxis;
-
- aZAxis = gp_Dir ((gp_Vec (theCamera->Eye(), aCameraCenter)));
- aZAxis.Reverse();
- double aZValue = 0;//aCamera->Scale();
-
- TColgp_SequenceOfPnt aPoints;
- aPoints.Append (gp_Pnt (aCameraCenter.XYZ() - aXAxis.XYZ() * aCameraHalfDims.X() + anYAxis.XYZ() * aCameraHalfDims.Y()));
- aPoints.Append (gp_Pnt (aCameraCenter.XYZ() + aXAxis.XYZ() * aCameraHalfDims.X() + anYAxis.XYZ() * aCameraHalfDims.Y()));
- aPoints.Append (gp_Pnt (aCameraCenter.XYZ() + aXAxis.XYZ() * aCameraHalfDims.X() - anYAxis.XYZ() * aCameraHalfDims.Y()));
- aPoints.Append (gp_Pnt (aCameraCenter.XYZ() - aXAxis.XYZ() * aCameraHalfDims.X() - anYAxis.XYZ() * aCameraHalfDims.Y()));
- aPoints.Append (gp_Pnt (aCameraCenter.XYZ() - aXAxis.XYZ() * aCameraHalfDims.X() + anYAxis.XYZ() * aCameraHalfDims.Y()));
-
- return aPoints;
-}
-
-// =======================================================================
-// function : projectToView
-// purpose :
-// =======================================================================
-TColgp_SequenceOfPnt2d View_CameraPositionPrs::projectToView (const TColgp_SequenceOfPnt& thePoints,
- const Handle(V3d_View)& theView)
-{
- TColgp_SequenceOfPnt2d aPoints;
-
- Standard_Integer aX, anY;
- for (Standard_Integer aPointIndex = 1, aPointCount = thePoints.Length(); aPointIndex <= aPointCount; aPointIndex++)
- {
- gp_Pnt aPoint = thePoints (aPointIndex);
-
- theView->Convert (aPoint.X(), aPoint.Y(), aPoint.Z(), aX, anY);
- aPoints.Append (gp_Pnt2d (aX, anY));
- }
- return aPoints;
-}
+++ /dev/null
-// Created on: 2018-12-11
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef View_View_CameraPositionPrs_H
-#define View_View_CameraPositionPrs_H
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <Graphic3d_Camera.hxx>
-#include <TColgp_SequenceOfPnt2d.hxx>
-#include <TColgp_SequenceOfPnt.hxx>
-
-//! \class View_CameraPositionPrs
-//! \brief Displays contour of the camera position of another view
-class View_CameraPositionPrs : public AIS_InteractiveObject
-{
-public:
-
- //! Constructor
- View_CameraPositionPrs (const Handle(AIS_InteractiveContext)& theContext,
- const Standard_Integer theViewId)
- : myContext (theContext), myViewId (theViewId), myIsTransformationStarted (Standard_False) {}
-
- //! Destructor
- virtual ~View_CameraPositionPrs() {}
-
- Standard_EXPORT void StartTransformation (const int theX, const int theY);
- Standard_EXPORT void StopTransformation (const int theX, const int theY);
- Standard_EXPORT void Transform (const int theX, const int theY, const Handle(V3d_View) theView);
-
-protected:
- Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode = 0) Standard_OVERRIDE;
-
- Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
- const Standard_Integer theMode) Standard_OVERRIDE;
-
-protected:
- //! Returns the camera of the viewer of the context by the view index
- //! \return camera instance or NULL
- Handle (V3d_View) GetView() const;
-
- //! Computes the camera bounding points
- //! \param theCamera source camera
- //! \return container of bound points
- TColgp_SequenceOfPnt getCameraPoints (const Handle (Graphic3d_Camera)& theCamera);
-
- //! Converts container of 3D points in the container of points in pixels on the parameter view
- //! \param thePoints container of source points
- //! \return container of projectd points
- TColgp_SequenceOfPnt2d projectToView (const TColgp_SequenceOfPnt& thePoints,
- const Handle(V3d_View)& theView);
-
-protected:
- Handle(AIS_InteractiveContext) myContext; //!< interactive context
- Standard_Integer myViewId; //!< index of the view in the viewer
- Standard_Boolean myIsTransformationStarted;
- gp_Pnt2d myStartPosition;
-};
-
-#endif // View_CameraPositionPrs_H
+++ /dev/null
-// Created on: 2018-08-19
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef View_DisplayActionType_H
-#define View_DisplayActionType_H
-
-//! \enum View_DisplayActionType
-enum View_DisplayActionType
-{
- View_DisplayActionType_NoneId, //!< No action activated
- View_DisplayActionType_DisplayId, //!< Display action
- View_DisplayActionType_RedisplayId, //!< Redisplay action
- View_DisplayActionType_EraseId, //!< Erase action
- View_DisplayActionType_RemoveId //!< Remove action
-};
-
-#endif
+++ /dev/null
-// Created on: 2019-07-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/View_DisplayPreview.hxx>
-#include <inspector/View_PreviewParameters.hxx>
-#include <inspector/View_Tools.hxx>
-
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <inspector/Convert_Tools.hxx>
-#include <inspector/Convert_TransientShape.hxx>
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_Shape.hxx>
-
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-
-#include <Geom_Axis2Placement.hxx>
-#include <TopoDS_Compound.hxx>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-View_DisplayPreview::View_DisplayPreview()
-{
- myPreviewParameters = new View_PreviewParameters();
-}
-
-// =======================================================================
-// function : SetContext
-// purpose :
-// =======================================================================
-void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theContext)
-{
- if (myContext == theContext)
- return;
-
- // remove all preview presentations from the previous context, display it in the new
-
- myContext = theContext;
- myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer());
-}
-
-// =======================================================================
-// function : UpdatePreview
-// purpose :
-// =======================================================================
-void View_DisplayPreview::UpdatePreview (const View_DisplayActionType theType,
- const NCollection_List<Handle(Standard_Transient)>& thePresentations)
-{
- if (myContext.IsNull())
- return;
-
- if (thePresentations.IsEmpty())
- {
- myContext->Remove (myPreviewPresentation, Standard_True);
- myPreviewPresentation = NULL;
- return;
- }
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator (thePresentations); anIterator.More(); anIterator.Next())
- {
- Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (anIterator.Value());
- if (aShapePtr.IsNull())
- continue;
-
- aBuilder.Add (aCompound, aShapePtr->GetShape());
- }
-
- if (myPreviewPresentation.IsNull())
- {
- myPreviewPresentation = new AIS_Shape (aCompound);
- myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
-
- //myPreviewPresentation->SetTransformPersistence(thePersistent);
- myContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
- }
- else
- {
- Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
- //myPreviewPresentation->SetTransformPersistence(thePersistent);
- myContext->Redisplay (myPreviewPresentation, Standard_True);
- }
-}
-
-// =======================================================================
-// function : DisplayDefaultPreview
-// purpose :
-// =======================================================================
-
-void View_DisplayPreview::DisplayDefaultPreview()
-{
- if (myContext.IsNull())
- return;
-
- BRep_Builder aBuilder;
- TopoDS_Compound aCompound;
- aBuilder.MakeCompound (aCompound);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (gp_Pnt(25., 10., 0.)));
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt(20., 20., 0.), gp_Pnt(30., 20., 10.)));
- //aBuilder.Add (aCompound, BRepBuilderAPI_MakeFace (gp_Pln (gp_Pnt (20., 30., 0.), gp_Dir (1., 0., 0.))).Face());
- aBuilder.Add (aCompound, Convert_Tools::CreateBoxShape (gp_Pnt(20., 40., 0.), gp_Pnt(30., 60., 10.)));
-
- Handle(AIS_Shape) aDefaultPreview = new AIS_Shape (aCompound);
- aDefaultPreview->SetAttributes (myPreviewParameters->GetDrawer());
- myContext->Display (aDefaultPreview, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
-}
+++ /dev/null
-// Created on: 2019-07-14
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef View_DisplayPreview_H
-#define View_DisplayPreview_H
-
-#include <inspector/View_DisplayActionType.hxx>
-
-#include <AIS_InteractiveContext.hxx>
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Macro.hxx>
-
-class AIS_InteractiveObject;
-class View_PreviewParameters;
-
-//! \class View_DisplayPreview
-//! \brief It is responsible for communication with AIS Interactive Context to:
-//! - display/erase presentations;
-//! - change display mode of visualized presentations (Shaded or WireFrame mode)
-//!
-//! It contains containers of visualized presentations to obtain presentations relating only to this displayer.
-//! Displayer is connected to AIS Interactive Context
-class View_DisplayPreview
-{
-public:
-
- //! Constructor
- Standard_EXPORT View_DisplayPreview();
-
- //! Destructor
- virtual ~View_DisplayPreview() {}
-
- //! Stores the current context where the presentations will be displayed/erased.
- //! Erases previuously displayd presentations if there were some displayed
- //! \param theContext a context instance
- Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext);
-
- //!< Returns preview parameters
- View_PreviewParameters* GetPreviewParameters() const { return myPreviewParameters; }
-
- //!< Updates visibility of the presentations for the display type
- Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType,
- const NCollection_List<Handle(Standard_Transient)>& thePresentations);
-
- //!< Returns true if preview presentation is shown
- Standard_EXPORT Standard_Boolean HasPreview() const { return !myPreviewPresentation.IsNull(); }
-
- //!< Displays default preview to set visualization properties
- Standard_EXPORT void DisplayDefaultPreview();
-
-protected:
-
- //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes
- //!< \param theShape container of shapes
- //!< \param thePersistent transform persistent to be used in preview presentation
- //void updatePreviewPresentation (const NCollection_List<TopoDS_Shape>& theShapes,
- // const Handle(Graphic3d_TransformPers)& thePersistent);
-
-private:
-
- //! Returns the current context
- const Handle(AIS_InteractiveContext)& GetContext() const { return myContext; }
-
-private:
-
- Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
-
- View_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation
- Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
-};
-
-#endif
#include <Prs3d_PointAspect.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
-
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
-#include <inspector/View_Tools.hxx>
// =======================================================================
// function : Constructor
// =======================================================================
Handle(V3d_View) View_Displayer::GetView() const
{
- return View_Tools::FindActiveView (GetContext());
+ Handle(V3d_View) aView;
+ if (GetContext().IsNull())
+ return aView;
+
+ const Handle(V3d_Viewer)& aViewer = GetContext()->CurrentViewer();
+ if (!aViewer.IsNull())
+ {
+ aViewer->InitActiveViews();
+ if (aViewer->MoreActiveViews())
+ aView = aViewer->ActiveView();
+ }
+ return aView;
}
// =======================================================================
{
Handle(AIS_Shape) aShape = new AIS_Shape (theShape);
- //aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
+ aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
return aShape;
}
+++ /dev/null
-// Created on: 2019-05-03
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/View_PreviewParameters.hxx>
-
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-View_PreviewParameters::View_PreviewParameters()
-{
- myDrawer = new Prs3d_Drawer();
-
- Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1));
- Standard_ShortReal aTransparency = 0.8;
-
- // point parameters
- myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
-
- // shading parameters
- Graphic3d_MaterialAspect aShadingMaterial;
- aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
- aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
-
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
- myDrawer->ShadingAspect()->SetColor (aColor);
- myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial);
-
- myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency);
- myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency);
- myDrawer->SetTransparency (aTransparency);
-
- // common parameters
- myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
-}
-
-// =======================================================================
-// function : SaveState
-// purpose :
-// =======================================================================
-void View_PreviewParameters::SaveState (View_PreviewParameters* theParameters,
- QMap<QString, QString>& theItems,
- const QString& thePrefix)
-{
- Handle(Prs3d_Drawer) aDrawer = theParameters->GetDrawer();
-
- //Quantity_Color aColor = aDrawer->Color();
- //Standard_ShortReal aTransparency = aDrawer->Transparency();
-
- //// point parameters
- //{
- // Standard_Boolean anOwnPointAspect = aDrawer->HasOwnPointAspect();
- // Standard_SStream OS;
- // if (anOwnPointAspect)
- // myDrawer->PointAspect()->Dump (OS);
- // TCollection_AsciiString aStream (OS.str().c_str());
- // theItems[thePrefix + "has_point_aspect"] = anOwnPointAspect;
- // theItems[thePrefix + "point_aspect"] = aStream.ToCString();
- //}
- //// shading parameters
- //{
- // Standard_Boolean anOwnShadingAspect = aDrawer->HasOwnShadingAspect();
- // Standard_SStream OS;
- // if (anOwnShadingAspect)
- // myDrawer->ShadingAspect()->Dump (OS);
- // TCollection_AsciiString aStream (OS.str().c_str());
- // theItems[thePrefix + "has_shading_aspect"] = anOwnShadingAspect;
- // theItems[thePrefix + "shading_aspect"] = aStream.ToCString();
- //}
-}
-
-// =======================================================================
-// function : RestoreState
-// purpose :
-// =======================================================================
-bool View_PreviewParameters::RestoreState (View_PreviewParameters* theParameters,
- const QString& theKey, const QString& theValue,
- const QString& thePrefix)
-{
- //if (theKey == thePrefix + "has_point_aspect") // point parameters
- //{
- // myDrawer->SetOwnPointAspect (theValue.toBool());
- //}
- //else if (theKey == thePrefix + "point_aspect") // point parameters
- //{
- // Standard_SStream aStream;
- // aStream << theValue.ToString().ToStdString();
- // myDrawer->PointAspect()->Init (aStream);
- //}
- //else if (theKey == thePrefix + "has_shading_aspect") // shading parameters
- //{
- // myDrawer->SetOwnShadingAspect (theValue.toBool());
- //}
- //else if (theKey == thePrefix + "shading_aspect") // shading parameters
- //{
- // Standard_SStream aStream;
- // aStream << theValue.ToString().ToStdString();
- // myDrawer->ShadingAspect()->Init (aStream);
- //}
- //else
- // return false;
- return true;
-}
+++ /dev/null
-// Created on: 2019-05-03
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef View_PreviewParameters_H
-#define View_PreviewParameters_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <Prs3d_Drawer.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QMap>
-#include <QString>
-#include <Standard_WarningsRestore.hxx>
-
-//! \class View_PreviewParameters
-//! Container of View tool bar actions
-class View_PreviewParameters
-{
-public:
-
- //! Constructor
- Standard_EXPORT View_PreviewParameters ();
-
- //! Destructor
- virtual ~View_PreviewParameters() {}
-
- //! Returns main control
- const Handle(Prs3d_Drawer)& GetDrawer() const { return myDrawer; }
-
- //! Save state of three view in a container in form: key, value. It saves:
- //! - visibiblity of columns,
- //! - columns width
- //! \param theTreeView a view instance
- //! \param theItems [out] properties
- //! \param thePrefix peference item prefix
- Standard_EXPORT static void SaveState (View_PreviewParameters* theParameters,
- QMap<QString, QString>& theItems,
- const QString& thePrefix = QString());
- //! Restore state of three view by a container
- //! \param theTreeView a view instance
- //! \param theKey property key
- //! \param theValue property value
- //! \param thePrefix peference item prefix
- //! \return boolean value whether the property is applyed to the tree view
- Standard_EXPORT static bool RestoreState (View_PreviewParameters* theParameters,
- const QString& theKey, const QString& theValue,
- const QString& thePrefix = QString());
-
-private:
-
- Handle(Prs3d_Drawer) myDrawer;
-};
-
-#endif
return anAction;
}
-// =======================================================================
-// function : GetView
-// purpose :
-// =======================================================================
-Handle(V3d_View) View_Tools::FindActiveView (const Handle(AIS_InteractiveContext)& theContext)
-{
- if (theContext.IsNull())
- return NULL;
-
- const Handle(V3d_Viewer)& aViewer = theContext->CurrentViewer();
- if (aViewer.IsNull())
- return NULL;
-
- aViewer->InitActiveViews();
- if (!aViewer->MoreActiveViews())
- return NULL;
-
- return aViewer->ActiveView();
-}
-
// =======================================================================
// function : SaveState
// purpose :
{
QStringList aCameraDirection;
Standard_Real aVX, aVY, aVZ;
- Handle(V3d_View) aView = theView->GetView()->GetViewer()->GetView();
- if (aView.IsNull())
- return;
-
- aView->Proj (aVX, aVY, aVZ);
+ theView->GetView()->GetViewer()->GetView()->Proj (aVX, aVY, aVZ);
aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
#include <QString>
#include <Standard_WarningsRestore.hxx>
-#include <V3d_View.hxx>
-#include <AIS_InteractiveContext.hxx>
-
class View_Window;
class QAction;
Standard_EXPORT static QAction* CreateAction (const QString& theText, const char* theSlot,
QObject* theParent, QObject* theContext);
-
- //! Gets current viewer from the context and returns active view of the viewer
- //! \return view or NULL
- Standard_EXPORT static Handle(V3d_View) FindActiveView (const Handle(AIS_InteractiveContext)& theContext);
-
//! Save state of three view in a container in form: key, value. It saves:
//! - visibiblity of columns,
//! - columns width
#include <Standard_ExtString.hxx>
#include <Standard_Version.hxx>
-//#define USE_CLIPPLANE
-
-#ifdef USE_CLIPPLANE
-#include <Graphic3d_ClipPlane.hxx>
-#include <gp_Pln.hxx>
-#endif
-
// =======================================================================
// function : CreateView
// purpose :
void View_Viewer::CreateView()
{
if (myView.IsNull())
- {
myView = myContext->CurrentViewer()->CreateView();
-
-#ifdef USE_CLIPPLANE
- gp_Pln aPln (gp_Pnt (50, 0, 0), gp_Dir (-1., 0., 0.));
- Handle(Graphic3d_ClipPlane) aClipPlane = new Graphic3d_ClipPlane(aPln);
- myView->AddClipPlane (aClipPlane);
-#endif
- }
}
// =======================================================================
}
// =======================================================================
-// function : InitViewer
-// purpose :
-// =======================================================================
-void View_Viewer::InitViewer (const Handle(AIS_InteractiveContext)& theContext)
-{
- myContext = theContext;
- myViewer = myContext->CurrentViewer();
-}
-
-// =======================================================================
-// function : CreateStandardViewer
+// function : InitStandardViewer
// purpose :
// =======================================================================
-Handle(AIS_InteractiveContext) View_Viewer::CreateStandardViewer()
+void View_Viewer::InitStandardViewer()
{
Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
static Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection);
#if OCC_VERSION_HEX > 0x060901
- Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
+ myViewer = new V3d_Viewer (aGraphicDriver);
#else
TCollection_AsciiString a3DName ("Visu3D");
- Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver, a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos,
- Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_False);
+ myViewer = new V3d_Viewer (aGraphicDriver, a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30,
+ V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_False);
#endif
- aViewer->SetDefaultLights();
- aViewer->SetLightOn();
- aViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
-
- Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (aViewer);
- aContext->UpdateCurrentViewer();
+ myViewer->SetDefaultLights();
+ myViewer->SetLightOn();
+ myViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
- return aContext;
+ myContext = new AIS_InteractiveContext (myViewer);
+ myContext->UpdateCurrentViewer();
}
//! Creates OCC components on the window
//! \param theWindowHandle an id of the application window
- Standard_EXPORT void InitViewer (const Handle(AIS_InteractiveContext)& theContext);
-
- //! Creates OCC components on the window
- //! \param theWindowHandle an id of the application window
- Standard_EXPORT static Handle(AIS_InteractiveContext) CreateStandardViewer();
+ Standard_EXPORT void InitStandardViewer();
//! Returns an OCC viewer
const Handle(V3d_Viewer)& GetViewer() { return myViewer; }
// function : Constructor
// purpose :
// =======================================================================
-View_Widget::View_Widget (QWidget* theParent,
- const Handle(AIS_InteractiveContext)& theContext,
- const bool isFitAllActive)
+View_Widget::View_Widget (QWidget* theParent, const bool isFitAllActive)
: QWidget (theParent), myCurrentMode (View_CurrentAction3d_Nothing), myFirst (true), myDefaultWidth (-1),
myDefaultHeight (-1), myViewIsEnabled (true), myXmin (0), myYmin (0), myXmax (0), myYmax (0), myDragButtonDownX (0),
myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0),
myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
{
myViewer = new View_Viewer (View_Viewer::DefaultColor());
- if (!theContext.IsNull())
- myViewer->InitViewer (theContext);
- else
- {
- myViewer->InitViewer (myViewer->CreateStandardViewer());
+ myViewer->InitStandardViewer();
- //Handle(AIS_Trihedron) aTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY()));
- //aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded);
- //myViewer->GetContext()->Display (aTrihedron, Standard_True);
- }
+ myViewer->GetContext()->Display(new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())), Standard_True);
setAttribute (Qt::WA_PaintOnScreen);
setAttribute (Qt::WA_NoSystemBackground);
}
}
activateCursor (myCurrentMode);
- emit leftButtonDown(thePoint.x(), thePoint.y());
}
// =======================================================================
myDragMultiButtonDownX = 0;
myDragMultiButtonDownY = 0;
- myCurrentMode = View_CurrentAction3d_Nothing;
activateCursor (myCurrentMode);
emit selectionChanged();
- emit leftButtonUp(thePoint.x(), thePoint.y());
}
// =======================================================================
else
processMoveEvent (thePoint.x(), thePoint.y());
}
- emit moveTo (thePoint.x(), thePoint.y());
}
// =======================================================================
public:
//! Constructor
- Standard_EXPORT View_Widget (QWidget* theParent,
- const Handle(AIS_InteractiveContext)& theContext,
- const bool isFitAllActive);
+ Standard_EXPORT View_Widget (QWidget* theParent, const bool isFitAllActive);
//! Destructor
virtual ~View_Widget() {}
//! Sends a signal about selection change if the left mouse button is pressed and current action does not process it
void selectionChanged();
- //! Sends a signal about moving to the point in the view
- //! \param theX X mouse position in pixels
- //! \param theY Y mouse position in pixels
- void moveTo (const int theX, const int theY);
-
- //! Sends a signal about up the left mouse button down
- //! \param theX X mouse position in pixels
- //! \param theY Y mouse position in pixels
- void leftButtonDown (const int theX, const int theY);
-
- //! Sends a signal about up the left mouse button up
- //! \param theX X mouse position in pixels
- //! \param theY Y mouse position in pixels
- void leftButtonUp (const int theX, const int theY);
-
//! Sends a signal about display mode change
void displayModeClicked();
// function : Constructor
// purpose :
// =======================================================================
-View_Window::View_Window (QWidget* theParent,
- const Handle(AIS_InteractiveContext)& theContext,
- const bool isUseKeepView, const bool isFitAllActive)
+View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bool isFitAllActive)
: QWidget (theParent)
{
QGridLayout* aViewLayout = new QGridLayout (this);
aViewLayout->setContentsMargins (0, 0, 0, 0);
aViewLayout->setSpacing (DEFAULT_SPACING);
- myView = new View_Widget (this, theContext, isFitAllActive);
+ myView = new View_Widget (this, isFitAllActive);
myViewToolBar = new View_ToolBar (this, isUseKeepView);
aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
public:
//! Constructor
- Standard_EXPORT View_Window (QWidget* theParent,
- const Handle(AIS_InteractiveContext)& theContext = Handle(AIS_InteractiveContext)(),
- const bool isUseKeepView = true, const bool isFitAllActive = true);
+ Standard_EXPORT View_Window (QWidget* theParent, const bool isUseKeepView = true, const bool isFitAllActive = true);
//! Destructor
virtual ~View_Window() {}
-ViewControl.hxx
-ViewControl_ColorSelector.cxx
-ViewControl_ColorSelector.hxx
-ViewControl_EditType.hxx
ViewControl_MessageDialog.cxx
ViewControl_MessageDialog.hxx
-ViewControl_Pane.hxx
-ViewControl_PaneCreator.cxx
-ViewControl_PaneCreator.hxx
-ViewControl_PaneItem.hxx
-ViewControl_PropertiesStream.cxx
-ViewControl_PropertiesStream.hxx
-ViewControl_PropertyView.cxx
-ViewControl_PropertyView.hxx
-ViewControl_Table.cxx
-ViewControl_Table.hxx
-ViewControl_TableDoubleVector.cxx
-ViewControl_TableDoubleVector.hxx
-ViewControl_TableItemDelegate.cxx
-ViewControl_TableItemDelegate.hxx
-ViewControl_TableModel.cxx
-ViewControl_TableModel.hxx
-ViewControl_TableModelValues.cxx
-ViewControl_TableModelValues.hxx
-ViewControl_TableModelValuesDefault.cxx
-ViewControl_TableModelValuesDefault.hxx
ViewControl_Tools.cxx
ViewControl_Tools.hxx
-ViewControl_TreeView.hxx
+ViewControl_TreeView.hxx
\ No newline at end of file
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef VIEWCONTROL_H
-#define VIEWCONTROL_H
-
-#ifdef __ViewControl_DLL
- #ifdef _WIN32
- #define VIEWCONTROL_EXPORT __declspec(dllexport)
- #else
- #define VIEWCONTROL_EXPORT
- #endif
-#else
- #ifdef _WIN32
- #define VIEWCONTROL_EXPORT __declspec(dllimport)
- #else
- #define VIEWCONTROL_EXPORT
- #endif
-#endif
-
-#endif
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ViewControl_ColorSelector.hxx>
-#include <inspector/ViewControl_TableItemDelegate.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/TreeModel_Tools.hxx>
-
-#include <Quantity.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QDialogButtonBox>
-#include <QHeaderView>
-#include <QGridLayout>
-#include <QItemSelectionModel>
-#include <QPainter>
-#include <QTableView>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-//! Kinds of delegate cell in OCCT Color model to present a custom presentation (rect bounded by a colored frame)
-enum ViewControl_ColorDelegateKind
-{
- ViewControl_ColorDelegateKind_None, //!< usual item
- ViewControl_ColorDelegateKind_Activated, //!< active item
- ViewControl_ColorDelegateKind_Highlighted, //!< highlighted item
- ViewControl_ColorDelegateKind_Selected //!< selected item
-};
-
-//! Model for a table of parameters: Current Color, Red, Green, Blue, Alpha, OCCT color name
-class ViewControl_ParametersModel : public ViewControl_TableModelValues
-{
-public:
- ViewControl_ParametersModel (ViewControl_ColorSelector* theSelector)
- : ViewControl_TableModelValues(), mySelector (theSelector) {}
- virtual ~ViewControl_ParametersModel() {}
-
- //! Inits model by the parameter color
- //! \param theColor model active color
- void SetColor (const Quantity_ColorRGBA& theColor, ViewControl_TableModel* theModel)
- { myColor = theColor; theModel->EmitLayoutChanged(); }
-
- //! Returns current selected color
- //! \return color value
- Quantity_ColorRGBA GetColor() const { return myColor; }
-
- //! Returns item information(short) for display role.
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn,
- int theRole = Qt::DisplayRole) const Standard_OVERRIDE
- {
- if (theRole == Qt::BackgroundRole && theColumn == 1 && theRow == 0)
- return ViewControl_ColorSelector::ColorToQColor (myColor);
-
- if (theRole == Qt::ForegroundRole && theColumn == 1 && theRow >= 2 && theRow <= 5)
- return ViewControl_TableModelValues::EditCellColor();
-
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant ("Color") : QVariant ();
- case 1:
- {
- if (isFirstColumn)
- return QVariant ("Name");
- Quantity_NameOfColor aColorName;
- if (ViewControl_ColorSelector::IsExactColorName(myColor, aColorName))
- return Quantity::NameOfColorToString (aColorName);
- }
- break;
- case 2: return isFirstColumn ? QVariant ("Red") : ViewControl_Tools::ToVariant (myColor.GetRGB().Red());
- case 3: return isFirstColumn ? QVariant ("Green") : ViewControl_Tools::ToVariant (myColor.GetRGB().Green());
- case 4: return isFirstColumn ? QVariant ("Blue") : ViewControl_Tools::ToVariant (myColor.GetRGB().Blue());
- case 5: return isFirstColumn ? QVariant ("Alpha") : ViewControl_Tools::ToVariant (myColor.Alpha());
- case 6: return isFirstColumn ? QVariant ("Near Name")
- : Quantity::NameOfColorToString (myColor.GetRGB().Name());
- }
- return QVariant();
- }
-
- //! Sets content of the model index for the given role, it is applyed to internal container of values
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return true if the value is changed
- virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue, int)
- {
- if (theColumn != 1 || theRow < 2 || theRow > 5)
- return false;
-
- switch (theRow)
- {
- case 2:
- case 3:
- case 4:
- {
- myColor.ChangeRGB().SetValues (theRow == 2 ? ViewControl_Tools::ToShortRealValue (theValue) : myColor.GetRGB().Red(),
- theRow == 3 ? ViewControl_Tools::ToShortRealValue (theValue) : myColor.GetRGB().Green(),
- theRow == 4 ? ViewControl_Tools::ToShortRealValue (theValue) : myColor.GetRGB().Blue(),
- Quantity_TOC_RGB);
- }
- break;
- case 5: myColor.SetAlpha (ViewControl_Tools::ToShortRealValue (theValue)); break;
- }
- mySelector->ParameterColorChanged();
- return true;
- }
-
- //! Returns number of tree level line items = colums in table view
- virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 2; }
-
- //! Returns onlly one row in table view
- virtual int RowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 7; }
-
- //! Returns editable flag for color RGB and alpha rows
- //! \return flags
- Qt::ItemFlags Flags (const QModelIndex& theIndex) const
- {
- Qt::ItemFlags aFlags = ViewControl_TableModelValues::Flags (theIndex);
-
- if (theIndex.column() == 1 && theIndex.row() >= 2 && theIndex.row() <= 5)
- aFlags = aFlags | Qt::ItemIsEditable;
-
- return aFlags;
- }
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetEditType (const int theRow, const int theColumn) const
- {
- if (theColumn == 1 && theRow >= 2 && theRow <= 5)
- return ViewControl_EditType_Double;
-
- return ViewControl_EditType_None;
- }
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetEnumValues (const int theRow, const int theColumn) const
- {
- if (theColumn == 1 && theRow >= 2 && theRow <= 5)
- {
- QList<QVariant> aValues;
- aValues << 0 << 1 << 6;
- return aValues;
- }
- return QList<QVariant>();
- }
-
-private:
- Quantity_ColorRGBA myColor;
- ViewControl_ColorSelector* mySelector;
-};
-
-//! Table of parameters: Red, Green, Blue, Alpha, OCCT color name
-class ViewControl_OCCTColorModel : public QAbstractTableModel
-{
-public:
- ViewControl_OCCTColorModel (QObject* theParent)
- : QAbstractTableModel (theParent), myCurrentIndexKind (ViewControl_ColorDelegateKind_None) {}
- virtual ~ViewControl_OCCTColorModel() {}
-
- //! Sets current color, that should have custom presented
- //! \param theColor current color
- //! \param theKind presentation kind
- void SetColor (const Quantity_NameOfColor& theColor, const ViewControl_ColorDelegateKind theKind)
- {
- int aColorPosition = (int)theColor;
- int aRow = (int) (aColorPosition / columnCount());
- int aColumn = aColorPosition - aRow * columnCount();
- myCurrentIndex = index (aRow, aColumn);
- myCurrentIndexKind = theKind;
-
- emit layoutChanged();
- }
-
- //! Returns OCCT name of color if index position does not exceed Quantity_NameOfColor elements
- //! \param theIndex model index
- //! \param theNameOfColor [out] OCCT color name
- //! \return true if the color is found
- bool GetOCCTColor (const QModelIndex& theIndex, Quantity_NameOfColor& theNameOfColor) const
- {
- int aNameOfColorId = theIndex.row() * columnCount() + theIndex.column();
- if (aNameOfColorId > Quantity_NOC_WHITE)
- return false;
- theNameOfColor = (Quantity_NameOfColor)aNameOfColorId;
- return true;
- }
-
- //! Returns index that has custom presentation
- //! \return model index
- QModelIndex GetCurrentIndex() const { return myCurrentIndex; }
-
- //! Returns index color kind that has custom presentation
- //! \return kind
- ViewControl_ColorDelegateKind GetCurrentIndexKind() const { return myCurrentIndexKind; }
-
- //! Returns item information(short) for display role.
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
- int theRole = Qt::DisplayRole) const Standard_OVERRIDE
- {
- if (theRole != Qt::ToolTipRole) // background is processed in table item delegate
- return QVariant();
-
- Quantity_NameOfColor aNameOfColor;
- if (!GetOCCTColor (theIndex, aNameOfColor))
- return QVariant();
-
- if (theRole == Qt::ToolTipRole)
- return QString("%1 (%2)").arg(Quantity::NameOfColorToString (aNameOfColor))
- .arg (ViewControl_ColorSelector::ColorToString (Quantity_Color (aNameOfColor)));
- return QVariant();
- }
-
- //! Returns number of tree level line items = colums in table view
- virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 26; }
-
- //! Returns onlly one row in table view
- virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 20; }
-
- //! Returns color for the delegate kind
- //! \param theKind kind
- //! \return color
- static QColor GetKindColor (const ViewControl_ColorDelegateKind theKind)
- {
- switch (theKind)
- {
- case ViewControl_ColorDelegateKind_Activated:
- case ViewControl_ColorDelegateKind_Highlighted: return Qt::blue;
- case ViewControl_ColorDelegateKind_Selected: return Qt::black;
- default: break;
- }
- return QColor();
- }
-
-private:
- QModelIndex myCurrentIndex; //!< index to be presented through item delegate
- ViewControl_ColorDelegateKind myCurrentIndexKind; //!< kind of custom item
-};
-
-//! \class DFBrowser_HighlightDelegate
-//! \brief An item delegate to paint in highlight color the cell when the mouse cursor is over it
-class ViewControl_OCCTColorDelegate : public QItemDelegate
-{
-public:
-
- //! Constructor
- ViewControl_OCCTColorDelegate (QObject* theParent = 0) : QItemDelegate (theParent) {}
-
- //! Destructor
- virtual ~ViewControl_OCCTColorDelegate() Standard_OVERRIDE {}
-
- //! Redefine of the parent virtual method to color the cell rectangle in highlight style
- //! \param thePainter a painter
- //! \param theOption a paint options
- //! \param theIndex a view index
- virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
- const QModelIndex& theIndex) const Standard_OVERRIDE
- {
- QRect aBaseRect = theOption.rect;
- int aNameOfColorId = theIndex.row() * theIndex.model()->columnCount(theIndex) + theIndex.column();
- Quantity_NameOfColor aNameOfColor = Quantity_NOC_WHITE;
- if (aNameOfColorId < (int)Quantity_NOC_WHITE)
- aNameOfColor = (Quantity_NameOfColor)aNameOfColorId;
-
- Quantity_Color anOCCTColor (aNameOfColor);
- QColor aQColor = ViewControl_ColorSelector::ColorToQColor (Quantity_ColorRGBA (anOCCTColor));
- thePainter->fillRect (aBaseRect, aQColor);
-
- QColor aColor;
- // highlight cell
- if (theOption.state & QStyle::State_MouseOver)
- aColor = ViewControl_OCCTColorModel::GetKindColor (ViewControl_ColorDelegateKind_Highlighted);
- else
- {
- const ViewControl_OCCTColorModel* aTableModel = dynamic_cast<const ViewControl_OCCTColorModel*> (theIndex.model());
- QModelIndex anIndex = aTableModel->GetCurrentIndex();
- if (anIndex.isValid() && anIndex.row() == theIndex.row() && anIndex.column() == theIndex.column())
- aColor = ViewControl_OCCTColorModel::GetKindColor (aTableModel->GetCurrentIndexKind());
- }
-
- if (aColor.isValid())
- {
- int aRectSize = 2;
- thePainter->fillRect (QRect (aBaseRect.topLeft(), QPoint (aBaseRect.bottomLeft().x() + aRectSize, aBaseRect.bottomLeft().y())),
- aColor);
- thePainter->fillRect (QRect (QPoint (aBaseRect.topRight().x() - aRectSize, aBaseRect.topRight().y()), aBaseRect.bottomRight()),
- aColor);
- thePainter->fillRect (QRect (QPoint (aBaseRect.topLeft().x() + aRectSize, aBaseRect.topLeft().y()),
- QPoint (aBaseRect.topRight().x() - aRectSize, aBaseRect.topRight().y() + aRectSize)),
- aColor);
- thePainter->fillRect (QRect (QPoint (aBaseRect.bottomLeft().x() + aRectSize, aBaseRect.bottomLeft().y() - aRectSize),
- QPoint (aBaseRect.bottomRight().x() - aRectSize, aBaseRect.bottomRight().y())),
- aColor);
- }
- }
-};
-
-//! Color picker class
-class ViewControl_ColorPicker : public QWidget
-{
-public:
- ViewControl_ColorPicker (QWidget* theParent) : QWidget (theParent) {}
- virtual ~ViewControl_ColorPicker() {}
-};
-
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-
-ViewControl_ColorSelector::ViewControl_ColorSelector (QWidget* theParent)
-: QDialog (theParent)
-{
- QGridLayout* aLayout = new QGridLayout (this);
- aLayout->setContentsMargins (0, 0, 0, 0);
-
- myParameters = new QTableView (this);
- ViewControl_TableModel* aTableModel = new ViewControl_TableModel (myParameters);
- aTableModel->SetModelValues (new ViewControl_ParametersModel (this));
- myParameters->setModel(aTableModel);
-
- ViewControl_TableItemDelegate* anItemDelegate = new ViewControl_TableItemDelegate();
- anItemDelegate->SetModelValues (aTableModel->GetModelValues());
- myParameters->setItemDelegate(anItemDelegate);
-
- myParameters->verticalHeader()->setDefaultSectionSize (myParameters->verticalHeader()->minimumSectionSize());
- myParameters->verticalHeader()->setVisible (false);
- myParameters->horizontalHeader()->setVisible (false);
- myParameters->setMinimumHeight (myParameters->verticalHeader()->minimumSectionSize() * aTableModel->rowCount() +
- TreeModel_Tools::HeaderSectionMargin());
-
- QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myParameters->model());
- myParameters->setSelectionMode (QAbstractItemView::SingleSelection);
- myParameters->setSelectionModel (aSelectionModel);
- connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onParametersTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
-
- aLayout->addWidget (myParameters, 0, 0);
-
- myColorPicker = new ViewControl_ColorPicker (this);
- aLayout->addWidget (myColorPicker, 0, 1);
-
- myOCCTColors = new QTableView (this);
- myOCCTColors->setFixedSize (525, 405);
- myOCCTColors->verticalHeader()->setDefaultSectionSize (20);
- myOCCTColors->verticalHeader()->setVisible (false);
- myOCCTColors->horizontalHeader()->setDefaultSectionSize (20);
- myOCCTColors->horizontalHeader()->setVisible (false);
- myOCCTColors->setModel(new ViewControl_OCCTColorModel(myOCCTColors));
-
- myOCCTColors->viewport()->setAttribute (Qt::WA_Hover);
- myOCCTColors->setItemDelegate (new ViewControl_OCCTColorDelegate (myOCCTColors));
-
- aSelectionModel = new QItemSelectionModel (myOCCTColors->model());
- myOCCTColors->setSelectionMode (QAbstractItemView::SingleSelection);
- myOCCTColors->setSelectionModel (aSelectionModel);
- connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onOCCTColorsTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
- aLayout->addWidget (myOCCTColors, 1, 0, 1, 2);
-
- myDialogButtons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
- connect(myDialogButtons, &QDialogButtonBox::accepted, this, &QDialog::accept);
- connect(myDialogButtons, &QDialogButtonBox::rejected, this, &QDialog::reject);
-
- aLayout->addWidget(myDialogButtons, 2, 0, 1, 2);
-}
-
-// =======================================================================
-// function : SetColor
-// purpose :
-// =======================================================================
-
-void ViewControl_ColorSelector::SetColor (const QString& theColor)
-{
- Quantity_ColorRGBA aColor = StringToColorRGBA (theColor);
- // parameters model
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- ViewControl_ParametersModel* aParametersModel = dynamic_cast<ViewControl_ParametersModel*> (aTableModel->GetModelValues());
- aParametersModel->SetColor (aColor, aTableModel);
-
- // OCCT color model
- Quantity_NameOfColor aColorName;
- bool isExactColorName = ViewControl_ColorSelector::IsExactColorName(aColor, aColorName);
- ViewControl_OCCTColorModel* anOCCTColorModel = dynamic_cast<ViewControl_OCCTColorModel*>(myOCCTColors->model());
- anOCCTColorModel->SetColor (aColorName, isExactColorName ? ViewControl_ColorDelegateKind_Selected
- : ViewControl_ColorDelegateKind_Activated);
-}
-
-// =======================================================================
-// function : GetColor
-// purpose :
-// =======================================================================
-
-QString ViewControl_ColorSelector::GetColor() const
-{
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- ViewControl_ParametersModel* aParametersModel = dynamic_cast<ViewControl_ParametersModel*> (aTableModel->GetModelValues());
-
- return ColorToString (aParametersModel->GetColor());
-}
-
-// =======================================================================
-// function : ParameterColorChanged
-// purpose :
-// =======================================================================
-
-void ViewControl_ColorSelector::ParameterColorChanged()
-{
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- ViewControl_ParametersModel* aParametersModel = dynamic_cast<ViewControl_ParametersModel*> (aTableModel->GetModelValues());
- Quantity_ColorRGBA aColor = aParametersModel->GetColor();
-
- // OCCT color model
- Quantity_NameOfColor aColorName;
- bool isExactColorName = ViewControl_ColorSelector::IsExactColorName(aColor, aColorName);
- ViewControl_OCCTColorModel* anOCCTColorModel = dynamic_cast<ViewControl_OCCTColorModel*>(myOCCTColors->model());
- anOCCTColorModel->SetColor (aColorName, isExactColorName ? ViewControl_ColorDelegateKind_Selected
- : ViewControl_ColorDelegateKind_Activated);
-}
-
-// =======================================================================
-// function : ColorToString
-// purpose :
-// =======================================================================
-
-QString ViewControl_ColorSelector::ColorToString (const Quantity_Color& theColor)
-{
- Standard_Real aRed, aGreen, aBlue;
- theColor.Values (aRed, aGreen, aBlue, Quantity_TOC_RGB);
- return QString::number (aRed) + ViewControl_ColorSelector::ColorSeparator() +
- QString::number (aGreen) + ViewControl_ColorSelector::ColorSeparator() +
- QString::number (aBlue);
-}
-
-// =======================================================================
-// function : ColorToString
-// purpose :
-// =======================================================================
-
-QString ViewControl_ColorSelector::ColorToString (const Quantity_ColorRGBA& theColor)
-{
- const Quantity_Color& aRGBColor = theColor.GetRGB();
- Standard_ShortReal anAlpha = theColor.Alpha();
-
- return ColorToString (aRGBColor) + ViewControl_ColorSelector::ColorSeparator() + QString::number (anAlpha);
-}
-
-// =======================================================================
-// function : ColorToQColor
-// purpose :
-// =======================================================================
-
-QColor ViewControl_ColorSelector::ColorToQColor (const Quantity_Color& theColor)
-{
- int aDelta = 255;
-
- Standard_Real aRed, aGreen, aBlue;
- theColor.Values (aRed, aGreen, aBlue, Quantity_TOC_RGB);
-
- return QColor((int)(aRed * aDelta), (int)(aGreen * aDelta), (int)(aBlue * aDelta));
-}
-
-// =======================================================================
-// function : ColorToQColor
-// purpose :
-// =======================================================================
-
-QColor ViewControl_ColorSelector::ColorToQColor (const Quantity_ColorRGBA& theColor)
-{
- int aDelta = 255;
-
- Standard_Real aRed, aGreen, aBlue;
- theColor.GetRGB().Values (aRed, aGreen, aBlue, Quantity_TOC_RGB);
-
- return QColor((int)(aRed * aDelta), (int)(aGreen * aDelta), (int)(aBlue * aDelta));
-}
-
-// =======================================================================
-// function : StringToColor
-// purpose :
-// =======================================================================
-
-Quantity_Color ViewControl_ColorSelector::StringToColor (const QString& theColor, Standard_ShortReal& theAlpha)
-{
- Quantity_ColorRGBA aColorGRBA = StringToColorRGBA (theColor);
- theAlpha = aColorGRBA.Alpha();
- return aColorGRBA.GetRGB();
-}
-
-// =======================================================================
-// function : StringToColor
-// purpose :
-// =======================================================================
-
-Quantity_Color ViewControl_ColorSelector::StringToColor (const QString& theColor)
-{
- return StringToColorRGBA (theColor).GetRGB();
-}
-
-// =======================================================================
-// function : StringToColorRGBA
-// purpose :
-// =======================================================================
-
-Quantity_ColorRGBA ViewControl_ColorSelector::StringToColorRGBA (const QString& theColor)
-{
- float anAlpha = 1.0f;
-
- QStringList aList = theColor.split (ViewControl_ColorSelector::ColorSeparator(), QString::SkipEmptyParts);
- if (aList.size() < 3)
- return Quantity_ColorRGBA();
-
- if (aList.size() == 4)
- anAlpha = aList[3].toFloat();
-
- return Quantity_ColorRGBA (aList[0].toFloat(), aList[1].toFloat(), aList[2].toFloat(), anAlpha);
-}
-
-// =======================================================================
-// function : onParametersTableSelectionChanged
-// purpose :
-// =======================================================================
-
-Standard_Boolean ViewControl_ColorSelector::IsExactColorName (const Quantity_ColorRGBA& theColor,
- Quantity_NameOfColor& theColorName)
-{
- theColorName = theColor.GetRGB().Name();
- return Quantity_Color (theColorName).IsEqual (theColor.GetRGB());
-}
-
-// =======================================================================
-// function : onParametersTableSelectionChanged
-// purpose :
-// =======================================================================
-
-void ViewControl_ColorSelector::onParametersTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection&)
-{
- //Quantity_ColorRGBA aColor = StringToColorRGBA (theColor);
- //// parameters model
- //ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- //ViewControl_ParametersModel* aParametersModel = dynamic_cast<ViewControl_ParametersModel*> (aTableModel->GetModelValues());
- //aParametersModel->SetColor (aColor);
-
- //// OCCT color model
- //Quantity_NameOfColor aColorName;
- //bool isExactColorName = ViewControl_ColorSelector::IsExactColorName(aColor, aColorName);
- //ViewControl_OCCTColorModel* anOCCTColorModel = dynamic_cast<ViewControl_OCCTColorModel*>(myOCCTColors->model());
- //anOCCTColorModel->SetColor (aColorName, isExactColorName ? ViewControl_ColorDelegateKind_Selected
- // : ViewControl_ColorDelegateKind_Activated);
-}
-
-// =======================================================================
-// function : onOCCTColorsTableSelectionChanged
-// purpose :
-// =======================================================================
-
-void ViewControl_ColorSelector::onOCCTColorsTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection&)
-{
- QModelIndexList aSelectedIndices = theSelected.indexes();
- if (aSelectedIndices.size() != 1)
- return;
-
- ViewControl_OCCTColorModel* anOCCTColorModel = dynamic_cast<ViewControl_OCCTColorModel*>(myOCCTColors->model());
- Quantity_NameOfColor aNameOfColor;
- if (!anOCCTColorModel->GetOCCTColor (aSelectedIndices.first(), aNameOfColor))
- return;
-
- anOCCTColorModel->SetColor (aNameOfColor, ViewControl_ColorDelegateKind_Selected);
-
- // parameters model
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- ViewControl_ParametersModel* aParametersModel = dynamic_cast<ViewControl_ParametersModel*> (aTableModel->GetModelValues());
- Quantity_Color anOCCTColor (aNameOfColor);
- aParametersModel->SetColor (Quantity_ColorRGBA (anOCCTColor), aTableModel);
-}
+++ /dev/null
-// Created on: 2018-08-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2018 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_ColorSelector_H
-#define ViewControl_ColorSelector_H
-
-#include <inspector/ViewControl.hxx>
-
-#include <Quantity_ColorRGBA.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QColor>
-#include <QDialog>
-//#include <QPushButton>
-#include <QItemSelection>
-#include <QString>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-class ViewControl_ColorPicker;
-class QDialogButtonBox;
-class QTableView;
-
-//! \class ViewControl_ColorSelector
-//! \brief Selector of OCCT color
-class VIEWCONTROL_EXPORT ViewControl_ColorSelector : public QDialog
-{
- Q_OBJECT
-public:
-
- //! Constructor
- ViewControl_ColorSelector (QWidget* theParent);
-
- //! Destructor
- virtual ~ViewControl_ColorSelector() Standard_OVERRIDE {}
-
- //! Inits control by the color value
- //! \param theColor text color value
- void SetColor (const QString& theColor);
-
- //! Returns current selected color value
- //! \return text color value
- QString GetColor() const;
-
- //! Updates OCCT color model by changing color in parameter model
- void ParameterColorChanged();
-
- //! Converts color to string value in form: r;g;b
- //! \param theColor color value
- //! \return text value
- static QString ColorToString (const Quantity_Color& theColor);
-
- //! Converts color to string value in form: r;g;b;alpha
- //! \param theColor color value
- //! \return text value
- static QString ColorToString (const Quantity_ColorRGBA& theColor);
-
- //! Converts color to QColor value in form: r;g;b
- //! \param theColor color value
- //! \return qt color value
- static QColor ColorToQColor (const Quantity_Color& theColor);
-
- //! Converts color to QColor value in form: r;g;b;a
- //! \param theColor color value
- //! \return qt color value
- static QColor ColorToQColor (const Quantity_ColorRGBA& theColor);
-
- //! Converts string to color value from a form: r;g;b;a
- //! \param theColor text color value
- //! \return color value
- static Quantity_Color StringToColor (const QString& theColor, Standard_ShortReal& theAlpha);
-
- //! Converts string to color value from a form: r;g;b
- //! \param theColor text color value
- //! \return color value
- static Quantity_Color StringToColor (const QString& theColor);
-
- //! Converts string to color value from a form: r;g;b;a
- //! \param theColor text color value
- //! \return color value
- static Quantity_ColorRGBA StringToColorRGBA (const QString& theColor);
-
- static Standard_Boolean IsExactColorName (const Quantity_ColorRGBA& theColor,
- Quantity_NameOfColor& theColorName);
-
-private:
- //! Returns symbol used as a separtor of color components in string conversion
- //! \return symbol value
- static QString ColorSeparator() { return ";"; }
-
-private slots:
- //! Slots listen selection change and update the current control content by selection
- //! \param theSelected container of selected items
- //! \param theDeselected container of items that become deselected
- void onParametersTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
- //! Slots listen selection change and update the current control content by selection
- //! \param theSelected container of selected items
- //! \param theDeselected container of items that become deselected
- void onOCCTColorsTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
-private:
- QTableView* myParameters; //! current color parameters (RGB, alpha, color name)
- ViewControl_ColorPicker* myColorPicker; //! color picker
- QTableView* myOCCTColors; //! OCCT color values
- QDialogButtonBox* myDialogButtons; //! OK/Cancel buttons
-};
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_EditType_H
-#define ViewControl_EditType_H
-
-//! Type of context used in a tool library
-enum ViewControl_EditType
-{
- ViewControl_EditType_None, //!< View widget is null
- ViewControl_EditType_Bool, //!< check box widget
- ViewControl_EditType_Color, //!< color selector widget
- ViewControl_EditType_Combo, //!< combo box widget
- ViewControl_EditType_Double, //!< line edit widget used double validator
- ViewControl_EditType_Line, //!< line edit widget
- ViewControl_EditType_Spin, //!< spin box widget
- ViewControl_EditType_DoubleVector, //!< control to enter three double values
- ViewControl_EditType_DoAction //!< control to perform the row action
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-12-08
-// 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 ViewControl_Pane_H
-#define ViewControl_Pane_H
-
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Transient.hxx>
-
-#include <inspector/ViewControl_EditType.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class ViewControl_PaneItem;
-
-//! \class ViewControl_PaneItem
-//! Pane for getting/setting pane table values
-//!
-class ViewControl_Pane
-{
-public:
-
- //! Returns number of table rows
- //! \param theObject current pane object
- //! \return an integer value
- virtual int GetTableRowCount (const Handle(Standard_Transient)& theObject) const = 0;
-
- //! Returns table value for the row in form: <function name> <function value>
- //! \param theObject current pane object
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual QVariant GetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn, const int theRole) const = 0;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theObject current pane object
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetTableEditType (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn) const
- { (void)theObject; (void)theRow; (void)theColumn; return ViewControl_EditType_None; }
-
- //! Returns container of string values for enumeration in the model row
- //! \param theObject current pane object
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- virtual QList<QVariant> GetTableEnumValues (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn) const
- { (void)theObject; (void)theRow; (void)theColumn; return QList<QVariant>(); }
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theObject current pane object
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- virtual bool SetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn, const QVariant& theValue)
- { (void)theObject; (void)theRow; (void)theColumn; (void)theValue; return false; }
-
- //! Return selected element in the pane cell
- //! \param theObject current pane object
- //! \param theRow a model index row
- //! \param theColumn a model index column
- virtual ViewControl_PaneItem* GetSelected (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn)
- { (void)theObject; (void)theRow; (void)theColumn; return 0; }
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-// Created on: 2018-12-08
-// 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/ViewControl_PaneCreator.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(ViewControl_PaneCreator, Standard_Transient)
+++ /dev/null
-// Created on: 2018-12-08
-// 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 ViewControl_PaneCreator_H
-#define ViewControl_PaneCreator_H
-
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-
-class ViewControl_Pane;
-
-DEFINE_STANDARD_HANDLE (ViewControl_PaneCreator, Standard_Transient)
-
-//! \class ViewControl_PaneCreator
-//! \brief An interface to create custom panes by transient object name.
-class ViewControl_PaneCreator : public Standard_Transient
-{
-public:
-
- //! Constructor
- ViewControl_PaneCreator() {}
-
- //! Destructor
- virtual ~ViewControl_PaneCreator() {}
-
- //! Creates pane for type
- //! \param theName a type name
- //! \return a pane if it can be created for this type or NULL
- virtual ViewControl_Pane* GetPane (const Standard_CString& theName) = 0;
-
- DEFINE_STANDARD_RTTIEXT (ViewControl_PaneCreator, Standard_Transient)
-};
-
-#endif
+++ /dev/null
-// Created on: 2018-12-08
-// 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 ViewControl_PaneItem_H
-#define ViewControl_PaneItem_H
-
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Transient.hxx>
-
-#include <TopoDS_Shape.hxx>
-
-//! \class ViewControl_PaneItem
-//! Container of pane item information
-
-class ViewControl_PaneItem
-{
-public:
-
- //! Returns shape of the item or NULL
- //! \return shape instance
- virtual TopoDS_Shape GetShape() { return myShape; }
-
- //! Sets shape
- //! \param theShape shape instance
- void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; }
-
- //! Returns object or NULL
- //! \return current object
- virtual Handle(Standard_Transient) GetObject() { return myObject; }
-
- //! Sets object
- //! \param theObject an object
- virtual void SetObject (Handle(Standard_Transient)& theObject) { myObject = theObject; }
-
-protected:
- TopoDS_Shape myShape; //!< current shape
- Handle(Standard_Transient) myObject; //!< current object
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-// Created on: 2019-04-28
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ViewControl_PropertiesStream.hxx>
-
-#include <BRepBuilderAPI_MakeVertex.hxx>
-
-#include <Message.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(ViewControl_PropertiesStream, TreeModel_ItemProperties)
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void ViewControl_PropertiesStream::Init()
-{
- if (!getItem() || !myValues.IsEmpty())
- return;
-
- Standard_SStream aSStream;
- getItem()->Dump (aSStream);
-
- Message::ConvertStream (aSStream, myColumnCount, myValues);
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-
-void ViewControl_PropertiesStream::Reset()
-{
- if (!getItem())
- return;
- myValues.Clear();
- myColumnCount = 0;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-
-void ViewControl_PropertiesStream::initItem() const
-{
- const_cast<ViewControl_PropertiesStream*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-
-int ViewControl_PropertiesStream::GetTableRowCount() const
-{
- initItem();
-
- return getValues().Length() / myColumnCount;
-}
-
-// =======================================================================
-// function : GetTableData
-// purpose :
-// =======================================================================
-
-QVariant ViewControl_PropertiesStream::GetTableData (const int theRow, const int theColumn, int theRole) const
-{
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- initItem();
-
- int anIndex = theRow * myColumnCount + theColumn;
- if (theRole == Qt::DisplayRole && anIndex < getValues().Length())
- return getValues().Value(anIndex).ToCString();
-
- return QVariant();
-}
-
-// =======================================================================
-// function : GetPresentations
-// purpose :
-// =======================================================================
-
-void ViewControl_PropertiesStream::GetPresentations (const int theRow,
- const int theColumn,
- NCollection_List<Handle(Standard_Transient)>& thePresentations)
-{
- if (theColumn == 0)
- return;
-
- QVariant aValue = GetTableData (theRow, theColumn, Qt::DisplayRole);
- TCollection_AsciiString aStrValue = aValue.toString().toStdString().c_str();
-
- gp_XYZ aPoint;
- if (!aPoint.Init (Standard_SStream (aStrValue.ToCString())))
- return;
-
- //thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint)));
-}
+++ /dev/null
-// Created on: 2019-04-28
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_PropertiesStream_H
-#define ViewControl_PropertiesStream_H
-
-#include <Standard.hxx>
-#include <Standard_SStream.hxx>
-#include <NCollection_Vector.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-DEFINE_STANDARD_HANDLE (ViewControl_PropertiesStream, TreeModel_ItemProperties)
-
-//! \class ViewControl_PropertiesStream
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class ViewControl_PropertiesStream : public TreeModel_ItemProperties
-{
-public:
-
- //! Constructor
- Standard_EXPORT ViewControl_PropertiesStream (const TreeModel_ItemBasePtr& theItem)
- : TreeModel_ItemProperties (theItem) {}
-
- //! Destructor
- virtual ~ViewControl_PropertiesStream() {}
-
- //! If me has internal values, it should be initialized here.
- Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
- //! If the item has internal values, there should be reseted here.
- Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
- //! Returns number of table columns
- //! \return an integer value
- virtual int GetTableColumnCount() const { initItem(); return myColumnCount; }
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Returns presentation of the attribute to be visualized in the view
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \thePresentations [out] container of presentation handles to be visualized
- Standard_EXPORT virtual void GetPresentations (const int theRow, const int theColumn,
- NCollection_List<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE;
-
-protected:
- //! Returns values
- //! @return values
- const NCollection_Vector<TCollection_AsciiString>& getValues() const { return myValues; }
-
-protected:
-
- //! Initialize me.
- Standard_EXPORT void initItem() const;
-
-public:
- DEFINE_STANDARD_RTTIEXT (ViewControl_PropertiesStream, TreeModel_ItemProperties)
-
-protected:
- NCollection_Vector<TCollection_AsciiString> myValues; //!< container of values
- Standard_Integer myColumnCount; //!< value to present container of values into table
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ViewControl_PropertyView.hxx>
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QStackedWidget>
-#include <QScrollArea>
-#include <QTableView>
-#include <QVBoxLayout>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-class ViewControl_Widget : public QWidget
-{
-public:
- //! Constructor
- ViewControl_Widget (QWidget* theParent, const QSize& theSize) : QWidget (theParent) { SetPredefinedSize (theSize); }
-
- //! Destructor
- virtual ~ViewControl_Widget() {}
-
- //! Sets default size of control, that is used by the first control show
- //! \param theDefaultWidth the width value
- //! \param theDefaultHeight the height value
- void SetPredefinedSize (const QSize& theSize) { myDefaultSize = theSize;}
-
- //! Returns predefined size if both values are positive, otherwise parent size hint
- virtual QSize sizeHint() const Standard_OVERRIDE { return myDefaultSize.isValid() ? myDefaultSize : QWidget::sizeHint(); }
-
-private:
- QSize myDefaultSize; //! default size, empty isze if it should not be used
-};
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-ViewControl_PropertyView::ViewControl_PropertyView (QWidget* theParent, const QSize& thePredefinedSize)
-: QObject (theParent), myOwnSelectionChangeBlocked (false)
-{
- myMainWidget = new ViewControl_Widget (theParent, QSize (1, 100));
- if (!thePredefinedSize.isEmpty())
- ((ViewControl_Widget*)myMainWidget)->SetPredefinedSize (thePredefinedSize);
-
- QVBoxLayout* aLayout = new QVBoxLayout (myMainWidget);
- aLayout->setContentsMargins (0, 0, 0, 0);
-
- QScrollArea* anArea = new QScrollArea (myMainWidget);
-
- myAttributesStack = new QStackedWidget (myMainWidget);
- anArea->setWidget (myAttributesStack);
- anArea->setWidgetResizable( true );
- aLayout->addWidget (anArea);
-
- myEmptyWidget = new QWidget (myAttributesStack);
- myAttributesStack->addWidget (myEmptyWidget);
-
- myTableWidget = new QWidget (myAttributesStack);
- myTableWidgetLayout = new QVBoxLayout (myTableWidget);
- myTableWidgetLayout->setContentsMargins (0, 0, 0, 0);
- myAttributesStack->addWidget (myTableWidget);
-
- myAttributesStack->setCurrentWidget (myEmptyWidget);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void ViewControl_PropertyView::Init (const QList<ViewControl_TableModelValues*>& theTableValues)
-{
- for (int aTableId = 0; aTableId < theTableValues.size(); aTableId++)
- {
- ViewControl_TableModelValues* aValues = theTableValues[aTableId];
-
- ViewControl_Table* aTable = findTable (aTableId);
-
- aTable->Init (aValues);
- ViewControl_Tools::SetDefaultHeaderSections (aTable->GetTableView(), Qt::Horizontal);
-
- aTable->SetActive (true);
- }
- // hide not used tables
- for (int aTableId = theTableValues.size(); aTableId < myTables.size(); aTableId++)
- {
- ViewControl_Table* aTable = findTable (aTableId, false);
- if (!aTable)
- continue;
-
- ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (aTable->GetTableView()->model());
- aModel->SetModelValues (0);
-
- aTable->SetActive (false);
- }
-
- if (theTableValues.size() > 0)
- myAttributesStack->setCurrentWidget (myTableWidget);
- else
- myAttributesStack->setCurrentWidget (myEmptyWidget);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void ViewControl_PropertyView::Init (QWidget*)
-{
-}
-
-// =======================================================================
-// function : GetActiveTables
-// purpose :
-// =======================================================================
-void ViewControl_PropertyView::GetActiveTables (QList<ViewControl_Table*>& theTables)
-{
- for (int aTableId = 0; aTableId < myTables.size(); aTableId++)
- {
- ViewControl_Table* aTable = findTable (aTableId, false);
- if (aTable && aTable->IsActive())
- theTables.append (aTable);
- }
-}
-
-// =======================================================================
-// function : ClearActiveTablesSelection
-// purpose :
-// =======================================================================
-void ViewControl_PropertyView::ClearActiveTablesSelection()
-{
- bool aWasBlocked = myOwnSelectionChangeBlocked;
- myOwnSelectionChangeBlocked = true;
-
- QList<ViewControl_Table*> aTables;
- for (int aTableId = 0; aTableId < myTables.size(); aTableId++)
- {
- ViewControl_Table* aTable = findTable (aTableId, false);
- if (aTable && aTable->IsActive())
- aTable->GetTableView()->selectionModel()->clearSelection();
- }
- myOwnSelectionChangeBlocked = aWasBlocked;
-}
-
-// =======================================================================
-// function : Clear
-// purpose :
-// =======================================================================
-void ViewControl_PropertyView::Clear()
-{
- for (int aTableId = 0; aTableId < myTables.size(); aTableId++)
- {
- ViewControl_Table* aTable = findTable (aTableId, false);
- if (!aTable)
- continue;
-
- ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (aTable->GetTableView()->model());
- aModel->SetModelValues (0);
-
- aTable->SetActive (true);
- }
- myAttributesStack->setCurrentWidget (myEmptyWidget);
-}
-
-// =======================================================================
-// function : findTable
-// purpose :
-// =======================================================================
-ViewControl_Table* ViewControl_PropertyView::findTable (const int theTableId, const bool isToCreate)
-{
- if (!isToCreate && theTableId >= myTables.size())
- return 0;
-
- if (theTableId < myTables.size())
- return myTables[theTableId];
-
- ViewControl_Table* aTable = new ViewControl_Table (myMainWidget);
- ViewControl_TableModel* aModel = new ViewControl_TableModel(aTable->GetTableView());
- aTable->SetModel (aModel);
-
-
- connect (aTable->GetTableView()->selectionModel(),
- SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT(onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
-
- myTableWidgetLayout->addWidget (aTable->GetControl());
-
- myTables.insert (theTableId, aTable);
-
- return myTables[theTableId];
-}
-
-// =======================================================================
-// function : onTableSelectionChanged
-// purpose :
-// =======================================================================
-void ViewControl_PropertyView::onTableSelectionChanged (const QItemSelection&, const QItemSelection&)
-{
- if (myOwnSelectionChangeBlocked)
- return;
-
- emit propertyViewSelectionChanged();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TreeModel_PropertyView_H
-#define TreeModel_PropertyView_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <inspector/ViewControl_Table.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QObject>
-#include <QList>
-#include <Standard_WarningsRestore.hxx>
-
-class QAbstractTableModel;
-class QStackedWidget;
-class QWidget;
-class QVBoxLayout;
-
-class ViewControl_TableModelValues;
-
-//! \class ViewControl_PropertyView
-//! \brief View widget where several tables are visualized in vertical layout.
-class ViewControl_PropertyView : public QObject
-{
- Q_OBJECT
-public:
-
- //! Constructor
- Standard_EXPORT ViewControl_PropertyView (QWidget* theParent, const QSize& thePredefinedSize = QSize());
-
- //! Destructor
- virtual ~ViewControl_PropertyView() Standard_OVERRIDE {}
-
- //! Fills the view content with values. Number of visible tables is size of container,
- //! Each element of container is values of the corresponded table
- //! \param theTableValues values
- Standard_EXPORT void Init (const QList<ViewControl_TableModelValues*>& theTableValues);
-
- //! Fills the view content with the parameter custom widget.
- //! \param theWidget control
- Standard_EXPORT void Init (QWidget* theWidget);
-
- //! Clears layout of the view and tables models.
- Standard_EXPORT void Clear();
-
- //! \return the text edit control
- QWidget* GetControl() const { return myMainWidget; }
-
- //! Returns container of active tables
- //! \param theTables [out] modified container
- Standard_EXPORT void GetActiveTables (QList<ViewControl_Table*>& theTables);
-
- //! Clears selection in active tables
- Standard_EXPORT void ClearActiveTablesSelection();
-
-signals:
- void propertyViewSelectionChanged();
-
-protected slots:
- //! Emits signal about selection is changed
- //! \param theSelected container of selected table cells
- //! \param theDeselected container of selected table cells
- void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
-protected:
- //! Returns table instance or create if it was not created ealier
- //! \param theTableId an index in internal container of tables
- //! \param isToCreate if true, the table is created if not exists
- ViewControl_Table* findTable (const int theTableId, const bool isToCreate = true);
-
-private:
- bool myOwnSelectionChangeBlocked; //! blocking emit of selection changed signal
-
- QWidget* myMainWidget; //! parent of all controls
-
- QStackedWidget* myAttributesStack; //!< container of already created panes
- QWidget* myEmptyWidget; //!< an empty widget when nothing is selected in tree view
-
- QWidget* myTableWidget; //!< widget of tables in vertical layout
- QVBoxLayout* myTableWidgetLayout; //! main view layout where tables or custom widgets are presented
- QList<ViewControl_Table*> myTables; //!< table view, shown only first tables filled in Init method
- QWidget* myCustomWidget; //!< custom view widget
-};
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ViewControl_Table.hxx>
-#include <inspector/ViewControl_TableItemDelegate.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAction>
-#include <QGridLayout>
-#include <QHeaderView>
-#include <QItemDelegate>
-#include <QLabel>
-#include <QTableView>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-#include <limits>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-
-ViewControl_Table::ViewControl_Table (QWidget* theParent)
-: QObject (theParent), myIsUseProperty (false)
-{
- myMainWidget = new QWidget (theParent);
- QGridLayout* aLayout = new QGridLayout (myMainWidget);
- aLayout->setContentsMargins (0, 0, 0, 0);
-
- myTableView = new QTableView (myMainWidget);
- myTableView->setVerticalScrollMode (QAbstractItemView::ScrollPerPixel);
-
- myTableView->setItemDelegate (new ViewControl_TableItemDelegate (theParent));
-
- QHeaderView* aVHeader = myTableView->verticalHeader();
- int aDefCellSize = aVHeader->minimumSectionSize();
- aVHeader->setDefaultSectionSize (aDefCellSize);
-
- aLayout->addWidget (myTableView);
-}
-
-// =======================================================================
-// function : SetModel
-// purpose :
-// =======================================================================
-
-void ViewControl_Table::SetModel (QAbstractTableModel* theModel)
-{
- myTableView->setModel (theModel);
-
- myTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
- QItemSelectionModel* aSelectionModel = new QItemSelectionModel(theModel);
- myTableView->setSelectionModel (aSelectionModel);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-
-void ViewControl_Table::Init (ViewControl_TableModelValues* theModelValues)
-{
- myTableView->selectionModel()->clearSelection();
-
- ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (myTableView->model());
- aModel->SetModelValues (theModelValues);
-
- ViewControl_TableItemDelegate* aDelegate = dynamic_cast<ViewControl_TableItemDelegate*>(myTableView->itemDelegate());
- aDelegate->SetModelValues (theModelValues);
-
- int aSectionSize;
- myTableView->horizontalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Horizontal));
- if (theModelValues->GetDefaultSectionSize (Qt::Horizontal, aSectionSize) )
- myTableView->horizontalHeader()->setDefaultSectionSize (aSectionSize);
-
- myTableView->verticalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Vertical));
- if (theModelValues->GetDefaultSectionSize (Qt::Vertical, aSectionSize) )
- {
- myTableView->verticalHeader()->setDefaultSectionSize (aSectionSize);
- }
- else
- myTableView->verticalHeader()->setDefaultSectionSize (myTableView->verticalHeader()->minimumSectionSize());
-
- aModel->EmitLayoutChanged();
-}
-
-// =======================================================================
-// function : GetSelectedIndices
-// purpose :
-// =======================================================================
-
-void ViewControl_Table::GetSelectedIndices (QMap<int, QList<int>>& theSelectedIndices) const
-{
- QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes();
-
- int aRow, aColumn;
- for (QModelIndexList::const_iterator anIt = aSelected.begin(); anIt != aSelected.end(); anIt++)
- {
- QModelIndex anIndex = *anIt;
- aRow = anIndex.row();
- aColumn = anIndex.column();
- if (!theSelectedIndices.contains (aRow))
- theSelectedIndices.insert (aRow, QList<int>());
- theSelectedIndices[aRow].append (aColumn);
- }
-}
-
-// =======================================================================
-// function : SeparatorData
-// purpose :
-// =======================================================================
-
-QString ViewControl_Table::SeparatorData()
-{
- return ViewControl_Tools::TableSeparator();
-}
-
-// =======================================================================
-// function : GetSelectedPresentations
-// purpose :
-// =======================================================================
-
-void ViewControl_Table::GetSelectedPresentations (const TreeModel_ItemBasePtr& theTreeItem,
- NCollection_List<Handle(Standard_Transient)>& theSelPresentations) const
-{
- Handle(TreeModel_ItemProperties) anItemProperties = theTreeItem->GetProperties();
- if (anItemProperties.IsNull())
- return;
-
- QMap<int, QList<int>> aSelectedIndices;
- GetSelectedIndices (aSelectedIndices);
-
- for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- int aRowId = aSelIt.key();
- QList<int> aColIds = aSelIt.value();
- for (int aColId = 0; aColId < aColIds.size(); aColId++)
- {
- int aSelectedColId = aColIds[aColId];
- if (aSelectedColId != 1)
- continue;
-
- if (anItemProperties)
- anItemProperties->GetPresentations (aRowId, aSelectedColId, theSelPresentations);
- }
- }
-}
-
-// =======================================================================
-// function : GetSelectedPointers
-// purpose :
-// =======================================================================
-
-void ViewControl_Table::GetSelectedPointers (QStringList& thePointers) const
-{
- QMap<int, QList<int>> aSelectedIndices;
- GetSelectedIndices (aSelectedIndices);
-
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(GetTableView()->model());
- ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues();
-
- for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
- {
- int aRowId = aSelIt.key();
- QList<int> aColIds = aSelIt.value();
- for (int aColId = 0; aColId < aColIds.size(); aColId++)
- {
- int aSelectedColId = aColIds[aColId];
- if (aSelectedColId != 1)
- continue;
-
- QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString();
- if (aData.contains (ViewControl_Tools::GetPointerPrefix().ToCString()))
- thePointers.append (aData);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_Table_H
-#define ViewControl_Table_H
-
-#include <NCollection_List.hxx>
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_Transient.hxx>
-
-#include <inspector/TreeModel_ItemBase.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QItemSelection>
-#include <QObject>
-#include <QTableView>
-#include <Standard_WarningsRestore.hxx>
-
-class ViewControl_TableModelValues;
-
-class QAbstractTableModel;
-class QContextMenuEvent;
-class QWidget;
-
-//! \class ViewControl_Table
-//! \brief View to display table values with possibility to change table columns
-//! if the table has 1D dimension and Horizontal orientation
-class ViewControl_Table : public QObject
-{
- Q_OBJECT
-public:
-
- //! Constructor
- Standard_EXPORT ViewControl_Table (QWidget* theParent);
-
- //! Destructor
- virtual ~ViewControl_Table() Standard_OVERRIDE {}
-
- //! Set model into table view, init selection model by the given model, connect to selection change
- //! \param theModel table values model
- void SetModel (QAbstractTableModel* theModel);
-
- //! Fills table view and table size control by the model
- //! \param theModel values model
- Standard_EXPORT void Init (ViewControl_TableModelValues* theModelValues);
-
- //! Sets the table active and show the table
- //! \param theState boolean value
- void SetActive (const bool theState) { myIsActive = theState; GetTableView()->setVisible (theState); }
-
- //!< true if the table is used in property view and visible
- bool IsActive() const { return myIsActive; }
-
- //! \return the text edit control
- QWidget* GetControl() const { return myMainWidget; }
-
- //! \return the table view
- QTableView* GetTableView() const { return myTableView; }
-
- //! Retuns model indices of the selected cells in table view
- //! \param theSelectedIndices [out] a container of indices: row to list of columns
- Standard_EXPORT void GetSelectedIndices (QMap<int, QList<int>>& aSelectedIndices) const;
-
- //! Returns presentations by the property item of tree item for the selected cells
- Standard_EXPORT void GetSelectedPresentations (const TreeModel_ItemBasePtr& theTreeItem,
- NCollection_List<Handle(Standard_Transient)>& theSelPresentations) const;
-
- //! Returns pointers from selected cells
- Standard_EXPORT void GetSelectedPointers (QStringList& thePointers) const;
-
- //! Returns text of separation row in table
- //! \return string value
- Standard_EXPORT static QString SeparatorData();
-
-private:
- bool myIsActive; //!< true if the table is used in property view and visible
-
- QWidget* myMainWidget; //!< parent of all controls
- bool myIsUseProperty; //!< boolean value whether the property control should be shown/hidden
- QTableView* myTableView; //!< table view
-};
-#endif
+++ /dev/null
-//-----------------------------------------------------------------------------
-// Created on: 2019-03-28
-// Created by: Vadim LEONTIEV
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of commercial software by OPEN CASCADE SAS.
-//
-// This software is furnished in accordance with the terms and conditions
-// of the contract and with the inclusion of this copyright notice.
-// This software or any other copy thereof may not be provided or otherwise
-// be made available to any third party.
-// No ownership title to the software is transferred hereby.
-//
-// OPEN CASCADE SAS makes no representation or warranties with respect to the
-// performance of this software, and specifically disclaims any responsibility
-// for any damages, special or consequential, connected with its use.
-//-----------------------------------------------------------------------------
-
-#include <inspector/ViewControl_TableDoubleVector.hxx>
-#include <inspector/ViewControl_TableItemDelegate.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/TreeModel_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QDialogButtonBox>
-#include <QHeaderView>
-#include <QGridLayout>
-#include <QItemSelectionModel>
-#include <QTableView>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-//! Model for a table of parameters: Values: X, Y, Z
-class ViewControl_ParametersModelVector : public ViewControl_TableModelValues
-{
-public:
- ViewControl_ParametersModelVector(ViewControl_TableDoubleVector* theDoubleVector)
- : ViewControl_TableModelValues(), myDoubleVector(theDoubleVector) {}
-
- virtual ~ViewControl_ParametersModelVector() {}
-
- //! Inits model by the parameters vector
- //! \param theVector model the vector
- void SetVector(const QList<QVariant>& theVector)
- {
- if (myVector.isEmpty())
- { myVector.clear(); }
-
- for (int aNumberVector = 0; aNumberVector < theVector.size(); ++aNumberVector)
- {
- myVector.append(theVector[aNumberVector]);
- }
- }
-
- //! Returns current vector
- //! \return vector value to string
- QList<QVariant> GetVector() const { return myVector; }
-
- //! Returns current vector
- //! \return vector value to QList
- QList<QVariant> GetListFromString(const QString& theVector) const
- {
- QList<QVariant> aDoubleList;
-
- QStringList aList = theVector.split(QString(","), QString::SkipEmptyParts);
- if (aList.isEmpty())
- return aDoubleList;
-
- for (int aNumberValue = 0; aNumberValue < aList.size(); ++aNumberValue)
- {
- aDoubleList.append(QVariant(aList[aNumberValue]));
- }
-
- return aDoubleList;
- }
-
- //! Returns item information(short) for display role.
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant Data(const int theRow, const int theColumn,
- int theRole = Qt::DisplayRole) const Standard_OVERRIDE
- {
- if (theRole != Qt::DisplayRole)
- return QVariant();
-
- bool isFirstColumn = theColumn == 0;
- switch (theRow)
- {
- case 0: return isFirstColumn ? QVariant("X") : myVector[theRow];
- case 1: return isFirstColumn ? QVariant("Y") : myVector[theRow];
- case 2: return isFirstColumn ? QVariant("Z") : myVector[theRow];
- }
- return QVariant();
- }
-
- //! Sets content of the model index for the given role, it is applyed to internal container of values
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return true if the value is changed
- virtual bool SetData(const int theRow, const int theColumn, const QVariant& theValue, int)
- {
- if (theColumn != 1 || theRow < 0 || theRow > 2)
- return false;
-
- switch (theRow)
- {
- case 0: myVector[theRow] = theValue; break;
- case 1: myVector[theRow] = theValue; break;
- case 2: myVector[theRow] = theValue; break;
- }
-
- return true;
- }
-
- //! Returns number of tree level line items = colums in table view
- virtual int ColumnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 2; }
-
- //! Returns onlly one row in table view
- virtual int RowCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 3; }
-
- //! Returns editable flag for DoubleVector
- //! \return flags
- Qt::ItemFlags Flags(const QModelIndex& theIndex) const
- {
- Qt::ItemFlags aFlags = ViewControl_TableModelValues::Flags(theIndex);
-
- if (theIndex.column() == 1 && theIndex.row() >= 0 && theIndex.row() <= 2)
- aFlags = aFlags | Qt::ItemIsEditable;
-
- return aFlags;
- }
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- virtual ViewControl_EditType GetEditType(const int theRow, const int theColumn) const
- {
- if (theColumn == 1 && theRow >= 0 && theRow <= 2)
- return ViewControl_EditType_Double;
-
- return ViewControl_EditType_None;
- }
-
-private:
- QList<QVariant> myVector;
- ViewControl_TableDoubleVector* myDoubleVector;
-};
-
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-
-ViewControl_TableDoubleVector::ViewControl_TableDoubleVector(QWidget* theParent)
-: QDialog(theParent)
-{
- QGridLayout* aLayout = new QGridLayout(this);
- aLayout->setContentsMargins(0, 0, 0, 0);
-
- myParameters = new QTableView(this);
-
- ViewControl_TableModel* aTableModel = new ViewControl_TableModel(myParameters);
- aTableModel->SetModelValues(new ViewControl_ParametersModelVector(this));
- myParameters->setModel(aTableModel);
-
- ViewControl_TableItemDelegate* anItemDelegate = new ViewControl_TableItemDelegate();
- anItemDelegate->SetModelValues(aTableModel->GetModelValues());
- myParameters->setItemDelegate(anItemDelegate);
-
- myParameters->verticalHeader()->setDefaultSectionSize(myParameters->verticalHeader()->minimumSectionSize());
- myParameters->verticalHeader()->setVisible(false);
- myParameters->horizontalHeader()->setVisible(false);
- myParameters->setMinimumHeight(myParameters->verticalHeader()->minimumSectionSize() * aTableModel->rowCount() +
- TreeModel_Tools::HeaderSectionMargin());
- myParameters->setMinimumWidth(myParameters->horizontalHeader()->defaultSectionSize() * aTableModel->columnCount() +
- TreeModel_Tools::HeaderSectionMargin());
-
- QItemSelectionModel* aSelectionModel = new QItemSelectionModel(myParameters->model());
- myParameters->setSelectionMode(QAbstractItemView::SingleSelection);
- myParameters->setSelectionModel(aSelectionModel);
-
- aLayout->addWidget(myParameters, 0, 0);
-
- myDialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
- connect(myDialogButtons, &QDialogButtonBox::accepted, this, &QDialog::accept);
- connect(myDialogButtons, &QDialogButtonBox::rejected, this, &QDialog::reject);
-
- aLayout->addWidget(myDialogButtons, 1, 0, 1, 2);
-}
-
-// =======================================================================
-// function : SetVectorValue
-// purpose :
-// =======================================================================
-
-void ViewControl_TableDoubleVector::SetVectorValue(const QString& theVector)
-{
- QList<QVariant> aVector = GetListVector(theVector);
- // parameters model
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- ViewControl_ParametersModelVector* aParametersModel = dynamic_cast<ViewControl_ParametersModelVector*> (aTableModel->GetModelValues());
- aParametersModel->SetVector(aVector);
-}
-
-// =======================================================================
-// function : GetListVector
-// purpose :
-// =======================================================================
-
-QList<QVariant> ViewControl_TableDoubleVector::GetListVector(const QString& theVector)
-{
- QList<QVariant> aDoubleList;
-
- QStringList aList = theVector.split(ViewControl_TableDoubleVector::DoubleSeparator(), QString::SkipEmptyParts);
-
- if (aList.isEmpty())
- return aDoubleList;
-
- for (int aNumberValue = 0; aNumberValue < aList.size(); ++aNumberValue)
- {
- aDoubleList.append(QVariant(aList[aNumberValue]));
- }
-
- return aDoubleList;
-}
-
-// =======================================================================
-// function : GetVector
-// purpose :
-// =======================================================================
-
-QString ViewControl_TableDoubleVector::GetVector() const
-{
- ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
- ViewControl_ParametersModelVector* aParametersModel = dynamic_cast<ViewControl_ParametersModelVector*> (aTableModel->GetModelValues());
-
- return VectorToString(aParametersModel->GetVector());
-}
-
-// =======================================================================
-// function : VectorToString
-// purpose :
-// =======================================================================
-
-QString ViewControl_TableDoubleVector::VectorToString(const QList<QVariant>& theVector) const
-{
- QString aVectorToString;
-
- for (int aNumberValue = 0; aNumberValue < theVector.size(); ++aNumberValue)
- {
- aVectorToString += theVector[aNumberValue].toString() + DoubleSeparator();
- }
- aVectorToString.remove(aVectorToString.length() - 1, 1);
-
- return aVectorToString;
-}
-
+++ /dev/null
-//-----------------------------------------------------------------------------
-// Created on: 2019-03-28
-// Created by: Vadim LEONTIEV
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of commercial software by OPEN CASCADE SAS.
-//
-// This software is furnished in accordance with the terms and conditions
-// of the contract and with the inclusion of this copyright notice.
-// This software or any other copy thereof may not be provided or otherwise
-// be made available to any third party.
-// No ownership title to the software is transferred hereby.
-//
-// OPEN CASCADE SAS makes no representation or warranties with respect to the
-// performance of this software, and specifically disclaims any responsibility
-// for any damages, special or consequential, connected with its use.
-//-----------------------------------------------------------------------------
-
-#ifndef ViewControl_TableDoubleVector_H
-#define ViewControl_TableDoubleVector_H
-
-#include <inspector/ViewControl.hxx>
-#include <inspector/ViewControl_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <Standard_Macro.hxx>
-#include <QDialog>
-#include <QString>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-class QDialogButtonBox;
-class QTableView;
-
-//! \class ViewControl_PointCoordinates
-//! \dialog of change the point coordinates
-class VIEWCONTROL_EXPORT ViewControl_TableDoubleVector : public QDialog
-{
- Q_OBJECT
-public:
-
- //! Constructor
- ViewControl_TableDoubleVector(QWidget* theParent);
-
- //! Destructor
- virtual ~ViewControl_TableDoubleVector() Standard_OVERRIDE{}
-
- //! Inits control by the vector value
- //! \param theVector text vector value
- void SetVectorValue(const QString& theVector);
-
- //! Returns vector value
- //! \return QList<QVariant> vector value
- static QList<QVariant> ViewControl_TableDoubleVector::GetListVector(const QString& theVector);
-
- //! Returns vector value
- //! \return text vector value
- QString GetVector() const;
-
- //! Converts vector to string value in form
- //! \param theVector vector value
- //! \return text value
- QString VectorToString(const QList<QVariant>& theVector) const;
-
-private:
- //! Returns symbol used as a separtor of vector components in string conversion
- //! \return symbol value
- static QString DoubleSeparator() { return ","; }
-
-private:
- QTableView* myParameters; //! current vector parameters
- QDialogButtonBox* myDialogButtons; //! OK/Cancel buttons
-
-};
-
-#endif // ViewControl_TableDoubleVector_H
+++ /dev/null
-// Created on: 2018-08-09
-// 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/ViewControl_TableItemDelegate.hxx>
-#include <inspector/ViewControl_ColorSelector.hxx>
-#include <inspector/ViewControl_TableModelValues.hxx>
-#include <inspector/ViewControl_EditType.hxx>
-#include <inspector/ViewControl_TableDoubleVector.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QFont>
-#include <QCheckBox>
-#include <QComboBox>
-#include <QDoubleValidator>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QSpinBox>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-
-ViewControl_TableItemDelegate::ViewControl_TableItemDelegate (QObject* theParent)
- : QItemDelegate (theParent), myModelValues (0)
-{
-}
-
-// =======================================================================
-// function : createEditor
-// purpose :
-// =======================================================================
-
-QWidget* ViewControl_TableItemDelegate::createEditor (QWidget* theParent,
- const QStyleOptionViewItem&,
- const QModelIndex& theIndex) const
-{
- if (!myModelValues)
- return 0;
-
- int aRow = theIndex.row();
- int aColumn = theIndex.column();
- ViewControl_EditType anEditType = myModelValues->GetEditType (aRow, aColumn);
-
- QWidget* anEditor = createEditorControl (theParent, anEditType);
- initEditorParameters (anEditor, anEditType, myModelValues, aRow, aColumn);
- return anEditor;
-}
-
-// =======================================================================
-// function : setEditorData
-// purpose :
-// =======================================================================
-
-void ViewControl_TableItemDelegate::setEditorData (QWidget* theEditor, const QModelIndex& theIndex) const
-{
- if (!myModelValues)
- return;
-
- int aRow = theIndex.row();
- int aColumn = theIndex.column();
- ViewControl_EditType anEditType = myModelValues->GetEditType (aRow, aColumn);
-
- setEditorValue (theEditor, anEditType, theIndex.model()->data(theIndex));
-}
-
-// =======================================================================
-// function : setModelData
-// purpose :
-// =======================================================================
-
-void ViewControl_TableItemDelegate::setModelData (QWidget* theEditor, QAbstractItemModel* theModel,
- const QModelIndex& theIndex) const
-{
- if (!myModelValues)
- return;
-
- int aRow = theIndex.row();
- int aColumn = theIndex.column();
- ViewControl_EditType anEditType = myModelValues->GetEditType (aRow, aColumn);
-
- theModel->setData (theIndex, getEditorValue (theEditor, anEditType));
-}
-
-// =======================================================================
-// function : createEditorControl
-// purpose :
-// =======================================================================
-
-QWidget* ViewControl_TableItemDelegate::createEditorControl (QWidget* theParent, const ViewControl_EditType theEditType)
-{
- switch (theEditType)
- {
- case ViewControl_EditType_None: return 0;
- case ViewControl_EditType_Bool: return new QComboBox (theParent);
- case ViewControl_EditType_Color: return new ViewControl_ColorSelector (theParent);
- case ViewControl_EditType_Combo: return new QComboBox (theParent);
- case ViewControl_EditType_Double:
- {
- QLineEdit* aLineEdit = new QLineEdit (theParent);
- aLineEdit->setValidator (new QDoubleValidator (theParent));
- return aLineEdit;
- }
- case ViewControl_EditType_Line: return new QLineEdit (theParent);
- case ViewControl_EditType_Spin:
- {
- QSpinBox* aSpinBox = new QSpinBox (theParent);
- aSpinBox->setRange (IntegerFirst(), IntegerLast());
- return aSpinBox;
- }
- case ViewControl_EditType_DoAction: return new QPushButton (theParent);
- case ViewControl_EditType_DoubleVector: return new ViewControl_TableDoubleVector(theParent);
-
- default: return 0;
- }
-}
-
-// =======================================================================
-// function : initEditorParameters
-// purpose :
-// =======================================================================
-
-void ViewControl_TableItemDelegate::initEditorParameters (QWidget* theEditor,
- const ViewControl_EditType theEditType,
- ViewControl_TableModelValues* theModelValues,
- const int theRow, const int theColumn)
-{
- switch (theEditType)
- {
- case ViewControl_EditType_Bool:
- {
- (qobject_cast<QComboBox*> (theEditor))->insertItem(0, "true");
- (qobject_cast<QComboBox*> (theEditor))->insertItem(1, "false");
- break;
- }
- case ViewControl_EditType_Combo:
- {
- QList<QVariant> aValues = theModelValues->GetEnumValues (theRow, theColumn);
- for (int aValuesId = 0; aValuesId < aValues.size(); aValuesId++)
- (qobject_cast<QComboBox*> (theEditor))->insertItem(aValuesId, aValues[aValuesId].toString());
- }
- break;
- case ViewControl_EditType_Double:
- {
- QList<QVariant> aValues = theModelValues->GetEnumValues (theRow, theColumn);
- if (aValues.size() < 3)
- break;
-
- QDoubleValidator* aValidator = (QDoubleValidator*)(qobject_cast<QLineEdit*> (theEditor))->validator();
- aValidator->setBottom (aValues[0].toDouble());
- aValidator->setTop (aValues[1].toDouble());
- aValidator->setDecimals (aValues[2].toInt());
- break;
- }
- default: break;
- }
-}
-
-// =======================================================================
-// function : setEditorValue
-// purpose :
-// =======================================================================
-
-void ViewControl_TableItemDelegate::setEditorValue (QWidget* theEditor, const ViewControl_EditType theEditType,
- const QVariant& theValue)
-{
- switch (theEditType)
- {
- case ViewControl_EditType_None: break;
- case ViewControl_EditType_Bool: (qobject_cast<QComboBox*>(theEditor))->setCurrentIndex (theValue.toBool() ? 0 : 1); break;
- case ViewControl_EditType_Color: (qobject_cast<ViewControl_ColorSelector*>(theEditor))->SetColor (theValue.toString()); break;
- case ViewControl_EditType_Combo: (qobject_cast<QComboBox*>(theEditor))->setCurrentText (theValue.toString()); break;
- case ViewControl_EditType_Double:
- case ViewControl_EditType_Line: (qobject_cast<QLineEdit*>(theEditor))->setText (theValue.toString()); break;
- case ViewControl_EditType_Spin: (qobject_cast<QSpinBox*>(theEditor))->setValue (theValue.toInt()); break;
- case ViewControl_EditType_DoAction: (qobject_cast<QPushButton*>(theEditor))->setText ("UnSelect"); break;
- case ViewControl_EditType_DoubleVector: (qobject_cast<ViewControl_TableDoubleVector*>(theEditor))->SetVectorValue(theValue.toString()); break;
-
- default: break;
- }
-}
-
-// =======================================================================
-// function : getEditorValue
-// purpose :
-// =======================================================================
-
-QVariant ViewControl_TableItemDelegate::getEditorValue (QWidget* theEditor, const ViewControl_EditType theEditType)
-{
- switch (theEditType)
- {
- case ViewControl_EditType_None: return QVariant();
- case ViewControl_EditType_Bool: return (qobject_cast<QComboBox*>(theEditor))->currentIndex() == 0 ? true : false;
- case ViewControl_EditType_Color: return (qobject_cast<ViewControl_ColorSelector*>(theEditor))->GetColor();
- case ViewControl_EditType_Combo: return (qobject_cast<QComboBox*>(theEditor))->currentText();
- case ViewControl_EditType_Double:
- case ViewControl_EditType_Line: return (qobject_cast<QLineEdit*>(theEditor))->text();
- case ViewControl_EditType_Spin: return (qobject_cast<QSpinBox*>(theEditor))->value();
- case ViewControl_EditType_DoAction: return QVariant ("Clicked");
- case ViewControl_EditType_DoubleVector: return (qobject_cast<ViewControl_TableDoubleVector*>(theEditor))->GetVector();
-
- default: return QVariant();
- }
-}
+++ /dev/null
-// Created on: 2018-08-09
-// 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 ViewControl_TableItemDelegate_H
-#define ViewControl_TableItemDelegate_H
-
-#include <Standard_Macro.hxx>
-#include <inspector/ViewControl_EditType.hxx>
-
-#include <QItemDelegate>
-
-class ViewControl_TableModelValues;
-
-//! \class ViewControl_TableItemDelegate
-//! \brief This is an implementation for ViewControl_TableModel to present AIS_InteractiveContext object
-class ViewControl_TableItemDelegate : public QItemDelegate
-{
-public:
-
- //! Constructor
- //! \param theParent parent object
- Standard_EXPORT ViewControl_TableItemDelegate (QObject* theParent = 0);
-
- //! Destructor
- virtual ~ViewControl_TableItemDelegate() Standard_OVERRIDE {}
-
- //! Sets table model values
- //! \param theModelValues instance of model values
- void SetModelValues (ViewControl_TableModelValues* theModelValues) { myModelValues = theModelValues; }
-
- //! Creates widget editor: spin box, combo box or line edit
- //! \param theParent parent widget
- //! \param theOption style option
- //! \param theIndex index of requested widget
- virtual QWidget* createEditor (QWidget* theParent, const QStyleOptionViewItem& theOption,
- const QModelIndex& theIndex) const Standard_OVERRIDE;
-
- //! Sets the data to be displayed and edited by the editor from the data model item specified by the model index
- //! \param theEditor editor to be filled
- //! \param theIndex index of requested widget, contains information about model
- virtual void setEditorData (QWidget* theEditor, const QModelIndex& theIndex) const Standard_OVERRIDE;
-
- //! Gets data from the editor widget and stores it in the specified model at the item index.
- //! \param theEditor editor to be filled
- //! \param theModel data model
- //! \param theIndex index of requested widget, contains information about model
- virtual void setModelData (QWidget* theEditor, QAbstractItemModel* theModel,
- const QModelIndex& theIndex) const Standard_OVERRIDE;
-
-private:
- //! Creates an editor
- //! \param theParent parent widget
- //! \param theEditType edition control type
- //! \return edit control
- static QWidget* createEditorControl (QWidget* theParent, const ViewControl_EditType theEditType);
-
- //! Inits an editor by model values parameters
- //! \param theEditor editor
- //! \param theEditType edition control type
- //! \param theModelValues custom implementation to provide parameters
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit control
- static void initEditorParameters (QWidget* theEditor, const ViewControl_EditType theEditType,
- ViewControl_TableModelValues* theModelValues,
- const int theRow, const int theColumn);
-
- //! Sets editor value
- //! \param theEditor editor
- //! \param theEditType editor typ
- //! \param theValue new value
- static void setEditorValue (QWidget* theEditor, const ViewControl_EditType theEditType, const QVariant& theValue);
-
- //! Returns value of spin box editor
- //! \param theEditor editor
- //! \param theEditType editor typ
- //! \return current value
- static QVariant getEditorValue (QWidget* theEditor, const ViewControl_EditType theEditType);
-
-private:
- ViewControl_TableModelValues* myModelValues; //!< table model values
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ViewControl_TableModel.hxx>
-
-// =======================================================================
-// function : SetModelValues
-// purpose :
-// =======================================================================
-void ViewControl_TableModel::SetModelValues (ViewControl_TableModelValues* theModelValues)
-{
- if (myModelValues)
- delete myModelValues;
-
- myModelValues = theModelValues;
-}
-
-// =======================================================================
-// function : columnCount
-// purpose :
-// =======================================================================
-int ViewControl_TableModel::columnCount(const QModelIndex& theParent) const
-{
- if (!myModelValues)
- return 0;
-
- return myModelValues->ColumnCount (theParent);
-}
-
-// =======================================================================
-// function : rowCount
-// purpose :
-// =======================================================================
-int ViewControl_TableModel::rowCount(const QModelIndex& theParent ) const
-{
- if (!myModelValues)
- return 0;
-
- return myModelValues->RowCount (theParent);
-}
-
-// =======================================================================
-// function : data
-// purpose :
-// =======================================================================
-QVariant ViewControl_TableModel::data (const QModelIndex& theIndex, int theRole) const
-{
- if (!myModelValues)
- return QVariant();
-
- int aRow = theIndex.row(), aColumn = theIndex.column();
- return myModelValues->Data (aRow, aColumn, theRole);
-}
-
-// =======================================================================
-// function : setData
-// purpose :
-// =======================================================================
-bool ViewControl_TableModel::setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole)
-{
- if (!myModelValues)
- return false;
-
- int aRow = theIndex.row(), aColumn = theIndex.column();
- return myModelValues->SetData (aRow, aColumn, theValue, theRole);
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_TableModel_H
-#define ViewControl_TableModel_H
-
-#include <Standard.hxx>
-
-#include <inspector/ViewControl_TableModelValues.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-#include <vector>
-
-//! \class ViewControl_TableModel
-//! \brief This is an extension of table model to visualize a container of values
-//! It is possible to:
-//! - set orientation to interpretate the values.
-//! - set table view header values.
-//! Items of the view are enabled and selectable.
-class ViewControl_TableModel : public QAbstractTableModel
-{
-public:
-
- //! Constructor
- ViewControl_TableModel (QObject* theParent = 0) : myModelValues (0) { (void)theParent; }
-
- //! Destructor
- virtual ~ViewControl_TableModel() {}
-
- //! Sets interface to table values
- //! \theModelValues instance of values
- Standard_EXPORT void SetModelValues (ViewControl_TableModelValues* theModelValues);
-
- //! Returns instance of interface for access totable values
- //! \return interface or NULL
- ViewControl_TableModelValues* GetModelValues() const { return myModelValues; }
-
- //! Emits the layoutChanged signal from outside of this class
- void EmitLayoutChanged() { emit layoutChanged(); }
-
- //! Returns number of columns, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Sets the new value of passed role to tree cell.
- //! \param[in] index refers to item in tree.
- //! \param[in] value the new value.
- //! \param[in] role the role of value.
- Standard_EXPORT virtual bool setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole) Standard_OVERRIDE;
-
- //! Returns content of the model index for the given role, it is obtainer from internal container of header values
- //! It returns value only for DisplayRole.
- //! \param theSection an index of value in the container
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- virtual QVariant headerData (int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const Standard_OVERRIDE
- { return myModelValues ? myModelValues->HeaderData (theSection, theOrientation, theRole) : QVariant(); }
-
- //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
- //! \param theIndex a model index
- //! \return flags
- Qt::ItemFlags flags (const QModelIndex& theIndex) const
- { return myModelValues ? myModelValues->Flags (theIndex) : Qt::NoItemFlags; }
-
-private:
- ViewControl_TableModelValues* myModelValues; //! interface to table values
-};
-
-#endif
+++ /dev/null
-// Created on: 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/ViewControl_TableModelValues.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : ColumnCount
-// purpose :
-// =======================================================================
-
-int ViewControl_TableModelValues::ColumnCount (const QModelIndex&) const
-{
- if (!GetProperties().IsNull())
- return GetProperties()->ColumnCount();
-
- return 0;
-}
-
-
-// =======================================================================
-// function : RowCount
-// purpose :
-// =======================================================================
-
-int ViewControl_TableModelValues::RowCount (const QModelIndex&) const
-{
- if (!GetProperties().IsNull())
- return GetProperties()->RowCount();
-
- return 0;
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant ViewControl_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const
-{
- if (!GetProperties().IsNull())
- {
- QVariant aValue = GetProperties()->Data (theRow, theColumn, theRole);
- if (aValue.isValid())
- return aValue;
- }
-
- if (theRole == Qt::TextAlignmentRole) // for multi-lines text, align it to the top
- return Qt::AlignTop;
-
- if ((theRole == Qt::FontRole || theRole == Qt::ForegroundRole) && isItalicHeader (theRow, theColumn))
- {
- if (theRole == Qt::FontRole)
- {
- QFont aFont = qApp->font();
- aFont.setItalic (true);
- return aFont;
- }
- else
- QColor (Qt::darkGray).darker (150);
- }
- return QVariant();
-}
-
-// =======================================================================
-// function : SetData
-// purpose :
-// =======================================================================
-
-bool ViewControl_TableModelValues::SetData (const int theRow, const int theColumn, const QVariant& theValue, int)
-{
- if (!GetProperties().IsNull())
- return GetProperties()->SetTableData (theRow, theColumn, theValue);
-
- return false;
-}
-
-// =======================================================================
-// function : HeaderData
-// purpose :
-// =======================================================================
-
-QVariant ViewControl_TableModelValues::HeaderData (int theSection, Qt::Orientation theOrientation, int theRole) const
-{
- if (theRole == Qt::DisplayRole)
- return myHeaderValues.contains (theOrientation) ? myHeaderValues[theOrientation][theSection].GetName()
- : QString::number (theSection + 1);
- else if (theRole == Qt::ForegroundRole)
- return QColor (Qt::darkGray);
-
- return QVariant();
-}
-
-// =======================================================================
-// function : GetEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType ViewControl_TableModelValues::GetEditType (const int theRow, const int theColumn) const
-{
- if (!GetProperties().IsNull())
- {
- return GetProperties()->GetTableEditType (theRow, theColumn);
- }
- return ViewControl_EditType_None;
-}
-
-// =======================================================================
-// function : GetEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> ViewControl_TableModelValues::GetEnumValues (const int theRow, const int theColumn) const
-{
- if (!GetProperties().IsNull())
- {
- return GetProperties()->GetTableEnumValues (theRow, theColumn);
- }
- return QList<QVariant>();
-}
-
-// =======================================================================
-// function : isItalicHeader
-// purpose :
-// =======================================================================
-Qt::ItemFlags ViewControl_TableModelValues::Flags (const QModelIndex& theIndex) const
-{
- if (!GetProperties().IsNull())
- {
- return GetProperties()->GetTableFlags (theIndex.row(), theIndex.column());
- }
- return theIndex.isValid() ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags;
-}
-
-// =======================================================================
-// function : isItalicHeader
-// purpose :
-// =======================================================================
-bool ViewControl_TableModelValues::isItalicHeader (const int theRow, const int theColumn) const
-{
- Qt::Orientation anOrientation = myOrientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical;
- int aCell = anOrientation == Qt::Horizontal ? theColumn : theRow;
-
- return GetHeaderItem (anOrientation, aCell).IsItalic();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_TableModelValues_H
-#define ViewControl_TableModelValues_H
-
-#include <Standard.hxx>
-
-#include <inspector/TreeModel_HeaderSection.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/ViewControl_EditType.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-//! \class ViewControl_TableModelValues
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class ViewControl_TableModelValues
-{
-public:
-
- //! Constructor
- Standard_EXPORT ViewControl_TableModelValues (const Qt::Orientation& theOrientation = Qt::Vertical)
- { SetOrientation (theOrientation); }
-
- //! Destructor
- virtual ~ViewControl_TableModelValues() {}
-
- //! Sets item table properties builder
- void SetProperties (const Handle(TreeModel_ItemProperties)& theProperties) { myProperties = theProperties; }
-
- //! Returns item table properties builder
- Handle(TreeModel_ItemProperties) GetProperties() const { return myProperties; }
-
- //! Sets direction of the values applying, whether it should be placed by rows or by columns
- //! \param theOrientation if horizontal, the values are applyed by rows, otherwise by columns
- void SetOrientation (const Qt::Orientation& theOrientation) { myOrientation = theOrientation; }
-
- //! Fills the model header values for orientation.
- //! \param theValues a container of header text values
- //! \param theOrientation an orientation of header
- void SetHeaderValues (const QList<TreeModel_HeaderSection>& theValues, const Qt::Orientation theOrientation)
- { myHeaderValues.insert (theOrientation, theValues); }
-
- //! Returns whether the column is hidden by default
- //! \param theColumnId a column index
- //! \return header section values container
- TreeModel_HeaderSection GetHeaderItem (const Qt::Orientation theOrientation, const int theColumnId) const
- { return myHeaderValues.contains(theOrientation) ? myHeaderValues[theOrientation][theColumnId] : TreeModel_HeaderSection(); }
-
- //! Stores information about table view header visibility
- //! \param theOrientation an orientation of header
- //! \param theVisibility if true, header is visible
- void SetHeaderVisible (const Qt::Orientation theOrientation, const bool theVisibility)
- { myVisibleHeader.insert (theOrientation, theVisibility); }
-
- //! Stores information about table view header visibility
- //! \param theOrientation an orientation of header
- //! \param theVisibility if true, header is visible
- bool IsHeaderVisible (const Qt::Orientation theOrientation) const
- { return myVisibleHeader.contains(theOrientation) ? myVisibleHeader[theOrientation] : true; }
-
- //! Set default section size if defined
- //! \param theOrientation an orientation of header
- //! \param theVisibility if true, header is visible
- void SetDefaultSectionSize (const Qt::Orientation theOrientation, const int& theSectionSize)
- { myDefaultSectionSize.insert(theOrientation, theSectionSize); }
-
- //! Get default section size if defined
- //! \param theOrientation an orientation of header
- //! \param theVisibility if true, header is visible
- bool GetDefaultSectionSize (const Qt::Orientation theOrientation, int& theSectionSize)
- {
- theSectionSize = myDefaultSectionSize.contains (theOrientation) ? myDefaultSectionSize[theOrientation] : -1;
- return myDefaultSectionSize.contains (theOrientation);
- }
-
- //! Returns number of columns, size of header values
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const;
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int RowCount (const QModelIndex& theParent = QModelIndex()) const;
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const;
-
- //! Sets content of the model index for the given role, it is applyed to internal container of values
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return true if the value is changed
- Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
- int theRole = Qt::DisplayRole);
-
- //! Returns content of the model index for the given role, it is obtainer from internal container of header values
- //! It returns value only for DisplayRole.
- //! \param theSection an index of value in the container
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant HeaderData (int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const;
-
- //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
- //! \param theIndex a model index
- //! \return flags
- Standard_EXPORT virtual Qt::ItemFlags Flags (const QModelIndex& theIndex) const;
-
- //! Returns item delegate to provide cell editors. By default, it is empty
- //! \return delegate
- virtual QItemDelegate* GetItemDelegate() { return 0; }
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- Standard_EXPORT virtual ViewControl_EditType GetEditType (const int theRow, const int theColumn) const;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- Standard_EXPORT virtual QList<QVariant> GetEnumValues (const int theRow, const int theColumn) const;
-
- //! Returns default color for editable cell
- //! \return color value
- static QColor EditCellColor() { return QColor (Qt::darkBlue); }
-
-protected:
- //! Returns true if the header item is italic of the parameter index
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param boolean value
- bool isItalicHeader (const int theRow, const int theColumn) const;
-
-protected:
-
- Qt::Orientation myOrientation; //!< orientation how the values should fill the current table view
- QMap<Qt::Orientation, QList<TreeModel_HeaderSection> > myHeaderValues; //!< table header values
- QMap<Qt::Orientation, bool> myVisibleHeader; //! table header visibility
- QMap<Qt::Orientation, int> myDefaultSectionSize; //! table section default size
-
- Handle(TreeModel_ItemProperties) myProperties; //!< item properties
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <inspector/ViewControl_TableModelValuesDefault.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFont>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : ColumnCount
-// purpose :
-// =======================================================================
-
-int ViewControl_TableModelValuesDefault::ColumnCount (const QModelIndex&) const
-{
- Qt::Orientation anAdditionalOrientation = myOrientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical;
- if (myHeaderValues[anAdditionalOrientation].size() > 0)
- return myHeaderValues[anAdditionalOrientation].size();
-
- return myValues.size();
-}
-
-// =======================================================================
-// function : Data
-// purpose :
-// =======================================================================
-
-QVariant ViewControl_TableModelValuesDefault::Data (const int theRow, const int theColumn, int theRole) const
-{
- if (theRole == Qt::DisplayRole)
- return myValues.at ((int)getPosition (theRow, theColumn));
-
- return ViewControl_TableModelValues::Data (theRow, theColumn, theRole);
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ViewControl_TableModelValuesDefault_H
-#define ViewControl_TableModelValuesDefault_H
-
-#include <Standard.hxx>
-
-#include <inspector/ViewControl_TableModelValues.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QColor>
-#include <QList>
-#include <QModelIndexList>
-#include <QVariant>
-#include <Standard_WarningsRestore.hxx>
-
-class QItemDelegate;
-
-//! \class ViewControl_TableModelValuesDefault
-//! \brief This is an interace for ViewControl_TableModel to give real values of the model
-//! It should be filled or redefined.
-class ViewControl_TableModelValuesDefault : public ViewControl_TableModelValues
-{
-public:
-
- //! Constructor
- Standard_EXPORT ViewControl_TableModelValuesDefault (const Qt::Orientation& theOrientation = Qt::Vertical)
- : ViewControl_TableModelValues (theOrientation) {}
-
- //! Destructor
- virtual ~ViewControl_TableModelValuesDefault() {}
-
- //! Fills the model values.
- //! \param theValues a container of table model values
- void SetValues (const QVector<QVariant>& theValues) { myValues = theValues; }
-
- //! Returns number of columns, size of header values
- //! \param theParent an index of the parent item
- //! \return an integer value
- Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- virtual int RowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { return ColumnCount (theParent) > 0 ? GetValuesCount() / ColumnCount (theParent) : 0; }
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Returns number of rows, depending on orientation: myColumnCount or size of values container
- //! \param theParent an index of the parent item
- //! \return an integer value
- virtual int GetValuesCount () const { return myValues.size(); }
-
-protected:
- //! Finds position in internal vector of values using the table column/row count
- //! \param theRow a row of a table cell
- //! \param theColumn a column of a table cell
- size_t getPosition (const int theRow, const int theColumn) const { return ColumnCount() * theRow + theColumn; }
-
- //! Returns true if the header item is italic of the parameter index
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param boolean value
- bool isItalicHeader (const int theRow, const int theColumn) const;
-
-protected:
-
- QVector<QVariant> myValues; //! cached container of table values
-};
-
-#endif
// commercial license or contractual agreement.
#include <inspector/ViewControl_Tools.hxx>
-#include <inspector/ViewControl_TableModel.hxx>
-
-#include <Geom_Transformation.hxx>
-
-#include <TColgp_Array1OfPnt.hxx>
-#include <TCollection.hxx>
-#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-#include <BRepPrimAPI_MakeBox.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QAction>
-#include <QHeaderView>
-#include <QLocale>
#include <QObject>
#include <QPalette>
-#include <QTableView>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
aPalette.setColor (QPalette::All, QPalette::Foreground, Qt::white);
theControl->setPalette (aPalette);
}
-
-// =======================================================================
-// function : SetDefaultHeaderSections
-// purpose :
-// =======================================================================
-void ViewControl_Tools::SetDefaultHeaderSections(QTableView* theTableView, const Qt::Orientation theOrientation)
-{
- ViewControl_TableModel * aTableModel = dynamic_cast<ViewControl_TableModel*> (theTableView->model());
- ViewControl_TableModelValues* aModelValues = aTableModel->GetModelValues();
- if (!aModelValues)
- return;
-
- int aSectionSize;
- if (aModelValues->GetDefaultSectionSize (Qt::Horizontal, aSectionSize) )
- theTableView->horizontalHeader()->setDefaultSectionSize (aSectionSize);
- else {
- bool isStretchLastSection = true;
- for (int aColumnId = 0, aNbColumns = aTableModel->columnCount(); aColumnId < aNbColumns; aColumnId++)
- {
- TreeModel_HeaderSection aSection = aModelValues->GetHeaderItem (theOrientation, aColumnId);
- if (aSection.IsEmpty())
- continue;
-
- int aColumnWidth = aSection.GetWidth();
- if (aColumnWidth > 0)
- {
- theTableView->setColumnWidth (aColumnId, aColumnWidth);
- if (aColumnId == aNbColumns - 1)
- isStretchLastSection = false;
- }
- theTableView->setColumnHidden (aColumnId, aSection.IsHidden());
- }
- if (isStretchLastSection != theTableView->horizontalHeader()->stretchLastSection())
- theTableView->horizontalHeader()->setStretchLastSection (isStretchLastSection);
-
- }
-}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
- return TCollection::GetPointerInfo (thePointer);
- /*if (thePointer.IsNull())
- return TCollection_AsciiString();
-
- return GetPointerInfo(thePointer.operator->(), isShortInfo);*/
-}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::GetPointerInfo (const void* thePointer, const bool isShortInfo)
-{
- return TCollection::GetPointerInfo (thePointer);
- /*
- std::ostringstream aPtrStr;
- aPtrStr << thePointer;
- if (!isShortInfo)
- return aPtrStr.str().c_str();
-
- TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
- for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
- {
- if (anInfoPtr.Value(aSymbolId) != '0')
- {
- anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
- anInfoPtr.Prepend(GetPointerPrefix());
- return anInfoPtr;
- }
- }
- return aPtrStr.str().c_str();*/
-}
-
-// =======================================================================
-// function : ToVariant
-// purpose :
-// =======================================================================
-QVariant ViewControl_Tools::ToVariant (const Standard_ShortReal theValue)
-{
- return QVariant (QLocale().toString (theValue));
-}
-
-// =======================================================================
-// function : ToVariant
-// purpose :
-// =======================================================================
-QVariant ViewControl_Tools::ToVariant (const Standard_Real theValue)
-{
- return QVariant (QLocale().toString (theValue));
-}
-
-// =======================================================================
-// function : ToRealValue
-// purpose :
-// =======================================================================
-Standard_ShortReal ViewControl_Tools::ToShortRealValue (const QVariant& theValue)
-{
- return QLocale().toFloat (theValue.toString());
-}
-
-// =======================================================================
-// function : ToRealValue
-// purpose :
-// =======================================================================
-Standard_Real ViewControl_Tools::ToRealValue (const QVariant& theValue)
-{
- return QLocale().toDouble (theValue.toString());
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const Handle(Geom_Transformation)& theValue)
-{
- if (theValue.IsNull())
- return TCollection_AsciiString();
-
- return ViewControl_Tools::ToString (theValue->Trsf());
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const gp_Trsf& theValue)
-{
- TCollection_AsciiString aValues;
- for (int aRowId = 1; aRowId <= 3; aRowId++)
- {
- for (int aColId = 1; aColId <= 4; aColId++) {
- aValues += TCollection_AsciiString (theValue.Value(aRowId, aColId));
- if (aColId != 4)
- aValues += ",";
- }
- if (aRowId != 3)
- aValues += " ";
- }
- return aValues;
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const gp_Pnt& thePoint)
-{
- return TCollection_AsciiString (thePoint.X()) + ","
- + TCollection_AsciiString (thePoint.Y()) + ","
- + TCollection_AsciiString (thePoint.Z());
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const gp_Dir& theDir)
-{
- return TCollection_AsciiString (theDir.X()) + ","
- + TCollection_AsciiString (theDir.Y()) + ","
- + TCollection_AsciiString (theDir.Z());
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const gp_XYZ& theValue)
-{
- return TCollection_AsciiString (theValue.X()) + ","
- + TCollection_AsciiString (theValue.Y()) + ","
- + TCollection_AsciiString (theValue.Z());
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const Bnd_Box& theValue)
-{
- if (theValue.IsVoid())
- return "Bnd_Box is void";
-
- return QString ("(%1, %2, %3), (%4, %5, %6)")
- .arg (theValue.CornerMin().X()).arg (theValue.CornerMin().Y()).arg (theValue.CornerMin().Z())
- .arg (theValue.CornerMax().X()).arg (theValue.CornerMax().Y()).arg (theValue.CornerMax().Z()).toStdString().c_str();
-
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const Handle(TColgp_HArray1OfPnt)& thePoints)
-{
- QStringList aPointList;
- for (Standard_Integer aPntIter = thePoints->Lower(); aPntIter <= thePoints->Upper(); ++aPntIter)
- aPointList.append(ViewControl_Tools::ToString (thePoints->Value (aPntIter)).ToCString());
-
- return aPointList.join(" ,").toStdString().c_str();
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString ViewControl_Tools::ToString (const TopLoc_Location& theLocation)
-{
- return ToString (theLocation.Transformation());
-}
#ifndef ViewControl_Tools_H
#define ViewControl_Tools_H
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_XYZ.hxx>
-#include <Bnd_Box.hxx>
-#include <Bnd_OBB.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QString>
-#include <QVariant>
#include <Standard_WarningsRestore.hxx>
-class Geom_Transformation;
-
class QAction;
class QObject;
-class QTableView;
class QWidget;
//! \class ViewControl_Tools
class ViewControl_Tools
{
public:
- //! Returns text of separation row in table
- //! \return string value
- static QString TableSeparator() { return "---------------------------"; }
//! Creates an action with the given text connected to the slot
//! \param theText an action text value
//! \param theControl a widget to be modified
Standard_EXPORT static void SetWhiteBackground (QWidget* theControl);
- //! Fills tree view by default sections parameters obtained in view's table model
- //! \param theTableView table view instance
- //! \param theOrientation header orientation
- Standard_EXPORT static void SetDefaultHeaderSections (QTableView* theTableView, const Qt::Orientation theOrientation);
-
- //! Returns default prefix added for each pointer info string
- Standard_EXPORT static TCollection_AsciiString GetPointerPrefix() { return "0x"; }
-
- //! Convert handle pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
- const bool isShortInfo = true);
-
- //! Convert pointer to string value
- //! \param thePointer a pointer
- //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
- //! \return the string value
- Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const void* thePointer,
- const bool isShortInfo = true);
-
- //! Convert real value to string value
- //! \param theValue a short real value
- //! \return the string value
- Standard_EXPORT static QVariant ToVariant (const Standard_ShortReal theValue);
-
- //! Convert real value to string value
- //! \param theValue a real value
- //! \return the string value
- Standard_EXPORT static QVariant ToVariant (const Standard_Real theValue);
-
- //! Convert real value to real value
- //! \param theValue a string value
- //! \return the real value
- Standard_EXPORT static Standard_ShortReal ToShortRealValue (const QVariant& theValue);
-
- //! Convert real value to string value
- //! \param theValue a string value
- //! \return the real value
- Standard_EXPORT static Standard_Real ToRealValue (const QVariant& theValue);
-
- //! Returns text of orientation
- //! \param theLocation a location value
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const Handle(Geom_Transformation)& theValue);
-
- //! Returns text of orientation
- //! \param theLocation a location value
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const gp_Trsf& theValue);
-
- //! Returns text of point
- //! \param theValue a 3D point
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const gp_Pnt& thePoint);
-
- //! Returns text of direction
- //! \param theValue a direction
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const gp_Dir& theDir);
-
- //! Returns text of cartesian entity in 3D space
- //! \param theValue an entity
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const gp_XYZ& theValue);
-
- //! Returns text of bounding box in form: (xmin, ymin, zmin), (xmax, ymax, zmax)
- //! \param theValue a bounding box
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const Bnd_Box& theValue);
-
- //! Returns text of array of points
- //! \param thePoints points
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const Handle(TColgp_HArray1OfPnt)& thePoints);
-
- //! Returns text of location
- //! \param theLocation object location
- //! \return text value
- Standard_EXPORT static TCollection_AsciiString ToString (const TopLoc_Location& theLocation);
-
};
#endif