1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0030268: Inspectors - improvements in VInspector plugin

Modifications in src:
implementing methods to have text information for some of OCCT enums;
moving out the text information from Quantity_Color;
expansionFactor() in Graphic3d_AspectText3d for access to this parameter;

Modifications in tools:
implementing common controls in ViewControl to be used in all plugins: table, property view and color selector;
move properties from columns of VInspector into property view, filled by tree view item selecting;
implementing new items (aspects, graphical information)
extending information of already existing items (presentations, selection entities)
display preview presentation for selected item (if possible, GetPresentations or GetPresentationShape of the item returns not empty value)

(cherry picked from commit 6dce71df876075a54ca7ef0a267fdbbdfceb6ac8)
This commit is contained in:
nds
2018-10-19 08:26:37 +03:00
parent e9a83b5f59
commit 7d2af73a33
106 changed files with 13140 additions and 443 deletions

View File

@@ -82,6 +82,14 @@
const Standard_Real SquareTolerance = Precision::SquareConfusion();
namespace
{
static Standard_CString AIS_Table_PrintDisplayStatus[3] =
{
"DISPLAYED", "ERASED", "NONE"
};
}
//=======================================================================
//function : Nearest
//purpose :
@@ -1538,3 +1546,33 @@ void AIS::ComputeProjVertexPresentation (const Handle( Prs3d_Presentation )& aPr
StdPrs_WFShape::Add (aPresentation, MakEd.Edge(), aDrawer);
}
}
//=======================================================================
//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;
}

View File

@@ -27,6 +27,7 @@
#include <AIS_KindOfSurface.hxx>
#include <Prs3d_Drawer.hxx>
#include <Quantity_NameOfColor.hxx>
#include <AIS_DisplayStatus.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_TypeOfMarker.hxx>
class gp_Pnt;
@@ -250,6 +251,28 @@ public:
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 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);
};
#endif // _AIS_HeaderFile

452
src/Aspect/Aspect.cxx Normal file
View File

@@ -0,0 +1,452 @@
// 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;
}

284
src/Aspect/Aspect.hxx Normal file
View File

@@ -0,0 +1,284 @@
// 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

View File

@@ -1,3 +1,5 @@
Aspect.cxx
Aspect.hxx
Aspect_AspectFillAreaDefinitionError.hxx
Aspect_AspectLineDefinitionError.hxx
Aspect_AspectMarkerDefinitionError.hxx

View File

@@ -1,3 +1,5 @@
Font.cxx
Font.hxx
Font_BRepFont.cxx
Font_BRepFont.hxx
Font_BRepTextBuilder.cxx

56
src/Font/Font.cxx Normal file
View File

@@ -0,0 +1,56 @@
// 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;
}

54
src/Font/Font.hxx Normal file
View File

@@ -0,0 +1,54 @@
// 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

View File

@@ -1,3 +1,5 @@
GeomAbs.cxx
GeomAbs.hxx
GeomAbs_BSplKnotDistribution.hxx
GeomAbs_CurveForm.hxx
GeomAbs_CurveType.hxx

59
src/GeomAbs/GeomAbs.cxx Normal file
View File

@@ -0,0 +1,59 @@
// 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 <GeomAbs.hxx>
#include <TCollection_AsciiString.hxx>
namespace
{
static Standard_CString GeomAbs_Table_PrintSurfaceTypeEnum[11] =
{
"Plane", "Cylinder", "Cone", "Sphere", "Torus", "BezierSurface", "BSplineSurface",
"SurfaceOfRevolution", "SurfaceOfExtrusion", "OffsetSurface", "OtherSurface"
};
}
//=======================================================================
//function : SurfaceTypeToString
//purpose :
//=======================================================================
Standard_CString GeomAbs::SurfaceTypeToString (const GeomAbs_SurfaceType theValue)
{
return GeomAbs_Table_PrintSurfaceTypeEnum[theValue];
}
//=======================================================================
//function : SurfaceTypeFromString
//purpose :
//=======================================================================
Standard_Boolean GeomAbs::SurfaceTypeFromString (const Standard_CString theString,
GeomAbs_SurfaceType& theType)
{
TCollection_AsciiString aName (theString);
//aName.UpperCase();
for (Standard_Integer aTypeIter = GeomAbs_Plane; aTypeIter <= GeomAbs_OtherSurface; ++aTypeIter)
{
Standard_CString aTypeName = GeomAbs_Table_PrintSurfaceTypeEnum[aTypeIter];
if (aName == aTypeName)
{
theType = GeomAbs_SurfaceType (aTypeIter);
return Standard_True;
}
}
return Standard_False;
}

54
src/GeomAbs/GeomAbs.hxx Normal file
View File

@@ -0,0 +1,54 @@
// 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 _GeomAbs_HeaderFile
#define _GeomAbs_HeaderFile
#include <GeomAbs_SurfaceType.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
//! Defines
//! - tools to work with geomAbs
class GeomAbs
{
public:
DEFINE_STANDARD_ALLOC
//! Returns the string name for a type.
//! @param surface type
//! @return string identifier from the enumeration
Standard_EXPORT static Standard_CString SurfaceTypeToString (const GeomAbs_SurfaceType theSurfaceType);
//! Returns the surface type from the given string identifier (using case-insensitive comparison).
//! @param theString string identifier
//! @return type or GeomAbs_OtherSurface if string identifier is invalid
static GeomAbs_SurfaceType SurfaceTypeFromString (const Standard_CString theString)
{
GeomAbs_SurfaceType aSurfaceType = GeomAbs_OtherSurface;
SurfaceTypeFromString (theString, aSurfaceType);
return aSurfaceType;
}
//! Determines the surface type from the given string identifier (using case-insensitive comparison).
//! @param theString string identifier
//! @param theSurfaceType detected surface type
//! @return TRUE if string identifier is known
Standard_EXPORT static Standard_Boolean SurfaceTypeFromString (const Standard_CString theString,
GeomAbs_SurfaceType& theType);
};
#endif // _GeomAbs_HeaderFile

View File

@@ -1,3 +1,5 @@
Graphic3d.cxx
Graphic3d.hxx
Graphic3d_AlphaMode.hxx
Graphic3d_ArrayFlags.hxx
Graphic3d_ArrayOfPoints.hxx

370
src/Graphic3d/Graphic3d.cxx Normal file
View File

@@ -0,0 +1,370 @@
// 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] =
{
"INKNOWN", "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"
};
}
//=======================================================================
//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;
}
}
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;
}

237
src/Graphic3d/Graphic3d.hxx Normal file
View File

@@ -0,0 +1,237 @@
// 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_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_TransModeFlags.hxx>
#include <Graphic3d_TypeOfShadingModel.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);
};
#endif // _Graphic3d_HeaderFile

View File

@@ -80,6 +80,9 @@ public:
//! Modifies the color.
void SetColor (const Quantity_ColorRGBA& theColor) { myColor = theColor; }
//! Returns the expansion factor.
Standard_Real ExpansionFactor() const { return myFactor; }
//! Modifies the expansion factor (height/width ratio)
//! If the factor is less than 1, the characters will
//! be higher than they are wide.

View File

@@ -64,7 +64,8 @@ OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
myAspectText(NULL),
myFirst(NULL),
myLast(NULL),
myIsRaytracable (Standard_False)
myIsRaytracable (Standard_False),
myIsDestroyElements (Standard_True)
{
Handle(OpenGl_Structure) aStruct = Handle(OpenGl_Structure)::DownCast (myStructure->CStructure());
if (aStruct.IsNull())
@@ -499,12 +500,15 @@ void OpenGl_Group::Clear (const Standard_Boolean theToUpdateStructureMgr)
void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
{
// Delete elements
while (myFirst != NULL)
if (myIsDestroyElements)
{
OpenGl_ElementNode* aNext = myFirst->next;
OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
delete myFirst;
myFirst = aNext;
while (myFirst != NULL)
{
OpenGl_ElementNode* aNext = myFirst->next;
OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
delete myFirst;
myFirst = aNext;
}
}
myLast = NULL;

View File

@@ -154,6 +154,14 @@ public:
//! Add stencil test element
Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) Standard_OVERRIDE;
//! Sets possibility to destroy or not OpenGl_Elements by Release() of the group. The default value is Standard_True
//! \param theIsEnabled state whether destroy element or not
void SetDestroyElements (const Standard_Boolean& theIsEnabled) { myIsDestroyElements = theIsEnabled; }
//! Returns flag whether OpenGl_Elements are to be destroyed by Release() of the group.
//! \return state whether elements are destroyed or not
Standard_Boolean DestroyElements() const { return myIsDestroyElements; }
public:
OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
@@ -191,6 +199,7 @@ protected:
OpenGl_ElementNode* myLast;
Standard_Boolean myIsRaytracable;
Standard_Boolean myIsDestroyElements;
public:

View File

@@ -26,6 +26,57 @@
#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 :
@@ -145,3 +196,273 @@ void Prs3d::AddPrimitivesGroup (const Handle(Prs3d_Presentation)& thePrs,
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;
}

View File

@@ -18,13 +18,22 @@
#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_VertexDrawMode.hxx>
class TopoDS_Shape;
class Prs3d_Presentation;
@@ -76,6 +85,204 @@ public:
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

View File

@@ -1,3 +1,5 @@
PrsMgr.cxx
PrsMgr.hxx
PrsMgr_ListOfPresentableObjects.hxx
PrsMgr_ListOfPresentations.hxx
PrsMgr_ModedPresentation.cxx

54
src/PrsMgr/PrsMgr.cxx Normal file
View File

@@ -0,0 +1,54 @@
// 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;
}

53
src/PrsMgr/PrsMgr.hxx Normal file
View File

@@ -0,0 +1,53 @@
// 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

View File

@@ -1,3 +1,5 @@
Quantity.cxx
Quantity.hxx
Quantity_AbsorbedDose.hxx
Quantity_Acceleration.hxx
Quantity_AcousticIntensity.hxx

191
src/Quantity/Quantity.cxx Normal file
View File

@@ -0,0 +1,191 @@
// 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;
}

53
src/Quantity/Quantity.hxx Normal file
View File

@@ -0,0 +1,53 @@
// 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

View File

@@ -14,6 +14,7 @@
// commercial license or contractual agreement.
#include <Quantity_Color.hxx>
#include <Quantity.hxx>
#include <Quantity_ColorDefinitionError.hxx>
#include <Standard_ErrorHandler.hxx>
@@ -47,6 +48,8 @@ static Standard_Real TheEpsilon = 0.0001;
Standard_Boolean Quantity_Color::ColorFromName (const Standard_CString theName,
Quantity_NameOfColor& theColor)
{
return Quantity::NameOfColorFromString (theName, theColor);
/*
TCollection_AsciiString aName (theName);
aName.UpperCase();
if (aName.Search("QUANTITY_NOC_") == 1)
@@ -63,7 +66,7 @@ Standard_Boolean Quantity_Color::ColorFromName (const Standard_CString theName,
return Standard_True;
}
}
return Standard_False;
return Standard_False;*/
}
Quantity_Color::Quantity_Color () {
@@ -2040,6 +2043,8 @@ switch (AName) {
Standard_CString Quantity_Color::StringName (
const Quantity_NameOfColor AName) {
return Quantity::NameOfColorToString (AName);
/*
Standard_CString TheName;
switch (AName) {
@@ -3600,7 +3605,7 @@ switch (AName) {
throw Standard_OutOfRange("Bad name");
break;
}
return (TheName);
return (TheName);*/
}
//

View File

@@ -1,3 +1,5 @@
SelectMgr.cxx
SelectMgr.hxx
SelectMgr_AndFilter.cxx
SelectMgr_AndFilter.hxx
SelectMgr_BaseFrustum.cxx

View File

@@ -0,0 +1,54 @@
// 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"
};
}
//=======================================================================
//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;
}

View File

@@ -0,0 +1,57 @@
// 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_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);
};
#endif // _SelectMgr_HeaderFile

View File

@@ -1,5 +1,7 @@
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)

View File

@@ -1 +1,3 @@
TKernel
TKMath
CSF_QT

View File

