1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

226
src/AIS2D/AIS2D.cdl Executable file
View File

@@ -0,0 +1,226 @@
-- File : AIS2D.cdl
-- Created : 07 April 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
package AIS2D
---Purpose: FOR APPLICATION INTERACTIVE SERVICES
--
-- This package provides the classes and methods
-- to the maintenance of the high level 2D visualization .
-- The central entity is Interactive Context for easily
-- piloting presentation and selection.
-- AIS2D package proposes the classes of standard Interactive Objects
-- and this one allows to implement users classes of interactive objects,
-- by respecting a certain rules of creating of Interactive Object.
uses
Aspect,
Quantity,
TColStd,
TCollection,
V2d,
Graphic2d,
GGraphic2d,
TopoDS,
TopTools,
HLRAlgo,
HLRBRep,
Prs2d
is
enumeration KindOfIO is
KOI_None,
KOI_DATUM,
KOI_DIMENSION,
KOI_SHAPE,
KOI_PROJSHAPE,
KOI_COMPOUND
end KindOfIO;
enumeration KindOfDimension is
KOD_NONE,
KOD_LENGTH,
KOD_ANGLE,
KOD_DIAMETER,
KOD_RADIUS
end KindOfDimension;
enumeration KindOfPrimitive is
KOP_NONE,
KOP_CIRCLE,
KOP_CIRCLEMARKER,
KOP_ELLIPS,
KOP_ELLIPSEMARKER,
KOP_FRAMEDTEXT,
KOP_HIDINGTEXT,
KOP_IMAGE,
KOP_IMAGEFILE,
KOP_INFINITELINE,
KOP_MARKER,
KOP_PARAGRAPH,
KOP_POLYLINE,
KOP_POLYLINEMARKER,
KOP_SEGMENT,
KOP_SETOFMARKERS,
KOP_SETOFPOLYLINES,
KOP_SETOFSEGMENTS,
KOP_TEXT,
KOP_CURVE,
KOP_SETOFCURVES,
KOP_ANGLE,
KOP_ANGULARITY,
KOP_ARROW,
KOP_AXIS,
KOP_CIRCULARITY,
KOP_CONCENTRIC,
KOP_CYLINDRIC,
KOP_DIAMETER,
KOP_FLATNESS,
KOP_LENGTH,
KOP_LINEPROFILE,
KOP_PARALLELISM,
KOP_PERPENDICULAR,
KOP_POINT,
KOP_RADIUS,
KOP_RADIUSINDEP,
KOP_REPERE,
KOP_STRAIGHTNESS,
KOP_SURFPROFILE,
KOP_SYMCIRCULAR,
KOP_SYMMETRY,
KOP_SYMTOTAL,
KOP_TAPER,
KOP_TOLERANCEFRAME
end KindOfPrimitive;
enumeration TypeOfAxis is
TOAX_Unknown,
TOAX_XAxis,
TOAX_YAxis
end TypeOfAxis;
enumeration DisplayStatus is
DS_Displayed, -- displayed in main viewer
DS_Erased, -- erased in the collector
DS_FullErased, -- erased but not in the collector
DS_Temporary, -- temporary displayed
DS_None -- nowhere
end DisplayStatus;
enumeration SelectStatus is
SS_Added,
SS_Removed,
SS_NotDone
end SelectStatus;
enumeration StatusOfPick is
SOP_Error,
SOP_NothingSelected,
SOP_Removed,
SOP_OneSelected,
SOP_SeveralSelected
end StatusOfPick;
enumeration StatusOfDetection is
SOD_Error,
SOD_Nothing,
SOD_AllBad,
SOD_Selected,
SOD_OnlyOneDetected,
SOD_OnlyOneGood,
SOD_SeveralGood
end StatusOfDetection;
enumeration TypeOfDetection is
TOD_OBJECT,
TOD_PRIMITIVE,
TOD_ELEMENT,
TOD_VERTEX,
TOD_NONE
end TypeOfDetection;
enumeration ClearMode is
CM_All,
CM_Interactive,
CM_StandardModes,
CM_TemporaryShapePrs
end ClearMode;
class InteractiveContext;
class InteractiveObject;
class ProjShape;
private class LocalStatus;
private class GlobalStatus;
private class LocalContext;
private class PrimitiveArchit;
private class SequenceOfIO instantiates Sequence from TCollection
( InteractiveObject from AIS2D );
private class HSequenceOfIO instantiates HSequence from TCollection
( InteractiveObject from AIS2D, SequenceOfIO from AIS2D );
private class SequenceOfPrimArchit instantiates Sequence from TCollection
( PrimitiveArchit from AIS2D );
private class HSequenceOfPrimArchit instantiates HSequence from TCollection
( PrimitiveArchit from AIS2D, SequenceOfPrimArchit from AIS2D );
private class DataMapOfIOStatus instantiates DataMap from TCollection
( InteractiveObject from AIS2D,
GlobalStatus from AIS2D,
MapTransientHasher from TColStd );
-- Management of interactiveObjects Status...
class ListOfIO instantiates List from TCollection
( InteractiveObject from AIS2D );
class DataMapOfPrimAspects instantiates DataMap from TCollection
( Primitive from Graphic2d,
AspectRoot from Prs2d,
MapTransientHasher from TColStd);
private class DataMapOfLC instantiates DataMap from TCollection
( Integer from Standard,
LocalContext from AIS2D,
MapIntegerHasher from TColStd );
private class DataMapOfLocStat instantiates DataMap from TCollection
( InteractiveObject from AIS2D,
LocalStatus from AIS2D,
MapTransientHasher from TColStd );
-- to tell if an object is sensitive to Standard Modes Of Selection....
pointer PToListOfInt to ListOfInteger from TColStd;
Save( aCntx: InteractiveContext from AIS2D; aFile: CString from Standard )
returns Boolean;
Retrieve( aCntx: InteractiveContext from AIS2D; aFile: CString from Standard )
returns InteractiveObject from AIS2D;
end AIS2D;

127
src/AIS2D/AIS2D.cxx Executable file
View File

@@ -0,0 +1,127 @@
#include <AIS2D.hxx>
#include <Graphic2d_Primitive.hxx>
#include <Graphic2d_DisplayList.hxx>
#include <Graphic2d_Circle.hxx>
#include <Graphic2d_CircleMarker.hxx>
#include <Graphic2d_Ellips.hxx>
#include <Graphic2d_EllipsMarker.hxx>
#include <Graphic2d_InfiniteLine.hxx>
#include <Graphic2d_Marker.hxx>
#include <Graphic2d_VectorialMarker.hxx>
#include <Graphic2d_PolylineMarker.hxx>
#include <Graphic2d_SetOfMarkers.hxx>
#include <Graphic2d_SetOfSegments.hxx>
#include <Graphic2d_Segment.hxx>
#include <Graphic2d_Polyline.hxx>
#include <Graphic2d_SetOfPolylines.hxx>
#include <Graphic2d_Image.hxx>
#include <Graphic2d_ImageFile.hxx>
#include <Graphic2d_Text.hxx>
#include <Graphic2d_FramedText.hxx>
#include <Graphic2d_HidingText.hxx>
#include <GGraphic2d_Curve.hxx>
#include <GGraphic2d_SetOfCurves.hxx>
#include <Graphic2d_View.hxx>
#include <Graphic2d_Paragraph.hxx>
#include <V2d_Viewer.hxx>
#include <Quantity_Color.hxx>
#include <Prs2d_AspectRoot.hxx>
#include <Prs2d_AspectLine.hxx>
#include <Prs2d_AspectText.hxx>
#include <Prs2d_Angle.hxx>
#include <AIS2D_InteractiveContext.hxx>
#include <AIS2D_InteractiveObject.hxx>
#include <AIS2D_KindOfPrimitive.hxx>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Standard_Stream.hxx>
Standard_Boolean AIS2D::Save( const Handle(AIS2D_InteractiveContext)& aCntx,
const Standard_CString aFile ) {
if ( !aCntx.IsNull() ) {
Handle( Graphic2d_DisplayList ) theDL = aCntx->CurrentViewer()->View()->DisplayList();
if ( !theDL->IsEmpty() ) {
Aspect_FStream ofs = new ofstream;
ofs->open( aFile, ios::out );
int LnOfDL = theDL->Length();
TCollection_AsciiString thestr;
for ( int i = 1; i <= LnOfDL; ++i )
{
Handle(AIS2D_InteractiveObject) theIO =
Handle(AIS2D_InteractiveObject)::DownCast( theDL->Value(i) );
theIO->Save( ofs );
/* int lnOfPr = theIO->Length();
for ( int j = 1; j <= lnOfPr; j++ ) {
Handle(Graphic2d_Primitive) thePrm = theIO->Primitive( j );
Handle( Prs2d_AspectRoot ) theAsp = theIO->GetAspect( thePrm );
if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Line ) ) ) {
Handle(Prs2d_AspectLine) theAL = Handle(Prs2d_AspectLine)::DownCast( theAsp );
Quantity_Color theColor;
Aspect_TypeOfLine theTOL;
Aspect_WidthOfLine theWOL;
theAL->ValuesOfLine( theColor, theTOL, theWOL );
Standard_Real R1, R2, R3;
theColor.Values( R1, R2, R3, Quantity_TOC_RGB );
} else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Paragraph ) ) ) {
} else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Image ) ) ) {
} else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_ImageFile ) ) ) {
} else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Text ) ) ) {
Handle(Prs2d_AspectText) theAT = Handle(Prs2d_AspectText)::DownCast( theAsp );
Quantity_Color aColor;
Aspect_FontStyle aFont;
Quantity_PlaneAngle aSlant;
Aspect_TypeOfText aType;
Standard_Boolean isUnderlined;
theAT->Values( aColor, aFont, aSlant, aType, isUnderlined );
}
}*/
}
ofs->close();
} //if sequence of displyed objects isn't empty
} // if context isn't NULL
return Standard_False;
}
Handle (AIS2D_InteractiveObject)
AIS2D::Retrieve( const Handle(AIS2D_InteractiveContext)& /*aCntx*/,
const Standard_CString aFile )
{
char buf[100];
Aspect_IFStream ifs = new ifstream;
Handle(AIS2D_InteractiveObject) theIO;
ifs->open(aFile, ios::in);
ifs->getline(buf, 100);
while (! ifs->eof())
{
if (! strcmp(buf, "AIS2D_InteractiveObject"))
{
theIO = new AIS2D_InteractiveObject();
theIO->Retrieve(ifs);
}
ifs->getline(buf, 100);
}
ifs->close();
return theIO;
}

145
src/AIS2D/AIS2D_GlobalStatus.cdl Executable file
View File

@@ -0,0 +1,145 @@
-- File : AIS2D_GlobalStatus.cdl
-- Created : February 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
private class GlobalStatus from AIS2D inherits TShared from MMgt
---Purpose: Stores information about objects in graphic context:
-- - Status Of Display : in the main viewer
-- in the collector
-- fully Erased
-- - Displayed Modes
-- - Active Selection Modes
-- - is the Interactive Object Current ?
-- - Layer Index
uses
ListOfInteger from TColStd,
PToListOfInt from AIS2D,
DisplayStatus from AIS2D,
NameOfColor from Quantity
is
Create returns mutable GlobalStatus from AIS2D;
---Purpose: Initialize GlobalStatus the default properties
Create( aStat : DisplayStatus from AIS2D;
aDMode : Integer from Standard;
aSMode : Integer from Standard;
isHighlight : Boolean from Standard=Standard_False;
aHighlCol : NameOfColor from Quantity = Quantity_NOC_WHITE;
aLayerIndex : Integer from Standard = 0)
returns mutable GlobalStatus from AIS2D;
---Purpose: Initialize GlobalStatus the concrete properties
SetGraphicStatus( me: mutable; aStat : DisplayStatus from AIS2D );
---C++: inline
---Level: Internal
---Purpose: Sets the graphic status <aStat>
AddDisplayMode( me: mutable; aMode: Integer from Standard );
---Level: Internal
---Purpose: Adds the display mode <aMode> to the list of display modes
RemoveDisplayMode( me: mutable; aMode: Integer from Standard);
---Level: Internal
---Purpose: Removes the display mode <aMode> from the list of display modes
IsDModeIn( me; aMode: Integer from Standard ) returns Boolean from Standard;
---Level: Internal
---Purpose: Returns True if the list of display modes
-- contains the display mode <aMode>
AddSelectionMode( me: mutable; aMode: Integer from Standard );
---Level: Internal
---Purpose: Adds the selection mode <aMode> to the list of selection modes
RemoveSelectionMode( me: mutable; aMode: Integer from Standard );
---Level: Internal
---Purpose: Removes the selection mode <aMode> from the list of selection modes
ClearSelectionModes( me: mutable );
---Level: Internal
---Purpose: Removes all selection modes from the list of selection modes
IsSModeIn( me; aMode: Integer from Standard ) returns Boolean from Standard;
---Level: Internal
---Purpose: Returns True if the list of selection modes
-- contains the selection mode <aMode>
SetLayerIndex( me: mutable; anIndex: Integer from Standard );
---C++: inline
---Level: Internal
---Purpose: Sets the layer index <anIndex>
SetHighlightStatus( me: mutable; aStat: Boolean from Standard );
---C++: inline
---Level: Internal
---Purpose: Sets the highlight status
SetHighlightColor( me: mutable; aHiCol: NameOfColor from Quantity );
---C++: inline
---Level: Internal
---Purpose: Sets the color of highight
IsSubIntensityOn( me ) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose: Return True if SubIntensity is on
SubIntensityOn( me: mutable );
---C++: inline
---Level: Internal
---Purpose: Sets the SubIntensity
SubIntensityOff( me: mutable );
---C++: inline
---Level: Internal
---Purpose: Unsets the SubIntensity
GraphicStatus( me ) returns DisplayStatus from AIS2D;
---C++: inline
---Level: Internal
---Purpose: Indicates the display status
DisplayedModes( me: mutable ) returns PToListOfInt from AIS2D;
---C++: inline
---Level: Internal
---Purpose: keeps the information of displayed modes in the
-- main viewer.
-- (The convention is that the object is displayed
-- with the mode 0 in the collector...)
SelectionModes( me: mutable ) returns PToListOfInt from AIS2D;
---C++: inline
---Level: Internal
---Purpose: keeps the active selection modes of the object
-- in the main viewer.
-- (The convention is that the active selection mode
-- for an object in the collector is the mode 0).
IsHighlight(me) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose: Returns True if highlight is on
HighlightColor( me ) returns NameOfColor from Quantity;
---C++: inline
---Level: Internal
---Purpose: Returns the color of highlight
fields
myStatus : DisplayStatus from AIS2D;
myDispModes : ListOfInteger from TColStd;
mySelModes : ListOfInteger from TColStd;
myLayerIndex : Integer from Standard;
myIsHighl : Boolean from Standard;
myHiCol : NameOfColor from Quantity;
mySubInt : Boolean from Standard;
end GlobalStatus;

View File

@@ -0,0 +1,80 @@
#include <AIS2D_GlobalStatus.ixx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
static TColStd_ListIteratorOfListOfInteger It;
AIS2D_GlobalStatus::AIS2D_GlobalStatus():
myStatus( AIS2D_DS_None ),
myDispModes(),
mySelModes(),
myLayerIndex( 0 ),
myIsHighl( Standard_False ),
myHiCol( Quantity_NOC_WHITE ),
mySubInt( Standard_False )
{
}
AIS2D_GlobalStatus::AIS2D_GlobalStatus(
const AIS2D_DisplayStatus DS,
const Standard_Integer DMode,
const Standard_Integer SMode,
const Standard_Boolean /*isHighlight*/,
const Quantity_NameOfColor aHighlCol,
const Standard_Integer aLayerIndex ):
myStatus( DS ),
myLayerIndex( aLayerIndex ),
myIsHighl( Standard_False ),
myHiCol( aHighlCol ),
mySubInt( Standard_False )
{
myDispModes.Append( DMode );
mySelModes.Append( SMode );
}
void AIS2D_GlobalStatus::RemoveDisplayMode( const Standard_Integer aMode ) {
for ( It.Initialize( myDispModes ); It.More(); It.Next() )
if ( It.Value() == aMode ) {
myDispModes.Remove( It );
return;
}
}
void AIS2D_GlobalStatus::RemoveSelectionMode( const Standard_Integer aMode) {
for ( It.Initialize( mySelModes ); It.More(); It.Next() )
if ( It.Value() == aMode ) {
mySelModes.Remove( It );
return;
}
}
void AIS2D_GlobalStatus::ClearSelectionModes() {
mySelModes.Clear();
}
void AIS2D_GlobalStatus::AddSelectionMode( const Standard_Integer aMode ) {
if ( !IsSModeIn( aMode ) )
mySelModes.Append( aMode );
}
Standard_Boolean AIS2D_GlobalStatus::IsDModeIn( const Standard_Integer aMode) const {
for ( It.Initialize( myDispModes ); It.More(); It.Next() )
if ( It.Value() == aMode ) return Standard_True;
return Standard_False;
}
Standard_Boolean AIS2D_GlobalStatus::IsSModeIn( const Standard_Integer aMode) const {
for ( It.Initialize( mySelModes ); It.More(); It.Next() )
if ( It.Value() == aMode ) return Standard_True;
return Standard_False;
}
void AIS2D_GlobalStatus::AddDisplayMode( const Standard_Integer aMode ) {
if ( !IsDModeIn( aMode ) )
myDispModes.Append( aMode );
}

