//-------------------------------------------------------------------------------------------------- void _VisualShape_AisObjectChanged(VisualShape theShape) { if (theShape.AisObject != null) { UpdateShape(theShape); } }
//-------------------------------------------------------------------------------------------------- public void UpdateShape(VisualShape visualShape) { bool includeByDefault = _Options.HasFlag(Options.IncludeAll); bool isInOrExcluded = _InOrExcludedShapes.Contains(visualShape); UpdateShape(visualShape, includeByDefault ? !isInOrExcluded : isInOrExcluded); }
// Start is called before the first frame update void Start() { ParentShape = GetComponentInParent <VisualShape>(); boundaries = new Vector3[4]; Lane.GetWorldCorners(boundaries); _handSpriteRenderer = GetComponentInChildren <SpriteRenderer>(); handPosition = _handSpriteRenderer.transform.position; }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Creates and returns a Relationship Visual Representation shortcut (as Main Central/Main Symbol) /// to the target Relationship, for the specified target view, center position, symbol and connectors format, /// plus indication as a shortcut. /// </summary> public static RelationshipVisualRepresentation CreateRelationshipVisualRepresentation(Relationship Target, View TargetView, Point CenterPosition, bool AsShortcut = false) { var Representator = new RelationshipVisualRepresentation(Target, TargetView) { IsShortcut = AsShortcut }; var Width = Target.RelationshipDefinitor.Value.DefaultSymbolFormat.InitialWidth.SubstituteFor(0, ProductDirector.DefaultRelationshipCentralSymbolSize.Width); var Height = Target.RelationshipDefinitor.Value.DefaultSymbolFormat.InitialHeight.SubstituteFor(0, ProductDirector.DefaultRelationshipCentralSymbolSize.Height); // Notice that "hidden" symbols are not adjusted/snapped to grid if (TargetView.SnapToGrid && !(Target.RelationshipDefinitor.Value.IsSimple && Target.RelationshipDefinitor.Value.HideCentralSymbolWhenSimple)) { var SnappedArea = TargetView.GetGridSnappedArea(CenterPosition, Width, Height); if (!Target.RelationshipDefinitor.Value.DefaultSymbolFormat.HasFixedWidth) { Width = SnappedArea.Width; } if (!Target.RelationshipDefinitor.Value.DefaultSymbolFormat.HasFixedWidth) { Height = SnappedArea.Height; } CenterPosition = new Point(SnappedArea.X + SnappedArea.Width / 2.0, SnappedArea.Y + SnappedArea.Height / 2.0); } var Body = new VisualShape(Representator, EVisualRepresentationPart.RelationshipCentralSymbol, CenterPosition, Width, Height) { IsAutoPositionable = true // Very important (for users) to work more easily }; Representator.AddVisualPart(Body); // Append possible Group Region Complement if (Target.IdeaDefinitor.HasGroupRegion) { var Params = VisualComplement.GetGroupRegionInitialParams(Body); ComplementCreationCommand.CreateComplement(TargetView.OwnerCompositeContainer, Domain.ComplementDefGroupRegion, TargetView, Body, Params.Item1, Params.Item2); } // Append possible Group Line Complement if (Target.IdeaDefinitor.HasGroupLine) { ComplementCreationCommand.CreateComplement(TargetView.OwnerCompositeContainer, Domain.ComplementDefGroupLine, TargetView, Body, VisualComplement.GetGroupLineInitialPosition(Body)); } // NOTE: This does not render because the connectors are expected to be added later. return(Representator); }
//-------------------------------------------------------------------------------------------------- public override void Stop() { if (_OverriddenVisualShape != null) { _OverriddenVisualShape.OverrideBrep = null; WorkspaceController.Invalidate(); _OverriddenVisualShape = null; } base.Stop(); }
private void CreateMarkingZones(SolidColorBrush ZoneBrush, Pen ZonePen, VisualShape ManipulatedShape) { foreach (var MarkingZone in ManipulatedShape.CurrentMarkingZones) { var IconZone = (new GeometryDrawing(ZoneBrush, ZonePen, new RectangleGeometry(MarkingZone.Item2))).RenderToDrawingVisual(); IconZone.Opacity = FrmOpacityEdit; Indicators.Add(IconZone); FrmMarkingZones.Add(IconZone, MarkingZone.Item1); } }
public DrawableClassObject CreateNewClass(Point size, Brush brush, VisualShape shape, Point position, double scale) { DrawableClassObject newClass = new DrawableClassObject(size, brush, shape); _classes.Add(newClass); InstanceObject newInstance = new InstanceObject(newClass, position, scale); newClass.Instances.Add(newInstance); StartTranslation(); return(newClass); }
//-------------------------------------------------------------------------------------------------- void _UpdateGhost() { if (Entity.IsVisible && Entity.Layer.IsVisible) { _GhostVisualObject?.Remove(); _GhostVisualObject = null; } else { _GhostVisualObject ??= new VisualShape(WorkspaceController, Entity, VisualShape.Options.Ghosting); } }
//-------------------------------------------------------------------------------------------------- public void UpdateShape(VisualShape visualShape, bool activate) { var aisContext = _WorkspaceController?.Workspace?.AisContext; if (aisContext == null) { return; } var aisObject = visualShape.AisObject; if (visualShape.IsSelectable()) { // Get already activated modes var colActivatedModes = new TColStd_ListOfInteger(); aisContext.ActivatedModes(aisObject, colActivatedModes); var activatedModes = colActivatedModes.ToList(); // Enlist all requested modes var modesToBeActivated = new bool[5]; var snapHandler = _WorkspaceController.SnapHandler; modesToBeActivated[0] = activate && _SubshapeTypes == SubshapeTypes.None; modesToBeActivated[SubshapeType.Vertex.ToAisSelectionMode()] = activate && _SubshapeTypes.HasFlag(SubshapeTypes.Vertex) || snapHandler.NeedActiveSubshapes(SubshapeType.Vertex); modesToBeActivated[SubshapeType.Edge.ToAisSelectionMode()] = activate && _SubshapeTypes.HasFlag(SubshapeTypes.Edge) || snapHandler.NeedActiveSubshapes(SubshapeType.Edge); modesToBeActivated[SubshapeType.Wire.ToAisSelectionMode()] = activate && _SubshapeTypes.HasFlag(SubshapeTypes.Wire) || snapHandler.NeedActiveSubshapes(SubshapeType.Wire); modesToBeActivated[SubshapeType.Face.ToAisSelectionMode()] = activate && _SubshapeTypes.HasFlag(SubshapeTypes.Face) || snapHandler.NeedActiveSubshapes(SubshapeType.Face); // Deactivate all modes which are not requested foreach (var mode in activatedModes) { if (!modesToBeActivated[mode]) { aisContext.SetSelectionModeActive(aisObject, mode, false, AIS_SelectionModesConcurrency.AIS_SelectionModesConcurrency_Multiple); } } // Activate all requested modes for (int mode = 0; mode < 5; mode++) { if (modesToBeActivated[mode]) { aisContext.SetSelectionModeActive(aisObject, mode, true, AIS_SelectionModesConcurrency.AIS_SelectionModesConcurrency_Multiple); } } } else { aisContext.Deactivate(visualShape.AisObject); } }
//-------------------------------------------------------------------------------------------------- public override void Stop() { InteractiveEntity.VisualChanged -= _InteractiveEntity_VisualChanged; Entity.PropertyChanged -= _Body_PropertyChanged; _GhostVisualObject?.Remove(); _GhostVisualObject = null; foreach (var componentEditor in _ComponentEditors.Values) { componentEditor.Stop(); } _ComponentEditors.Clear(); InteractiveContext.Current.PropertyPanelManager?.RemovePanel(_ShapePanel); _ShapePanel = null; InteractiveContext.Current.PropertyPanelManager?.RemovePanel(_Panel); _Panel = null; }
//-------------------------------------------------------------------------------------------------- public override bool Start() { if (_TargetShape != _TargetBody?.Shape) { _OverriddenVisualShape = WorkspaceController.VisualShapes.GetVisualShape(_TargetBody); if (_OverriddenVisualShape != null) { _OverriddenVisualShape.OverrideBrep = _TargetShape.GetTransformedBRep(); WorkspaceController.Invalidate(); } } var toolAction = new SelectSubshapeAction(this, SubshapeTypeHelper.GetTypes(_SubshapeType), _TargetBody, _SelectionFilter); if (!WorkspaceController.StartToolAction(toolAction)) { return(false); } toolAction.Finished += _OnActionFinished; StatusText = _StatusText; switch (_SubshapeType) { case SubshapeType.Vertex: WorkspaceController.HudManager?.SetCursor(Cursors.SelectVertex); break; case SubshapeType.Edge: WorkspaceController.HudManager?.SetCursor(Cursors.SelectEdge); break; case SubshapeType.Wire: WorkspaceController.HudManager?.SetCursor(Cursors.SelectWire); break; case SubshapeType.Face: WorkspaceController.HudManager?.SetCursor(Cursors.SelectFace); break; } return(true); }
//-------------------------------------------------------------------------------------------------- public void Include(VisualShape visShape) { if (_Options.HasFlag(Options.IncludeAll)) { if (_InOrExcludedShapes.Contains(visShape)) { _InOrExcludedShapes.Remove(visShape); _RaiseParametersChanged(); } return; } if (_InOrExcludedShapes.Contains(visShape)) { return; } _InOrExcludedShapes.Add(visShape); _RaiseParametersChanged(); }
/// <summary> /// Constructor which initilizes the Class Object. /// </summary> public DrawableClassObject(Point size, Brush brush, VisualShape shape) { Size = size; VisualShape = shape; if (brush == null) { GradientStopCollection gradient = new GradientStopCollection(); GradientStop top = new GradientStop(); GradientStop down = new GradientStop(); top.Color = Color.FromArgb(0, 38, 50, 56); down.Color = Color.FromArgb(0, 84, 110, 122); down.Offset = 1.0; gradient.Add(top); gradient.Add(down); Brush = new LinearGradientBrush(new GradientStopCollection(), 90); } else { Brush = brush; } }
private void CreateDetailZones(SolidColorBrush ZoneBrush, Pen ZonePen, VisualShape ManipulatedShape) { foreach (var DetailZone in ManipulatedShape.CurrentDetailZones) { if (DetailZone.Value == null) { break; } else { // Title-Designate zone if (DetailZone.Value.Item1 != null && DetailZone.Value.Item1 != Rect.Empty) { var DetailTitleNamingZone = (new GeometryDrawing(ZoneBrush, ZonePen, new RectangleGeometry(DetailZone.Value.Item1))).RenderToDrawingVisual(); DetailTitleNamingZone.Opacity = FrmOpacityEdit; var EditZone = (new GeometryDrawing(FrmStrokeEdit, FrmPencil, new RectangleGeometry(DetailZone.Value.Item1))).RenderToDrawingVisual(); EditZone.Opacity = FrmOpacityEdit; Indicators.Add(EditZone); FrmDetailTitleDesignateZones.Add(DetailTitleNamingZone, DetailZone.Key); Indicators.Add(DetailTitleNamingZone); } // Title-Expand zone if (DetailZone.Value.Item2 != null && DetailZone.Value.Item2 != Rect.Empty) { var DetailTitleExpandZone = (new GeometryDrawing(ZoneBrush, ZonePen, new RectangleGeometry(DetailZone.Value.Item2))).RenderToDrawingVisual(); DetailTitleExpandZone.Opacity = FrmOpacityEdit; FrmDetailTitleExpandZones.Add(DetailTitleExpandZone, DetailZone.Key); Indicators.Add(DetailTitleExpandZone); } // Content-Edit zone // IMPORTANT: Put this edit-zone before the assign-zone to be on the background of it. if (DetailZone.Value.Item4 != null && DetailZone.Value.Item4 != Rect.Empty) { var DetailContentEditZone = (new GeometryDrawing(ZoneBrush, ZonePen, new RectangleGeometry(DetailZone.Value.Item4))).RenderToDrawingVisual(); DetailContentEditZone.Opacity = FrmOpacityEdit; FrmDetailContentEditZones.Add(DetailContentEditZone, DetailZone.Key); Indicators.Add(DetailContentEditZone); } // Content-Assign zone // IMPORTANT: Put this assign-zone after the edit-zone to be on the foreground of it. if (DetailZone.Value.Item3 != null && DetailZone.Value.Item3 != Rect.Empty) { var DetailContentAssignZone = (new GeometryDrawing(ZoneBrush, ZonePen, new RectangleGeometry(DetailZone.Value.Item3))).RenderToDrawingVisual(); DetailContentAssignZone.Opacity = FrmOpacityEdit; var EditZone = (new GeometryDrawing(FrmStrokeEdit, FrmPencil, new RectangleGeometry(DetailZone.Value.Item3))).RenderToDrawingVisual(); EditZone.Opacity = FrmOpacityEdit; Indicators.Add(EditZone); FrmDetailContentAssignZones.Add(DetailContentAssignZone, DetailZone.Key); Indicators.Add(DetailContentAssignZone); } } } }