@@ -41,6 +41,11 @@ public:
//! 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; }

View File

@@ -206,6 +206,24 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const
#endif
}
// =======================================================================
// 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 :
@@ -213,15 +231,8 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const
QModelIndex TreeModel_ModelBase::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
const Qt::Orientation theOrientation)
{
QModelIndexList aFirstColumnSelectedIndices;
for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
{
QModelIndex anIndex = *anIndicesIt;
if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
(theOrientation == Qt::Vertical && anIndex.row() == theCellId))
aFirstColumnSelectedIndices.append (anIndex);
}
return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
QModelIndexList aSelected = GetSelected (theIndices, theCellId, theOrientation);
return aSelected.size() == 1 ? aSelected.first() : QModelIndex();
}
// =======================================================================

View File

@@ -146,6 +146,14 @@ public:
//! \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

View File

@@ -4,14 +4,21 @@ VInspector_CallBack.hxx
VInspector_CallBackMode.hxx
VInspector_Communicator.cxx
VInspector_Communicator.hxx
VInspector_DisplayActionType.hxx
VInspector_ItemBase.cxx
VInspector_ItemBase.hxx
VInspector_ItemContext.cxx
VInspector_ItemContext.hxx
VInspector_ItemFolderObject.cxx
VInspector_ItemFolderObject.hxx
VInspector_ItemEntityOwner.cxx
VInspector_ItemEntityOwner.hxx
VInspector_ItemGraphic3dClipPlane.cxx
VInspector_ItemGraphic3dClipPlane.hxx
VInspector_ItemGraphic3dCStructure.cxx
VInspector_ItemGraphic3dCStructure.hxx
VInspector_ItemGraphic3dGroup.cxx
VInspector_ItemGraphic3dGroup.hxx
VInspector_ItemGraphic3dTransformPers.cxx
VInspector_ItemGraphic3dTransformPers.hxx
VInspector_ItemHistoryElement.cxx
VInspector_ItemHistoryElement.hxx
VInspector_ItemHistoryRoot.cxx
@@ -19,15 +26,37 @@ VInspector_ItemHistoryRoot.hxx
VInspector_ItemHistoryType.cxx
VInspector_ItemHistoryType.hxx
VInspector_ItemHistoryTypeInfo.hxx
VInspector_ItemOpenGlElement.cxx
VInspector_ItemOpenGlElement.hxx
VInspector_ItemPresentableObject.cxx
VInspector_ItemPresentableObject.hxx
VInspector_ItemSelection.cxx
VInspector_ItemSelection.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_ItemSelectBasicsEntityOwner.cxx
VInspector_ItemSelectBasicsEntityOwner.hxx
VInspector_ItemSelectBasicsSensitiveEntity.cxx
VInspector_ItemSelectBasicsSensitiveEntity.hxx
VInspector_ItemSelectMgrFilter.cxx
VInspector_ItemSelectMgrFilter.hxx
VInspector_ItemSensitiveEntity.cxx
VInspector_ItemSensitiveEntity.hxx
VInspector_ItemSelectMgrSelection.cxx
VInspector_ItemSelectMgrSelection.hxx
VInspector_ItemSelectMgrSensitiveEntity.cxx
VInspector_ItemSelectMgrSensitiveEntity.hxx
VInspector_ItemV3dView.cxx
VInspector_ItemV3dView.hxx
VInspector_ItemV3dViewer.cxx
VInspector_ItemV3dViewer.hxx
VInspector_PrsOpenGlElement.cxx
VInspector_PrsOpenGlElement.hxx
VInspector_SelectionType.hxx
VInspector_TableModelValues.cxx
VInspector_TableModelValues.hxx
VInspector_ToolActionType.hxx
VInspector_ToolBar.cxx
VInspector_ToolBar.hxx

View File

@@ -0,0 +1,29 @@
// 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 VInspector_DisplayActionType_H
#define VInspector_DisplayActionType_H
//! \enum VInspector_DisplayActionType
enum VInspector_DisplayActionType
{
VInspector_DisplayActionType_NoneId, //!< No action activated
VInspector_DisplayActionType_DisplayId, //!< Display action
VInspector_DisplayActionType_RedisplayId, //!< Redisplay action
VInspector_DisplayActionType_EraseId, //!< Erase action
VInspector_DisplayActionType_RemoveId //!< Remove action
};
#endif

View File

@@ -17,6 +17,16 @@
#include <inspector/VInspector_ItemBase.hxx>
#include <inspector/VInspector_ItemContext.hxx>
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemBase::Reset()
{
myPresentationShape = TopoDS_Shape();
TreeModel_ItemBase::Reset();
}
// =======================================================================
// function : GetContext
// purpose :

View File

@@ -18,7 +18,10 @@
#include <AIS_InteractiveContext.hxx>
#include <Standard.hxx>
#include <TopoDS_Shape.hxx>
#include <inspector/TreeModel_ItemBase.hxx>
#include <inspector/ViewControl_EditType.hxx>
class VInspector_ItemBase;
typedef QExplicitlySharedDataPointer<VInspector_ItemBase> VInspector_ItemBasePtr;
@@ -29,7 +32,7 @@ class VInspector_ItemBase : public TreeModel_ItemBase
{
public:
//! Resets cached values
virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
virtual void Reset() Standard_OVERRIDE;
//! Sets the context
//! \param theLabel an object where the child items structure is found
@@ -43,6 +46,46 @@ public:
//! \return a context
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
//! 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 shape of the item parameters
//! \return generated shape of the item parameters
virtual TopoDS_Shape GetPresentationShape() const { initItem(); return myPresentationShape; }
//! 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:
//! Initialize the current item. It creates a backup of the specific item information
@@ -60,6 +103,7 @@ protected:
protected:
Handle(AIS_InteractiveContext) myContext; //!< the current context
TopoDS_Shape myPresentationShape; //!< item presentation shape
};
#endif

View File

@@ -15,7 +15,9 @@
#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>
@@ -109,6 +111,115 @@ QVariant VInspector_ItemContext::initValue (const int theItemRole) const
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 :

View File

@@ -47,6 +47,33 @@ public:
//! \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

View File