View File

@@ -0,0 +1,47 @@
inline void AIS2D_GlobalStatus::SetGraphicStatus( const AIS2D_DisplayStatus aStat ) {
myStatus = aStat;
}
inline void AIS2D_GlobalStatus::SetLayerIndex( const Standard_Integer AnIndex ) {
myLayerIndex=AnIndex;
}
inline void AIS2D_GlobalStatus::SetHighlightStatus( const Standard_Boolean aStat ) {
myIsHighl = aStat;
}
inline void AIS2D_GlobalStatus::SetHighlightColor( const Quantity_NameOfColor aCol ) {
myHiCol = aCol;
}
inline Standard_Boolean AIS2D_GlobalStatus::IsSubIntensityOn() const {
return mySubInt;
}
inline void AIS2D_GlobalStatus::SubIntensityOn() {
mySubInt = Standard_True;
}
inline void AIS2D_GlobalStatus::SubIntensityOff() {
mySubInt = Standard_False;
}
inline AIS2D_DisplayStatus AIS2D_GlobalStatus::GraphicStatus() const {
return myStatus;
}
inline AIS2D_PToListOfInt AIS2D_GlobalStatus::DisplayedModes() {
return & myDispModes;
}
inline AIS2D_PToListOfInt AIS2D_GlobalStatus::SelectionModes() {
return & mySelModes;
}
inline Standard_Boolean AIS2D_GlobalStatus::IsHighlight() const {
return myIsHighl;
}
inline Quantity_NameOfColor AIS2D_GlobalStatus::HighlightColor() const {
return myHiCol;
}

View File

