MODULE*************************************************************************** Colour_PN ***************************************************************************MarkerGO EXPORTSMarkerGO ,MarkerGOProxy ; IMPORT Color, ColorProp, ColorPropPrivate, GO, GOPrivate, GraphicsBase, GraphicsBasePrivate, MarkerTypeProp, MarkerTypePropPrivate, Prop, PropPrivate, Point3, PointProp, PointPropPrivate, RealProp, RealPropPrivate; REVEAL T = Public BRANDED OBJECT OVERRIDES init := Init; draw := Draw; damageIfDependent := DamageIfDependent; needsTransparency := NeedsTransparency; END; PROCEDUREInit (self : T) : T = BEGIN EVAL GO.T.init (self); IF MkProxyT # NIL AND self.proxy = NIL THEN MkProxyT (self); END; RETURN self; END Init; PROCEDUREDraw (self : T; state : GraphicsBase.T) = BEGIN state.push (self); WITH center = Center.getState (state) DO state.drawMarker (center); (*** The bounding sphere of every GO must have size > 0 ***) state.growBoundingVolume (center, 1.0e-10); END; state.pop (self); END Draw; PROCEDUREDamageIfDependent (self : T; pn : Prop.Name) = BEGIN IF pn = Center THEN self.damaged := TRUE; END; END DamageIfDependent; PROCEDURENeedsTransparency (<* UNUSED *> self : T; <* UNUSED *> t : REAL) : BOOLEAN = BEGIN RETURN FALSE; END NeedsTransparency; PROCEDURENew (p : Point3.T) : T = VAR marker := NEW (T).init (); BEGIN SetCenter (marker, p); RETURN marker; END New;
TYPE Colour_PN = ColorProp.Name OBJECT OVERRIDES damage := DamageColour; push := PushColour; pop := PopColour; END; PROCEDURE*************************************************************************** Scale_PN ***************************************************************************DamageColour (<* UNUSED *> self : Colour_PN; caller : GO.T) = BEGIN caller.damaged := TRUE; END DamageColour; PROCEDUREPushColour (self : Colour_PN; state : GraphicsBase.T; pv : Prop.Val) = BEGIN WITH stack = NARROW (state.stacks[self.id], ColorPropPrivate.Stack), val = NARROW (pv, ColorProp.Val).val DO IF stack.top # val THEN state.setMarkerColor (val); END; stack.push (val); END; END PushColour; PROCEDUREPopColour (self : Colour_PN; state : GraphicsBase.T) = BEGIN WITH stack = NARROW (state.stacks[self.id], ColorPropPrivate.Stack) DO state.setMarkerColor (stack.pop ()); END; END PopColour;
TYPE Scale_PN = RealProp.Name OBJECT OVERRIDES damage := DamageScale; push := PushScale; pop := PopScale; END; PROCEDURE*************************************************************************** Type_PN ***************************************************************************DamageScale (<* UNUSED *> self : Scale_PN; caller : GO.T) = BEGIN caller.damaged := TRUE; END DamageScale; PROCEDUREPushScale (self : Scale_PN; state : GraphicsBase.T; pv : Prop.Val) = BEGIN WITH stack = NARROW (state.stacks[self.id], RealPropPrivate.Stack), val = NARROW (pv, RealProp.Val).val DO IF stack.top # val THEN state.setMarkerScale (val); END; stack.push (val); END; END PushScale; PROCEDUREPopScale (self : Scale_PN; state : GraphicsBase.T) = BEGIN WITH stack = NARROW (state.stacks[self.id], RealPropPrivate.Stack) DO state.setMarkerScale (stack.pop ()); END; END PopScale;
TYPE Type_PN = MarkerTypeProp.Name OBJECT OVERRIDES damage := DamageType; push := PushType; pop := PopType; END; PROCEDURE*************************************************************************** Convenience Procedures ***************************************************************************DamageType (<* UNUSED *> self : Type_PN; caller : GO.T) = BEGIN caller.damaged := TRUE; END DamageType; PROCEDUREPushType (self : Type_PN; state : GraphicsBase.T; pv : Prop.Val) = BEGIN WITH stack = NARROW (state.stacks[self.id], MarkerTypePropPrivate.Stack), val = NARROW (pv, MarkerTypeProp.Val).val DO IF stack.top # val THEN state.setMarkerType (val); END; stack.push (val); END; END PushType; PROCEDUREPopType (self : Type_PN; state : GraphicsBase.T) = BEGIN WITH stack = NARROW (state.stacks[self.id], MarkerTypePropPrivate.Stack) DO state.setMarkerType (stack.pop ()); END; END PopType;
PROCEDURE*************************************************************************** Module Body ***************************************************************************SetCenter (o : GO.T; v : Point3.T) = BEGIN o.setProp (Center.bind (PointProp.NewConst (v))); END SetCenter; PROCEDURESetColour (o : GO.T; v : Color.T) = BEGIN o.setProp (Colour.bind (ColorProp.NewConst (v))); END SetColour; PROCEDURESetScale (o : GO.T; v : REAL) = BEGIN o.setProp (Scale.bind (RealProp.NewConst (v))); END SetScale; PROCEDURESetType (o : GO.T; v : MarkerTypeProp.Kind) = BEGIN o.setProp (Type.bind (MarkerTypeProp.NewConst (v))); END SetType;
BEGIN Center := NEW (PointProp.Name).init (Point3.T {0.0, 0.0, 0.0}); Colour := NEW (Colour_PN).init (Color.White); Scale := NEW (Scale_PN).init (1.0); Type := NEW (Type_PN).init (MarkerTypeProp.Kind.Asterisk); END MarkerGO.