@@ -1,186 +0,0 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemSensitiveEntity.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <SelectMgr_SensitiveEntity.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_ItemEntityOwner::initValue(int theItemRole) const
{
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();
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(SelectBasics_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(SelectBasics_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(SelectBasics_EntityOwner) VInspector_ItemEntityOwner::getEntityOwner() const
{
initItem();
return myOwner;
}

View File

@@ -16,7 +16,14 @@
#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_ItemV3dViewer.hxx>
#include <AIS_InteractiveObject.hxx>
#include <Prs3d.hxx>
// =======================================================================
// function : initValue
@@ -24,13 +31,17 @@
// =======================================================================
QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
{
if (Column() == 0 && (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole))
if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
return QVariant();
ParentKind aParentKind = GetParentItemKind();
switch (aParentKind)
{
if (parentItemIsContext()) return "Properties";
else if (Row() == 0) return "Filters";
else return QVariant();
case ParentKind_ContextItem: return "Properties";
case ParentKind_PresentationItem: return "Properties";
case ParentKind_FolderItem: return Row() == 0 ? "Filters" : QVariant();
default: return QVariant();
}
return QVariant();
}
// =======================================================================
@@ -39,7 +50,30 @@ QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
// =======================================================================
int VInspector_ItemFolderObject::initRowCount() const
{
return parentItemIsContext() ? 1 : (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
ParentKind aParentKind = GetParentItemKind();
switch (aParentKind)
{
case ParentKind_ContextItem:
{
int aNbChildren = 2; // Filters, Viewer
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;
}
}
// =======================================================================
@@ -48,10 +82,29 @@ int VInspector_ItemFolderObject::initRowCount() const
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int theColumn)
{
if (parentItemIsContext())
return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
else
return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
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
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();
}
}
// =======================================================================
@@ -72,6 +125,62 @@ void VInspector_ItemFolderObject::Reset()
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) // "Filters", "Viewer"
return 0;
if (theRow == 2)
{
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 - 3)
{
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 :
@@ -84,10 +193,18 @@ void VInspector_ItemFolderObject::initItem() const
}
// =======================================================================
// function : parentItemIsContext
// function : GetParentItemKind
// purpose :
// =======================================================================
bool VInspector_ItemFolderObject::parentItemIsContext() const
VInspector_ItemFolderObject::ParentKind VInspector_ItemFolderObject::GetParentItemKind() const
{
return itemDynamicCast<VInspector_ItemContext> (Parent());
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;
}

View File

@@ -23,6 +23,8 @@
#include <NCollection_List.hxx>
#include <TCollection_AsciiString.hxx>
class Prs3d_Drawer;
class QItemSelectionModel;
class VInspector_ItemFolderObject;
@@ -49,6 +51,23 @@ public:
//! 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.
@@ -69,11 +88,6 @@ protected:
//! \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

View File

@@ -0,0 +1,212 @@
// 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 : GetCStructure
// purpose :
// =======================================================================
Handle(Graphic3d_CStructure) VInspector_ItemGraphic3dCStructure::GetCStructure() const
{
initItem();
return myCStructure;
}
// =======================================================================
// 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();
TreeModel_ItemBase::Init();
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemGraphic3dCStructure::Reset()
{
VInspector_ItemBase::Reset();
myCStructure = 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
{
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();
case 1: return rowCount();
default:
break;
}
return QVariant();
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemGraphic3dCStructure::GetTableRowCount() const
{
return 40;
}
// =======================================================================
// 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")
: (!aCStructure->Transformation().IsNull() ?
QVariant (ViewControl_Tools::ToString (aCStructure->Transformation()->Trsf()).ToCString()) : QVariant());
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 : 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();
}

View File

@@ -0,0 +1,103 @@
// 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 the current C structure, init item if it was not initialized yet
//! \return graphic C structure object
Standard_EXPORT Handle(Graphic3d_CStructure) GetCStructure() const;
//! 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 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_ItemGraphic3dCStructure(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:
Handle(Graphic3d_CStructure) myCStructure;
};
#endif

View File

@@ -0,0 +1,179 @@
// 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
{
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();
case 1: return rowCount();
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 : GetView
// purpose :
// =======================================================================
Handle(Graphic3d_ClipPlane) VInspector_ItemGraphic3dClipPlane::GetClipPlane() const
{
initItem();
return myClipPlane;
}
// =======================================================================
// 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();
}

View File

@@ -0,0 +1,120 @@
// 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 current clip plane, initialize if it was not initialized yet
Standard_EXPORT Handle(Graphic3d_ClipPlane) GetClipPlane() 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 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

View File

@@ -0,0 +1,211 @@
// 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_ItemOpenGlElement.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 : GetGroup
// purpose :
// =======================================================================
Handle(Graphic3d_Group) VInspector_ItemGraphic3dGroup::GetGroup() const
{
initItem();
return myGroup;
}
// =======================================================================
// 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;
int aNbElements = 0;
for (const OpenGl_ElementNode* aNodeIter = anOpenGlGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
{
aNbElements++;
}
return aNbElements;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemGraphic3dGroup::initValue (const int theItemRole) const
{
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();
case 1:
return rowCount();
case 2:
return ViewControl_Tools::GetPointerInfo (aGroup, true).ToCString();
default:
break;
}
return QVariant();
}
// =======================================================================
// function : GetElementNode
// purpose :
// =======================================================================
OpenGl_Element* VInspector_ItemGraphic3dGroup::GetElementNode (const int theRowId) const
{
int aCurrentIndex = 0;
Handle(Graphic3d_Group) aGroup = GetGroup();
Handle(OpenGl_Group) anOpenGlGroup = Handle(OpenGl_Group)::DownCast(aGroup);
if (anOpenGlGroup.IsNull())
return 0;
for (const OpenGl_ElementNode* aNodeIter = anOpenGlGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
{
if (theRowId == aCurrentIndex)
return aNodeIter->elem;
aCurrentIndex++;
}
return 0;
}
// =======================================================================
// 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 : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemGraphic3dGroup::createChild (int theRow, int theColumn)
{
return VInspector_ItemOpenGlElement::CreateItem (currentItem(), theRow, theColumn);
}

View File

@@ -0,0 +1,104 @@
// 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 the current graphic3d group, init item if it was not initialized yet
//! \return graphic group
Standard_EXPORT Handle(Graphic3d_Group) GetGroup() 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 element node or NULL
//! \param theRowId row index
//! \return element node
OpenGl_Element* GetElementNode(const int theRowId) 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_ItemGraphic3dGroup(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:
Handle(Graphic3d_Group) myGroup; //! current graphic group
};
#endif

View File

@@ -0,0 +1,164 @@
// 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 : GetTransformPers
// purpose :
// =======================================================================
Handle(Graphic3d_TransformPers) VInspector_ItemGraphic3dTransformPers::GetTransformPers() const
{
initItem();
return myTransformPers;
}
// =======================================================================
// 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
{
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();
case 1: return rowCount();
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();
}

View File

@@ -0,0 +1,98 @@
// 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 the current C structure, init item if it was not initialized yet
//! \return graphic C structure object
Standard_EXPORT Handle(Graphic3d_TransformPers) GetTransformPers() 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 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

View File

@@ -0,0 +1,223 @@
// 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_ItemOpenGlElement.hxx>
#include <inspector/VInspector_ItemGraphic3dGroup.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 : GetGroup
// purpose :
// =======================================================================
OpenGl_Element* VInspector_ItemOpenGlElement::GetElement() const
{
initItem();
return myElement;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemOpenGlElement::Init()
{
VInspector_ItemGraphic3dGroupPtr aParentItem = itemDynamicCast<VInspector_ItemGraphic3dGroup>(Parent());
myElement = aParentItem->GetElementNode (Row());
TreeModel_ItemBase::Init();
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemOpenGlElement::Reset()
{
VInspector_ItemBase::Reset();
myElement = 0;
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemOpenGlElement::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemOpenGlElement*>(this)->Init();
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemOpenGlElement::initRowCount() const
{
if (Column() != 0)
return 0;
return 0;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlElement::initValue (const int theItemRole) const
{
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
OpenGl_Element* anElement = GetElement();
if (anElement == 0)
return Column() == 0 ? "Empty element" : "";
switch (Column())
{
case 0:
{
if (theItemRole != Qt::ToolTipRole)
return "OpenGl_Element";
VInspector_ElementKind aKind = GetElementKind();
if (aKind == VInspector_ElementKind_PrimitiveArray) return "OpenGl_PrimitiveArray";
else if (aKind == VInspector_ElementKind_Text) return "OpenGl_Text";
else return "OpenGl_Element";
}
case 1:
return rowCount();
case 2:
return ViewControl_Tools::GetPointerInfo (anElement, true).ToCString();
default:
break;
}
return QVariant();
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemOpenGlElement::GetTableRowCount() const
{
return 40;
}
// =======================================================================
// function : GetTableData
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlElement::GetTableData (const int theRow, const int theColumn, const int theRole) const
{
if (theRole != Qt::DisplayRole)
return QVariant();
OpenGl_Element* anElement = GetElement();
if (anElement == 0)
return QVariant();
bool isFirstColumn = theColumn == 0;
VInspector_ElementKind aKind = GetElementKind();
if (aKind == VInspector_ElementKind_PrimitiveArray)
{
OpenGl_PrimitiveArray* aCElement = dynamic_cast<OpenGl_PrimitiveArray*>(anElement);
switch (theRow)
{
case 0: return isFirstColumn ? QVariant ("IsInitialized") : QVariant (aCElement->IsInitialized());
case 1: return isFirstColumn ? QVariant ("DrawMode") : QVariant (aCElement->DrawMode());
case 2: return isFirstColumn ? QVariant ("IsFillDrawMode") : QVariant (aCElement->IsFillDrawMode());
case 3: return isFirstColumn ? QVariant ("GetUID") : QVariant (aCElement->GetUID());
case 4: return isFirstColumn ? QVariant ("IndexVbo()")
: !aCElement->IndexVbo().IsNull() ? QVariant (ViewControl_Tools::GetPointerInfo (aCElement->IndexVbo()).ToCString()) : QVariant();
case 5: return isFirstColumn ? QVariant ("AttributesVbo()")
: !aCElement->AttributesVbo().IsNull() ? QVariant (ViewControl_Tools::GetPointerInfo (aCElement->AttributesVbo()).ToCString()) : QVariant();
case 6: return isFirstColumn ? QVariant ("Indices") : VInspector_Tools::ToVariant (aCElement->Indices());
case 7:
{
const Handle(Graphic3d_Buffer)& anAttributes = aCElement->Attributes();
return isFirstColumn ? QVariant ("Attributes") : VInspector_Tools::ToVariant (aCElement->Attributes());
}
case 8: return isFirstColumn ? QVariant ("Bounds") : VInspector_Tools::ToVariant (aCElement->Bounds());
default: return QVariant();
}
}
else if (aKind == VInspector_ElementKind_Text)
{
OpenGl_Text* aCmElement = dynamic_cast<OpenGl_Text*>(anElement);
switch (theRow)
{
case 0:
{
if (isFirstColumn)
return QVariant ("PixelTolerance");
//: QVariant (myContext->PixelTolerance());
return QVariant();
}
default: return QVariant();
}
}
return QVariant();
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemOpenGlElement::createChild (int theRow, int theColumn)
{
//if (theRow == 0)
// return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
//else
// return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
return TreeModel_ItemBasePtr();
}
// =======================================================================
// function : GetElementKind
// purpose :
// =======================================================================
VInspector_ItemOpenGlElement::VInspector_ElementKind VInspector_ItemOpenGlElement::GetElementKind() const
{
OpenGl_Element* anElement = GetElement();
if (anElement == 0)
return VInspector_ElementKind_Undefined;
if (dynamic_cast<OpenGl_PrimitiveArray*>(anElement))
return VInspector_ElementKind_PrimitiveArray;
else if (dynamic_cast<OpenGl_Text*>(anElement))
return VInspector_ElementKind_Text;
return VInspector_ElementKind_Undefined;
}

View File

@@ -0,0 +1,109 @@
// 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_ItemOpenGlElement_H
#define VInspector_ItemOpenGlElement_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
class Graphic3d_Group;
class OpenGl_Element;
class VInspector_ItemOpenGlElement;
typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlElement> VInspector_ItemOpenGlElementPtr;
//! \class VInspector_ItemOpenGlElement
//! 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_ItemOpenGlElement : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemOpenGlElementPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemOpenGlElementPtr (new VInspector_ItemOpenGlElement (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemOpenGlElement() Standard_OVERRIDE {};
//! Returns the current graphic3d group, init item if it was not initialized yet
//! \return graphic group
Standard_EXPORT OpenGl_Element* GetElement() 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 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:
enum VInspector_ElementKind
{
VInspector_ElementKind_PrimitiveArray, //!< OpenGl_PrimitiveArray
VInspector_ElementKind_Text, //!< OpenGl_Text
VInspector_ElementKind_Undefined //!< another OpenGl_Element kind
};
//! Returns kind of the current element
//! \return kind
VInspector_ElementKind GetElementKind() 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
VInspector_ItemOpenGlElement(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn), myElement (0) {}
private:
OpenGl_Element* myElement; //! current element
};
#endif

View File

@@ -18,15 +18,22 @@
#include <AIS_Shape.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <Aspect.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemSelection.hxx>
#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemPresentations.hxx>
#include <inspector/VInspector_ItemSelectMgrSelection.hxx>
#include <inspector/ViewControl_Table.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <NCollection_List.hxx>
#include <Prs3d.hxx>
#include <Prs3d_Drawer.hxx>
#include <PrsMgr.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <Standard_Version.hxx>
@@ -155,7 +162,7 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
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();
: /*19*/ ViewControl_Tools::ToString (aShape.Location()).ToCString();
}
default: break;
}
@@ -192,6 +199,11 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
// =======================================================================
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;
@@ -200,12 +212,12 @@ int VInspector_ItemPresentableObject::initRowCount() const
// iteration through sensitive privitives
for (anIO->Init(); anIO->More(); anIO->Next())
aRows++;
return aRows;
int aNbSelected = aRows;
#else
return !anIO.IsNull()
? anIO->Selections().Size()
: 0;
int aNbSelected = !anIO.IsNull() ? anIO->Selections().Size() : 0;
#endif
return aNbProperties + aNbSelected;
}
// =======================================================================
@@ -214,7 +226,12 @@ int VInspector_ItemPresentableObject::initRowCount() const
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemPresentableObject::createChild (int theRow, int theColumn)
{
return VInspector_ItemSelection::CreateItem(currentItem(), theRow, 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);
}
// =======================================================================
@@ -246,6 +263,11 @@ void VInspector_ItemPresentableObject::Init()
}
setInteractiveObject (anIO);
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIO);
if (!aShape.IsNull())
myPresentationShape = aShape->Shape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
@@ -292,40 +314,147 @@ QString VInspector_ItemPresentableObject::PointerInfo() const
}
// =======================================================================
// function : GetSelectedPresentations
// function : GetPresentations
// purpose :
// =======================================================================
NCollection_List<Handle(AIS_InteractiveObject)> VInspector_ItemPresentableObject::GetSelectedPresentations
(QItemSelectionModel* theSelectionModel)
void VInspector_ItemPresentableObject::GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
NCollection_List<Handle(AIS_InteractiveObject)> aResultList;
if (!theSelectionModel)
return aResultList;
QList<TreeModel_ItemBasePtr> anItems;
QModelIndexList anIndices = theSelectionModel->selectedIndexes();
for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
{
TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
if (!anItem || anItems.contains (anItem))
continue;
anItems.append (anItem);
}
if (Column() != 0)
return;
QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
{
TreeModel_ItemBasePtr anItem = *anItemIt;
VInspector_ItemPresentableObjectPtr aPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(anItem);
if (!aPrsItem)
continue;
Handle(AIS_InteractiveObject) aPresentation = aPrsItem->GetInteractiveObject();
if (aSelectedIds.contains ((size_t)aPresentation.operator->()))
continue;
aSelectedIds.append ((size_t)aPresentation.operator->());
if (!aPresentation.IsNull())
aResultList.Append (aPresentation);
}
return aResultList;
thePresentations.Append (GetInteractiveObject());
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemPresentableObject::GetTableRowCount() const
{
return 23;
}
// =======================================================================
// function : GetTableEditType
// purpose :
// =======================================================================
ViewControl_EditType VInspector_ItemPresentableObject::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_ItemPresentableObject::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_ItemPresentableObject::GetTableData (const int theRow, const int theColumn, const int theRole) const
{
if (theRole != Qt::DisplayRole)
return QVariant();
bool isFirstColumn = theColumn == 0;
Handle(AIS_InteractiveObject) aPrs = GetInteractiveObject();
switch (theRow)
{
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 ("HasWidth") : QVariant (aPrs->HasWidth());
case 4: return isFirstColumn ? QVariant ("Width") : QVariant (aPrs->Width());
case 5: return isFirstColumn ? QVariant ("CurrentFacingModel")
: QVariant (Aspect::TypeOfFacingModelToString (aPrs->CurrentFacingModel()));
case 6: return isFirstColumn ? QVariant ("IsInfinite") : QVariant (aPrs->IsInfinite());
case 7: return isFirstColumn ? QVariant ("HasColor") : QVariant (aPrs->HasColor());
case 8: return isFirstColumn ? QVariant ("HasMaterial") : QVariant (aPrs->HasMaterial());
case 9: return ViewControl_Table::SeparatorData();
case 10: return isFirstColumn ? QVariant (STANDARD_TYPE (SelectMgr_SelectableObject)->Name())
: ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
case 11: return ViewControl_Table::SeparatorData();
case 12: return isFirstColumn ? QVariant ("IsAutoHilight") : QVariant (aPrs->IsAutoHilight());
case 13: return isFirstColumn ? QVariant ("GlobalSelectionMode") : QVariant (aPrs->GlobalSelectionMode());
case 14: return ViewControl_Table::SeparatorData();
case 15: return isFirstColumn ? QVariant (STANDARD_TYPE (PrsMgr_PresentableObject)->Name())
: ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
case 16: return ViewControl_Table::SeparatorData();
case 17: return isFirstColumn ? QVariant ("TypeOfPresentation3d")
: QVariant (PrsMgr::TypeOfPresentation3dToString (aPrs->TypeOfPresentation3d()));
case 18: return isFirstColumn ? QVariant ("IsMutable") : QVariant (aPrs->IsMutable());
case 19: return isFirstColumn ? QVariant ("HasOwnPresentations") : QVariant (aPrs->HasOwnPresentations());
case 20: return isFirstColumn ? QVariant ("TransformationGeom")
: (!aPrs->TransformationGeom().IsNull()
? QVariant (ViewControl_Tools::ToString(aPrs->TransformationGeom()->Trsf()).ToCString()) : QVariant());
case 21: return isFirstColumn ? QVariant ("LocalTransformationGeom")
: (!aPrs->LocalTransformationGeom().IsNull()
? QVariant (ViewControl_Tools::ToString(aPrs->LocalTransformationGeom()->Trsf()).ToCString()) : QVariant());
case 22: return isFirstColumn ? QVariant ("ResetTransformation") : (!aPrs->LocalTransformationGeom().IsNull());
default: return QVariant();
}
return QVariant();
}
// =======================================================================
// function : SetTableData
// purpose :
// =======================================================================
bool VInspector_ItemPresentableObject::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;
}