@@ -0,0 +1,770 @@
-- File : AIS2D_InteractiveContext.cdl
-- Created : February 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
-- Modified: EAV: 07-09-01 : NbSelected(), InitSelected(),
-- MoreSelected(), NextSelected()
-- SAV: 15/11/01 MoveCircleTo(). detection by circle. SetDetectionMode().
-- Detect() - internal
class InteractiveContext from AIS2D inherits TShared from MMgt
---Purpose: The InteractiveContext class allows you to manage
-- graphic behavior and selection of Interactive Objects
-- in one or more viewers.
uses
TypeOfLine from Aspect,
WidthOfLine from Aspect,
MarkerStyle from Aspect,
TypeOfMarker from Aspect,
FontStyle from Aspect,
GenericColorMap from Aspect,
TypeMap from Aspect,
WidthMap from Aspect,
MarkMap from Aspect,
FontMap from Aspect,
GridType from Aspect,
GridDrawMode from Aspect,
CardinalPoints from Aspect,
Color from Quantity,
PlaneAngle from Quantity,
Length from Quantity,
NameOfColor from Quantity,
ExtendedString from TCollection,
Primitive from Graphic2d,
PickMode from Graphic2d,
TransientManager from Graphic2d,
DisplayList from Graphic2d,
Viewer from V2d,
View from V2d,
Drawer from Prs2d,
InteractiveObject from AIS2D,
KindOfIO from AIS2D,
DataMapOfIOStatus from AIS2D,
DataMapOfLC from AIS2D,
StatusOfDetection from AIS2D,
DisplayStatus from AIS2D,
StatusOfPick from AIS2D,
TypeOfDetection from AIS2D,
PToListOfInt from AIS2D,
ListOfIO from AIS2D,
HSequenceOfIO from AIS2D
is
Create( MainViewer: Viewer from V2d )
returns mutable InteractiveContext from AIS2D;
---Purpose: Initiates <MainViewer>
Create( MainViewer, aCollector: Viewer from V2d)
returns mutable InteractiveContext from AIS2D;
---Purpose: Initiates the principal viewer and Collector(trash) viewer together
-- *************************************************************
---Category: Editing general Display Services
-- *************************************************************
Display( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Display when no local context is opened.
-- if <anIObj> has no proper display mode, the defaut
-- display mode of the session is used
-- Same for the selection Mode (by default =0)
Display( me : mutable;
anIObj : InteractiveObject from AIS2D;
aDispMode : Integer from Standard ;
aSelectMode : Integer from Standard;
UpdateVwr : Boolean from Standard = Standard_True;
AllowDecomp : Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Use only if a local context is opened. Displays the
-- <aDispMode> the presentation of interactive object,
-- activates the selection mode <aSelectMode> if
-- <UpdateVwr> = Standard_False, the object is
-- displayed but no viewer will be updated; CONVENTION :
-- <aSelectMode> = -1 means no activation for <anIObj>
-- : it will be displayed but not selectable. (Option
-- only available for local context...)
-- <AllowDecomp> = true means that <anIObj> is
-- able to have subshapes detected by selection mechanisms.
-- 2 conditions: <anIObj> must be able to give a shape
-- selection modes fit the AIS2D_Shape
-- selection modes ( 1->vertex, 2->edges, 3->wires...)
Load( me: mutable;
anIObj: InteractiveObject from AIS2D;
SelMode : Integer from Standard = -1;
AllowDecomp : Boolean from Standard = Standard_False );
---Purpose: Available when opened local contexts only;
-- option to load in the selector objects which will
-- be selectable but not displayed. Nevertheless, they
-- will be hilighted when detected by the selector.
-- ex : be able to select center of a line without
-- displaying all centers before selection process
Erase( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True;
PutInCollector : Boolean from Standard = Standard_True );
---Level: Public
---Purpose: Erases presentations in current local context,
-- or failing that, in other local contexts which allow erasing.
-- If <PutInCollector> is false, the object is erased but
-- not put in the Collector.
EraseMode( me : mutable;
anIObj : InteractiveObject from AIS2D;
aMode : Integer from Standard;
UpdateVwr : Boolean from Standard = Standard_True);
---Purpose: Selects an erase mode. Used only if more than one
-- mode is displayed in the main viewer. If aMode is
-- the Prs used by default, no erase mode is selected.
EraseAll( me : mutable;
PutInCollector : Boolean from Standard = Standard_True;
updateVwr : Boolean from Standard = Standard_True );
---Purpose: Every erased object goes into the Collector viewer
DisplayAll( me : mutable;
OnlyFromCollector : Boolean from Standard = Standard_True;
updateVwr : Boolean from Standard = Standard_True);
---Purpose: Displays all erased objects, in other words,
-- all objects in the Collector viewer.
EraseSelected( me : mutable;
PutInCollector : Boolean from Standard = Standard_True;
updateVwr : Boolean from Standard = Standard_True );
---Purpose: Erases selected objects if a local context is open.
-- Erases current objects if there is no active local context.
-- If a local context is open and if <updateVwr> equals
-- Standard_False, the presentation of the Interactive Object
-- activates the selection mode; the object is displayed but
-- no viewer will be updated.
DisplaySelected( me : mutable;
updateVwr : Boolean from Standard = Standard_True );
---Purpose: Displays or erases selected objects if a local
-- context is open. If no active local context is found,
-- only current objects can be displayed or erased.
KeepTemporary( me : mutable;
anIObj : InteractiveObject from AIS2D;
InWhichLocal: Integer from Standard = -1)
returns Boolean from Standard;
---Purpose: Changes the status of a temporary object it will be --
-- kept at the neutral point, i.e. put in the list of
-- displayed objects, with its temporary attributes
-- (displaymode,selection mode) returns true if done --
-- inWhichLocal means that gives the local context in
-- which <anIObj> is displayed. By default, -1 means the
-- last opened one
Redisplay( me : mutable;
anIObj : InteractiveObject from AIS2D;
updateVwr : Boolean from Standard = Standard_True;
allModes : Boolean from Standard = Standard_False);
---Purpose: Forces Recompute of the seen presentations of the object;
-- if <allModes>= True -> recomputes all the
-- presentations .
--***********************************************************************
---Category: Querying and Editing Selection Process
--***********************************************************************
IsCurrent( me; anIObj: InteractiveObject from AIS2D )
returns Boolean from Standard;
---Purpose: Finds the current selected entity <anIObj> in Neutral Point.
IsSelected( me; anIObj: InteractiveObject from AIS2D )
returns Boolean from Standard;
---Purpose: Confirms selection. Returns true if <anIObj> is selected in the interactive context
Highlight( me : mutable;
anIObj : InteractiveObject from AIS2D;
updateVwr: Boolean from Standard = Standard_True);
---Purpose: Updates the display in the viewer to take dynamic detection
-- into account.
-- If a local context is open and if <updateVwr> equals Standard_False,
-- the presentation of the Interactive Object activates the selection
-- mode; the object is displayed but no viewer will be updated.
HighlightWithColor( me: mutable;
anIObj:InteractiveObject from AIS2D;
aCol: NameOfColor from Quantity;
updateVwr: Boolean from Standard = Standard_True );
---Purpose: Changes the color of the object in view <anIObj>.
-- It paints this object the color passed as the argument <aCol>
-- If a local context is open and if <updateVwr> equals Standard_False,
-- the presentation of the Interactive Object activates the selection
-- mode; the object is displayed but no viewer will be updated.
Unhighlight( me : mutable;
anIObj : InteractiveObject from AIS2D;
updateVwr : Boolean from Standard = Standard_True );
---Purpose: Removes hilighting from the entity <anIObj>. Updates the viewer.
-- If a local context is open and if <updateVwr> equals Standard_False,
-- the presentation of the Interactive Object activates the selection
-- mode; the object is displayed but no viewer will be updated.
--****************************************************************
---Category: Graphic Detection and Selection
--****************************************************************
SetPrecision( me: mutable; aPrec: Integer from Standard );
---C++: inline
---Level: Public
---Purpose: Sets the precision of detection
DetectPrecision( me ) returns Integer from Standard;
---C++: inline
---Level: Public
---Purpose: Returns the precision of detection
Place( me : mutable;
XPix, YPix : Integer from Standard;
aView : View from V2d;
anIO : InteractiveObject from AIS2D;
isTemporary : Boolean from Standard = Standard_False );
---Level: Public
---Purpose: Places object <anIO> to the pixel position (XPix, YPix)
-- in the view <aView> is using TransientManager.
-- It's possible to use without preliminary application of Display method.
Drag( me : mutable;
XPix, YPix : Integer from Standard;
aView : View from V2d;
isTemporary: Boolean from Standard = Standard_True );
---Level: Public
---Purpose: Places selected objects to the pixel position (XPix, YPix)
-- in the view <aView>. If <isTemporary> is True, is used TransientManager.
MoveTo( me: mutable;
XPix, YPix: Integer from Standard;
aView: View from V2d ) returns StatusOfDetection from AIS2D;
---Level: Public
---Purpose: Relays mouse position in pixels XPix and YPix to the
-- interactive context selectors. This is done by the view <aView>
-- passing this position to the main viewer and updating it.
-- Functions in both Neutral Point and local contexts.
---SAV
MoveCircleTo( me: mutable; XPix, YPix, Radius : Integer from Standard;
aView: View from V2d ) returns StatusOfDetection from AIS2D;
---Level: Public
---Purpose: Relays mouse position in circle <XPix, YPix> and <Radius> to the
-- interactive context selectors. This is done by the view <aView>
-- passing this position to the main viewer and updating it.
-- Functions in both Neutral Point and local contexts.
MoveTo( me: mutable;
Xmin, Ymin, Xmax, Ymax: Integer from Standard;
aView: View from V2d ) returns StatusOfDetection from AIS2D;
---Level: Public
---Purpose: Relays mouse position in rectangle Xmin, Ymin, Xmax, Ymax to the
-- interactive context selectors. This is done by the view <aView>
-- passing this position to the main viewer and updating it.
-- Functions in both Neutral Point and local contexts.
---SAV
Detect( me: mutable; dList : DisplayList from Graphic2d; aView : View from V2d )
returns StatusOfDetection from AIS2D is private;
Select( me : mutable;
UpdateVwr : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS2D;
---Level: Public
---Purpose: Stores and hilights the previous detected; Unhilights
-- the previous picked.
ShiftSelect( me: mutable; UpdateVwr: Boolean from Standard = Standard_True )
returns StatusOfPick from AIS2D;
---Level: Public
---Purpose: adds the last detected to the list of previous picked.
-- if the last detected was already declared as picked,
-- removes it from the Picked List.
ShiftSelect( me: mutable; XPMin, YPMin, XPMax, YPMax: Integer from Standard;
aView: View from V2d; UpdateVwr : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS2D;
---Level: Public
---Purpose: rectangle of selection ; adds new detected entities into the
-- picked list, removes the detected entities that were already stored...
SetHighlightColor( me: mutable; aCol: NameOfColor from Quantity );
---Purpose: Allows to set the color used to show highlighted entities,
-- that is, entities picked out by the mouse.
SetSelectionColor( me: mutable; aCol: NameOfColor from Quantity );
---Purpose: Sets the color used to show selected entities
SetSubIntensityColor( me: mutable; aCol: NameOfColor from Quantity );
---Purpose: Allows you to set the color used to show that an object
-- is not currently selected
DisplayMode( me ) returns Integer from Standard;
---C++: inline
---Purpose: Returns the display mode setting
HighlightColor( me ) returns NameOfColor from Quantity;
---C++: inline
---Level: Public
---Purpose: Returns the name of the color used to show highlighted entities,
-- that is, entities picked out by the mouse
SelectionColor( me ) returns NameOfColor from Quantity;
---C++: inline
---Level: Public
---Purpose: Returns the name of the color used to show selected entities.
SubIntensityColor( me ) returns NameOfColor from Quantity;
---C++: inline
---Level: Public
---Purpose: Returns the name of the color used to show
-- that an object is not currently selected.
SubIntensityOn( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Highlights, and removes highlights from, the displayed object
-- <anIObj> which is displayed at Neutral Point with subintensity
-- color; available only for active local context.
-- There is no effect if there is no local context.
SubIntensityOff( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Removes the subintensity option for the entity <anIObj>.
-- *************************************************************
-- Management of the Trash Bin Viewer
-- *************************************************************
IsCollectorClosed( me ) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose:
CloseCollector( me: mutable );
---C++: inline
---Level: Internal
---Purpose: Allows to close Collector
OpenCollector( me: mutable );
---Level: Internal
---Purpose: Allows to open Collector
--************************************************************************
---Category: Specific Local Context Action
--************************************************************************
OpenLocalContext( me : mutable;
UseDispObj : Boolean from Standard = Standard_True;
AllowDecomposit : Boolean from Standard = Standard_True;
AcceptEraseOfObj: Boolean from Standard = Standard_False )
returns Integer from Standard;
---Level: Public
---Purpose: Opens a local context of display and selection
-- returns the index of new opened local context.
-- Must be stored and used to close the local context.
CloseLocalContext( me : mutable;
ind : Integer from Standard = -1;
updateVwr : Boolean from Standard = Standard_True );
---Level: Public
---Purpose: close the current opened local context.
-- Use <ind> to be sure to close the local context you Opened !
-- if <ind> == -1 the current local context is closed
-- WITHOUT VERIFICATION.
-- if <ind> is greater than the current opened local context,
-- nothing is done.
IndexOfCurrentLocal( me ) returns Integer from Standard;
---Level: Public
---Purpose: returns -1 if no opened local context.
CloseAllContext( me: mutable; updateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Allows to close all local contexts at one go and return to
-- Neutral Point.
--****************************************************************
---Category: non interactive actions about Selection
-- 2 categories are distinct:
-- - Current Objects
-- - Selected Objects
-- a Current object is the object picked
-- at neutral Point.
-- The Selected objects are objects picked
-- when a local context is opened
SetCurrentObject( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr: Boolean from Standard = Standard_True );
---Level: Public
---Purpose: Updates the view of the current object in open context.
-- Objects selected when there is no open local context
-- are called current objects; those selected in open local context,
-- selected objects.
AddOrRemoveCurObject( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Allows to add a current object to the list of current objects
-- or remove it from that list.
-- Objects selected when there is no open local context are called
-- current objects; those selected in open local context,
-- selected objects.
UpdateCurrent( me: mutable );
---Level: Public
---Purpose: updates the list of current objects
-- i.e. hilights new current objects,
-- unhighlights old current objects
--
SetOkCurrent( me: mutable );
---Level: Internal
---Purpose:
--FirstCurrentObject( me: mutable ) returns InteractiveObject from AIS2D;
---Level: Public
---Purpose: Returns the first current object in the list of current objects.
HighlightCurrent( me: mutable;
UpdateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Highlights current objects.
UnhighlightCurrent( me: mutable;
UpdateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Unhighlights current objects.
ClearCurrent(me: mutable; UpdateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Empties previous current objects in order to get the current
-- objects detected by the selector using UpdateCurrent.
SetSelected( me: mutable; anIObj: InteractiveObject from AIS2D;
UpdateVwr: Boolean from Standard = Standard_True );
---Level: Public
---Purpose: Puts the selected <anIObj> in the current objects list.
SetSelectedCurrent( me: mutable );
---Level: Public
---Purpose: Puts the selected list in the current objects list.
UpdateSelected( me: mutable;
UpdateVwr: Boolean from Standard=Standard_True );
---Level: Public
---Purpose: Updates the list of selected objects, i.e. hilights
-- new selected objects, removes hilighting from former
-- selected objects.
AddOrRemoveSelected( me: mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Allows you to add a selected object <anIObj> to the list of selected
-- objects or remove it from that list.
HighlightSelected( me: mutable;
UpdateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Highlights selected objects.
UnhighlightSelected( me: mutable;
UpdateVwr: Boolean from Standard = Standard_True );
---Level: Public
---Purpose: UnHighlights selected objects.
ClearSelected( me: mutable;
UpdateVwr: Boolean from Standard = Standard_True);
---Level: Public
---Purpose: Empties previous selected objects in order to get
-- the selected objects detected by the selector using UpdateSelected.
NbSelected( me ) returns Integer from Standard;
---Level: Public
---Purpose: Returns number of objects selected in
--- local context ( if opened ) or in neutral context
InitSelected( me: mutable );
---Level: Public
---Purpose: Iteration
MoreSelected( me ) returns Boolean from Standard;
---Level: Public
---Purpose: Iteration
NextSelected( me: mutable );
---Level: Public
---Purpose: Iteration
SelectedObject( me ) returns TShared from MMgt;
---Level: Public
---Purpose: Returns current selected object ( see InitSelected() .. )
-- The object type depends on highlight mode
-- ( OBJECT, PRIMITIVE etc )
--*****************************************************************
-- Querying Graphic Attributes
--*****************************************************************
DisplayStatus( me; anIObj: InteractiveObject from AIS2D )
returns DisplayStatus from AIS2D;
---Level: Public
---Purpose: Returns the display status of the entity <anIObj>.
DisplayedModes( me; anIObj: InteractiveObject from AIS2D )
returns PToListOfInt from AIS2D;
---Level: Public
---Purpose: Returns the list of active display modes for the entity <anIObj>
IsDisplayed( me; anIObj:InteractiveObject from AIS2D )
returns Boolean from Standard;
---Level: Public
---Purpose: Returns true if <anIObj> is displayed in the interactive context
IsDisplayed( me;
anIObj: InteractiveObject from AIS2D;
aMode : Integer from Standard )
returns Boolean from Standard;
---Level: Public
---Purpose: Returns true if <anIObj> is displayed in the interactive context with <aMode> display mode
IsHighlighted( me; anIObj: InteractiveObject from AIS2D )
returns Boolean from Standard;
---Level: Public
---Purpose: Returns true if the Interactive Object <anIObj>
-- is highlighted in the interactive context.
IsHighlighted( me;
anIObj : InteractiveObject from AIS2D;
WithColor : out Boolean from Standard;
theHiCol : out NameOfColor from Quantity )
returns Boolean from Standard;
---Level: Public
---Purpose: if <anIObj> is highlighted with a specific color
-- <WithColor> will be returned TRUE
-- <theHiCol> gives the name of the hilightcolor
IsInCollector( me; anIObj: InteractiveObject from AIS2D )
returns Boolean from Standard;
---Level: Public
---Purpose: Returns true if the entity <anIObj> is in the Collector viewer.
Status( me;
anIObj : InteractiveObject from AIS2D;
aStatus: in out ExtendedString from TCollection);
---Level: Public
---Purpose: Modified the status of the entity <anIObj>
UpdateCurrentViewer( me: mutable );
---Level: Public
---Purpose: Updates the current viewer, the viewer in Neutral Point.
UpdateCollector( me: mutable );
---Level: Public
---Purpose: Updates the Collector viewer
--********************************************************************************
---Category: Information methods - Get Fields
--********************************************************************************
CurrentViewer( me ) returns any Viewer from V2d;
---C++: inline
---Level: Public
---Purpose: Returns the current viewer.
HasOpenedContext( me ) returns Boolean from Standard;
---C++: inline
---Level: Public
---Purpose: Returns true if there is an open context.
DisplayedObjects( me;
aListOfIO : in out ListOfIO from AIS2D;
OnlyFromNeutral : Boolean from Standard = Standard_False );
---Level: Public
---Purpose: gives the list of displayed objects in the main viewer.
--********************************************************************************
GetDefModes( me;
anIObj : InteractiveObject from AIS2D;
Dmode : out Integer from Standard;
HiMod : out TypeOfDetection from AIS2D;
SelMode : out Integer from Standard ) is private;
---Level: Public
---Purpose: Returns display, highlight and selection modes of the <anIObj>
EraseGlobal( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True;
PutInCollector : Boolean from Standard = Standard_True) is private;
---Level: Internal
---Purpose:
SetPickMode( me: mutable; aMode: PickMode from Graphic2d );
---C++: inline
---Level: Public
---Purpose: Allows to provide settings for pick mode.
GetPickMode( me) returns PickMode from Graphic2d;
---C++: inline
---Level: Public
---Purpose: Returns the pick mode
--**********************************************************************************
HighestIndex( me ) returns Integer from Standard;
---Level: Internal
---Purpose:
--**********************************************************************************
-- Category: initialization of the attributes
--**********************************************************************************
InitializeColor( me: mutable; aColor: Color from Quantity ) returns Integer from Standard;
---Purpose: Initialize <aColor> in the color map
InitializeStyle( me: mutable; aType: TypeOfLine from Aspect ) returns Integer from Standard;
---Purpose: Initialize <aType> in the type map
InitializeWidth( me: mutable; aWidth: WidthOfLine from Aspect ) returns Integer from Standard;
---Purpose: Initialize <aWidth> in the width map
InitializeMarker( me: mutable; aMark: TypeOfMarker from Aspect ) returns Integer from Standard;
---Purpose: Initialize <aMark> in the mark map
InitializeFont( me: mutable; aFont: FontStyle from Aspect ) returns Integer from Standard;
---Purpose: Initialize <aFont> in the font map
--**********************************************************************************
ResetOriginalState( me : mutable;
updateVwr : Boolean from Standard = Standard_True );
---Level: Public
---Purpose: to be used only with no opened
-- local context.. displays and activates objects in their
-- original state before local contexts were opened...
DrawObject( me: mutable; anObj: InteractiveObject from AIS2D; aDispMode: Integer from Standard )
is private;
AvailableToDetect( me; anObj: InteractiveObject from AIS2D ) returns Boolean from Standard
is private;
DoDetectObject( me: mutable; anObj: InteractiveObject from AIS2D; aDrawer: TransientManager from Graphic2d )
is private;
IsIOPicked( me; anObj: InteractiveObject from AIS2D )
returns Boolean from Standard is private;
IsPrimPicked( me; anObj: InteractiveObject from AIS2D; aPrim: Primitive from Graphic2d )
returns Boolean from Standard is private;
IsElemPicked( me; anObj: InteractiveObject from AIS2D;
aPrim: Primitive from Graphic2d; ind: Integer from Standard )
returns Boolean from Standard is private;
IsElemSelected( me; anObj: InteractiveObject from AIS2D;
aPrim: Primitive from Graphic2d; ind: Integer from Standard )
returns Boolean from Standard is private;
IsIOSelected( me; anObj: InteractiveObject from AIS2D )
returns Boolean from Standard is private;
IsPrimSelected( me; anObj: InteractiveObject from AIS2D;
aPrim: Primitive from Graphic2d )
returns Boolean from Standard is private;
--**********************************************************************************
-- Category: immediate mode management
--**********************************************************************************
BeginImmediateDraw( me: mutable; aView: View from V2d );
---Level: Public
---Purpose: switches on immediate mode
ImmediateDraw(me: mutable; anIObj: InteractiveObject from AIS2D; aView: View from V2d );
---Level: Public
---Purpose: draws object <anIObj> into immediate mode
EndImmediateDraw( me: mutable; aView: View from V2d );
---Level: Public
---Purpose: switches of immediate mode
IsImmediateModeOn( me; aView: View from V2d ) returns Boolean from Standard;
---Level: Public
---Purpose: returns true if immediate mode is on
---SAV
SetDetectionMode(me:mutable; mode : TypeOfDetection from AIS2D);
fields
myMainVwr : Viewer from V2d;
myCollectorVwr : Viewer from V2d;
myIsCollClosed : Boolean from Standard;
myObjects : DataMapOfIOStatus from AIS2D;
-- the selection and current objects.
myDetectPrecision: Integer from Standard;
myResetDetect : Boolean from Standard;
myLastPicked : InteractiveObject from AIS2D;
myLastinMain : InteractiveObject from AIS2D;
myLastinColl : InteractiveObject from AIS2D;
mySeqOfDetIO : HSequenceOfIO from AIS2D;
mySeqOfSelIO : HSequenceOfIO from AIS2D;
myCurDetectMode : TypeOfDetection from AIS2D;
myWasLastMain : Boolean from Standard;
myPickMode : PickMode from Graphic2d;
-- the attributes of session...
myHighlightColor : NameOfColor from Quantity;
mySelectionColor : NameOfColor from Quantity;
mySubIntensity : NameOfColor from Quantity;
myDisplayMode : Integer from Standard;
-- The Local Context...
myLocalContexts : DataMapOfLC from AIS2D;
myCurLocalIndex : Integer from Standard;
myLastMoveView : View from V2d;
myColorMap : GenericColorMap from Aspect is protected;
myTypeMap : TypeMap from Aspect is protected;
myWidthMap : WidthMap from Aspect is protected;
myMarkMap : MarkMap from Aspect is protected;
myFontMap : FontMap from Aspect is protected;
-- Iteration
myCurSelected : Integer from Standard;
myMaxSelected : Integer from Standard;
friends
class LocalContext from AIS2D
end InteractiveContext;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
inline Handle(V2d_Viewer) AIS2D_InteractiveContext::CurrentViewer() const {
return myMainVwr;
}
inline Standard_Boolean AIS2D_InteractiveContext::IsCollectorClosed() const {
return myIsCollClosed;
}
inline void AIS2D_InteractiveContext::CloseCollector() {
myIsCollClosed = Standard_True;
}
inline Standard_Boolean AIS2D_InteractiveContext::HasOpenedContext() const {
return myCurLocalIndex != 0;
}
inline void AIS2D_InteractiveContext::SetPrecision( const Standard_Integer aPrec ) {
myDetectPrecision = aPrec;
}
inline Standard_Integer AIS2D_InteractiveContext::DetectPrecision() const {
return myDetectPrecision;
}
inline Quantity_NameOfColor AIS2D_InteractiveContext::HighlightColor() const {
return myHighlightColor;
}
inline Quantity_NameOfColor AIS2D_InteractiveContext::SelectionColor() const {
return mySelectionColor;
}
inline Quantity_NameOfColor AIS2D_InteractiveContext::SubIntensityColor() const {
return mySubIntensity;
}
inline Standard_Integer AIS2D_InteractiveContext::DisplayMode() const {
return myDisplayMode;
}
inline Graphic2d_PickMode AIS2D_InteractiveContext::GetPickMode() const {
return myPickMode;
}
inline void AIS2D_InteractiveContext::SetPickMode(const Graphic2d_PickMode aPickMode ) {
myPickMode = aPickMode;
}

View File

@@ -0,0 +1,266 @@
-- File : AIS2D_InteractiveObject.cdl
-- Created : 07 April 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
class InteractiveObject from AIS2D inherits GraphicObject from Graphic2d
---Purpose: Class Interactive Object defines a class of objects
-- with display and selection services.
-- Using visualization and selection machanisms,
-- interactive objects are used to display datum, curves,
-- shapes, markers, dimensions, etc. Interactive objects
-- also provide links to the interactive context.
uses
Primitive from Graphic2d,
TypeOfDetection from AIS2D,
KindOfIO from AIS2D,
InteractiveContext from AIS2D,
Drawer from Prs2d,
AspectRoot from Prs2d,
AspectName from Prs2d,
DataMapOfPrimAspects from AIS2D,
HSequenceOfPrimArchit from AIS2D,
AsciiString from TCollection,
FStream from Aspect,
IFStream from Aspect
is
Create returns mutable InteractiveObject from AIS2D;
---Purpose: Initialize the Interactive Object
--------------------------------------------------------------------
---Category: Methods for attributes management
Attributes( me ) returns Drawer from Prs2d;
---C++: inline
---Level: Public
---Purpose: Returns the attributes settings
SetAttributes( me: mutable; aDrawer: Drawer from Prs2d ) is virtual;
---Level: Public
---Purpose: Initializes the drawing tool <aDrawer>
UnsetAttributes( me: mutable ) is virtual;
---Level: Public
---Purpose: Clears settings provided by the drawing tool <aDrawer>
SetAspect( me: mutable; anAspect: AspectRoot from Prs2d );
---Level: Public
---Purpose: Sets the attributes from Aspect <anAspect>
-- to all primitives appropriate this Aspect.
SetAspect( me: mutable; anAspect: AspectRoot from Prs2d;
aPrimitive: Primitive from Graphic2d );
---Level: Public
---Purpose: Sets the attributes from Aspect <anAspect>
-- to primitive <aPrimitive>
-- Method works only for objects are linked
-- with InteractiveContext
GetAspect( me; aPrimitive: Primitive from Graphic2d )
returns AspectRoot from Prs2d;
---Level: Public
---Purpose: Returns Aspect for primitive <aPrimitive>
-- Method works only for objects are linked
-- with InteractiveContext
HasAspect( me; aPrimitive: Primitive from Graphic2d )
returns Boolean from Standard;
---Level: Public;
---Purpose: Returns true if primitive <aPrimitive>
-- is linked with an aspect
--------------------------------------------------------------------
---Category: Link To InteractiveContext
HasInteractiveContext( me ) returns Boolean from Standard;
---Level: Public
---Purpose: Indicates whether the Interactive Object has a pointer
-- to an interactive context.
GetContext( me ) returns InteractiveContext from AIS2D;
---Level: Public
---Purpose: Returns the context pointer to the interactive context.
SetContext( me:mutable; aCntx : InteractiveContext from AIS2D ) is virtual;
---Level: Public
---Purpose: Places a link to <aCnTx>. The drawer of AIS2D_InteractiveObject
-- is connected to the Default Drawer Of <aCntx>.
-- That Means that this method has to be redefined if
-- computations depend on drawer values.
--------------------------------------------------------------------
---Category: Methods for display modes management
DisplayMode( me ) returns Integer;
---C++: inline
---Level: Public
---Purpose: Indicates the display mode of the Interactive Object
HasDisplayMode ( me ) returns Boolean from Standard;
---C++: inline
---Level: Public
---Purpose: Returns True if the Interactive Object has
-- a display mode setting. Otherwise, it is
-- displayed in Neutral Point.
SetDisplayMode( me: mutable; aMode: Integer from Standard );
---C++: inline
---Level: Public
---Purpose: Allows to provide a setting <aMode> for an
-- Interactive Object's display mode.
UnsetDisplayMode( me: mutable );
---C++: inline
---Level: Public
---Purpose: Removes display mode settings from the Interactive object
DefaultDisplayMode( me ) returns Integer from Standard is virtual;
---C++: inline
---Level: Public
---Purpose: Returns the default display mode. This method is to be
-- implemented when the main mode is not mode 0.
AcceptDisplayMode( me; aMode: Integer from Standard ) returns Boolean from Standard is virtual;
---C++: inline
---Level: Public
---Purpose: Returns true if the class of objects accepts the display mode <aMode>
--------------------------------------------------------------------
---Category: Methods for highlight modes management
HighlightMode( me ) returns TypeOfDetection from AIS2D;
---C++: inline
---Level: Public
---Purpose: Returns the setting for highlight mode.
HasHighlightMode( me ) returns Boolean from Standard;
---C++: inline
---Level: Public
---Purpose: Returns true if the Interactive Object is in highlight mode
SetHighlightMode( me: mutable; aMode: TypeOfDetection from AIS2D );
---C++: inline
---Level: Public
---Purpose: Allows to provide settings for highlight mode.
UnsetHighlightMode( me: mutable );
---C++: inline
---Level: Public
---Purpose: Removes settings for highlight mode
DefaultHighlightMode( me ) returns TypeOfDetection from AIS2D is virtual;
---C++: inline
---Level: Public
---Purpose: Returns the default highlight mode
--------------------------------------------------------------------
---Category: Methods for selection modes management
--------------------------------------------------------------------
SelectionMode( me ) returns Integer from Standard;
---C++: inline
---Level: Public
---Purpose: Indicates the selection mode of the Interactive Object
HasSelectionMode( me ) returns Boolean from Standard;
---C++: inline
---Level: Public
---Purpose: Allows you to change the selection mode of an Interactive Object
SetSelectionMode( me: mutable; aMode: Integer from Standard );
---C++: inline
---Level: Public
---Purpose: Allows to provide a setting <aMode> for an
-- Interactive Object's selection mode.
UnsetSelectionMode( me: mutable );
---C++: inline
---Level: Public
---Purpose: Removes settings for selection mode
DefaultSelectionMode( me ) returns Integer from Standard is virtual;
---C++: inline
---Level: Public
---Purpose: Returns the default selection mode
PrimitiveExist( me; aName: AspectName from Prs2d )
returns Boolean from Standard is private;
---Level: Internal
State( me ) returns Integer from Standard;
---C++: inline
---Level: Internal
---Purpose:
SetState( me: mutable; aState: Integer from Standard );
---C++: inline
---Level: Internal
---Purpose:
SelectPrimitive (me : mutable; anIndex: Integer from Standard;
append: Boolean from Standard );
---Level: Public
---Purpose: Selects primitive with index( TOD_PRIMITIVE mode only )
AddDetectPrim( me: mutable; aPrim: Primitive from Graphic2d;
anInd: Integer from Standard ) is private;
---Level: Internal
---Purpose:
AddSelectPrim( me: mutable; aPrim: Primitive from Graphic2d;
anInd: Integer from Standard ) is private;
---Level: Internal
---Purpose:
RemoveSelectPrim( me: mutable; aPrim: Primitive from Graphic2d;
anInd: Integer from Standard ) is private;
---Level: Internal
---Purpose:
SetSelSeqPrim( me: mutable; aSeq: HSequenceOfPrimArchit from AIS2D ) is private;
---Level: Internal
---Purpose:
ClearSeqDetPrim( me: mutable ) is private;
---Level: Internal
---Purpose:
ClearSeqSelPrim( me: mutable ) is private;
---Level: Internal
---Purpose:
GetDetectSeqPrim( me ) returns HSequenceOfPrimArchit from AIS2D is private;
---Level: Internal
---Purpose:
GetSelectedSeqPrim( me ) returns HSequenceOfPrimArchit from AIS2D is private;
---Level: Internal
---Purpose:
--------------------------------------------------------------------
Save(me; aFStream: in out FStream from Aspect) is virtual;
Retrieve(me; anIFStream: in out IFStream from Aspect) is virtual;
fields
myICTX : InteractiveContext from AIS2D;
myDrawer : Drawer from Prs2d is protected;
myDisplayMode : Integer from Standard;
myHighlightMode : TypeOfDetection from AIS2D is protected;
mySelectionMode : Integer from Standard;
myAspects : DataMapOfPrimAspects from AIS2D;
myState : Integer from Standard;
myDetectedPrimSeq : HSequenceOfPrimArchit from AIS2D;
mySelectedPrimSeq : HSequenceOfPrimArchit from AIS2D;
friends
class InteractiveContext from AIS2D
end InteractiveObject;

View File

@@ -0,0 +1,465 @@
#include <AIS2D_InteractiveObject.ixx>
#include <Prs2d_AspectLine.hxx>
#include <Prs2d_Point.hxx>
#include <V2d_Viewer.hxx>
#include <AIS2D_ProjShape.hxx>
#include <AIS2D_PrimitiveArchit.hxx>
#include <Graphic2d_Segment.hxx>
#include <Graphic2d_InfiniteLine.hxx>
#include <Graphic2d_Polyline.hxx>
#include <Graphic2d_PolylineMarker.hxx>
#include <Graphic2d_Circle.hxx>
#include <Graphic2d_CircleMarker.hxx>
#include <Graphic2d_Ellips.hxx>
#include <Graphic2d_EllipsMarker.hxx>
#include <GGraphic2d_Curve.hxx>
#include <stdio.h>
#define NUM_ASPECTROOT 29
AIS2D_InteractiveObject::AIS2D_InteractiveObject()
: Graphic2d_GraphicObject(),
myDrawer( new Prs2d_Drawer() ),
myHighlightMode( AIS2D_TOD_PRIMITIVE ),
myICTX(),
myDisplayMode( 0 ),
mySelectionMode( 0 ),
myAspects(),
myState( 0 ),
myDetectedPrimSeq( new AIS2D_HSequenceOfPrimArchit() ),
mySelectedPrimSeq( new AIS2D_HSequenceOfPrimArchit() )
{
AIS2D_DataMapOfPrimAspects theAspect(NUM_ASPECTROOT);
myAspects = theAspect;
printf(" $$$ Creates AIS2D_InteractiveObject()\n");
}
void AIS2D_InteractiveObject::SetAttributes( const Handle(Prs2d_Drawer)& aDrawer ) {
myDrawer = aDrawer;
}
void AIS2D_InteractiveObject::UnsetAttributes() {
myDrawer = new Prs2d_Drawer();
}
void AIS2D_InteractiveObject::SetAspect( const Handle(Prs2d_AspectRoot)& anAspect ) {
if ( ! PrimitiveExist(anAspect->GetAspectName()) ) return;
switch ( anAspect->GetAspectName() ) {
case Prs2d_AN_LINE: {
if ( GetContext().IsNull() ) {
myDrawer->SetAspect( anAspect, Prs2d_AN_LINE );
return;
}
Handle(Prs2d_AspectLine) theAspLine =
Handle(Prs2d_AspectLine)::DownCast( anAspect );
Quantity_Color aColor;
Aspect_TypeOfLine aType;
Aspect_WidthOfLine aWidth;
Quantity_Color aIntColor;
Graphic2d_TypeOfPolygonFilling aTypeFill;
Standard_Integer aTile;
Standard_Boolean aDrawEdge;
theAspLine->ValuesOfLine( aColor, aType, aWidth );
theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge );
Standard_Integer colorInd = theAspLine->ColorIndex();
Standard_Integer typeInd = theAspLine->TypeIndex();
Standard_Integer widthInd = theAspLine->WidthIndex();
Standard_Integer colorIntInd = theAspLine->InterColorIndex();
if ( !colorInd ) {
colorInd = GetContext()->InitializeColor( aColor );
theAspLine->SetColorIndex( colorInd );
}
if ( !typeInd ) {
typeInd = GetContext()->InitializeStyle( aType );
theAspLine->SetTypeIndex( typeInd );
}
if ( !widthInd ) {
widthInd = GetContext()->InitializeWidth( aWidth );
theAspLine->SetWidthIndex( widthInd );
}
if ( !colorIntInd ) {
colorIntInd = GetContext()->InitializeColor( aIntColor );
theAspLine->SetIntColorInd( colorIntInd );
}
if ( this->IsKind(STANDARD_TYPE(AIS2D_ProjShape) ) ) {
Handle(AIS2D_ProjShape) thePS = Handle(AIS2D_ProjShape)::DownCast(this);
Handle(Graphic2d_Line) theLines = thePS->GetPrimitives();
theLines->SetColorIndex( colorInd );
theLines->SetTypeIndex( typeInd );
theLines->SetWidthIndex( widthInd );
if ( thePS->IsHLMode() ) {
Handle(Graphic2d_Line) theHLines = thePS->GetHLPrimitives();
theHLines->SetColorIndex( colorInd );
theHLines->SetWidthIndex( widthInd );
Standard_Integer theDashInd = GetContext()->InitializeStyle( Aspect_TOL_DASH );
theHLines->SetTypeIndex( theDashInd );
}
} else
for ( Standard_Integer i = 1; i <= Length(); i++ ) {
if ( Primitive(i)->IsKind(STANDARD_TYPE(Graphic2d_Line)) ) {
Handle(Graphic2d_Line) theLine =
Handle(Graphic2d_Line)::DownCast( Primitive(i) );
theLine->SetColorIndex( colorInd );
theLine->SetTypeIndex( typeInd );
theLine->SetWidthIndex( widthInd );
theLine->SetInteriorColorIndex( colorIntInd );
theLine->SetTypeOfPolygonFilling( aTypeFill );
theLine->SetInteriorPattern( aTile );
theLine->SetDrawEdge( aDrawEdge );
if ( !myAspects.IsBound(theLine) )
myAspects.Bind( theLine, theAspLine );
else
myAspects( theLine ) = theAspLine;
} // end if STANDARD_TYPE is Graphic2d_Line
} // end for
break;
} // end case Prs2d_AN_LINE
case Prs2d_AN_HIDDENLINE: {
}
case Prs2d_AN_TEXT: {
}
case Prs2d_AN_HIDINGPOLY: {
}
case Prs2d_AN_HIDINGTEXT: {
}
case Prs2d_AN_FRAMEDTEXT: {
}
case Prs2d_AN_LAST: {
}
case Prs2d_AN_UNKNOWN: {
}
}
myDrawer->SetAspect( anAspect, anAspect->GetAspectName() );
if ( !GetContext().IsNull() )
GetContext()->CurrentViewer()->Update();
}
void AIS2D_InteractiveObject::SetAspect( const Handle(Prs2d_AspectRoot)& anAspect,
const Handle(Graphic2d_Primitive)& aPrim ) {
if ( ( GetContext().IsNull() ) || ( !IsIn(aPrim) ) ) return;
switch ( anAspect->GetAspectName() ) {
case Prs2d_AN_LINE: {
if ( aPrim->IsKind(STANDARD_TYPE(Graphic2d_Line)) ) {
Handle(Prs2d_AspectLine) theAspLine =
Handle(Prs2d_AspectLine)::DownCast( anAspect );
Quantity_Color aColor;
Aspect_TypeOfLine aType;
Aspect_WidthOfLine aWidth;
Quantity_Color aIntColor;
Graphic2d_TypeOfPolygonFilling aTypeFill;
Standard_Integer aTile;
Standard_Boolean aDrawEdge;
theAspLine->ValuesOfLine( aColor, aType, aWidth );
theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge );
Standard_Integer colorInd = theAspLine->ColorIndex();
Standard_Integer typeInd = theAspLine->TypeIndex();
Standard_Integer widthInd = theAspLine->WidthIndex();
Standard_Integer colorIntInd = theAspLine->InterColorIndex();
if ( !colorInd ) {
colorInd = GetContext()->InitializeColor( aColor );
theAspLine->SetColorIndex( colorInd );
}
if ( !typeInd ) {
typeInd = GetContext()->InitializeStyle( aType );
theAspLine->SetTypeIndex( typeInd );
}
if ( !widthInd ) {
widthInd = GetContext()->InitializeWidth( aWidth );
theAspLine->SetWidthIndex( widthInd );
}
if ( !colorIntInd ) {
colorIntInd = GetContext()->InitializeColor( aIntColor );
theAspLine->SetIntColorInd( colorIntInd );
}
Handle(Graphic2d_Line) theLine = Handle(Graphic2d_Line)::DownCast( aPrim );
theLine->SetColorIndex( colorInd );
theLine->SetTypeIndex( typeInd );
theLine->SetWidthIndex( widthInd );
theLine->SetInteriorColorIndex( colorIntInd );
theLine->SetTypeOfPolygonFilling( aTypeFill );
theLine->SetInteriorPattern( aTile );
theLine->SetDrawEdge( aDrawEdge );
if ( !myAspects.IsBound(aPrim) )
myAspects.Bind( theLine, theAspLine );
else
myAspects( theLine ) = theAspLine;
} // end if STANDARD_TYPE is Graphic2d_Line
break;
} // end case Prs2d_AN_LINE
case Prs2d_AN_HIDDENLINE: {
break;
}
case Prs2d_AN_TEXT: {
break;
}
case Prs2d_AN_HIDINGPOLY: {
break;
}
case Prs2d_AN_HIDINGTEXT: {
break;
}
case Prs2d_AN_FRAMEDTEXT: {
break;
}
case Prs2d_AN_LAST: {
break;
}
case Prs2d_AN_UNKNOWN: {
break;
}
} // end switch
myDrawer->SetAspect( anAspect, anAspect->GetAspectName() );
GetContext()->CurrentViewer()->Update();
}
Handle(Prs2d_AspectRoot) AIS2D_InteractiveObject::GetAspect
( const Handle(Graphic2d_Primitive)& aPrim ) const {
return myAspects( aPrim );
}
Standard_Boolean AIS2D_InteractiveObject::HasAspect
( const Handle(Graphic2d_Primitive)& aPrim ) const {
return myAspects.IsBound( aPrim );
}
Standard_Boolean AIS2D_InteractiveObject::HasInteractiveContext() const {
return ( ! myICTX.IsNull() );
}
Handle(AIS2D_InteractiveContext) AIS2D_InteractiveObject::GetContext() const {
return myICTX;
}
void AIS2D_InteractiveObject::SetContext( const Handle(AIS2D_InteractiveContext)& aCtx) {
myICTX = aCtx;
if ( myDrawer.IsNull() )
myDrawer = new Prs2d_Drawer;
}
void AIS2D_InteractiveObject::SelectPrimitive (const Standard_Integer anIndex, const Standard_Boolean append )
{
if ( !append )
{ // unselect all
for ( Standard_Integer i = 1; i <= mySelectedPrimSeq->Length(); i++ )
mySelectedPrimSeq->Value( i )->GetPrimitive()->Unhighlight();
mySelectedPrimSeq->Clear();
SetState( 0 );
}
// select new primitive
SetPickedIndex( anIndex );
}
Standard_Boolean AIS2D_InteractiveObject::PrimitiveExist( const Prs2d_AspectName aName) const {
Standard_Boolean isFound = Standard_False;
for ( Standard_Integer i = 1; i <= Length(); i++ )
switch ( aName ) {
case Prs2d_AN_LINE: {
if ( Primitive(i)->IsKind(STANDARD_TYPE(Graphic2d_Line)) )
isFound = Standard_True;
break;
}
case Prs2d_AN_HIDDENLINE: {
break;
}
case Prs2d_AN_TEXT: {
break;
}
case Prs2d_AN_HIDINGPOLY: {
break;
}
case Prs2d_AN_HIDINGTEXT: {
break;
}
case Prs2d_AN_FRAMEDTEXT: {
break;
}
case Prs2d_AN_LAST: {
break;
}
case Prs2d_AN_UNKNOWN: {
break;
}
} // end switch
return isFound;
}
void AIS2D_InteractiveObject::AddDetectPrim ( const Handle(Graphic2d_Primitive)& aPrim,
const Standard_Integer anInd) {
Handle(AIS2D_PrimitiveArchit) thePA = new AIS2D_PrimitiveArchit( aPrim, anInd );
myDetectedPrimSeq->Append( thePA );
}
void AIS2D_InteractiveObject::AddSelectPrim ( const Handle(Graphic2d_Primitive)& aPrim,
const Standard_Integer anInd) {
Handle(AIS2D_PrimitiveArchit) thePA = new AIS2D_PrimitiveArchit( aPrim, anInd );
mySelectedPrimSeq->Append( thePA );
}
void AIS2D_InteractiveObject::RemoveSelectPrim ( const Handle(Graphic2d_Primitive)& aPrim,
const Standard_Integer anInd) {
if ( mySelectedPrimSeq->IsEmpty() ) return;
for ( int i = 1; i <= mySelectedPrimSeq->Length(); ++i )
if ( mySelectedPrimSeq->Value(i)->GetPrimitive() == aPrim &&
mySelectedPrimSeq->Value(i)->GetIndex() == anInd ) {
mySelectedPrimSeq->Remove(i);
return;
}
}
void AIS2D_InteractiveObject::SetSelSeqPrim( const Handle(AIS2D_HSequenceOfPrimArchit)& aSeq ) {
mySelectedPrimSeq = aSeq;
}
void AIS2D_InteractiveObject::ClearSeqDetPrim() {
myDetectedPrimSeq->Clear();
}
void AIS2D_InteractiveObject::ClearSeqSelPrim() {
mySelectedPrimSeq->Clear();
}
Handle(AIS2D_HSequenceOfPrimArchit) AIS2D_InteractiveObject::GetDetectSeqPrim() const {
return myDetectedPrimSeq;
}
Handle(AIS2D_HSequenceOfPrimArchit) AIS2D_InteractiveObject::GetSelectedSeqPrim() const {
return mySelectedPrimSeq;
}
void AIS2D_InteractiveObject::Save(Aspect_FStream& aFStream) const
{
int lnOfPr = Length();
*aFStream << "AIS2D_InteractiveObject" << endl;
for (int j = 1; j <= lnOfPr; j++)
{
Handle(Graphic2d_Primitive) thePrm = this->Primitive(j);
thePrm->Save(aFStream);
}
}
void AIS2D_InteractiveObject::Retrieve(Aspect_IFStream& anIFStream) const
{
char buf[100];
anIFStream->getline(buf, 100);
while (! anIFStream->eof())
{
if (! strcmp(buf, "Graphic2d_Segment"))
{
Graphic2d_Segment::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_InfiniteLine"))
{
Graphic2d_InfiniteLine::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_Polyline"))
{
Graphic2d_Polyline::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_PolylineMarker"))
{
Graphic2d_PolylineMarker::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_Circle"))
{
Graphic2d_Circle::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_CircleMarker"))
{
Graphic2d_CircleMarker::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_Ellips"))
{
Graphic2d_Ellips::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "Graphic2d_EllipsMarker"))
{
Graphic2d_EllipsMarker::Retrieve(anIFStream, this);
}
else if (! strcmp(buf, "GGraphic2d_Curve"))
{
GGraphic2d_Curve::Retrieve(anIFStream, this);
}
anIFStream->getline(buf, 100);
}
}

View File

@@ -0,0 +1,75 @@
inline Handle(Prs2d_Drawer) AIS2D_InteractiveObject::Attributes() const {
return myDrawer;
}
inline Standard_Integer AIS2D_InteractiveObject::DisplayMode() const {
return myDisplayMode;
}
inline Standard_Boolean AIS2D_InteractiveObject::HasDisplayMode() const {
return myDisplayMode != -1;
}
inline void AIS2D_InteractiveObject::SetDisplayMode( const Standard_Integer aMode ) {
myDisplayMode = aMode;
}
inline void AIS2D_InteractiveObject::UnsetDisplayMode() {
myDisplayMode = -1;
}
inline Standard_Integer AIS2D_InteractiveObject::DefaultDisplayMode() const {
return 0;
}
inline Standard_Boolean AIS2D_InteractiveObject::AcceptDisplayMode( const Standard_Integer /*aMode*/ ) const {
return Standard_True;
}
inline AIS2D_TypeOfDetection AIS2D_InteractiveObject::HighlightMode() const {
return myHighlightMode;
}
inline Standard_Boolean AIS2D_InteractiveObject::HasHighlightMode() const {
return myHighlightMode != AIS2D_TOD_NONE;
}
inline void AIS2D_InteractiveObject::SetHighlightMode( const AIS2D_TypeOfDetection aMode ) {
myHighlightMode = aMode;
}
inline void AIS2D_InteractiveObject::UnsetHighlightMode() {
myHighlightMode = AIS2D_TOD_NONE;
}
inline AIS2D_TypeOfDetection AIS2D_InteractiveObject::DefaultHighlightMode() const {
return AIS2D_TOD_PRIMITIVE;
}
inline Standard_Integer AIS2D_InteractiveObject::SelectionMode() const {
return mySelectionMode;
}
inline Standard_Boolean AIS2D_InteractiveObject::HasSelectionMode() const {
return mySelectionMode != -1;
}
inline void AIS2D_InteractiveObject::SetSelectionMode( const Standard_Integer aMode ) {
mySelectionMode = aMode;
}
inline void AIS2D_InteractiveObject::UnsetSelectionMode() {
mySelectionMode = -1;
}
inline Standard_Integer AIS2D_InteractiveObject::DefaultSelectionMode() const {
return 0;
}
inline Standard_Integer AIS2D_InteractiveObject::State() const {
return myState;
}
inline void AIS2D_InteractiveObject::SetState( const Standard_Integer aState ) {
myState = aState;
}

213
src/AIS2D/AIS2D_LocalContext.cdl Executable file
View File

@@ -0,0 +1,213 @@
-- File : AIS2D_LocalContext.cdl
-- Created : February 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
private class LocalContext from AIS2D inherits TShared from MMgt
---Purpose: defines a specific context for selection: One can
-- loads InteractiveObjects with a mode to be
-- activated associate InteractiveObjects with a
-- set of temporary selectable Objects
--
uses
ListOfInteger from TColStd,
SequenceOfInteger from TColStd,
MapOfTransient from TColStd,
NameOfColor from Quantity,
PlaneAngle from Quantity,
Length from Quantity,
GridType from Aspect,
GridDrawMode from Aspect,
View from V2d,
Primitive from Graphic2d,
InteractiveObject from AIS2D,
InteractiveContext from AIS2D,
LocalStatus from AIS2D,
StatusOfPick from AIS2D,
StatusOfDetection from AIS2D,
PToListOfInt from AIS2D,
DataMapOfLocStat from AIS2D,
ClearMode from AIS2D
is
Create returns mutable LocalContext from AIS2D;
---Purpose: Constructor By Default, the displayed objects are
-- automatically loaded.
Create ( aCtx : InteractiveContext from AIS2D;
anIndex : Integer from Standard;
LoadDisplayed : Boolean from Standard = Standard_True;
AcceptStdModes : Boolean from Standard = Standard_True;
AcceptErase : Boolean from Standard = Standard_False )
returns mutable LocalContext from AIS2D;
---Purpose: Constructor
-- *************************************************************
-- Editing general Display Services
-- *************************************************************
Display( me : mutable;
anIObj : InteractiveObject from AIS2D;
DisplayMode : Integer from Standard = 0;
AllowDecomp : Boolean from Standard = Standard_True;
ActivationMode : Integer from Standard = 0 )
returns Boolean from Standard;
---Level: Internal
---Purpose:
Load( me : mutable;
anIObj : InteractiveObject from AIS2D;
AllowDecomp : Boolean from Standard = Standard_True;
ActivationMode : Integer from Standard = 0)
returns Boolean from Standard;
---Level: Internal
---Purpose:
Erase( me : mutable;
anIObj : InteractiveObject from AIS2D )
returns Boolean from Standard;
---Level: Internal
---Purpose:
Remove( me : mutable;
aSelObj : InteractiveObject from AIS2D )
returns Boolean from Standard;
---Level: Internal
---Purpose:
LoadContextObjects( me: mutable );
UnloadContextObjects( me: mutable );
Terminate( me: mutable );
---Level: Internal
---Purpose:
Clear( me: mutable; aType: ClearMode from AIS2D = AIS2D_CM_All );
---Purpose: according to <aType>, clears the different parts of
-- the selector (filters, modeof activation, objects...)
HighlightPicked( me: mutable; UpdateVwr: Boolean from Standard = Standard_True ) ;
UnhighlightPicked( me: mutable; UpdateVwr: Boolean from Standard = Standard_True ) ;
UpdateSelected( me : mutable;
UpdateVwr : Boolean from Standard = Standard_True );
SetSelected( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard=Standard_True );
---Purpose: useful to update selection with objects coming from
-- Collector or stack
AddOrRemoveSelected( me : mutable;
anIObj : InteractiveObject from AIS2D;
UpdateVwr : Boolean from Standard = Standard_True );
---Purpose: useful to update selection with objects coming from
-- Collector or stack
--***************************************************************************
-- Information about Detection
--***************************************************************************
IsSelected( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard;
SelectedIO( me ) returns InteractiveObject from AIS2D;
-- *******************************************************************************
-- Management Of Temporary Attributes
-- *******************************************************************************
SetDisplayPriority( me : mutable;
anIObj : InteractiveObject from AIS2D;
Prior : Integer from Standard);
DisplayedObjects( me; theMapToFill: in out MapOfTransient from TColStd )
returns Integer from Standard;
IsDisplayed( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard;
IsDisplayed( me; anIObj: InteractiveObject from AIS2D;
aMode: Integer from Standard)
returns Boolean from Standard;
Unhighlight( me:mutable; anIObj: InteractiveObject from AIS2D);
IsHighlight( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard;
IsHighlight( me;
anIObj : InteractiveObject from AIS2D;
WithColor : out Boolean from Standard;
HiCol : out NameOfColor from Quantity)
returns Boolean from Standard;
IsIn( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard;
SubIntensityOn( me: mutable; anIObj: InteractiveObject from AIS2D );
SubIntensityOff( me: mutable; anIObj: InteractiveObject from AIS2D );
--****************************************************************
-- Graphic Detection and Selection
--****************************************************************
UnhighLastDetect( me: mutable; aView: View from V2d) returns Boolean from Standard;
MoveTo( me: mutable; Xpix, Ypix: Integer from Standard; aView: View from V2d)
returns StatusOfDetection from AIS2D;
Select( me: mutable; UpdateVwr: Boolean from Standard = Standard_True )
returns StatusOfPick from AIS2D;
ShiftSelect( me: mutable; UpdateVwr: Boolean from Standard = Standard_True)
returns StatusOfPick from AIS2D;
--**********************************************************************************
--**********************************************************************************
ClearSelected( me: mutable; UpdateVwr: Boolean from Standard=Standard_True );
ClearObjects( me:mutable ) is static private;
ClearDetected( me:mutable ) is static private;
IsValidForSelection( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard is static private;
DrawObject( me: mutable; anObj: InteractiveObject from AIS2D; aDispMode: Integer from Standard )
is private;
DetectedIndex(me:mutable) returns Integer from Standard is static private;
Status( me; anObject: InteractiveObject from AIS2D )
returns any LocalStatus from AIS2D is private;
---C++: return const&
fields
myICTX : InteractiveContext from AIS2D;
myActiveObjects : DataMapOfLocStat from AIS2D;
myLastPicked : InteractiveObject from AIS2D;
myLastinMain : InteractiveObject from AIS2D;
myLastSelPrim : Primitive from Graphic2d;
myLastPickPrim : Primitive from Graphic2d;
myLastPickElInd : Integer from Standard;
myLastSelElInd : Integer from Standard;
myLoadDisplayed : Boolean from Standard;
myAcceptStdMode : Boolean from Standard;
myAcceptErase : Boolean from Standard;
myListOfStdMode : ListOfInteger from TColStd;
myAutoHighlight : Boolean from Standard;
myLastIndex : Integer from Standard;
myLastGood : Integer from Standard;
myDetectedSeq : SequenceOfInteger from TColStd;
myCurDetected : Integer from Standard;
myResetDetect : Boolean from Standard;
friends
KeepTemporary from InteractiveContext from AIS2D(me:mutable; anIObj:InteractiveObject from AIS2D; WhichMode: Integer from Standard = -1)
end LocalContext;

969
src/AIS2D/AIS2D_LocalContext.cxx Executable file
View File

@@ -0,0 +1,969 @@
#include <AIS2D_LocalContext.ixx>
#include <AIS2D_LocalStatus.hxx>
#include <AIS2D_ProjShape.hxx>
#include <AIS2D_ListOfIO.hxx>
#include <AIS2D_DataMapIteratorOfDataMapOfLocStat.hxx>
#include <Prs2d_AspectLine.hxx>
#include <Prs2d_Drawer.hxx>
#include <Prs2d_Point.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <AIS2D_ListIteratorOfListOfIO.hxx>
#include <TColStd_Array1OfTransient.hxx>
#include <TColStd_HArray1OfTransient.hxx>
#include <V2d_Viewer.hxx>
#include <Graphic2d_TransientManager.hxx>
#include <Graphic2d_Line.hxx>
#include <Graphic2d_View.hxx>
#include <Graphic2d_DisplayList.hxx>
#include <AIS2D_HSequenceOfIO.hxx>
static Standard_Integer GetHiMod(const Handle(AIS2D_InteractiveObject)& anIO)
{
return anIO->HasHighlightMode() ? anIO->HighlightMode()
: anIO->DefaultHighlightMode();
}
AIS2D_LocalContext::AIS2D_LocalContext()
{
}
AIS2D_LocalContext::AIS2D_LocalContext(
const Handle(AIS2D_InteractiveContext)& aCtx,
const Standard_Integer /*Index*/,
const Standard_Boolean LoadDisplayed,
const Standard_Boolean AcceptStdModes,
const Standard_Boolean AcceptEraseOfTemp ):
myICTX( aCtx ),
myLastPicked( new AIS2D_InteractiveObject()),
myLastinMain( new AIS2D_InteractiveObject()),
myLastPickElInd( 0 ),
myLastSelElInd( 0 ),
myLoadDisplayed( LoadDisplayed ),
myAcceptStdMode( AcceptStdModes ),
myAcceptErase( AcceptEraseOfTemp ),
myAutoHighlight( Standard_True ),
myLastIndex( 0 ),
myLastGood( 0 ),
myCurDetected( 0 ),
myResetDetect( Standard_True )
{
if ( myLoadDisplayed ) LoadContextObjects();
}
Standard_Boolean AIS2D_LocalContext::Display(
const Handle( AIS2D_InteractiveObject)& anIObj,
const Standard_Integer WhichMode,
const Standard_Boolean /*AllowDecomp*/,
const Standard_Integer ActivationMode ) {
if ( myActiveObjects.IsBound(anIObj) ) {
const Handle( AIS2D_LocalStatus )& LStatus = myActiveObjects( anIObj );
if ( LStatus->DisplayMode() == -1) {
if ( !anIObj->IsDisplayed() )
anIObj->Display();
if ( LStatus->IsTemporary() )
LStatus->SetDisplayMode( WhichMode );
} else if ( LStatus->DisplayMode() != WhichMode && LStatus -> IsTemporary() ) {
anIObj->Remove();
LStatus->SetDisplayMode( WhichMode );
if ( !anIObj->IsDisplayed() )
anIObj->Display();
}
if ( ActivationMode !=-1 ) {
if ( !LStatus->IsActivated( ActivationMode ) ) {
LStatus->ClearSelectionModes();
//mySelMgr->Load( anIObj, myMainVS );
LStatus->AddSelectionMode( ActivationMode );
//mySelMgr->Activate( anIObj, ActivationMode, myMainVS );
}
}
} else {
Handle(AIS2D_LocalStatus) LStatus = new AIS2D_LocalStatus();
/*if ( anIObj->AcceptDecomposition() && AllowDecomp )
LStatus->SetDecomposition(Standard_True);
else
LStatus->SetDecomposition(Standard_False);
*/
if( myICTX->DisplayStatus(anIObj) == AIS2D_DS_None ||
myICTX->DisplayStatus(anIObj) == AIS2D_DS_Temporary )
LStatus->SetTemporary(Standard_True);
else
LStatus->SetTemporary(Standard_False);
AIS2D_TypeOfDetection HiMod ;
if( !myICTX->IsDisplayed( anIObj, WhichMode) ) {
LStatus->SetDisplayMode(WhichMode);
if ( ActivationMode != -1 )
LStatus->AddSelectionMode(ActivationMode);
HiMod = anIObj->HasHighlightMode() ?
anIObj->HighlightMode() : anIObj->DefaultHighlightMode();
LStatus->SetHighlightMode( HiMod );
if( !anIObj->IsDisplayed()) {
DrawObject(anIObj,WhichMode);
anIObj->Display();
}
/*if(ActivationMode!=-1) {
mySelMgr->Load(anIObj,myMainVS);
mySelMgr->Activate(anIObj,ActivationMode,myMainVS);
} */
} else {
HiMod = anIObj->HasHighlightMode()? anIObj->HighlightMode(): anIObj->DefaultHighlightMode();
LStatus->SetHighlightMode( HiMod );
}
myActiveObjects.Bind(anIObj,LStatus);
}
return Standard_True;
}
Standard_Boolean AIS2D_LocalContext::Erase( const Handle(AIS2D_InteractiveObject)& anIObj) {
if ( !myActiveObjects.IsBound( anIObj ) ) return Standard_False;
const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects( anIObj );
if ( LStatus->IsSubIntensityOn() ) {
LStatus->SubIntensityOff();
anIObj->Unhighlight();
}
Standard_Boolean stat( Standard_False );
if ( LStatus->DisplayMode() != -1 ) {
// if ( IsSelected( anIObj ) )
// AddOrRemoveSelected( anIObj );
if ( anIObj->IsHighlighted() )
anIObj->Unhighlight();
anIObj->Remove();
LStatus->SetDisplayMode(-1);
stat = Standard_True;
}
if ( LStatus->IsTemporary() )
if ( anIObj->IsDisplayed() )
anIObj->Remove();
/* TColStd_ListIteratorOfListOfInteger It( * LStatus->SelectionModes() );
for ( ; It.More(); It.Next() )
mySelMgr->Deactivate( anIObj, It.Value(), myMainVS );
*/
return stat;
}
Standard_Boolean AIS2D_LocalContext::Load(
const Handle(AIS2D_InteractiveObject)& anIObj,
const Standard_Boolean /*AllowDecomp*/,
const Standard_Integer ActivationMode ) {
if ( myActiveObjects.IsBound( anIObj ) ) return Standard_False;
Handle(AIS2D_LocalStatus) LStatus = new AIS2D_LocalStatus();
/*if ( anIObj->AcceptDecomposition() && AllowDecomp )
LStatus->SetDecomposition( Standard_True );
else
LStatus->SetDecomposition( Standard_False );
*/
if ( !myICTX->IsDisplayed( anIObj ) )
LStatus->SetTemporary( Standard_True );
else
LStatus->SetTemporary( Standard_False );
LStatus->SetDisplayMode( -1 );
//storing information....
if ( ActivationMode !=-1 )
LStatus->AddSelectionMode( ActivationMode );
AIS2D_TypeOfDetection HiMod = anIObj->HasHighlightMode() ? anIObj->HighlightMode() : anIObj->DefaultHighlightMode();
LStatus->SetHighlightMode( HiMod );
/*mySelMgr->Load( anIObj, myMainVS );
if ( ActivationMode != -1 ) {
mySelMgr->Activate( anIObj, ActivationMode, myMainVS );
} */
myActiveObjects.Bind( anIObj, LStatus );
return Standard_True;
}
Standard_Boolean AIS2D_LocalContext::Remove(const Handle(AIS2D_InteractiveObject)& /*aSelObj*/ ) {
return Standard_False;
}
void AIS2D_LocalContext::LoadContextObjects() {
AIS2D_ListIteratorOfListOfIO It;
if ( myLoadDisplayed ) {
AIS2D_ListOfIO theLOI;
myICTX->DisplayedObjects( theLOI, Standard_True );
Handle(AIS2D_LocalStatus) LStatus;
for ( It.Initialize(theLOI); It.More(); It.Next() ) {
LStatus = new AIS2D_LocalStatus();
// LStatus->SetDecomposition((It.Value()->AcceptDecomposition() && myAcceptStdMode));
LStatus->SetTemporary(Standard_False);
LStatus->SetHighlightMode( It.Value()->HasHighlightMode() ? It.Value()->HighlightMode(): It.Value()->DefaultHighlightMode() );
myActiveObjects.Bind(It.Value(),LStatus);
}
}
}
void AIS2D_LocalContext::UnloadContextObjects()
{}
void AIS2D_LocalContext::Terminate() {
ClearDetected();
Clear();
myLastIndex = 0;
if ( ! myICTX->mySeqOfSelIO->IsEmpty() )
for ( int i = 1; i <= myICTX->mySeqOfSelIO->Length(); ++i )
myICTX->mySeqOfSelIO->Value(i)->SetState(0);
/*
AIS2D_Selection::Select();
AIS2D_Selection::Remove(mySelName.ToCString());*/
Handle(V2d_Viewer) Vwr = myICTX->CurrentViewer();
Handle(V2d_View) curV;
for ( Vwr->InitActiveViews(); Vwr->MoreActiveViews(); Vwr->NextActiveViews() ) {
curV = Vwr->ActiveView();
}
}
void AIS2D_LocalContext::Clear(const AIS2D_ClearMode aType) {
switch (aType){
case AIS2D_CM_All:
{
ClearObjects();
break;
}
case AIS2D_CM_Interactive:
ClearObjects();
break;
case AIS2D_CM_StandardModes:
{
while(!myListOfStdMode.IsEmpty())
//DeactivateStdMode(AIS2D_Shape::SelectionType(myListOfStdMode.Last()));
break;
}
case AIS2D_CM_TemporaryShapePrs:
ClearDetected();
}
//UpdateSort();
}
Standard_Boolean AIS2D_LocalContext::IsSelected( const Handle(AIS2D_InteractiveObject)& anIObj) const {
if ( ! myICTX->mySeqOfSelIO->IsEmpty() )
for ( int i = 1; i <= myICTX->mySeqOfSelIO->Length(); ++i )
if ( myICTX->mySeqOfSelIO->Value(i) == anIObj )
return Standard_True;
return Standard_False;
}
Handle(AIS2D_InteractiveObject) AIS2D_LocalContext::SelectedIO() const {
return myLastPicked;
}
AIS2D_StatusOfDetection AIS2D_LocalContext::MoveTo(
const Standard_Integer XPix,
const Standard_Integer YPix,
const Handle(V2d_View)& aView ) {
if ( aView->Viewer() == myICTX->CurrentViewer() ) {
Standard_Integer Dprecision = myICTX->DetectPrecision();
Standard_Boolean UpdVwr = Standard_False;
Handle(V2d_Viewer) theViewer = aView->Viewer();
AIS2D_StatusOfDetection theStat( AIS2D_SOD_Nothing );
Handle(Graphic2d_Primitive) thePrim;
Handle(Graphic2d_TransientManager) theDrawer =
Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() );
Handle(Graphic2d_DisplayList) thePickList = aView->Pick( XPix, YPix, Dprecision );
if ( thePickList->Length() > 0 ) {
if ( thePickList->Length() == 1 ) {
Handle(AIS2D_InteractiveObject) theIO = Handle(AIS2D_InteractiveObject)::DownCast(thePickList->Value(1));
if ( theIO == myLastPicked )
switch ( theIO->HighlightMode() ) {
default:
case AIS2D_TOD_OBJECT:
return AIS2D_SOD_OnlyOneDetected;
break;
case AIS2D_TOD_PRIMITIVE:
if ( myLastPicked->Primitive(myLastPicked->PickedIndex()) == myLastPickPrim )
return AIS2D_SOD_OnlyOneDetected;
break;
case AIS2D_TOD_ELEMENT:
if ( ( myLastPicked->Primitive(myLastPicked->PickedIndex()) == myLastPickPrim ) &&
( myLastPicked->Primitive(myLastPicked->PickedIndex())->PickedIndex() == myLastPickElInd ) )
return AIS2D_SOD_OnlyOneDetected;
break;
case AIS2D_TOD_VERTEX:
if ( ( myLastPicked->Primitive(myLastPicked->PickedIndex()) == myLastPickPrim ) &&
( myLastPicked->Primitive(myLastPicked->PickedIndex())->PickedIndex() == myLastPickElInd ) )
return AIS2D_SOD_OnlyOneDetected;
break;
}
}
if ( !myLastPicked.IsNull() )
if ( !myLastPicked->State() ) {
#ifdef DEB
AIS2D_TypeOfDetection HiMod = myLastPicked->HasHighlightMode() ?
myLastPicked->HighlightMode() : myLastPicked->DefaultHighlightMode();
#endif
myLastPicked->Unhighlight();
UpdVwr = Standard_True;
} // end if the last picked object isn't selected one
if ( myResetDetect ) {
theDrawer->SetOverride(Standard_True);
theDrawer->SetOverrideColor( theViewer->InitializeColor(myICTX->HighlightColor()) );
theDrawer->BeginDraw( aView->Driver() );
for ( int i = 1 ; i <= thePickList->Length(); i++ ) {
myLastPicked = Handle(AIS2D_InteractiveObject)::DownCast( thePickList->Value(i) );
myLastinMain = myLastPicked;
if ( myLastPicked->HasHighlightMode() ) {
myLastPicked->Highlight(theViewer->InitializeColor(myICTX->HighlightColor()));
switch( myLastPicked->HighlightMode() ) {
default:
case AIS2D_TOD_OBJECT:
if ( myLastPicked->State() != 1 ) {
theDrawer->Draw( myLastPicked );
} else {
theStat = AIS2D_SOD_Selected;
}
break;
case AIS2D_TOD_PRIMITIVE:
myLastPickPrim = myLastPicked->Primitive(myLastPicked->PickedIndex());
if ( !myLastPickPrim->IsHighlighted() ) {
theDrawer->Draw(myLastPickPrim);
} else {
theStat = AIS2D_SOD_Selected;
}
break;
case AIS2D_TOD_ELEMENT: {
Standard_Integer pInd = myLastPicked->PickedIndex();
myLastPickPrim = myLastPicked->Primitive(pInd);
if ( myLastPickPrim != myLastSelPrim ||
( myLastPickPrim == myLastSelPrim &&
myLastPickPrim->PickedIndex() != myLastSelElInd ) ||
( !myLastPickPrim->PickedIndex() &&
!myLastPickPrim->IsHighlighted() ) ) {
myLastPickElInd = myLastPickPrim->PickedIndex();
theDrawer->DrawElement(myLastPickPrim,myLastPickElInd);
} else {
theStat = AIS2D_SOD_Selected;
}
break;
}
case AIS2D_TOD_VERTEX: {
myLastPickPrim = myLastPicked->Primitive(myLastPicked->PickedIndex());
#ifdef DEB
Standard_Integer pInd = myLastPicked->PickedIndex();
#endif
if ( myLastPickPrim != myLastSelPrim ||
( myLastPickPrim == myLastSelPrim &&
myLastPickPrim->PickedIndex() != myLastSelElInd ) ||
( !myLastPickPrim->PickedIndex() &&
!myLastPickPrim->IsHighlighted() ) ) {
myLastPickElInd = myLastPickPrim->PickedIndex();
theDrawer->DrawVertex(myLastPickPrim,-myLastPickElInd);
} else {
theStat = AIS2D_SOD_Selected;
}
break;
}
} //end switch
} // end if lastPicked has highlight mode
} // end for
theDrawer->EndDraw();
theDrawer->SetOverride(Standard_False);
myResetDetect= Standard_False;
} // end if myResetDetect is true
} else {
theStat = AIS2D_SOD_Nothing;
theDrawer->RestoreArea( aView->Driver() );
myResetDetect= Standard_True;
if ( !myLastPicked.IsNull() ) {
if ( myLastPicked->HighlightMode() == AIS2D_TOD_ELEMENT ||
myLastPicked->HighlightMode() == AIS2D_TOD_VERTEX ) {
myLastPicked->Highlight(theViewer->InitializeColor( myICTX->SelectionColor() ));
myLastPicked->Unhighlight();
UpdVwr = Standard_True;
} else if ( !myLastPicked->State() ) {
myLastPicked->Unhighlight();
UpdVwr = Standard_True;
}
}
myLastinMain.Nullify();
myLastPickPrim.Nullify();
myLastPickElInd = 0;
} // end if PickList isn't empty
//if ( !myLastPicked.IsNull() ) myLastPicked->Unhighlight();
if ( UpdVwr ) theViewer->Update();
myLastPicked.Nullify();
//myLastMoveView = aView;
return theStat;
} else
return AIS2D_SOD_Error;
}
AIS2D_StatusOfPick AIS2D_LocalContext::Select( const Standard_Boolean UpdateVwr ) {
if ( myAutoHighlight )
UnhighlightPicked( Standard_False );
Standard_Integer DI = DetectedIndex();
// AIS2D_Selection::SetCurrentSelection( mySelName.ToCString() );
// Standard_Integer NbSel = AIS2D_Selection::Extent();
Standard_Integer NbSel = myICTX->mySeqOfSelIO->Length();
if ( DI <= 0 ) {
ClearSelected( UpdateVwr );
return NbSel == 0 ? AIS2D_SOP_NothingSelected : AIS2D_SOP_Removed;
}
if ( myAutoHighlight )
HighlightPicked( UpdateVwr );
//return ( AIS2D_Selection::Extent() == 1) ? AIS2D_SOP_OneSelected : AIS2D_SOP_SeveralSelected;
return ( myICTX->mySeqOfSelIO->Length() == 1) ? AIS2D_SOP_OneSelected : AIS2D_SOP_SeveralSelected;
}
AIS2D_StatusOfPick AIS2D_LocalContext::ShiftSelect( const Standard_Boolean /*UpdateVwr*/ ) {
/* Standard_Integer I = DetectedIndex();
if ( I > 0 ) {
UnhighlightPicked(Standard_False);
AIS2D_Selection::SetCurrentSelection(mySelName.ToCString());
const Handle(SelectMgr_EntityOwner)& EntOwr = myMapOfOwner(I);
Standard_Integer mod = EntOwr->State() == 0 ? 1 : 0;
EntOwr->State(mod);
AIS2D_Selection::Select(EntOwr);
if ( myAutoHighlight )
HighlightPicked(UpdateVwr);
}*/
return AIS2D_SOP_Error;
}
void AIS2D_LocalContext::SetDisplayPriority(
const Handle(AIS2D_InteractiveObject)& anIObj,
const Standard_Integer /*Prior*/ ) {
if ( !myActiveObjects.IsBound(anIObj) ) return;
const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(anIObj);
if ( LStatus->DisplayMode() == -1) return;
//myMainPM->SetDisplayPriority(anIObj, LStatus->DisplayMode(),Prior);
//if ( LStatus->IsSubIntensityOn())
// myMainPM->SetDisplayPriority(anIObj, LStatus->HighlightMode(), Prior);
}
Standard_Integer AIS2D_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const {
Standard_Integer NbDisp(0);
for ( AIS2D_DataMapIteratorOfDataMapOfLocStat theIt(myActiveObjects); theIt.More(); theIt.Next() ) {
const Handle(AIS2D_InteractiveObject)& SObj = theIt.Key();
if ( !theMap.Contains(SObj) )
if ( theIt.Value()->DisplayMode() != -1 ) {
theMap.Add(SObj);
NbDisp++;
}
}
return NbDisp;
}
Standard_Boolean AIS2D_LocalContext::IsDisplayed(const Handle(AIS2D_InteractiveObject)& anIObj) const {
if ( !myActiveObjects.IsBound(anIObj) )
return Standard_False;
return ( myActiveObjects(anIObj)->DisplayMode() != -1 );
}
Standard_Boolean AIS2D_LocalContext::IsDisplayed(const Handle(AIS2D_InteractiveObject)& anIObj,
const Standard_Integer aMode) const {
if (!myActiveObjects.IsBound(anIObj)) return Standard_False;
return (myActiveObjects(anIObj)->DisplayMode()==aMode);
}
void AIS2D_LocalContext::Unhighlight(const Handle(AIS2D_InteractiveObject)& /*anIObj*/)
{
}
Standard_Boolean AIS2D_LocalContext::IsHighlight(const Handle(AIS2D_InteractiveObject)& anIObj) const {
if ( !myActiveObjects.IsBound(anIObj) ) return Standard_False;
return myActiveObjects( anIObj )->IsSubIntensityOn();
}
Standard_Boolean AIS2D_LocalContext::IsHighlight(const Handle(AIS2D_InteractiveObject)& anIObj,
Standard_Boolean& WithColor,
Quantity_NameOfColor& HiCol) const
{
if(!myActiveObjects.IsBound(anIObj)) return Standard_False;
if( myActiveObjects(anIObj)->IsSubIntensityOn()){
HiCol = myActiveObjects(anIObj)->HighlightColor();
if(HiCol==Quantity_NOC_WHITE)
WithColor = Standard_True;
else
WithColor = Standard_False;
return Standard_True;
}
return Standard_False;
}
void AIS2D_LocalContext::SubIntensityOn(const Handle(AIS2D_InteractiveObject)& anIObj) {
if ( !myActiveObjects.IsBound(anIObj) ) return;
const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(anIObj);
if ( LStatus->IsTemporary() ) {
Quantity_NameOfColor aCol = myICTX->SubIntensityColor();
myICTX->HighlightWithColor(anIObj, aCol);
}
LStatus->SubIntensityOn();
}
void AIS2D_LocalContext::SubIntensityOff(const Handle(AIS2D_InteractiveObject)& anIObj) {
if ( !myActiveObjects.IsBound(anIObj) ) return;
const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(anIObj);
if ( LStatus->IsTemporary())
myICTX->Unhighlight(anIObj);
LStatus->SubIntensityOff();
}
Standard_Boolean AIS2D_LocalContext::IsIn( const Handle(AIS2D_InteractiveObject)& anIObj) const {
return myActiveObjects.IsBound(anIObj);
}
Standard_Boolean AIS2D_LocalContext::UnhighLastDetect(const Handle(V2d_View)& /*aView*/) {
// if ( !IsValidIndex(myLastIndex) ) return Standard_False;
/* myMainPM->BeginDraw();
const Handle(SelectMgr_EntityOwner)& Ownr = myMapOfOwner(myLastIndex);
Standard_Integer HM(0);
if ( Ownr->HasSelectable() ) {
Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
HM = GetHiMod(* ( (Handle(AIS2D_InteractiveObject ) * ) & SO ) );
}
myMapOfOwner( myLastIndex )->Unhilight( myMainPM, HM );
myMainPM->EndDraw( aView );
*/
myLastIndex =0;
return Standard_True;
}
void AIS2D_LocalContext::DrawObject( const Handle(AIS2D_InteractiveObject)& anIObj, const Standard_Integer /*aDispMode*/ ) {
if ( anIObj->IsKind(STANDARD_TYPE(AIS2D_ProjShape) ) ) {
Handle(AIS2D_ProjShape) thePS = Handle(AIS2D_ProjShape)::DownCast(anIObj);
Handle(Graphic2d_Line) theLines = thePS->GetPrimitives();
Handle(Prs2d_AspectLine) theAspLine;
if ( !anIObj->HasAspect(theLines) ) {
Handle(Prs2d_AspectRoot) theAspRoot = anIObj->Attributes()->FindAspect(Prs2d_AN_LINE);
theAspLine = Handle(Prs2d_AspectLine)::DownCast(theAspRoot);
anIObj->SetAspect( theAspLine, theLines );
} else {
theAspLine = Handle(Prs2d_AspectLine)::DownCast( anIObj->GetAspect(theLines) );
}
Quantity_Color aColor;
Aspect_TypeOfLine aType;
Aspect_WidthOfLine aWidth;
theAspLine->ValuesOfLine( aColor, aType, aWidth );
Standard_Integer colorInd = theAspLine->ColorIndex();
Standard_Integer typeInd = theAspLine->TypeIndex();
Standard_Integer widthInd = theAspLine->WidthIndex();
if ( !colorInd ) {
colorInd = myICTX->InitializeColor( aColor );
theLines->SetColorIndex( colorInd );
}
if ( !typeInd ) {
typeInd = myICTX->InitializeStyle( aType );
theLines->SetTypeIndex( typeInd );
}
if ( !widthInd ) {
widthInd = myICTX->InitializeWidth( aWidth );
theLines->SetWidthIndex( widthInd );
}
if ( thePS->IsHLMode() ) {
Handle(Graphic2d_Line) theHLines = thePS->GetHLPrimitives();
theHLines->SetColorIndex( colorInd );
theHLines->SetWidthIndex( widthInd );
Standard_Integer theDashInd = myICTX->InitializeStyle( Aspect_TOL_DASH );
theHLines->SetTypeIndex( theDashInd );
}
} else {
Handle(Graphic2d_Primitive) thePrim;
for ( Standard_Integer i = 1; i <= anIObj->Length(); i++ ) {
thePrim = anIObj->Primitive( i );
if ( thePrim->IsKind(STANDARD_TYPE(Graphic2d_Line) ) ) {
Handle(Graphic2d_Line) theLine = Handle(Graphic2d_Line)::DownCast(thePrim);
Handle(Prs2d_AspectLine) theAspLine;
if ( !anIObj->HasAspect(theLine) ) {
Handle(Prs2d_AspectRoot) theAspRoot = anIObj->Attributes()->FindAspect(Prs2d_AN_LINE);
theAspLine = Handle(Prs2d_AspectLine)::DownCast(theAspRoot);
anIObj->SetAspect( theAspLine, theLine );
} else {
theAspLine = Handle(Prs2d_AspectLine)::DownCast( anIObj->GetAspect(theLine) );
}
Quantity_Color aColor;
Aspect_TypeOfLine aType;
Aspect_WidthOfLine aWidth;
Quantity_Color aIntColor;
Graphic2d_TypeOfPolygonFilling aTypeFill;
Standard_Integer aTile;
Standard_Boolean aDrawEdge;
theAspLine->ValuesOfLine( aColor, aType, aWidth );
theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge );
Standard_Integer colorInd = theAspLine->ColorIndex();
Standard_Integer typeInd = theAspLine->TypeIndex();
Standard_Integer widthInd = theAspLine->WidthIndex();
Standard_Integer colorIntInd = theAspLine->InterColorIndex();
if ( !colorInd ) {
colorInd = myICTX->InitializeColor( aColor );
theLine->SetColorIndex( colorInd );
}
if ( !typeInd ) {
typeInd = myICTX->InitializeStyle( aType );
theLine->SetTypeIndex( typeInd );
}
if ( !widthInd ) {
widthInd = myICTX->InitializeWidth( aWidth );
theLine->SetWidthIndex( widthInd );
}
if ( !colorIntInd ) {
colorIntInd = myICTX->InitializeColor( aIntColor );
theLine->SetInteriorColorIndex( colorIntInd );
}
theLine->SetTypeOfPolygonFilling( aTypeFill );
theLine->SetInteriorPattern( aTile );
theLine->SetDrawEdge( aDrawEdge );
if ( theLine->IsKind(STANDARD_TYPE(Prs2d_Point) ) ) {
Handle(Prs2d_Point) thePnt = Handle(Prs2d_Point)::DownCast(theLine);
thePnt->SetIndex( myICTX->InitializeMarker( thePnt->Marker() ) );
}
} // end if the kind of primitive is Graphic2d_Line
} // end for exploration of the interactive object
} // end if IO is AIS2D_ProjShape
}
void AIS2D_LocalContext::ClearObjects() {
AIS2D_DataMapIteratorOfDataMapOfLocStat It( myActiveObjects );
for ( ; It.More(); It.Next() ) {
Handle(AIS2D_InteractiveObject) SObj = Handle(AIS2D_InteractiveObject)::DownCast( It.Key() );
const Handle(AIS2D_LocalStatus) LStatus = It.Value();
// TColStd_ListIteratorOfListOfInteger ItL;
AIS2D_DisplayStatus theDS = myICTX->DisplayStatus( SObj );
if ( theDS != AIS2D_DS_Displayed){
//if ( myMainPM->IsDisplayed( SObj, LStatus->DisplayMode() ) ) {
if ( myICTX->IsDisplayed(SObj) ) {
if ( LStatus->IsSubIntensityOn() && SObj->IsHighlighted() )
SObj->Unhighlight();
SObj->Remove();
}
if ( LStatus->IsTemporary() )
SObj->Remove();
} else {
if ( LStatus->IsSubIntensityOn() ) {
myICTX->SubIntensityOff(Handle(AIS2D_InteractiveObject)::DownCast(SObj) ); }
Standard_Integer DiMo = SObj->HasDisplayMode() ? SObj->DisplayMode() : myICTX->DisplayMode();
if ( LStatus->DisplayMode() !=-1 && LStatus->DisplayMode() != DiMo)
SObj->Remove();
}
}
ClearSelected();
myActiveObjects.Clear();
}
void AIS2D_LocalContext::ClearDetected() {
/*for ( Standard_Integer i = 1; i <= myMapOfOwner.Extent(); i++ ) {
if ( !myMapOfOwner(i).IsNull() ) {
if ( myMapOfOwner(i)->IsHilighted(myMainPM) )
myMapOfOwner(i)->Unhilight(myMainPM);
else if ( myMapOfOwner(i)->IsHilighted( myICTX->CollectorPrsMgr() ) )
myMapOfOwner(i)->Unhilight( myICTX->CollectorPrsMgr() );
else {
const Handle(SelectMgr_SelectableObject)& SO =
myMapOfOwner.FindKey(i)->Selectable();
if ( myActiveObjects.IsBound(SO) ) {
const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(SO);
if ( LStatus->IsTemporary() &&
LStatus->DisplayMode() == -1 &&
LStatus->SelectionModes()->IsEmpty() )
myMapOfOwner(i)->Clear(myMainPM);
}
}
}
} */
}
void AIS2D_LocalContext::ClearSelected(const Standard_Boolean UpdateVwr) {
UnhighlightPicked(UpdateVwr);
// AIS2D_Selection::SetCurrentSelection(mySelName.ToCString());
// Handle(AIS2D_Selection) Sel = AIS2D_Selection::CurrentSelection();
/*Handle(Standard_Transient) Tr;
Handle(SelectMgr_EntityOwner) EO;
const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
for ( Standard_Integer i = Obj.Lower(); i <= Sel->NbStored(); i++ ) {
Tr = Obj(i);
if ( !Tr.IsNull() )
(*((Handle(SelectMgr_EntityOwner)*)&Tr))->State(0);
} */
//AIS2D_Selection::Select();
myLastIndex = 0;
}
void AIS2D_LocalContext::HighlightPicked(const Standard_Boolean /*UpdateVwr*/) {
/*Standard_Boolean updMain(Standard_False),updColl(Standard_False);
Quantity_NameOfColor SelCol = myICTX->SelectionColor();
Handle(AIS2D_Selection) Sel = AIS2D_Selection::Selection(mySelName.ToCString());
Handle(Standard_Transient) Tr;
Handle(SelectMgr_EntityOwner) Ownr;
Handle(PrsMgr_PresentationManager2d) PM = myMainPM;
const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
for ( Standard_Integer i = Obj.Lower(); i <= Sel->NbStored(); i++ ) {
Tr = Obj(i);
if ( !Tr.IsNull() ) {
Ownr = * ( (Handle(SelectMgr_EntityOwner) * ) &Tr );
Handle(AIS2D_InteractiveObject) IO;
if ( Ownr->HasSelectable() )
if ( !Ownr->ComesFromDecomposition() ) {
Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
Handle(AIS2D_InteractiveObject) IO =
* ( (Handle(AIS2D_InteractiveObject) * ) &SO );
if ( myICTX->IsInCollector(IO) ) {
PM = myICTX->CollectorPrsMgr();
updColl = Standard_True;
} else
updMain = Standard_True;
} else
updMain = Standard_True;
else
updMain = Standard_True;
// endif HasSelectable
Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
Standard_Integer HM = GetHiMod( * ( (Handle(AIS2D_InteractiveObject ) * ) &SO ) );
// Ownr->HilightWithColor( PM, myICTX->SelectionColor(), HM );
if ( Ownr->HasSelectable() ) {
Quantity_NameOfColor aCol = myICTX->SelectionColor();
Standard_Integer indCol = myICTX->CurrentViewer()->InitializeColor( aCol );
PM->SetHighlightColor( indCol );
PM->ColorHighlight( SO, indCol, HM );
}
} //endif
} //end for
if (UpdateVwr) {
if ( updMain ) myICTX->CurrentViewer()->Update();
if ( updColl ) myICTX->Collector()->Update();
} */
}
void AIS2D_LocalContext::UnhighlightPicked( const Standard_Boolean /*UpdateVwr*/ ) {
/*Standard_Boolean updMain(Standard_False), updColl(Standard_False);
Quantity_NameOfColor SelCol = myICTX->SelectionColor();
Handle(AIS2D_Selection) Sel = AIS2D_Selection::Selection(mySelName.ToCString());
Handle(Standard_Transient) Tr;
Handle(SelectMgr_EntityOwner) Ownr;
Handle(PrsMgr_PresentationManager2d) PM = myMainPM;
const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
for ( Standard_Integer i = Obj.Lower(); i <= Sel->NbStored(); i++ ) {
Tr = Obj(i);
if ( !Tr.IsNull() ) {
Ownr = * ( (Handle(SelectMgr_EntityOwner) * ) &Tr );
Standard_Integer HM(0);
if ( Ownr->HasSelectable() )
if ( !Ownr->ComesFromDecomposition() ) {
Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
Handle(AIS2D_InteractiveObject) IO =
* ( (Handle(AIS2D_InteractiveObject) * ) &SO );
HM = GetHiMod(IO);
if ( myICTX->IsInCollector(IO) ) {
PM = myICTX->CollectorPrsMgr();
updColl = Standard_True;
} else
updMain = Standard_True;
} else
updMain = Standard_True;
// endif HasSelectable
Ownr->Unhilight( PM, HM );
} //end if
} //end for
if ( UpdateVwr ) {
if ( updMain ) myICTX->CurrentViewer()->Update();
if ( updColl ) myICTX->Collector()->Update();
} */
}
Standard_Boolean AIS2D_LocalContext::IsValidForSelection(const Handle(AIS2D_InteractiveObject)& /*anIObj*/) const {
// return myFilter->IsOk(new SelectMgr_EntityOwner(anIObj));
return Standard_False;
}
void AIS2D_LocalContext::UpdateSelected(const Standard_Boolean UpdateVwr) {
UnhighlightPicked(Standard_False);
HighlightPicked(UpdateVwr);
}
void AIS2D_LocalContext::SetSelected( const Handle(AIS2D_InteractiveObject)& /*anIObj*/,
const Standard_Boolean /*UpdateVwr*/ ) {
/*if ( !IsValidForSelection(anIObj) ) return;
UnhighlightPicked(Standard_False);
Handle(AIS2D_Selection) sel = AIS2D_Selection::Selection(mySelName.ToCString());
Standard_Boolean found(Standard_False);
Handle(Standard_Transient) Tr;
Handle(SelectMgr_EntityOwner) EntOwr = FindSelectedOwnerFromIO(anIObj);
if ( EntOwr.IsNull() ) {
if ( anIObj->HasSelection(0) ) {
const Handle(SelectMgr_Selection)& SIObj = anIObj->Selection(0);
SIObj->Init();
if ( SIObj->More() ) {
Handle(SelectBasics_EntityOwner) BO = SIObj->Sensitive()->OwnerId();
EntOwr = *( (Handle(SelectMgr_EntityOwner) * ) & BO );
}
}
if ( EntOwr.IsNull() )
EntOwr = new SelectMgr_EntityOwner(anIObj);
}
ClearSelected(Standard_False);
EntOwr->State(1);
AIS2D_Selection::Select(EntOwr);
HighlightPicked(UpdateVwr);
*/
}
void AIS2D_LocalContext::AddOrRemoveSelected(
const Handle(AIS2D_InteractiveObject)& /*anIObj*/,
const Standard_Boolean /*UpdateVwr*/) {
/*if ( !IsValidForSelection(anIObj) ) return;
UnhighlightPicked(Standard_False);
Handle(SelectMgr_EntityOwner) EntOwr;
EntOwr = FindSelectedOwnerFromIO(anIObj);
if ( !EntOwr.IsNull() )
EntOwr->State(0);
else {
if ( anIObj->HasSelection(0) ) {
const Handle(SelectMgr_Selection)& SIObj = anIObj->Selection(0);
SIObj->Init();
if ( SIObj->More() ) {
Handle(SelectBasics_EntityOwner) BO = SIObj->Sensitive()->OwnerId();
EntOwr = * ( ( Handle(SelectMgr_EntityOwner)* )& BO );
}
}
if ( EntOwr.IsNull() )
EntOwr = new SelectMgr_EntityOwner(anIObj);
EntOwr->State(1);
}
const Handle(AIS2D_Selection)& aSel = AIS2D_Selection::Selection(mySelName.ToCString() );
if ( !aSel.IsNull() )
aSel->Select(EntOwr);
HighlightPicked(UpdateVwr);
*/
}
Standard_Integer AIS2D_LocalContext::DetectedIndex() {
return myLastIndex;
}
const Handle(AIS2D_LocalStatus)& AIS2D_LocalContext::Status(const Handle(AIS2D_InteractiveObject)& anObject) const {
return myActiveObjects(anObject);
}

148
src/AIS2D/AIS2D_LocalStatus.cdl Executable file
View File

@@ -0,0 +1,148 @@
-- File : AIS2D_LocalStatus.cdl
-- Created : February 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
private class LocalStatus from AIS2D inherits TShared from MMgt
---Purpose: Stored Info about temporary objects.
uses
ListOfInteger from TColStd,
NameOfColor from Quantity,
PToListOfInt from AIS2D,
TypeOfDetection from AIS2D
is
Create( isTemporary : Boolean from Standard = Standard_True;
Decompose : Boolean from Standard = Standard_False;
DMode : Integer from Standard = -1;
SMode : Integer from Standard = -1;
HMode : TypeOfDetection from AIS2D = AIS2D_TOD_PRIMITIVE;
SubIntensity : Boolean from Standard = 0;
HighlCol : NameOfColor from Quantity = Quantity_NOC_WHITE )
returns mutable LocalStatus from AIS2D;
---Purpose: Initializes the default Local Status
Decomposed( me ) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose:
IsTemporary( me ) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose:
DisplayMode( me ) returns Integer from Standard;
---C++: inline
---Level: Internal
---Purpose:
SelectionModes( me: mutable ) returns PToListOfInt from AIS2D;
---C++: inline
---Level: Internal
---Purpose:
IsActivated( me; aSelMode: Integer from Standard ) returns Boolean from Standard;
---Level: Internal
---Purpose:
HighlightMode( me ) returns TypeOfDetection from AIS2D;
---C++: inline
---Level: Internal
---Purpose:
IsSubIntensityOn( me ) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose:
HighlightColor( me ) returns NameOfColor from Quantity;
---C++: inline
---Level: Internal
---Purpose:
IsFirstDisplay( me ) returns Boolean from Standard;
---C++: inline
---Level: Internal
---Purpose:
SetDecomposition( me:mutable; aStatus: Boolean from Standard);
---C++: inline
---Level: Internal
---Purpose:
SetTemporary( me:mutable; aStatus: Boolean from Standard);
---C++: inline
---Level: Internal
---Purpose:
SetDisplayMode( me:mutable; aMode: Integer from Standard);
---C++: inline
---Level: Internal
---Purpose:
SetFirstDisplay( me:mutable; aStatus: Boolean from Standard) ;
---C++: inline
---Level: Internal
---Purpose:
AddSelectionMode( me:mutable; aMode: Integer from Standard );
---Level: Internal
---Purpose:
RemoveSelectionMode( me:mutable; aMode: Integer from Standard );
---Level: Internal
---Purpose:
ClearSelectionModes( me:mutable );
---Level: Internal
---Purpose:
IsSelModeIn( me; aMode: Integer from Standard ) returns Boolean from Standard;
---Level: Internal
---Purpose:
SetHighlightMode( me: mutable; aMode: TypeOfDetection from AIS2D );
---C++: inline
---Level: Internal
---Purpose:
SetHighlightColor( me: mutable; aHiCol: NameOfColor from Quantity );
---C++: inline
---Level: Internal
---Purpose:
SubIntensityOn( me:mutable );
---C++: inline
---Level: Internal
---Purpose:
SubIntensityOff( me:mutable );
---Level: Internal
---Purpose:
SetPreviousState( me:mutable; aStatus: Transient from Standard );
---Level: Internal
---Purpose:
PreviousState( me ) returns any Transient from Standard;
---C++: inline
---Level: Internal
---Purpose:
fields
myDecomposition : Boolean from Standard;
myIsTemporary : Boolean from Standard;
myDMode : Integer from Standard;
myFirstDisplay : Boolean from Standard;
myHMode : TypeOfDetection from AIS2D;
mySModes : ListOfInteger from TColStd;
mySubIntensity : Boolean from Standard;
myHighlCol : NameOfColor from Quantity;
myPrevState : Transient from Standard;
end LocalStatus;

74
src/AIS2D/AIS2D_LocalStatus.cxx Executable file
View File

@@ -0,0 +1,74 @@
#include <AIS2D_LocalStatus.ixx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
AIS2D_LocalStatus::AIS2D_LocalStatus( const Standard_Boolean isTemporary,
const Standard_Boolean Decompose,
const Standard_Integer DMode,
const Standard_Integer SMode,
const AIS2D_TypeOfDetection HMode,
const Standard_Boolean SubIntensity,
const Quantity_NameOfColor HighlCol ):
myDecomposition( Decompose ),
myIsTemporary( isTemporary ),
myDMode( DMode ),
myFirstDisplay( Standard_False),
myHMode( HMode ),
mySModes(),
mySubIntensity( SubIntensity ),
myHighlCol( HighlCol )
{
if ( SMode != -1 ) mySModes.Append( SMode );
}
Standard_Boolean AIS2D_LocalStatus::IsActivated(const Standard_Integer aSelMode) const {
TColStd_ListIteratorOfListOfInteger It( mySModes );
for ( ; It.More(); It.Next() )
if ( It.Value() == aSelMode )
return Standard_True;
return Standard_False;
}
Standard_Boolean AIS2D_LocalStatus::IsSelModeIn(const Standard_Integer aMode) const {
TColStd_ListIteratorOfListOfInteger It( mySModes );
for ( ; It.More(); It.Next() )
if( It.Value() == aMode )
return Standard_True;
return Standard_False;
}
void AIS2D_LocalStatus::AddSelectionMode(const Standard_Integer aMode) {
if( IsSelModeIn( aMode ) ) return;
if( aMode != -1 )
mySModes.Append( aMode );
else
mySModes.Clear();
}
void AIS2D_LocalStatus::RemoveSelectionMode(const Standard_Integer aMode) {
TColStd_ListIteratorOfListOfInteger It(mySModes);
for ( ; It.More(); It.Next() )
if ( It.Value() == aMode ) {
mySModes.Remove( It );
return;
}
}
void AIS2D_LocalStatus::ClearSelectionModes() {
mySModes.Clear();
}
void AIS2D_LocalStatus::SubIntensityOff() {
mySubIntensity = Standard_False;
}
void AIS2D_LocalStatus::SetPreviousState(const Handle(Standard_Transient)& aStatus) {
myPrevState = aStatus;
}

65
src/AIS2D/AIS2D_LocalStatus.lxx Executable file
View File

@@ -0,0 +1,65 @@
inline Handle(Standard_Transient) AIS2D_LocalStatus::PreviousState() const {
return myPrevState;
}
inline Standard_Boolean AIS2D_LocalStatus::Decomposed() const {
return myDecomposition;
}
inline Standard_Boolean AIS2D_LocalStatus::IsTemporary() const {
return myIsTemporary;
}
inline Standard_Integer AIS2D_LocalStatus::DisplayMode() const {
return myDMode;
}
inline AIS2D_PToListOfInt AIS2D_LocalStatus::SelectionModes() {
return &mySModes;
}
inline AIS2D_TypeOfDetection AIS2D_LocalStatus::HighlightMode() const {
return myHMode;
}
inline Standard_Boolean AIS2D_LocalStatus::IsSubIntensityOn() const {
return mySubIntensity;
}
inline Standard_Boolean AIS2D_LocalStatus::IsFirstDisplay() const {
return myFirstDisplay;
}
inline Quantity_NameOfColor AIS2D_LocalStatus::HighlightColor() const {
return myHighlCol;
}
inline void AIS2D_LocalStatus::SubIntensityOn() {
mySubIntensity = Standard_True;
}
inline void AIS2D_LocalStatus::SetDecomposition(const Standard_Boolean aStatus) {
myDecomposition = aStatus;
}
inline void AIS2D_LocalStatus::SetTemporary(const Standard_Boolean aStatus) {
myIsTemporary = aStatus;
}
inline void AIS2D_LocalStatus::SetDisplayMode(const Standard_Integer aMode) {
myDMode = aMode;
}
inline void AIS2D_LocalStatus::SetFirstDisplay(const Standard_Boolean aStatus) {
myFirstDisplay = aStatus;
}
inline void AIS2D_LocalStatus::SetHighlightMode(const AIS2D_TypeOfDetection aMode) {
myHMode = aMode;
}
inline void AIS2D_LocalStatus::SetHighlightColor(const Quantity_NameOfColor aHiCol) {
myHighlCol = aHiCol;
}

View File

@@ -0,0 +1,23 @@
-- File : AIS2D_PrimitiveArchit.cdl
-- Created : June 2000
-- Author : TCL
---Copyright: Matra Datavision 2000
private class PrimitiveArchit from AIS2D inherits TShared from MMgt
uses
Primitive from Graphic2d
is
Create( aPrim: Primitive from Graphic2d; ind: Integer from Standard )
returns mutable PrimitiveArchit from AIS2D;
GetPrimitive( me ) returns Primitive from Graphic2d;
GetIndex( me ) returns Integer from Standard;
fields
myPrimitive : Primitive from Graphic2d;
myInd : Integer from Standard;
end PrimitiveArchit;

View File

@@ -0,0 +1,16 @@
#include <AIS2D_PrimitiveArchit.ixx>
AIS2D_PrimitiveArchit::AIS2D_PrimitiveArchit( const Handle(Graphic2d_Primitive)& aPrim,
const Standard_Integer ind ) :
myPrimitive( aPrim ),
myInd( ind )
{
}
Handle(Graphic2d_Primitive) AIS2D_PrimitiveArchit::GetPrimitive() const {
return myPrimitive;
}
Standard_Integer AIS2D_PrimitiveArchit::GetIndex() const {
return myInd;
}

118
src/AIS2D/AIS2D_ProjShape.cdl Executable file
View File

@@ -0,0 +1,118 @@
-- File : AIS2D_ProjShape.cdl
-- Created : April 2000
-- Author : Tanya COOL
---Copyright: Matra Datavision 2000
class ProjShape from AIS2D inherits InteractiveObject from AIS2D
---Purpose: Constructs presentable and selectable projection of
-- TopoDS_Shape on the view plane
uses
Shape from TopoDS,
Line from Graphic2d,
ListOfShape from TopTools,
Projector from HLRAlgo,
Algo from HLRBRep,
PolyAlgo from HLRBRep,
SetOfSegments from Graphic2d,
SetOfCurves from GGraphic2d
is
Create returns mutable ProjShape from AIS2D;
---Purpose: Initializes the projected shape
Create( aProjector: Projector from HLRAlgo;
nbIsos: Integer from Standard = 3;
isPolyAlgo: Boolean from Standard = Standard_False;
visHL: Boolean from Standard = Standard_True )
returns mutable ProjShape from AIS2D;
---Purpose: Initializes the projected shape with projector <aProjector>, number isolines <nbIsos>
Add( me: mutable; aShape: Shape from TopoDS );
---Level: Public
---Purpose: Adds <aShape> to the list of projected shapes.
SetProjector( me: mutable; aProjector: Projector from HLRAlgo );
---Level: Public
---Purpose: sets the projector <aProjector>
Projector( me ) returns Projector from HLRAlgo;
---Level: Public
---Purpose: Indicates the projector
SetNbIsos( me: mutable; aNbIsos: Integer from Standard );
---Level: Internal
---Purpose:
SetPolyAlgo( me: mutable; aIsPoly: Boolean from Standard = Standard_False );
---Level: Internal
---Purpose: sets the projection of the shape as a polyhedral
-- simplification of the shape if <aIsPoly> is True
SetHLMode( me: mutable; aIsHLM: Boolean from Standard = Standard_True );
---Level: Internal
---Purpose: Sets the hidden line mode if <aIsHLM> is True
IsHLMode( me ) returns Boolean from Standard;
---Level: Public
---Purpose: Indicates the hidden lines are visible
GetNbIsos( me ) returns Integer from Standard;
---Level: Public
---Purpose: Indicates the number of isolines
GetIsPoly( me ) returns Boolean from Standard;
---Level: Public
---Purpose: Indicates the shape was extracted as Algo or PolyAlgo
GetPrimitives( me ) returns Line from Graphic2d;
---Level: Internal
---Purpose: Returns the set of primitives are included into Shape,
-- except hidden lines
GetHLPrimitives( me ) returns Line from Graphic2d;
---Level: Internal
---Purpose: Returns the set of hidden line primitives are included into Shape
ShowEdges( me: mutable;
aSharp, aSmooth, aSewn, anOutline, anIsoline: Boolean from Standard = Standard_True );
---Level: Public
---Purpose: Sets the flags for display of all types of edges
----------------------------------------------------------------------------
---Category: Private methods
CreateAlgo( me: mutable ) is private;
CreatePolyAlgo( me: mutable ) is private;
DrawSegments( me: mutable; aShape: Shape from TopoDS;
aSofS: in out SetOfSegments from Graphic2d ) is private;
DrawCurves( me: mutable; aShape: Shape from TopoDS;
aSofC: in out SetOfCurves from GGraphic2d ) is private;
ComputeShape( me: mutable ) is private;
fields
myListOfShape : ListOfShape from TopTools;
myProjector : Projector from HLRAlgo;
myAlgo : Algo from HLRBRep;
myPolyAlgo : PolyAlgo from HLRBRep;
myNbIsos : Integer from Standard;
myIsPolyAlgo : Boolean from Standard;
myIsHiddenLine : Boolean from Standard;
myESharp : Boolean from Standard;
myESmooth : Boolean from Standard;
myESewn : Boolean from Standard;
myEOutline : Boolean from Standard;
myEIsoline : Boolean from Standard;
mySetOfSegments : SetOfSegments from Graphic2d;
myHSetOfSegments : SetOfSegments from Graphic2d;
mySetOfCurves : SetOfCurves from GGraphic2d;
myHSetOfCurves : SetOfCurves from GGraphic2d;
end ProjShape;

326
src/AIS2D/AIS2D_ProjShape.cxx Executable file
View File

@@ -0,0 +1,326 @@
#include "assert.h"
#include <AIS2D_ProjShape.ixx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_ListOfShape.hxx>
#include <HLRBRep_PolyAlgo.hxx>
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_PolyHLRToShape.hxx>
#include <HLRBRep_HLRToShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopLoc_Location.hxx>
#include <V2d_Viewer.hxx>
#include <AIS2D_InteractiveContext.hxx>
AIS2D_ProjShape::AIS2D_ProjShape( )
:
AIS2D_InteractiveObject(),
myProjector( HLRAlgo_Projector() ),
myNbIsos( 3 ),
myIsPolyAlgo( Standard_False ),
myIsHiddenLine( Standard_True ),
myESharp( Standard_True ),
myESmooth( Standard_True ),
myESewn( Standard_True ),
myEOutline( Standard_True ),
myEIsoline( Standard_True )
{
}
AIS2D_ProjShape::AIS2D_ProjShape( const HLRAlgo_Projector& aProjector,
const Standard_Integer nbIsos,
const Standard_Boolean isPolyAlgo,
const Standard_Boolean visHL )
:
AIS2D_InteractiveObject(),
myProjector( aProjector ),
myNbIsos( nbIsos ),
myIsPolyAlgo( isPolyAlgo ),
myIsHiddenLine( visHL ),
myESharp( Standard_True ),
myESmooth( Standard_True ),
myESewn( Standard_True ),
myEOutline( Standard_True ),
myEIsoline( Standard_True )
{
}
void AIS2D_ProjShape::Add( const TopoDS_Shape& aShape ) {
myListOfShape.Append( aShape );
myAlgo.Nullify();
myPolyAlgo.Nullify();
ComputeShape();
}
void AIS2D_ProjShape::ComputeShape() {
TopoDS_Shape VCompound, Rg1LineVCompound, RgNLineVCompound,
OutLineVCompound, IsoLineVCompound,
HCompound, Rg1LineHCompound, RgNLineHCompound,
OutLineHCompound, IsoLineHCompound;
if ( myIsPolyAlgo ) {
if ( myPolyAlgo.IsNull() ) CreatePolyAlgo();
HLRBRep_PolyHLRToShape aPolyHLRToShape;
aPolyHLRToShape.Update( myPolyAlgo );
mySetOfSegments = new Graphic2d_SetOfSegments( this );
myHSetOfSegments = new Graphic2d_SetOfSegments( this );
if ( myESharp ) {
VCompound = aPolyHLRToShape.VCompound();
DrawSegments( Rg1LineVCompound, mySetOfSegments );
}
if ( myESmooth ) {
Rg1LineVCompound = aPolyHLRToShape.Rg1LineVCompound();
DrawSegments( RgNLineVCompound, mySetOfSegments );
}
if ( myESewn ) {
RgNLineVCompound = aPolyHLRToShape.RgNLineVCompound();
DrawSegments( OutLineVCompound, mySetOfSegments );
}
if ( myEOutline ) {
OutLineVCompound = aPolyHLRToShape.OutLineVCompound();
DrawSegments( VCompound, mySetOfSegments );
}
if ( myIsHiddenLine ) {
if ( myESharp ) {
HCompound = aPolyHLRToShape.HCompound();
DrawSegments( Rg1LineHCompound, myHSetOfSegments );
}
if ( myESmooth ) {
Rg1LineHCompound = aPolyHLRToShape.Rg1LineHCompound();
DrawSegments( RgNLineHCompound, myHSetOfSegments );
}
if ( myESewn ) {
RgNLineHCompound = aPolyHLRToShape.RgNLineHCompound();
DrawSegments( OutLineHCompound, myHSetOfSegments );
}
if ( myEOutline ) {
OutLineHCompound = aPolyHLRToShape.OutLineHCompound();
DrawSegments( HCompound, myHSetOfSegments );
}
} // end if is HiddenLine
} else {
if ( myAlgo.IsNull() ) CreateAlgo();
HLRBRep_HLRToShape aHLRToShape( myAlgo );
mySetOfCurves = new GGraphic2d_SetOfCurves( this );
myHSetOfCurves = new GGraphic2d_SetOfCurves( this );
if ( myESharp ) {
VCompound = aHLRToShape.VCompound();
DrawCurves( VCompound, mySetOfCurves );
}
if ( myESmooth ) {
Rg1LineVCompound = aHLRToShape.Rg1LineVCompound();
DrawCurves( Rg1LineVCompound, mySetOfCurves );
}
if ( myESewn ) {
RgNLineVCompound = aHLRToShape.RgNLineVCompound();
DrawCurves( RgNLineVCompound, mySetOfCurves );
}
if ( myEOutline ) {
OutLineVCompound = aHLRToShape.OutLineVCompound();
DrawCurves( OutLineVCompound, mySetOfCurves );
}
if ( myEIsoline ) {
IsoLineVCompound = aHLRToShape.IsoLineVCompound();
DrawCurves( IsoLineVCompound, mySetOfCurves );
}
if ( myIsHiddenLine ) {
if ( myESharp ) {
HCompound = aHLRToShape.HCompound();
DrawCurves( HCompound, myHSetOfCurves );
}
if ( myESmooth ) {
Rg1LineHCompound = aHLRToShape.Rg1LineHCompound();
DrawCurves( Rg1LineHCompound, myHSetOfCurves );
}
if ( myESewn ) {
RgNLineHCompound = aHLRToShape.RgNLineHCompound();
DrawCurves( RgNLineHCompound, myHSetOfCurves );
}
if ( myEOutline ) {
OutLineHCompound = aHLRToShape.OutLineHCompound();
DrawCurves( OutLineHCompound, myHSetOfCurves );
}
if ( myEIsoline ) {
IsoLineHCompound = aHLRToShape.IsoLineHCompound();
DrawCurves( IsoLineHCompound, myHSetOfCurves );
}
} //end if is HiddenLine
} // end if is PolyAlgo
}
inline HLRAlgo_Projector AIS2D_ProjShape::Projector() const {
return myProjector;
}
void AIS2D_ProjShape::SetProjector(const HLRAlgo_Projector& aProjector) {
myProjector = aProjector;
myAlgo.Nullify();
myPolyAlgo.Nullify();
if ( Length() ) {
RemovePrimitives();
ComputeShape();
}
}
void AIS2D_ProjShape::SetNbIsos( const Standard_Integer aNbIsos ) {
myNbIsos = aNbIsos;
myAlgo.Nullify();
if ( Length() ) {
RemovePrimitives();
ComputeShape();
}
}
void AIS2D_ProjShape::SetPolyAlgo( const Standard_Boolean aIsPoly ) {
myIsPolyAlgo = aIsPoly;
if ( Length() ) {
RemovePrimitives();
ComputeShape();
}
}
void AIS2D_ProjShape::SetHLMode( const Standard_Boolean aIsHLM ) {
myIsHiddenLine = aIsHLM;
if ( Length() ) {
RemovePrimitives();
ComputeShape();
}
}
Standard_Boolean AIS2D_ProjShape::IsHLMode() const {
return myIsHiddenLine;
}
Standard_Integer AIS2D_ProjShape::GetNbIsos() const {
return myNbIsos;
}
Standard_Boolean AIS2D_ProjShape::GetIsPoly() const {
return myIsPolyAlgo;
}
Handle(Graphic2d_Line) AIS2D_ProjShape::GetPrimitives() const {
if ( myIsPolyAlgo )
return mySetOfSegments;
else
return mySetOfCurves;
}
Handle(Graphic2d_Line) AIS2D_ProjShape::GetHLPrimitives() const {
if ( myIsPolyAlgo )
return myHSetOfSegments;
else
return myHSetOfCurves;
}
void AIS2D_ProjShape::CreateAlgo() {
myAlgo = new HLRBRep_Algo();
TopTools_ListIteratorOfListOfShape anIterator( myListOfShape );
for ( ; anIterator.More(); anIterator.Next() )
myAlgo->Add( anIterator.Value(), myNbIsos );
myAlgo->Projector( myProjector );
myAlgo->Update();
myAlgo->Hide();
}
void AIS2D_ProjShape::CreatePolyAlgo() {
myPolyAlgo = new HLRBRep_PolyAlgo();
TopTools_ListIteratorOfListOfShape anIterator(myListOfShape);
for ( ; anIterator.More(); anIterator.Next() )
myPolyAlgo->Load( anIterator.Value() );
myPolyAlgo->Projector( myProjector );
myPolyAlgo->Update();
}
void AIS2D_ProjShape::DrawSegments( const TopoDS_Shape& aShape,
Handle(Graphic2d_SetOfSegments)& aSofS ) {
if ( aShape.IsNull() ) return;
TopExp_Explorer theExp( aShape, TopAbs_EDGE );
while ( theExp.More() ) {
const TopoDS_Edge& CurrentEdge = TopoDS::Edge( theExp.Current() );
const TopoDS_Vertex& FirstVertex = TopExp::FirstVertex(CurrentEdge);
const TopoDS_Vertex& LastVertex = TopExp::LastVertex(CurrentEdge);
gp_Pnt FirstPoint = BRep_Tool::Pnt(FirstVertex);
gp_Pnt LastPoint = BRep_Tool::Pnt(LastVertex);
aSofS->Add( FirstPoint.X(), FirstPoint.Y(), LastPoint.X(), LastPoint.Y() );
theExp.Next();
}
}
void AIS2D_ProjShape::DrawCurves( const TopoDS_Shape& aShape,
Handle(GGraphic2d_SetOfCurves)& aSofC) {
if ( aShape.IsNull() ) return;
TopExp_Explorer theExp( aShape, TopAbs_EDGE );
Handle(Geom2d_Curve) aCurve;
Handle(Geom_Surface) aSurface;
TopLoc_Location theLoc;
Standard_Real f, l;
while ( theExp.More() ) {
const TopoDS_Edge& CurrentEdge = TopoDS::Edge( theExp.Current() );
assert(CurrentEdge.Location().IsIdentity());
BRep_Tool::CurveOnSurface( CurrentEdge, aCurve, aSurface, theLoc, f, l );
assert(theLoc.IsIdentity());
Handle(Geom2d_TrimmedCurve) theCurve = new Geom2d_TrimmedCurve(aCurve,f,l);
assert( ! theCurve.IsNull() );
aSofC->Add(theCurve);
theExp.Next();
}
}
void AIS2D_ProjShape::ShowEdges( const Standard_Boolean aSharp,
const Standard_Boolean aSmooth,
const Standard_Boolean aSewn,
const Standard_Boolean anOutline,
const Standard_Boolean anIsoline ) {
myESharp = aSharp;
myESmooth = aSmooth;
myESewn = aSewn;
myEOutline = anOutline;
myEIsoline = anIsoline;
if ( Length() ) {
RemovePrimitives();
ComputeShape();
}
}