1 -- Created on: 1999-09-10
2 -- Created by: Andrey BETENEV
3 -- Copyright (c) 1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 class Styles from STEPConstruct inherits Tool from STEPConstruct
19 ---Purpose: Provides a mechanism for reading and writing shape styles
20 -- (such as color) to and from the STEP file
21 -- This tool maintains a list of styles, either taking them
22 -- from STEP model (reading), or filling it by calls to
23 -- AddStyle or directly (writing).
24 -- Some methods deal with general structures of styles and
25 -- presentations in STEP, but there are methods which deal
26 -- with particular implementation of colors (as described in RP)
29 WorkSession from XSControl,
30 InterfaceModel from Interface,
31 HGraph from Interface,
32 FinderProcess from Transfer,
33 TransientProcess from Transfer,
35 SequenceOfTransient from TColStd,
36 HSequenceOfTransient from TColStd,
37 MapOfShape from TopTools,
38 RepresentationItem from StepRepr,
39 RepresentationContext from StepRepr,
40 PresentationStyleAssignment from StepVisual,
41 StyledItem from StepVisual,
42 Colour from StepVisual,
44 IndexedMapOfTransient from TColStd,
45 IndexedDataMapOfTransientTransient from TColStd,
46 MechanicalDesignGeometricPresentationRepresentation from StepVisual,
47 ContextDependentShapeRepresentation from StepShape,
48 ProductDefinitionShape from StepRepr,
49 DataMapOfAsciiStringTransient from STEPConstruct,
50 DataMapOfPointTransient from STEPConstruct
53 Create returns Styles;
54 ---Purpose: Creates an empty tool
56 Create (WS: WorkSession from XSControl) returns Styles;
57 ---Purpose: Creates a tool and initializes it
59 Init (me: in out; WS: WorkSession from XSControl) returns Boolean;
60 ---Purpose: Initializes tool; returns True if succeeded
62 --Basic methods: general work with styles
64 NbStyles (me) returns Integer;
65 ---Purpose: Returns number of defined styles
67 Style (me; i: Integer) returns StyledItem from StepVisual;
68 ---Purpose: Returns style with given index
70 ClearStyles (me: in out);
71 ---Purpose: Clears all defined styles and PSA sequence
73 AddStyle (me: in out; style: StyledItem from StepVisual);
74 ---Purpose: Adds a style to a sequence
76 AddStyle (me: in out; item: RepresentationItem from StepRepr;
77 PSA: PresentationStyleAssignment from StepVisual;
78 Override: StyledItem from StepVisual)
79 returns StyledItem from StepVisual;
80 ---Purpose: Create a style linking giving PSA to the item, and add it to the
81 -- sequence of stored styles. If Override is not Null, then
82 -- the resulting style will be of the subtype OverridingStyledItem.
84 AddStyle (me: in out; Shape: Shape from TopoDS;
85 PSA: PresentationStyleAssignment from StepVisual;
86 Override: StyledItem from StepVisual)
87 returns StyledItem from StepVisual;
88 ---Purpose: Create a style linking giving PSA to the Shape, and add it to the
89 -- sequence of stored styles. If Override is not Null, then
90 -- the resulting style will be of the subtype OverridingStyledItem.
91 -- The Sape is used to find corresponding STEP entity by call to
92 -- STEPConstruct::FindEntity(), then previous method is called.
94 CreateMDGPR (me: in out; Context: RepresentationContext from StepRepr;
95 MDGPR :in out MechanicalDesignGeometricPresentationRepresentation from StepVisual)
97 ---Purpose: Create MDGPR, fill it with all the styles previously defined,
98 -- and add it to the model
100 CreateNAUOSRD (me: in out; Context: RepresentationContext from StepRepr;
101 CDSR : ContextDependentShapeRepresentation from StepShape;
102 initPDS : ProductDefinitionShape from StepRepr)
104 ---Purpose: Create MDGPR, fill it with all the styles previously defined,
105 -- and add it to the model
106 -- IMPORTANT: <initPDS> must be null when use for NAUO colors
107 -- <initPDS> initialised only for SHUO case.
109 FindContext (me; Shape: Shape from TopoDS)
110 returns RepresentationContext from StepRepr;
111 ---Purpose: Searches the STEP model for the RepresentationContext in which
112 -- given shape is defined. This context (if found) can be used
113 -- then in call to CreateMDGPR()
115 LoadStyles (me: in out) returns Boolean;
116 ---Purpose: Searches the STEP model for the MDGPR or DM entities
117 -- (which bring styles) and fills sequence of styles
119 LoadInvisStyles (me; InvSyles : in out HSequenceOfTransient from TColStd)
121 ---Purpose: Searches the STEP model for the INISIBILITY enteties
122 -- (which bring styles) and fills out sequence of styles
124 --Specialized methods: work with colors
126 MakeColorPSA (me; item: RepresentationItem from StepRepr;
127 SurfCol: Colour from StepVisual;
128 CurveCol: Colour from StepVisual;
129 isForNAUO : Boolean from Standard = Standard_False)
130 returns PresentationStyleAssignment from StepVisual;
131 ---Purpose: Create a PresentationStyleAssignment entity which defines
132 -- two colors (for filling surfaces and curves)
133 -- if isForNAUO true then returns PresentationStyleByContext
135 GetColorPSA (me: in out; item: RepresentationItem from StepRepr;
136 Col: Colour from StepVisual)
137 returns PresentationStyleAssignment from StepVisual;
138 ---Purpose: Returns a PresentationStyleAssignment entity which defines
139 -- surface and curve colors as Col. This PSA is either created
140 -- or taken from internal map where all PSAs created by this
141 -- method are remembered.
143 GetColors (me; style: StyledItem from StepVisual;
144 SurfCol : out Colour from StepVisual;
145 BoundCol: out Colour from StepVisual;
146 CurveCol: out Colour from StepVisual;
147 IsComponent: in out Boolean from Standard)
149 ---Purpose: Extract color definitions from the style entity
150 -- For each type of color supported, result can be either
151 -- NULL if it is not defined by that style, or last
152 -- definition (if they are 1 or more)
154 --Auxiliary methods: conversions between STEP and CASCADE color definitions
156 EncodeColor (myclass; Col: Color from Quantity) returns Colour from StepVisual;
157 ---Purpose: Create STEP color entity by given Quantity_Color
158 -- The analysis is performed for whether the color corresponds to
159 -- one of standard colors predefined in STEP. In that case,
160 -- PredefinedColour entity is created instead of RGBColour
162 EncodeColor (myclass; Col: Color from Quantity;
163 DPDCs : in out DataMapOfAsciiStringTransient from STEPConstruct;
164 ColRGBs : in out DataMapOfPointTransient from STEPConstruct)
165 returns Colour from StepVisual;
166 ---Purpose: Create STEP color entity by given Quantity_Color
167 -- The analysis is performed for whether the color corresponds to
168 -- one of standard colors predefined in STEP. In that case,
169 -- PredefinedColour entity is created instead of RGBColour
171 DecodeColor (myclass; Colour: Colour from StepVisual;
172 Col : out Color from Quantity)
174 ---Purpose: Decodes STEP color and fills the Quantity_Color.
175 -- Returns True if OK or False if color is not recognized
179 myMapOfStyles : IndexedDataMapOfTransientTransient from TColStd;
180 myStyles : IndexedMapOfTransient from TColStd;
181 myPSA : SequenceOfTransient from TColStd;