View File

@@ -55,11 +55,36 @@ public:
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns presentations, which items are selected in tree view
//! \param theSelectionModel a selection model
//! \return container of presentations
Standard_EXPORT static NCollection_List<Handle(AIS_InteractiveObject)> GetSelectedPresentations
(QItemSelectionModel* theSelectionModel);
//! Returns presentation of the attribute to be visualized in the view
//! \thePresentations [out] container of presentation handles to be visualized
Standard_EXPORT virtual void 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 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:

View File

@@ -0,0 +1,150 @@
// 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
{
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 (NULL).IsNull())
aNbProperties++;
if (!aPresentation->GetHilightPresentation (NULL).IsNull())
aNbProperties++;
for (PrsMgr_Presentations::Iterator aPrsIter (aPresentation->Presentations()); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
if (!aPrs3d.IsNull() && !aPrs3d->Presentation().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().Presentation();
if (aPrs3d.IsNull() || aPrs3d->Presentation().IsNull())
continue;
if (theRowId - aNextPresentationIndex == aCurrentIndex)
{
theName = QString ("Prs3d_Presentation (mode = %1)").arg (aPrsIter.ChangeValue().Mode()).toStdString().c_str();
return aPrs3d->Presentation();
}
aCurrentIndex++;
}
return Handle(Prs3d_Presentation)();
}

View File

@@ -13,31 +13,35 @@
// 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
#ifndef VInspector_ItemPresentations_H
#define VInspector_ItemPresentations_H
#include <AIS_InteractiveObject.hxx>
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
class QItemSelectionModel;
#include <TCollection_AsciiString.hxx>
#include <Prs3d_Presentation.hxx>
class VInspector_ItemEntityOwner;
typedef QExplicitlySharedDataPointer<VInspector_ItemEntityOwner> VInspector_ItemEntityOwnerPtr;
class VInspector_ItemPresentations;
typedef QExplicitlySharedDataPointer<VInspector_ItemPresentations> VInspector_ItemPresentationsPtr;
//! \class VInspector_ItemPresentableObject
//! Item for selection entity owner. The parent is sensitive entity item, there are no children
class VInspector_ItemEntityOwner : public VInspector_ItemBase
//! \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_ItemEntityOwnerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemEntityOwnerPtr (new VInspector_ItemEntityOwner (theParent, theRow, theColumn)); }
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_ItemEntityOwner() Standard_OVERRIDE {};
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;
@@ -45,45 +49,33 @@ public:
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns the current entity owner
Handle(SelectBasics_EntityOwner) EntityOwner() const { return myOwner; }
protected:
//! \return number of children.
virtual int initRowCount() const Standard_OVERRIDE{ return 0; }
//! 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;
//! 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(); }
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! param theParent a parent item
VInspector_ItemEntityOwner(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
VInspector_ItemPresentations(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;
private:
Handle(SelectBasics_EntityOwner) myOwner; //!< the current entity owner
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,179 @@
// 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;
Standard_EXPORT Handle(Prs3d_BasicAspect) GetAspect() const;
//! 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;
//! 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 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

View File

@@ -0,0 +1,587 @@
// 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
{
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());
}
case 1:
return rowCount();
case 2:
{
if (!aNullDrawer)
return VInspector_Tools::GetPointerInfo (aDrawer, true).ToCString();
break;
}
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_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
if (!aParentItem)
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)
{
VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
if (aParentItem)
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 : GetDrawer
// purpose :
// =======================================================================
Handle(Prs3d_Drawer) VInspector_ItemPrs3dDrawer::GetDrawer() const
{
initItem();
return myDrawer;
}
// =======================================================================
// 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;
}

View File

@@ -0,0 +1,129 @@
// 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 current drawer, initialize the drawer if it was not initialized yet
Standard_EXPORT Handle(Prs3d_Drawer) GetDrawer() const;
//! 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;
private:
//! 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; }
private:
//! 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

View File

@@ -0,0 +1,185 @@
// 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 <Graphic3d.hxx>
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemPrs3dPresentation::initValue (int theItemRole) const
{
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);
myPresentationShape = VInspector_Tools::CreateShape (aPresentation->MinMaxValues());
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 : GetInteractiveObject
// purpose :
// =======================================================================
Handle(Prs3d_Presentation) VInspector_ItemPrs3dPresentation::GetPresentation() const
{
initItem();
return myPresentation;
}
// =======================================================================
// 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 : 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 (Graphic3d_Structure)->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();
}

View File

@@ -0,0 +1,104 @@
// 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 the current presentation, init item if it was not initialized yet
//! \return presentation object
Standard_EXPORT Handle(Prs3d_Presentation) GetPresentation() 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 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;
//! Returns number of item selected
//! \return rows count
virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Set 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

View File

@@ -0,0 +1,325 @@
// 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_Tools.hxx>
#include <SelectMgr_SensitiveEntity.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
{
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();
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*/ ViewControl_Tools::ToString (aShape.Location()).ToCString();
}
case 21:
{
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 ViewControl_Tools::ToString (BROwnr->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_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();
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;
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 : getEntityOwner
// purpose :
// =======================================================================
Handle(SelectBasics_EntityOwner) VInspector_ItemSelectBasicsEntityOwner::getEntityOwner() const
{
initItem();
return myOwner;
}
// =======================================================================
// 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 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;
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(AIS_InteractiveObject) aPrs = GetInteractiveObject();
switch (theRow)
{
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 ("HasWidth") : QVariant (aPrs->HasWidth());
case 4: return isFirstColumn ? QVariant ("Width") : QVariant (aPrs->Width());
case 5: return isFirstColumn ? QVariant ("CurrentFacingModel")
: QVariant (Aspect::TypeOfFacingModelToString (aPrs->CurrentFacingModel()));
case 6: return isFirstColumn ? QVariant ("IsInfinite") : QVariant (aPrs->IsInfinite());
case 7: return isFirstColumn ? QVariant ("HasColor") : QVariant (aPrs->HasColor());
case 8: return isFirstColumn ? QVariant ("HasMaterial") : QVariant (aPrs->HasMaterial());
case 9: return ViewControl_Table::SeparatorData();
case 10: return isFirstColumn ? QVariant (STANDARD_TYPE (SelectMgr_SelectableObject)->Name())
: ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
case 11: return ViewControl_Table::SeparatorData();
case 12: return isFirstColumn ? QVariant ("IsAutoHilight") : QVariant (aPrs->IsAutoHilight());
case 13: return isFirstColumn ? QVariant ("GlobalSelectionMode") : QVariant (aPrs->GlobalSelectionMode());
case 14: return ViewControl_Table::SeparatorData();
case 15: return isFirstColumn ? QVariant (STANDARD_TYPE (PrsMgr_PresentableObject)->Name())
: ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
case 16: return ViewControl_Table::SeparatorData();
case 17: return isFirstColumn ? QVariant ("TypeOfPresentation3d")
: QVariant (PrsMgr::TypeOfPresentation3dToString (aPrs->TypeOfPresentation3d()));
case 18: return isFirstColumn ? QVariant ("IsMutable") : QVariant (aPrs->IsMutable());
case 19: return isFirstColumn ? QVariant ("HasOwnPresentations") : QVariant (aPrs->HasOwnPresentations());
default: return QVariant();
}*/
return QVariant();
}
// =======================================================================
// function : SetTableData
// purpose :
// =======================================================================
bool VInspector_ItemSelectBasicsEntityOwner::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());
default: return false;
}*/
return true;
}

View File

@@ -0,0 +1,116 @@
// 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 the current entity owner
Handle(SelectBasics_EntityOwner) EntityOwner() const { return myOwner; }
//! 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:
//! 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;
private:
Handle(SelectBasics_EntityOwner) myOwner; //!< the current entity owner
};
#endif

View File

@@ -0,0 +1,487 @@
// 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 <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_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 : GetSensitiveEntity
// purpose :
// =======================================================================
Handle(SelectBasics_SensitiveEntity) VInspector_ItemSelectBasicsSensitiveEntity::GetSensitiveEntity() const
{
initItem();
return myEntity;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
int VInspector_ItemSelectBasicsSensitiveEntity::initRowCount() const
{
return 0;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemSelectBasicsSensitiveEntity::initValue (int theItemRole) const
{
Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
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_ItemSelectBasicsEntityOwner::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();
myPresentationShape = buildPresentationShape (myEntity);
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 = Handle(Select3D_SensitiveEntity)::DownCast (GetSensitiveEntity());
if (aBaseEntity.IsNull())
return;
myPresentation = new AIS_Shape (myPresentationShape);
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();
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());
}
return QVariant();
}
// =======================================================================
// 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 = Handle(Select3D_SensitiveEntity)::DownCast (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();
}
}
}
//Select3D_SensitivePrimitiveArray
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 = Handle(Select3D_SensitiveEntity)::DownCast (theEntity);
if (aBaseEntity.IsNull())
return TopoDS_Shape();
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
aBuilder.MakeCompound (aCompound);
aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex(aBaseEntity->CenterOfGeometry()));
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 = VInspector_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_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;
}

View File

@@ -0,0 +1,132 @@
// 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_SensitiveEntity.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
class QItemSelectionModel;
class SelectBasics_EntityOwner;
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 {};
//! \return the current sensitive entity
Standard_EXPORT Handle(SelectBasics_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;
//! 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;
//! 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);
private:
//! 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

View File

@@ -13,7 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <inspector/VInspector_ItemSelection.hxx>
#include <inspector/VInspector_ItemSelectMgrSelection.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <SelectMgr_EntityOwner.hxx>
@@ -22,7 +22,7 @@
#include <Standard_Version.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ItemSensitiveEntity.hxx>
#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
@@ -35,7 +35,7 @@
// function : getSelection
// purpose :
// =======================================================================
Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
Handle(SelectMgr_Selection) VInspector_ItemSelectMgrSelection::getSelection() const
{
initItem();
return mySelection;
@@ -45,7 +45,7 @@ Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemSelection::initRowCount() const
int VInspector_ItemSelectMgrSelection::initRowCount() const
{
Handle(SelectMgr_Selection) aSelection = getSelection();
#if OCC_VERSION_HEX < 0x070201
@@ -62,7 +62,7 @@ int VInspector_ItemSelection::initRowCount() const
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemSelection::initValue (int theItemRole) const
QVariant VInspector_ItemSelectMgrSelection::initValue (int theItemRole) const
{
switch (theItemRole)
{
@@ -140,22 +140,23 @@ QVariant VInspector_ItemSelection::initValue (int theItemRole) const
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelection::createChild (int theRow, int theColumn)
TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelection::createChild (int theRow, int theColumn)
{
return VInspector_ItemSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
return VInspector_ItemSelectMgrSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemSelection::Init()
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++)
@@ -163,7 +164,7 @@ void VInspector_ItemSelection::Init()
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
#endif
{
if (aCurrentId != aRowId)
if (aCurrentId != aRowId - aDeltaIndex)
continue;
#if OCC_VERSION_HEX < 0x070201
mySelection = anIO->CurrentSelection();
@@ -179,7 +180,7 @@ void VInspector_ItemSelection::Init()
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemSelection::Reset()
void VInspector_ItemSelectMgrSelection::Reset()
{
// an empty method to don't clear the main label, otherwise the model will be empty
TreeModel_ItemBase::Reset();
@@ -191,10 +192,10 @@ void VInspector_ItemSelection::Reset()
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemSelection::initItem() const
void VInspector_ItemSelectMgrSelection::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemSelection*>(this)->Init();
const_cast<VInspector_ItemSelectMgrSelection*>(this)->Init();
// an empty method to don't initialize the main label, as it was not cleared in Reset()
}

View File

@@ -13,30 +13,30 @@
// 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
#ifndef VInspector_ItemSelectMgrSelection_H
#define VInspector_ItemSelectMgrSelection_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <SelectMgr_Selection.hxx>
class VInspector_ItemSelection;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelection> VInspector_ItemSelectionPtr;
class VInspector_ItemSelectMgrSelection;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelection> VInspector_ItemSelectMgrSelectionPtr;
//! \class VInspector_ItemSelection
//! \class VInspector_ItemSelectMgrSelection
//! Item about SelectMgr_Selection.
//! Parent is presentable object item, children are sensitive entity items
class VInspector_ItemSelection : public VInspector_ItemBase
class VInspector_ItemSelectMgrSelection : 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)); }
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_ItemSelection() {};
virtual ~VInspector_ItemSelectMgrSelection() {};
//! \return current selection value
Standard_EXPORT Handle(SelectMgr_Selection) getSelection() const;
@@ -73,7 +73,7 @@ private:
//! Constructor
//! param theParent a parent item
VInspector_ItemSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
VInspector_ItemSelectMgrSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:

View File

@@ -14,7 +14,8 @@
// commercial license or contractual agreement.
#include <inspector/VInspector_ItemSensitiveEntity.hxx>
#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
#include <inspector/VInspector_ItemSelectBasicsSensitiveEntity.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
@@ -25,9 +26,11 @@
#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_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>
@@ -38,7 +41,7 @@
// function : GetSensitiveEntity
// purpose :
// =======================================================================
Handle(SelectMgr_SensitiveEntity) VInspector_ItemSensitiveEntity::GetSensitiveEntity() const
Handle(SelectMgr_SensitiveEntity) VInspector_ItemSelectMgrSensitiveEntity::GetSensitiveEntity() const
{
initItem();
return myEntity;
@@ -48,10 +51,22 @@ Handle(SelectMgr_SensitiveEntity) VInspector_ItemSensitiveEntity::GetSensitiveEn
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
int VInspector_ItemSelectMgrSensitiveEntity::initRowCount() const
{
Handle(SelectMgr_SensitiveEntity) aBase = GetSensitiveEntity();
Handle(SelectBasics_EntityOwner) anOwner = aBase->BaseSensitive()->OwnerId();
if (GetSensitiveEntity()->BaseSensitive().IsNull())
return 0;
return 2;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemSelectMgrSensitiveEntity::initValue (int theItemRole) const
{
Handle(SelectMgr_SensitiveEntity) anEntity = GetSensitiveEntity();
Handle(SelectBasics_EntityOwner) anOwner = anEntity->BaseSensitive()->OwnerId();
switch (theItemRole)
{
@@ -61,8 +76,8 @@ QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
{
switch (Column())
{
case 0: return myEntity->DynamicType()->Name();
case 2: return VInspector_Tools::GetPointerInfo (GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
case 0: return anEntity->DynamicType()->Name();
/*case 2: return VInspector_Tools::GetPointerInfo (GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
case 3:
{
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
@@ -89,7 +104,7 @@ QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
if (BROwnr.IsNull())
return QVariant();
return anOwner->Priority();
}
}*/
default:
break;
}
@@ -107,7 +122,7 @@ QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
}
}
VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
VInspector_ItemSelectMgrSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelection>(Parent());
if (aParentItem)
return aParentItem->data(QModelIndex(), theItemRole);
break;
@@ -122,18 +137,23 @@ QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSensitiveEntity::createChild (int theRow, int theColumn)
TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntity::createChild (int theRow, int theColumn)
{
return VInspector_ItemEntityOwner::CreateItem (currentItem(), theRow, 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_ItemSensitiveEntity::Init()
void VInspector_ItemSelectMgrSensitiveEntity::Init()
{
VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
VInspector_ItemSelectMgrSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelection>(Parent());
Handle(SelectMgr_Selection) aSelection = aParentItem->getSelection();
@@ -161,7 +181,7 @@ void VInspector_ItemSensitiveEntity::Init()
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemSensitiveEntity::Reset()
void VInspector_ItemSelectMgrSensitiveEntity::Reset()
{
// an empty method to don't clear the main label, otherwise the model will be empty
TreeModel_ItemBase::Reset();
@@ -172,18 +192,18 @@ void VInspector_ItemSensitiveEntity::Reset()
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemSensitiveEntity::initItem() const
void VInspector_ItemSelectMgrSensitiveEntity::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemSensitiveEntity*>(this)->Init();
const_cast<VInspector_ItemSelectMgrSensitiveEntity*>(this)->Init();
}
// =======================================================================
// function : getEntityOwner
// purpose :
// =======================================================================
Handle(SelectBasics_EntityOwner) VInspector_ItemSensitiveEntity::getEntityOwner() const
Handle(SelectBasics_EntityOwner) VInspector_ItemSelectMgrSensitiveEntity::getEntityOwner() const
{
initItem();
@@ -193,3 +213,30 @@ Handle(SelectBasics_EntityOwner) VInspector_ItemSensitiveEntity::getEntityOwner(
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();
}
}

View File

@@ -13,8 +13,8 @@
// 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
#ifndef VInspector_ItemSelectMgrSensitiveEntity_H
#define VInspector_ItemSelectMgrSensitiveEntity_H
#include <SelectMgr_SensitiveEntity.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
@@ -22,24 +22,24 @@
#include <inspector/VInspector_ItemBase.hxx>
class SelectBasics_EntityOwner;
class VInspector_ItemSensitiveEntity;
class VInspector_ItemSelectMgrSensitiveEntity;
typedef QExplicitlySharedDataPointer<VInspector_ItemSensitiveEntity> VInspector_ItemSensitiveEntityPtr;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSensitiveEntity> VInspector_ItemSelectMgrSensitiveEntityPtr;
//! \class VInspector_ItemSensitiveEntity
//! \class VInspector_ItemSelectMgrSensitiveEntity
//! The item shows information about SelectBasics_EntityOwner.
//! The parent is item selection, children are item entity owners
class VInspector_ItemSensitiveEntity : public VInspector_ItemBase
class VInspector_ItemSelectMgrSensitiveEntity : 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)); }
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_ItemSensitiveEntity() Standard_OVERRIDE {};
virtual ~VInspector_ItemSelectMgrSensitiveEntity() Standard_OVERRIDE {};
//! \return the current sensitive entity
Standard_EXPORT Handle(SelectMgr_SensitiveEntity) GetSensitiveEntity() const;
@@ -50,13 +50,22 @@ public:
//! 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 !GetSensitiveEntity()->BaseSensitive().IsNull() ? 1 : 0; }
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
@@ -79,7 +88,7 @@ private:
//! Constructor
//! param theParent a parent item
VInspector_ItemSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
VInspector_ItemSelectMgrSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:

View File

@@ -0,0 +1,193 @@
// 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 <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemGraphic3dClipPlane.hxx>
#include <inspector/VInspector_ItemV3dViewer.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
Handle(Graphic3d_ClipPlane) VInspector_ItemV3dView::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 : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemV3dView::initRowCount() const
{
if (Column() != 0)
return 0;
return 1; // ClipPlanes
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemV3dView::initValue (const int theItemRole) const
{
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();
case 1: return rowCount();
default:
break;
}
return QVariant();
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemV3dView::Init()
{
VInspector_ItemV3dViewerPtr aParentItem = itemDynamicCast<VInspector_ItemV3dViewer>(Parent());
Handle(V3d_View) aView;
if (aParentItem)
{
Handle(V3d_Viewer) aViewer = aParentItem->GetViewer();
aViewer->InitActiveViews();
aView = aViewer->ActiveView();
}
setView (aView);
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 : GetView
// purpose :
// =======================================================================
Handle(V3d_View) VInspector_ItemV3dView::GetView() const
{
initItem();
return myView;
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemV3dView::GetTableRowCount() const
{
return 0;
}
// =======================================================================
// function : GetTableEditType
// purpose :
// =======================================================================
ViewControl_EditType VInspector_ItemV3dView::GetTableEditType (const int theRow, const int) const
{
return ViewControl_EditType_None;
}
// =======================================================================
// function : GetTableEnumValues
// purpose :
// =======================================================================
QList<QVariant> VInspector_ItemV3dView::GetTableEnumValues (const int theRow, 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();
}
// =======================================================================
// function : SetTableData
// purpose :
// =======================================================================
bool VInspector_ItemV3dView::SetTableData (const int theRow, const int, const QVariant& theValue)
{
return true;
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemV3dView::createChild (int theRow, int theColumn)
{
if (theRow == 0)
return VInspector_ItemGraphic3dClipPlane::CreateItem (currentItem(), theRow, theColumn);
return TreeModel_ItemBasePtr();
}

View File

@@ -0,0 +1,124 @@
// 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 <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 current drawer, initialize the drawer if it was not initialized yet
Standard_EXPORT Handle(V3d_View) GetView() const;
//! Returns clip plane of the row if possible
//! \param theRow child row index
Standard_EXPORT Handle(Graphic3d_ClipPlane) GetClipPlane(const int theRow);
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 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

View File

@@ -0,0 +1,174 @@
// 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 : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemV3dViewer::initRowCount() const
{
if (Column() != 0)
return 0;
return 1;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemV3dViewer::initValue (const int theItemRole) const
{
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();
case 1: return rowCount();
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 : GetViewer
// purpose :
// =======================================================================
Handle(V3d_Viewer) VInspector_ItemV3dViewer::GetViewer() const
{
initItem();
return myViewer;
}
// =======================================================================
// 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);
}

View File

@@ -0,0 +1,120 @@
// 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 {};
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns current drawer, initialize the drawer if it was not initialized yet
Standard_EXPORT Handle(V3d_Viewer) GetViewer() 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 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

View File

@@ -0,0 +1,50 @@
// 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_PrsOpenGlElement.hxx>
#include <OpenGl_Workspace.hxx>
IMPLEMENT_STANDARD_RTTIEXT(VInspector_PrsOpenGlElement, AIS_InteractiveObject)
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
VInspector_PrsOpenGlElement::VInspector_PrsOpenGlElement ()
: AIS_InteractiveObject ()
{
}
// =======================================================================
// function : Compute
// purpose :
// =======================================================================
void VInspector_PrsOpenGlElement::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer /*theMode*/)
{
thePrs->Clear();
Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (thePrs->NewGroup());
aGroup->SetDestroyElements (Standard_False);
for (NCollection_List<OpenGl_Element*>::Iterator anElementsIt (myElements); anElementsIt.More(); anElementsIt.Next())
{
OpenGl_Element* anElement = anElementsIt.Value();
aGroup->AddElement (anElement);
}
// invalidate bounding box of the scene
thePrsMgr->StructureManager()->Update();
}

View File

@@ -0,0 +1,68 @@
// 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_PrsOpenGlElement_H
#define VInspector_PrsOpenGlElement_H
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <AIS_InteractiveObject.hxx>
#include <NCollection_List.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_Workspace;
DEFINE_STANDARD_HANDLE(VInspector_PrsOpenGlElement, AIS_InteractiveObject)
//! \class VInspector_PrsOpenGlElement
//! Presentation to display container of OpenGl_Element
class VInspector_PrsOpenGlElement : public AIS_InteractiveObject
{
public:
//! Constructor
Standard_EXPORT VInspector_PrsOpenGlElement();
//! Destructor
~VInspector_PrsOpenGlElement() { myElements.Clear(); }
//! Fills internal container of elements
//! \param theElements elements to be displayed
void Set (const NCollection_List<OpenGl_Element*>& theElements) { myElements = theElements; }
private:
//! Calculates the 3D view aPresentation and its updates.
//! \param thePrsMgr processor for the presentation
//! \param thePrs presentation
//! \param theMode presentable object display mode
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Recovers and calculates any sensitive primitive,
//! aSelection, available in Shape mode, specified by
//! aMode
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) {}
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(VInspector_PrsOpenGlElement, AIS_InteractiveObject)
private:
NCollection_List<OpenGl_Element*> myElements;
};
#endif

View File

@@ -0,0 +1,149 @@
// 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_TableModel.hxx>
#include <inspector/ViewControl_TableModelFilter.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QFont>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
VInspector_TableModelValues::VInspector_TableModelValues (const TreeModel_ItemBasePtr& theItem)
: ViewControl_TableModelValues(), myItem (theItem)
{
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);
SetUseTableSeparateSize (false);
SetUseTableProperties (false);
SetUseTablePropertiesXStep (false, -1);
}
// =======================================================================
// function : Data
// purpose :
// =======================================================================
QVariant VInspector_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const
{
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 (theRow, theColumn) != ViewControl_EditType_None)
return ViewControl_TableModelValues::EditCellColor();
}
default:
return GetItem()->GetTableData (theRow, 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;
return GetItem()->SetTableData (theRow, 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 : GetRangeValues
// purpose :
// =======================================================================
int VInspector_TableModelValues::GetValuesCount () const
{
return GetItem()->GetTableRowCount() * 2;
}
// =======================================================================
// function : GetEditType
// purpose :
// =======================================================================
ViewControl_EditType VInspector_TableModelValues::GetEditType (const int theRow, const int theColumn) const
{
if (theColumn == 0)
return ViewControl_EditType_None;
return GetItem()->GetTableEditType (theRow, theColumn);
}
// =======================================================================
// function : GetEnumValues
// purpose :
// =======================================================================
QList<QVariant> VInspector_TableModelValues::GetEnumValues (const int theRow, const int theColumn) const
{
if (theColumn != 1)
return QList<QVariant>();
return GetItem()->GetTableEnumValues (theRow, theColumn);
}
// =======================================================================
// function : GetItem
// purpose :
// =======================================================================
VInspector_ItemBasePtr VInspector_TableModelValues::GetItem() const
{
return itemDynamicCast<VInspector_ItemBase>(myItem);
}

View File

@@ -0,0 +1,90 @@
// 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/ViewControl_TableModelFilter.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <inspector/TreeModel_ItemBase.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);
//! 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
{ (void)theParent; return 2; }
//! 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 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 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 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;
private:
//!< Returns source item base
VInspector_ItemBasePtr GetItem() const;
private:
TreeModel_ItemBasePtr myItem; //!< source item base
};
#endif

View File

@@ -15,14 +15,27 @@
#include <inspector/VInspector_Tools.hxx>
#include <inspector/ViewControl_TableModelValues.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_TableModelValues.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 <BRepTools.hxx>
#include <gp_Trsf.hxx>
#include <Graphic3d.hxx>
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_BoundBuffer.hxx>
#include <SelectMgr_StateOfSelection.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
#include <SelectMgr_TypeOfBVHUpdate.hxx>
@@ -234,11 +247,23 @@ void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveCo
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);
anOwnersIt.More(); anOwnersIt.Next())
{
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (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();
}
@@ -467,28 +492,6 @@ TCollection_AsciiString VInspector_Tools::OrientationToName (const TopAbs_Orient
return aSStream.str().c_str();
}
// =======================================================================
// function : LocationToName
// purpose :
// =======================================================================
TCollection_AsciiString VInspector_Tools::LocationToName (const TopLoc_Location& theLocation)
{
gp_Trsf aTrsf = theLocation.Transformation();
TCollection_AsciiString aValues;
for (int aRowId = 1; aRowId <= 3; aRowId++)
{
for (int aColId = 1; aColId <= 4; aColId++) {
aValues += TCollection_AsciiString (aTrsf.Value(aRowId, aColId));
if (aColId != 4)
aValues += ",";
}
if (aRowId != 3)
aValues += " ";
}
return aValues;
}
// =======================================================================
// function : ReadShape
// purpose :
@@ -502,3 +505,147 @@ TopoDS_Shape VInspector_Tools::ReadShape (const TCollection_AsciiString& theFile
return aShape;
}
// =======================================================================
// function : GetPropertyTableValues
// purpose :
// =======================================================================
void VInspector_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
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));
}
namespace
{
static Standard_CString VInspector_Table_PrintDisplayActionType[5] =
{
"None", "Display", "Redisplay", "Erase", "Remove"
};
}
//=======================================================================
//function : DisplayActionTypeToString
//purpose :
//=======================================================================
Standard_CString VInspector_Tools::DisplayActionTypeToString (VInspector_DisplayActionType theType)
{
return VInspector_Table_PrintDisplayActionType[theType];
}
//=======================================================================
//function : DisplayActionTypeFromString
//purpose :
//=======================================================================
Standard_Boolean VInspector_Tools::DisplayActionTypeFromString (Standard_CString theTypeString,
VInspector_DisplayActionType& theType)
{
TCollection_AsciiString aName (theTypeString);
for (Standard_Integer aTypeIter = 0; aTypeIter <= VInspector_DisplayActionType_RemoveId; ++aTypeIter)
{
Standard_CString aTypeName = VInspector_Table_PrintDisplayActionType[aTypeIter];
if (aName == aTypeName)
{
theType = VInspector_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 Bnd_Box& theBoundingBox)
{
if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole() ||
theBoundingBox.IsXThin (Precision::Confusion()) ||
theBoundingBox.IsYThin (Precision::Confusion()) ||
theBoundingBox.IsZThin (Precision::Confusion()))
return TopoDS_Shape();
BRepPrimAPI_MakeBox aBoxBuilder(theBoundingBox.CornerMin(), theBoundingBox.CornerMax());
return aBoxBuilder.Shape();
}
//=======================================================================
//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 : ToString
//purpose :
//=======================================================================
QString VInspector_Tools::ToString (const Graphic3d_Attribute& theAttribute)
{
Graphic3d_TypeOfAttribute anId = theAttribute.Id;
Graphic3d_TypeOfData aDataType = theAttribute.DataType;
QString anInfo = Graphic3d::TypeOfAttributeToString (anId);
anInfo += ": ";
anInfo += Graphic3d::TypeOfDataToString (aDataType);
return anInfo;
}

View File

@@ -17,6 +17,9 @@
#define VInspector_Tools_H
#include <AIS_InteractiveContext.hxx>
#include <Bnd_Box.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Select3D_BndBox3d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
@@ -26,13 +29,21 @@
#include <TopoDS_Shape.hxx>
#include <inspector/VInspector_CallBackMode.hxx>
#include <inspector/VInspector_DisplayActionType.hxx>
#include <inspector/VInspector_SelectionType.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
@@ -50,7 +61,7 @@ public:
//! \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);
const bool isShortInfo = true);
//! Returns number of selected owners for presentation
//! \param theContext an interactive context
@@ -128,15 +139,67 @@ public:
//! \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,
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 (VInspector_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 VInspector_DisplayActionType DisplayActionTypeFromString (Standard_CString theTypeString)
{
VInspector_DisplayActionType aType = VInspector_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,
VInspector_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 Bnd_Box& 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);
Standard_EXPORT static QString ToString (const Graphic3d_Attribute& theAttribute);
};
#endif

View File

@@ -17,9 +17,9 @@
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ItemSensitiveEntity.hxx>
#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Standard_WarningsDisable.hxx>
@@ -64,6 +64,8 @@ VInspector_ViewModel::VInspector_ViewModel (QObject* theParent)
SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
SetHeaderItem (21, TreeModel_HeaderSection ("Owner Location", -1, true)); // ItemEntityOwner
}
// =======================================================================
@@ -95,7 +97,8 @@ void VInspector_ViewModel::SetContext (const Handle(AIS_InteractiveContext)& the
// fill root item by the application
for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
itemDynamicCast<VInspector_ItemContext>(myRootItems[aColId])->SetContext (theContext);
EmitLayoutChanged();
UpdateTreeModel();
}
// =======================================================================
@@ -166,11 +169,11 @@ void VInspector_ViewModel::GetSelectedOwners (QItemSelectionModel* theSelectionM
{
TreeModel_ItemBasePtr anItem = *anItemIt;
Handle(SelectBasics_EntityOwner) anEntityOwner;
if (VInspector_ItemEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemEntityOwner>(anItem))
if (VInspector_ItemSelectBasicsEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemSelectBasicsEntityOwner>(anItem))
{
anEntityOwner = anOwnerItem->EntityOwner();
}
else if (VInspector_ItemSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(anItem))
else if (VInspector_ItemSelectMgrSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntity>(anItem))
{
anEntityOwner = aSensItem->GetSensitiveEntity()->BaseSensitive()->OwnerId();
}

View File

@@ -16,6 +16,8 @@
#include <inspector/VInspector_Window.hxx>
#include <AIS_Shape.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
@@ -24,19 +26,23 @@
#include <inspector/ViewControl_MessageDialog.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_CallBack.hxx>
#include <inspector/VInspector_Communicator.hxx>
#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemOpenGlElement.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_PrsOpenGlElement.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_ViewModelHistory.hxx>
#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_TreeView.hxx>
#include <inspector/View_Widget.hxx>
@@ -56,6 +62,9 @@
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
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;
@@ -96,6 +105,8 @@ VInspector_Window::VInspector_Window()
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);
myTreeView->setModel (aTreeModel);
// hide Visibility column
@@ -110,12 +121,23 @@ VInspector_Window::VInspector_Window()
QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
myTreeView->setSelectionModel (aSelModel);
connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
aParentLay->addWidget(myTreeView, 1, 0);
aParentLay->setRowStretch (1, 1);
myMainWindow->setCentralWidget (aCentralWidget);
// property view
myPropertyView = new ViewControl_PropertyView (myMainWindow,
QSize(VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH, VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT));
myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool)));
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,
@@ -280,6 +302,123 @@ void VInspector_Window::UpdateContent()
}
}
// =======================================================================
// function : GetSelectedPresentations
// purpose :
// =======================================================================
NCollection_List<Handle(AIS_InteractiveObject)> VInspector_Window::GetSelectedPresentations (QItemSelectionModel* theModel)
{
NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations;
QList<TreeModel_ItemBasePtr> anItems;
QModelIndexList anIndices = theModel->selectedIndexes();
for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
{
TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
if (!anItem || anItems.contains (anItem))
continue;
anItems.append (anItem);
}
QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
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 :
// =======================================================================
NCollection_List<TopoDS_Shape> VInspector_Window::GetSelectedShapes (QItemSelectionModel* theModel)
{
NCollection_List<TopoDS_Shape> aSelectedShapes;
QList<TreeModel_ItemBasePtr> anItems;
QModelIndexList anIndices = theModel->selectedIndexes();
for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
{
TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
if (!anItem || anItems.contains (anItem))
continue;
anItems.append (anItem);
}
QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
{
TreeModel_ItemBasePtr anItem = *anItemIt;
VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
if (!aVItem)
continue;
TopoDS_Shape aShape = aVItem->GetPresentationShape();
if (aShape.IsNull())
continue;
aSelectedShapes.Append (aShape);
}
return aSelectedShapes;
}
// =======================================================================
// function : GetSelectedElements
// purpose :
// =======================================================================
NCollection_List<OpenGl_Element*> VInspector_Window::GetSelectedElements (QItemSelectionModel* theModel)
{
NCollection_List<OpenGl_Element*> anElements;
QList<TreeModel_ItemBasePtr> anItems;
QModelIndexList anIndices = theModel->selectedIndexes();
for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
{
QModelIndex anIndex = *anIndicesIt;
TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (anIndex);
if (anIndex.column() != 0)
continue;
if (!anItem || anItems.contains (anItem))
continue;
anItems.append (anItem);
}
QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
{
TreeModel_ItemBasePtr anItem = *anItemIt;
VInspector_ItemOpenGlElementPtr aVItem = itemDynamicCast<VInspector_ItemOpenGlElement>(anItem);
if (!aVItem)
continue;
OpenGl_Element* anElement = aVItem->GetElement();
if (!anElement)
continue;
anElements.Append (anElement);
}
return anElements;
}
// =======================================================================
// function : Init
// purpose :
@@ -372,8 +511,12 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition
{
QMenu* aMenu = new QMenu (GetMainWindow());
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this));
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Show"), SLOT (onShow()), GetMainWindow(), this));
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Hide"), SLOT (onHide()), GetMainWindow(), this));
aMenu->addSeparator();
for (int aTypeId = (int)VInspector_DisplayActionType_DisplayId; aTypeId <= (int)VInspector_DisplayActionType_RemoveId; aTypeId++)
aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((VInspector_DisplayActionType) aTypeId),
SLOT (onDisplayActionTypeClicked()), GetMainWindow(), this));
aMenu->addSeparator();
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec(aPoint);
}
@@ -397,12 +540,12 @@ void VInspector_Window::onToolBarActionClicked (const int theActionId)
}
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 = VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
aPresentationsForViewer = GetSelectedPresentations (myTreeView->selectionModel());
Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
VInspector_Tools::AddOrRemovePresentations(aContext, aPresentationsForViewer);
VInspector_Tools::AddOrRemovePresentations (aContext, aPresentationsForViewer);
UpdateTreeModel();
break;
}
@@ -421,11 +564,85 @@ void VInspector_Window::onToolBarActionClicked (const int theActionId)
}
// =======================================================================
// function : onSelectionChanged
// function : onPropertyPanelShown
// purpose :
// =======================================================================
void VInspector_Window::onSelectionChanged (const QItemSelection&,
const QItemSelection&)
void VInspector_Window::onPropertyPanelShown (bool isToggled)
{
if (!isToggled)
return;
updatePropertyPanelBySelection();
}
// =======================================================================
// function : onPropertyViewSelectionChanged
// purpose :
// =======================================================================
void VInspector_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 : onTreeViewSelectionChanged
// purpose :
// =======================================================================
void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&,
const QItemSelection&)
{
QApplication::setOverrideCursor (Qt::WaitCursor);
@@ -434,6 +651,15 @@ void VInspector_Window::onSelectionChanged (const QItemSelection&,
else if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectOwnersId)->isChecked())
onToolBarActionClicked(VInspector_ToolActionType_SelectOwnersId);
if (myPropertyPanelWidget->toggleViewAction()->isChecked())
updatePropertyPanelBySelection();
NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel());
updatePreviewPresentation(aSelectedShapes);
NCollection_List<OpenGl_Element*> aSelectedElements = GetSelectedElements (myTreeView->selectionModel());
updatePreviewPresentation(aSelectedElements);
QApplication::restoreOverrideCursor();
}
@@ -475,8 +701,7 @@ void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& the
// =======================================================================
void VInspector_Window::onExportToShapeView()
{
NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations = GetSelectedPresentations (myTreeView->selectionModel());
if (aSelectedPresentations.Extent() <= 0)
return;
@@ -523,21 +748,14 @@ void VInspector_Window::onExportToShapeView()
}
// =======================================================================
// function : onShow
// function : onDisplayActionTypeClicked
// purpose :
// =======================================================================
void VInspector_Window::onShow()
void VInspector_Window::onDisplayActionTypeClicked()
{
displaySelectedPresentations (true);
}
QAction* anAction = (QAction*)sender();
// =======================================================================
// function : onHide
// purpose :
// =======================================================================
void VInspector_Window::onHide()
{
displaySelectedPresentations (false);
displaySelectedPresentations (VInspector_Tools::DisplayActionTypeFromString (anAction->text().toStdString().c_str()));
}
// =======================================================================
@@ -551,11 +769,33 @@ void VInspector_Window::UpdateTreeModel()
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, aTableValues);
}
myPropertyView->Init (aTableValues);
}
// =======================================================================
// function : displaySelectedPresentations
// purpose :
// =======================================================================
void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
void VInspector_Window::displaySelectedPresentations (const VInspector_DisplayActionType theType)
{
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (!aViewModel)
@@ -565,29 +805,38 @@ void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
if (aContext.IsNull())
return;
NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
if (!aSelectionModel)
return;
NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations = GetSelectedPresentations (aSelectionModel);
if (aSelectedPresentations.Extent() <= 0)
return;
// 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();
for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt(aSelectedPresentations); anIOIt.More(); anIOIt.Next())
{
Handle(AIS_InteractiveObject) aPresentation = anIOIt.Value();
if (theToDisplay)
switch (theType)
{
aContext->Display(aPresentation, false);
aContext->Load(aPresentation, -1);
case VInspector_DisplayActionType_DisplayId:
{
aContext->Display(aPresentation, false);
aContext->Load(aPresentation, -1);
}
break;
case VInspector_DisplayActionType_RedisplayId: aContext->Redisplay (aPresentation, false); break;
case VInspector_DisplayActionType_EraseId: aContext->Erase (aPresentation, false); break;
case VInspector_DisplayActionType_RemoveId: aContext->Remove (aPresentation, false); break;
default: break;
}
else
aContext->Erase(aPresentation, false);
}
aContext->UpdateCurrentViewer();
// the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
// Erased to Displayed container or back
QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
aSelectionModel->clear();
UpdateTreeModel();
}
@@ -604,3 +853,83 @@ Handle(AIS_InteractiveContext) VInspector_Window::createView()
return myViewWindow->GetView()->GetViewer()->GetContext();
}
// =======================================================================
// function : updatePreviewPresentation
// purpose :
// =======================================================================
void VInspector_Window::updatePreviewPresentation (const NCollection_List<TopoDS_Shape>& theShapes)
{
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->SetColor (Quantity_Color (Quantity_NOC_BLUE1));
myPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
if (!aContext.IsNull())
aContext->Display (myPreviewPresentation, Standard_True);
}
else
{
Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
if (!aContext.IsNull())
aContext->Redisplay (myPreviewPresentation, Standard_True);
}
}
// =======================================================================
// function : updatePreviewPresentation
// purpose :
// =======================================================================
void VInspector_Window::updatePreviewPresentation (const NCollection_List<OpenGl_Element*>& theElements)
{
Handle(AIS_InteractiveContext) aContext;
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (aViewModel)
aContext = aViewModel->GetContext();
if (theElements.IsEmpty())
{
if (!aContext.IsNull())
aContext->Remove (myOpenGlPreviewPresentation, Standard_False);
myOpenGlPreviewPresentation = NULL;
return;
}
if (myOpenGlPreviewPresentation.IsNull())
{
myOpenGlPreviewPresentation = new VInspector_PrsOpenGlElement();
myOpenGlPreviewPresentation->Set (theElements);
myOpenGlPreviewPresentation->SetColor (Quantity_Color (Quantity_NOC_BLUE1));
myOpenGlPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
if (!aContext.IsNull())
aContext->Display (myOpenGlPreviewPresentation, Standard_True);
}
else
{
Handle(VInspector_PrsOpenGlElement)::DownCast (myOpenGlPreviewPresentation)->Set (theElements);
if (!aContext.IsNull())
aContext->Redisplay (myOpenGlPreviewPresentation, Standard_True);
}
}

View File

@@ -23,6 +23,7 @@
#include <inspector/TInspectorAPI_PluginParameters.hxx>
#include <inspector/VInspector_CallBack.hxx>
#include <inspector/VInspector_DisplayActionType.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QObject>
@@ -30,14 +31,19 @@
#include <QMainWindow>
#include <Standard_WarningsRestore.hxx>
class OpenGl_Element;
class VInspector_PrsOpenGlElement;
class ViewControl_MessageDialog;
class ViewControl_PropertyView;
class VInspector_ToolBar;
class View_Window;
class QAbstractItemModel;
class QAction;
class QMainWindow;
class QDockWidget;
class QTreeView;
class QWidget;
@@ -82,6 +88,21 @@ public:
//! 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);
//! Returns selected shapes
//! \param theModel selection model
//! \return container of shapes
NCollection_List<TopoDS_Shape> GetSelectedShapes (QItemSelectionModel* theModel);
//! Returns selected elements
//! \param theModel selection model
//! \return container of OpenGl elements
NCollection_List<OpenGl_Element*> GetSelectedElements (QItemSelectionModel* theModel);
private:
//! Fills controls of the plugin by parameters:
@@ -103,6 +124,15 @@ private slots:
//! \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
@@ -113,16 +143,13 @@ private slots:
//! check box is checked
//! \param theSelected a selected items
//! \param theDeselected a deselected items
void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
//! Exports the first selected shape into ShapeViewer plugin.
void onExportToShapeView();
//! Shows selected presentation if it is not shown yet
void onShow();
//! Erase selected presentation if it is shown
void onHide();
//! Apply activated display action
void onDisplayActionTypeClicked();
private:
@@ -133,21 +160,36 @@ 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 theToDisplay if true, presentation is displayed otherwise erased
void displaySelectedPresentations (const bool theToDisplay);
//! \param theType display action type
void displaySelectedPresentations (const VInspector_DisplayActionType theType);
//! Creates an istance of 3D view to initialize context.
//! \return a context of created view.
Handle(AIS_InteractiveContext) createView();
//!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes
//!< \param theShape container of shapes
void updatePreviewPresentation (const NCollection_List<TopoDS_Shape>& theShapes);
//!< Updates presentation of preview for OpenGl elements.
//!< \param theElements container of elements
void updatePreviewPresentation (const NCollection_List<OpenGl_Element*>& theElements);
private:
QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
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
@@ -156,6 +198,8 @@ private:
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
Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
Handle(VInspector_PrsOpenGlElement) myOpenGlPreviewPresentation; //!< presentation of preview for OpenGl elements
};
#endif

View File

@@ -45,7 +45,11 @@ void View_Tools::SaveState (View_Window* theView, QMap<QString, QString>& theIte
{
QStringList aCameraDirection;
Standard_Real aVX, aVY, aVZ;
theView->GetView()->GetViewer()->GetView()->Proj (aVX, aVY, aVZ);
Handle(V3d_View) aView = theView->GetView()->GetViewer()->GetView();
if (aView.IsNull())
return;
aView->Proj (aVX, aVY, aVZ);
aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");

View File

@@ -1,5 +1,23 @@
ViewControl.hxx
ViewControl_ColorSelector.cxx
ViewControl_ColorSelector.hxx
ViewControl_EditType.hxx
ViewControl_MessageDialog.cxx
ViewControl_MessageDialog.hxx
ViewControl_PropertyView.cxx
ViewControl_PropertyView.hxx
ViewControl_Table.cxx
ViewControl_Table.hxx
ViewControl_TableItemDelegate.cxx
ViewControl_TableItemDelegate.hxx
ViewControl_TableModel.cxx
ViewControl_TableModel.hxx
ViewControl_TableModelFilter.cxx
ViewControl_TableModelFilter.hxx
ViewControl_TableModelValues.cxx
ViewControl_TableModelValues.hxx
ViewControl_TableProperty.cxx
ViewControl_TableProperty.hxx
ViewControl_Tools.cxx
ViewControl_Tools.hxx
ViewControl_TreeView.hxx
ViewControl_TreeView.hxx

View File

@@ -0,0 +1,33 @@
// 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

View File

@@ -0,0 +1,593 @@
// 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_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);
}

View File

@@ -0,0 +1,115 @@
// 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;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

View File

@@ -0,0 +1,31 @@
// 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
};
#endif

View File

@@ -0,0 +1,281 @@
// 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&)));
connect (aTable->GetProperty(), SIGNAL (propertyChanged()), this, SIGNAL (propertyViewSelectionChanged()));
if (myXStepValues.size() > theTableId)
aTable->GetProperty()->SetXStep (myXStepValues[theTableId]);
if (myDivideValues.size() > theTableId)
aTable->GetProperty()->SetDivideSize (myDivideValues[theTableId]);
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();
}
// =======================================================================
// function : SaveState
// purpose :
// =======================================================================
void ViewControl_PropertyView::SaveState (ViewControl_PropertyView* theView,
QMap<QString, QString>& theItems,
const QString& thePrefix)
{
QList<ViewControl_Table*> anActiveTables;
theView->GetActiveTables(anActiveTables);
if (anActiveTables.size() == 0)
return;
anActiveTables[0]->GetProperty()->GetXStep();
QStringList aDivideSizes, aXSteps;
for (int i = 0; i < anActiveTables.size(); i++)
{
aXSteps.append (QString::number (anActiveTables[i]->GetProperty()->GetXStep()));
aDivideSizes.append (QString::number (anActiveTables[i]->GetProperty()->GetDivideSize()));
}
theItems[thePrefix + "property_view_xstep_value"] = aXSteps.join (",");
theItems[thePrefix + "property_view_divide_value"] = aDivideSizes.join (",");
}
// =======================================================================
// function : RestoreState
// purpose :
// =======================================================================
bool ViewControl_PropertyView::RestoreState (ViewControl_PropertyView* theView,
const QString& theKey,
const QString& theValue,
const QString& thePrefix)
{
if (theKey == thePrefix + "property_view_xstep_value")
{
QList<double> aXStepValues;
QStringList aValues = theValue.split (",", QString::SkipEmptyParts);
for (int aValueId = 0; aValueId < aValues.size(); aValueId++)
aXStepValues.append (aValues.at (aValueId).toDouble());
theView->SetXSteps (aXStepValues);
}
else if (theKey == thePrefix + "property_view_divide_value")
{
QList<int> aDivideValues;
QStringList aValues = theValue.split (",", QString::SkipEmptyParts);
for (int aValueId = 0; aValueId < aValues.size(); aValueId++)
aDivideValues.append (aValues.at (aValueId).toInt());
theView->SetDivideValues (aDivideValues);
}
else
return false;
return true;
}

View File

@@ -0,0 +1,127 @@
// 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();
//! Sets X steps values for table properties
//! \param container of values
void SetXSteps (const QList<double>& theValues) { myXStepValues = theValues; }
//! Sets divide values for table properties
//! \param container of values
void SetDivideValues (const QList<int>& theValues) { myDivideValues = theValues; }
//! Save state of three view in a container in form: key, value. It saves:
//! - XStep of property table
//! - divide values of property table
//! \param theTreeView a view instance
//! \param theItems [out] properties
//! \param thePrefix peference item prefix
Standard_EXPORT static void SaveState (ViewControl_PropertyView* theView, QMap<QString, QString>& theItems,
const QString& thePrefix = QString());
//! Restore state of three view by a container
//! \param theTreeView a view instance
//! \param theKey property key
//! \param theValue property value
//! \param thePrefix peference item prefix
//! \return boolean value whether the property is applyed to the tree view
Standard_EXPORT static bool RestoreState (ViewControl_PropertyView* theView, const QString& theKey, const QString& theValue,
const QString& thePrefix = QString());
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
QList<double> myXStepValues; //! predefined values for XStep in ViewControl_TableProperty
QList<int> myDivideValues; //! predefined values for divide value in ViewControl_TableProperty
};
#endif

View File

@@ -0,0 +1,144 @@
// 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_TableProperty.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);
myProperty = new ViewControl_TableProperty(myMainWidget, this);
aLayout->addWidget (myProperty->GetControl());
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);
aLayout->addWidget (myProperty->GetInformationControl());
}
// =======================================================================
// function : SetModel
// purpose :
// =======================================================================
void ViewControl_Table::SetModel (QAbstractTableModel* theModel)
{
myTableView->setModel (theModel);
myTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
QItemSelectionModel* aSelectionModel = new QItemSelectionModel(theModel);
myTableView->setSelectionModel (aSelectionModel);
connect(aSelectionModel, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(onTableSelectionChanged(const QItemSelection&, const QItemSelection&)));
}
// =======================================================================
// 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);
myProperty->SetActive (theModelValues->UseTableProperties());
myProperty->Init();
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)
{
QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes();
ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (myTableView->model());
int aRow, aColumn;
for (QModelIndexList::const_iterator anIt = aSelected.begin(); anIt != aSelected.end(); anIt++)
{
aModel->GetSourcePosition (*anIt, aRow, aColumn);
if (!theSelectedIndices.contains (aRow))
theSelectedIndices.insert (aRow, QList<int>());
theSelectedIndices[aRow].append (aColumn);
}
}
// =======================================================================
// function : onTableSelectionChanged
// purpose :
// =======================================================================
void ViewControl_Table::onTableSelectionChanged(const QItemSelection&, const QItemSelection&)
{
QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes();
myProperty->UpdateOnTableSelectionChanged();
}

View File

@@ -0,0 +1,99 @@
// 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 <Standard.hxx>
#include <Standard_Macro.hxx>
#include <inspector/ViewControl_TableProperty.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; }
//! Returns instance of table property control
//! \return property
ViewControl_TableProperty* GetProperty() const { return myProperty; }
//! 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);
//! Returns text of separation row in table
//! \return string value
static QString SeparatorData() { return "---------------------------"; }
protected slots:
//! Updates controls by selection change in table view
//! \param theSelected container of selected table cells
//! \param theDeselected container of selected table cells
void onTableSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
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
ViewControl_TableProperty* myProperty; //!< modifier of the table visual properties
};
#endif

View File

@@ -0,0 +1,204 @@
// 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 <Standard_WarningsDisable.hxx>
#include <QFont>
#include <QCheckBox>
#include <QComboBox>
#include <QDoubleValidator>
#include <QLineEdit>
#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, aColumn;
myModelValues->GetSourcePosition (theIndex.row(), theIndex.column(), aRow, aColumn);
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, aColumn;
myModelValues->GetSourcePosition (theIndex.row(), theIndex.column(), aRow, aColumn);
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, aColumn;
myModelValues->GetSourcePosition (theIndex.row(), theIndex.column(), aRow, aColumn);
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: return new QSpinBox (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;
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();
default: return QVariant();
}
}

View File

@@ -0,0 +1,96 @@
// 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

View File

@@ -0,0 +1,99 @@
// 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;
SetFilter(0);
}
// =======================================================================
// function : columnCount
// purpose :
// =======================================================================
int ViewControl_TableModel::columnCount(const QModelIndex& theParent) const
{
if (!myModelValues)
return 0;
int aColumnCount = myModelValues->ColumnCount (theParent);
return isFilterActive() ? myFilter->ColumnCount (aColumnCount) : aColumnCount;
}
// =======================================================================
// function : rowCount
// purpose :
// =======================================================================
int ViewControl_TableModel::rowCount(const QModelIndex& theParent ) const
{
if (!myModelValues)
return 0;
return isFilterActive() ? myFilter->RowCount (myModelValues->ColumnCount (theParent))
: 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();
if (isFilterActive())
myFilter->GetSourcePosition (theIndex, aRow, aColumn);
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();
if (isFilterActive())
myFilter->GetSourcePosition (theIndex, aRow, aColumn);
return myModelValues->SetData (aRow, aColumn, theValue, theRole);
}
// =======================================================================
// function : GetSourcePosition
// purpose :
// =======================================================================
void ViewControl_TableModel::GetSourcePosition (const QModelIndex& theIndex, int& theRow, int& theColumn)
{
if (isFilterActive())
myFilter->GetSourcePosition (theIndex, theRow, theColumn);
else
myModelValues->GetSourcePosition (theIndex.row(), theIndex.column(), theRow, theColumn);
}

View File

@@ -0,0 +1,117 @@
// 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_TableModelFilter.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), myFilter (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; }
//! Sets table values filter to rearrange values presentation
//! \param filter instance
void SetFilter (ViewControl_TableModelFilter* theFilter) { myFilter = theFilter; }
//! 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; }
//! Returns source row and column values peforming conversion back from filter
//! \param theIndex a model index
//! \param theRow a model row
//! \param theColumn a model column
Standard_EXPORT void GetSourcePosition (const QModelIndex& theIndex, int& theRow, int& theColumn);
protected:
//! Returns true if the filter is not NULL and active
//! \return true if active
Standard_Boolean isFilterActive() const { return myFilter && myFilter->IsActive(); }
private:
ViewControl_TableModelValues* myModelValues; //! interface to table values
ViewControl_TableModelFilter* myFilter; //! filter of values
};
#endif

View File

@@ -0,0 +1,65 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <inspector/ViewControl_TableModelFilter.hxx>
// =======================================================================
// function : ColumnCount
// purpose :
// =======================================================================
int ViewControl_TableModelFilter::ColumnCount (const int theSourceColumnCount) const
{
return myColumnCount <= 0 ? theSourceColumnCount : myColumnCount;
}
// =======================================================================
// function : RowCount
// purpose :
// =======================================================================
int ViewControl_TableModelFilter::RowCount (const int theSourceColumnCount) const
{
if (myColumnCount <= 0)
return 1;
int aRows = (int) (theSourceColumnCount / myColumnCount);
if (myColumnCount > 0 && aRows * myColumnCount < theSourceColumnCount)
aRows++; /// row with left values, not fully filled
return aRows;
}
// =======================================================================
// function : GetSourcePosition
// purpose :
// =======================================================================
void ViewControl_TableModelFilter::GetSourcePosition (const QModelIndex& theIndex, int& theRow, int& theColumn) const
{
GetSourcePosition (theIndex.row(), theIndex.column(), theRow, theColumn);
}
// =======================================================================
// function : GetSourcePosition
// purpose :
// =======================================================================
void ViewControl_TableModelFilter::GetSourcePosition (const int theSourceRow, const int theSourceColumn, int& theRow,
int& theColumn) const
{
theRow = 0;
theColumn = myColumnCount * theSourceRow + theSourceColumn;
}

View File

@@ -0,0 +1,76 @@
// 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_TableModelFilter_H
#define ViewControl_TableModelFilter_H
#include <Standard.hxx>
#include <inspector/ViewControl_TableModelValues.hxx>
//! \class ViewControl_TableModelFilter
//! \brief It provides separation of 1D container of values in 2D presentation depending on number of column value
class ViewControl_TableModelFilter
{
public:
//! Constructor
Standard_EXPORT ViewControl_TableModelFilter(const Standard_Integer theColumnCount = -1)
: myIsActive (Standard_True), myColumnCount (theColumnCount) {}
//! Destructor
virtual ~ViewControl_TableModelFilter() {}
//! Activate/Deactivate filter
//! \param theActive state is the filter to be active or not
virtual void SetActive (const Standard_Boolean theActive) { myIsActive = theActive; }
//! Returns boolean state whether the filter is activated
//! \return true if active
virtual Standard_Boolean IsActive() const { return myIsActive; }
//! Sets number of columns
//! \param theColumnCount a column count
void SetColumnCount (const int theColumnCount) { myColumnCount = theColumnCount; }
//! Returns number of columns: parameter value
//! \param theSourceColumnCount number of columns in the source table
//! \return an integer value
Standard_EXPORT int ColumnCount (const int theSourceColumnCount) const;
//! Returns number of rows: whole number of columns is divided to the current column value
//! \param theSourceColumnCount number of columns in the source table
//! \return an integer value
Standard_EXPORT int RowCount (const int theSourceColumnCount) const;
//! Returns source row/column indices for the filtered model index
//! \param theIndex a model index
//! \param theRow [out] row number value
//! \param theColumn [out] column value
Standard_EXPORT void GetSourcePosition (const QModelIndex& theIndex, int& theRow, int& theColumn) const;
//! Returns source row/column indices for the filtered model index
//! \param theSourceRow model row index
//! \param theSourceColumn model column index
//! \param theRow [out] row number value
//! \param theColumn [out] column value
Standard_EXPORT void GetSourcePosition (const int theSourceRow, const int theSourceColumn, int& theRow, int& theColumn) const;
private:
Standard_Boolean myIsActive; //!< active state of the filter
Standard_Integer myColumnCount; //!< number of table columns
};
#endif

Some files were not shown because too many files have changed in this diff Show More