public void Move_MFacet_MFacetShiftedBy21AlongZ() { // arrange ShapeEditor editor = new ShapeEditor(); MFacet testedFacet = new MFacet(new MPoint(12, 10, -3), new MPoint(80, 49, 0), new MPoint(34, 105, 4)); MFacet expectedFacet = new MFacet(new MPoint(12, 10, -3), new MPoint(80, 49, 0), new MPoint(34, 105, 4)); SetPointCoordinatesToDestinationPoint(new MPoint(12, 10, 18), expectedFacet.Vertices[0]); SetPointCoordinatesToDestinationPoint(new MPoint(80, 49, 21), expectedFacet.Vertices[1]); SetPointCoordinatesToDestinationPoint(new MPoint(34, 105, 25), expectedFacet.Vertices[2]); float distanceZ = 21; // act editor.Translate(testedFacet, 0, 0, distanceZ); // assert CompareLogic compareLogic = new CompareLogic(); var comparsionResult = compareLogic.Compare(expectedFacet, testedFacet); Assert.IsTrue(comparsionResult.AreEqual); }
public MenuUpdater(IAppContext context, ShapeEditor plugin, IGeoprocessingService geoprocessingService) : base(context, plugin.Identity) { if (plugin == null) { throw new ArgumentNullException("plugin"); } _plugin = plugin; _geoprocessingService = geoprocessingService; plugin.ViewUpdating += OnViewUpdating; plugin.MapCursorChanged += OnMapCursorChanged; plugin.HistoryChanged += (s, e) => { OnViewUpdating(null, null); // we need to trigger the update of status bar _context.View.Update(); }; var item = FindMenuItem(MenuKeys.MainMenuEditKey) as IDropDownMenuItem; if (item != null) { item.DropDownOpening += MenuDropDownOpening; item.DropDownClosed += MenuDropDownClosed; } }
public void RotateZ_MFacet_MFacetRotatedBy45DegreesAlongZ() { // arrange ShapeEditor editor = new ShapeEditor(); MFacet testedFacet = new MFacet(new MPoint(50, 35, 0), new MPoint(100, 23, 0), new MPoint(72, 75, 0)); MFacet expectedFacet = new MFacet(new MPoint(50, 35, 0), new MPoint(100, 23, 0), new MPoint(72, 75, 0)); SetPointCoordinatesToDestinationPoint(new MPoint(67.2218246, 21.4228363, 0), expectedFacet.Vertices[0]); SetPointCoordinatesToDestinationPoint(new MPoint(111.062447, 48.2928925, 0), expectedFacet.Vertices[1]); SetPointCoordinatesToDestinationPoint(new MPoint(54.4939041, 65.26346, 0), expectedFacet.Vertices[2]); double angle = 45; // act editor.RotateZ(testedFacet, angle); // assert CompareLogic compareLogic = new CompareLogic(); var comparsionResult = compareLogic.Compare(expectedFacet, testedFacet); Assert.IsTrue(comparsionResult.AreEqual); }
public void RotateY_MFacet_MFacetRotatedBy45DegreesAlongZ() { // arrange ShapeEditor editor = new ShapeEditor(); MFacet testedFacet = new MFacet(new MPoint(50, 35, 0), new MPoint(100, 23, 0), new MPoint(72, 75, 0)); MFacet expectedFacet = new MFacet(new MPoint(50, 35, 0), new MPoint(100, 23, 0), new MPoint(72, 75, 0)); SetPointCoordinatesToDestinationPoint(new MPoint(57.32233, 35, 17.67767), expectedFacet.Vertices[0]); SetPointCoordinatesToDestinationPoint(new MPoint(92.67767, 23, -17.67767), expectedFacet.Vertices[1]); SetPointCoordinatesToDestinationPoint(new MPoint(72.87868, 75, 2.12132025), expectedFacet.Vertices[2]); double angle = 45; // act editor.RotateY(testedFacet, angle); // assert CompareLogic compareLogic = new CompareLogic(); var comparsionResult = compareLogic.Compare(expectedFacet, testedFacet); Assert.IsTrue(comparsionResult.AreEqual); }
public void RotateX_MFacet_MFacetRotatedBy45DegreesAlongZ() { // arrange ShapeEditor editor = new ShapeEditor(); MFacet testedFacet = new MFacet(new MPoint(50, 35, 0), new MPoint(100, 23, 0), new MPoint(72, 75, 0)); MFacet expectedFacet = new MFacet(new MPoint(50, 35, 0), new MPoint(100, 23, 0), new MPoint(72, 75, 0)); SetPointCoordinatesToDestinationPoint(new MPoint(50, 39.1005058, -9.899494), expectedFacet.Vertices[0]); SetPointCoordinatesToDestinationPoint(new MPoint(100, 30.6152229, -18.3847752), expectedFacet.Vertices[1]); SetPointCoordinatesToDestinationPoint(new MPoint(72, 67.38478, 18.3847752), expectedFacet.Vertices[2]); double angle = 45; // act editor.RotateX(testedFacet, angle); // assert CompareLogic compareLogic = new CompareLogic(); var comparsionResult = compareLogic.Compare(expectedFacet, testedFacet); Assert.IsTrue(comparsionResult.AreEqual); }
public void Move_MFacet_MFacetShiftedByMinus10AlongYAndBy208AlongX() { // arrange ShapeEditor editor = new ShapeEditor(); MFacet testedFacet = new MFacet(new MPoint(26, 18, 20), new MPoint(156, 74, 12), new MPoint(85, 26, 0)); MFacet expectedFacet = new MFacet(new MPoint(26, 18, 20), new MPoint(156, 74, 12), new MPoint(85, 26, 0)); SetPointCoordinatesToDestinationPoint(new MPoint(234, 8, 20), expectedFacet.Vertices[0]); SetPointCoordinatesToDestinationPoint(new MPoint(364, 64, 12), expectedFacet.Vertices[1]); SetPointCoordinatesToDestinationPoint(new MPoint(293, 16, 0), expectedFacet.Vertices[2]); float distanceY = -10, distanceX = 208; // act editor.Translate(testedFacet, distanceX, distanceY, 0); // assert CompareLogic compareLogic = new CompareLogic(); var comparsionResult = compareLogic.Compare(expectedFacet, testedFacet); Assert.IsTrue(comparsionResult.AreEqual); }
public MenuGenerator(IAppContext context, ShapeEditor plugin) { _commands = new MenuCommands(plugin.Identity); InitToolbar(context, plugin.Identity); InitMenu(context, plugin.Identity); }
internal GeometryEditor(ShapeEditor editor) { _editor = editor; if (editor == null) { throw new NullReferenceException("Internal reference is null."); } }
public void StartShapeEdit() { LedCursor = Cursors.Pen; ShapeEditor = new ShapeEditor(); CreateLedGeometry(); NotifyOfPropertyChange(() => IsEditingShape); NotifyOfPropertyChange(() => ZIndex); }
public void MouseMove(object sender, MouseEventArgs e) { if (ShapeEditor != null) { var percentagePosition = GetPercentagePosition(e.GetPosition((IInputElement)sender)); ShapeEditor.Move(percentagePosition); CreateLedGeometry(); } }
public override void onDeactivated() { ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow"; ShapeEdSelectWindow ShapeEdSelectWindow = "ShapeEdSelectWindow"; ShapeEdAdvancedWindow ShapeEdAdvancedWindow = "ShapeEdAdvancedWindow"; ShapeEdAnimWindow ShapeEdAnimWindow = "ShapeEdAnimWindow"; ShapeEditorToolbar ShapeEditorToolbar = "ShapeEditorToolbar"; ShapeEditor.ShapeEdPreviewGui ShapeEdPreviewGui = "ShapeEdPreviewGui"; editor Editor = "Editor"; ShapeEditor.ShapeEdMaterials ShapeEdMaterials = "ShapeEdMaterials"; ShapeEditor ShapeEditor = "ShapeEditor"; MaterialEditorPropertiesWindow MaterialEditorPropertiesWindow = "MaterialEditorPropertiesWindow"; //Copyright Winterleaf Entertainment L.L.C. 2013 if (!this["isActive"].AsBool()) { return; } this["isActive"] = false.AsString(); //Copyright Winterleaf Entertainment L.L.C. 2013 this.writeSettings(); // Notify game objects if shape has been modified if (ShapeEditor.isDirty()) { ShapeEditor.shape.notifyShapeChanged(); } bGlobal["$gfx::wireframe"] = bGlobal["$wasInWireFrameMode"]; ShapeEdMaterials.updateSelectedMaterial(false); ShapeEditorToolbar.setVisible(false); ShapeEdPreviewGui.setVisible(false); ShapeEdSelectWindow.setVisible(false); ShapeEdPropWindow.setVisible(false); ShapeEdAnimWindow.setVisible(false); ShapeEdAdvancedWindow.setVisible(false); //Copyright Winterleaf Entertainment L.L.C. 2013 if (MaterialEditorPropertiesWindow.visible) { ShapeEdMaterials.editSelectedMaterialEnd(true); } //Copyright Winterleaf Entertainment L.L.C. 2013 this.map.pop(); // Restore the original undo manager Editor.setUndoManager(this["oldUndoMgr"]); // Restore menu bar this.replaceMenuCmd("Camera", "8", this["oldCamFitCmd"]); this.replaceMenuCmd("Camera", "9", this["oldCamFitOrbitCmd"]); base.onDeactivated(); }
public MenuListener(IAppContext context, ShapeEditor plugin, ILayerEditingService layerService, IGeoprocessingService geoprocessingService) { _plugin = plugin ?? throw new ArgumentNullException("plugin"); _layerService = layerService ?? throw new ArgumentNullException("layerService"); _geoprocessingService = geoprocessingService ?? throw new ArgumentNullException("geoprocessingService"); _context = context ?? throw new ArgumentNullException("context"); plugin.ItemClicked += Plugin_ItemClicked; }
public void initStatusBar() { EditorGui.EditorGuiStatusBar EditorGuiStatusBar = "EditorGuiStatusBar"; ShapeEditor ShapeEditor = "ShapeEditor"; EditorGuiStatusBar.setInfo("Shape editor ( Shift Click ) to speed up camera."); if (ShapeEditor.shape != 0) { EditorGuiStatusBar.setSelection(ShapeEditor.shape["baseShape"]); } }
private void CreateLedGeometry() { var geometryRectangle = new Rect(0, 0, 1, 1); Geometry geometry; if (ShapeEditor != null) { try { geometry = Geometry.Combine(Geometry.Parse(LedLayout.ShapeData), ShapeEditor.GetGeometry(true), GeometryCombineMode.Xor, null); } catch (Exception) { geometry = ShapeEditor.GetGeometry(true); } } else { switch (LedLayout.Shape) { case Shape.Custom: try { geometry = Geometry.Parse(LedLayout.ShapeData); } catch (Exception e) { geometry = new RectangleGeometry(geometryRectangle); _windowManager.ShowMessageBox( "Failed to parse shape data, showing a rectangle instead.\n\n " + e.Message, InputId); } break; case Shape.Rectangle: geometry = new RectangleGeometry(geometryRectangle); break; case Shape.Circle: geometry = new EllipseGeometry(geometryRectangle); break; default: throw new ArgumentOutOfRangeException(); } } DisplayGeometry = Geometry.Combine(Geometry.Empty, geometry, GeometryCombineMode.Union, new ScaleTransform(LedLayout.Width, LedLayout.Height)); SetColor(Selected ? SelectedColor : UnselectedColor); NotifyOfPropertyChange(() => LedLayout); }
public void MouseUp(object sender, MouseEventArgs e) { _layoutViewModel.SelectLed(this); if (ShapeEditor != null) { var percentagePosition = GetPercentagePosition(e.GetPosition((IInputElement)sender)); ShapeEditor.Click(percentagePosition); CreateLedGeometry(); } }
//TODO Rework public void RotateSelected(double angle) { //TODO remove this SelectedShapes = Shapes; var editor = new ShapeEditor(); for (int i = 0; i < SelectedShapes.Count; ++i) { editor.Rotate(SelectedShapes[i], 10, 0, 0); } }
public void openShape(string path, bool discardChangesToCurrent) { EditorGui EditorGui = "EditorGui"; ShapeEditor ShapeEditor = "ShapeEditor"; ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView"; EditorGui.setEditor(this, false); if (ShapeEditor.isDirty() && !discardChangesToCurrent) { messageBox.MessageBoxYesNo("Save Changes?", "Save changes to current shape?", "ShapeEditor.saveChanges(); ShapeEditorPlugin.openShape(\"" + path + "\");", "ShapeEditorPlugin.openShape(\"" + path + "\");"); return; } ShapeEditor.selectShape(path, !discardChangesToCurrent); ShapeEdShapeView.fitToShape(); }
public void StopShapeEdit() { var geometry = ShapeEditor.GetGeometry(false); if (geometry is PathGeometry) { InputShapeData = geometry .ToString() .Replace(",", ".") .Replace(";", ",") .Replace("L", " L"); } LedCursor = Cursors.Hand; ShapeEditor = null; CreateLedGeometry(); NotifyOfPropertyChange(() => IsEditingShape); NotifyOfPropertyChange(() => ZIndex); }
public override void onActivated() { EWorldEditor EWorldEditor = "EWorldEditor"; ShapeEditor.ShapeEdShapeTreeView ShapeEdShapeTreeView = "ShapeEdShapeTreeView"; ShapeEditor ShapeEditor = "ShapeEditor"; ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView"; GuiCanvas Canvas = "Canvas"; //Copyright Winterleaf Entertainment L.L.C. 2013 this["isActive"] = true.AsString(); //Copyright Winterleaf Entertainment L.L.C. 2013 this.open(""); // Try to start with the shape selected in the world editor int count = EWorldEditor.getSelectionSize(); for (int i = 0; i < count; i++) { SimObject obj = EWorldEditor.getSelectedObject(i); string shapeFile = ShapeEditor.getObjectShapeFile(obj); if (shapeFile != "") { if (!ShapeEditor.shape.isObject() || (ShapeEditor.shape["baseShape"] != shapeFile)) { // Call the 'onSelect' method directly if the object is not in the // MissionGroup tree (such as a Player or Projectile object). ShapeEdShapeTreeView.clearSelection(); if (!ShapeEdShapeTreeView.selectItem(obj)) { ShapeEdShapeTreeView.onSelect(obj, ""); } // 'fitToShape' only works after the GUI has been rendered, so force a repaint first Canvas.repaint(0); ShapeEdShapeView.fitToShape(); } break; } } }
public ContextMenuPresenter(IAppContext context, ShapeEditor plugin, ILayerService layerService, IGeoprocessingService geoService, ContextMenuView view) : base(view) { if (context == null) { throw new ArgumentNullException("context"); } if (layerService == null) { throw new ArgumentNullException("layerService"); } if (geoService == null) { throw new ArgumentNullException("geoService"); } _context = context; _layerService = layerService; _geoService = geoService; _plugin = plugin; }
public override void onExitMission() { ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView"; ShapeEditor ShapeEditor = "ShapeEditor"; ShapeEditorActions.ShapeEdUndoManager ShapeEdUndoManager = "ShapeEdUndoManager"; ShapeEditor.ShapeEdSequenceList ShapeEdSequenceList = "ShapeEdSequenceList"; ShapeEditor.ShapeEdNodeTreeView ShapeEdNodeTreeView = "ShapeEdNodeTreeView"; ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow"; ShapeEditor.ShapeEdDetailTree ShapeEdDetailTree = "ShapeEdDetailTree"; GuiTextListCtrl ShapeEdMaterialList = "ShapeEdMaterialList"; ShapeEditor.ShapeEdMountWindow ShapeEdMountWindow = "ShapeEdMountWindow"; ShapeEditor.ShapeEdThreadWindow ShapeEdThreadWindow = "ShapeEdThreadWindow"; ShapeEditor.ShapeEdThreadList ShapeEdThreadList = "ShapeEdThreadList"; GuiTextListCtrl mountList = ShapeEdMountWindow.FOT("mountList"); GuiTextListCtrl seqList = ShapeEdThreadWindow.FOT("seqList"); // unselect the current shape ShapeEdShapeView.setModel(""); if (ShapeEditor.shape != 0) { ShapeEditor.shape.delete(); } ShapeEditor.shape = 0; ShapeEdUndoManager.clearAll(); ShapeEditor.setDirty(false); ShapeEdSequenceList.clear(); ShapeEdNodeTreeView.removeItem(0); ShapeEdPropWindow.update_onNodeSelectionChanged(-1); ShapeEdDetailTree.removeItem(0); ShapeEdMaterialList.clear(); mountList.clear(); seqList.clear(); ShapeEdThreadList.clear(); }
public MenuListener(IAppContext context, ShapeEditor plugin, ILayerEditingService layerService, IGeoprocessingService geoprocessingService) { if (context == null) { throw new ArgumentNullException("context"); } if (layerService == null) { throw new ArgumentNullException("layerService"); } if (geoprocessingService == null) { throw new ArgumentNullException("geoprocessingService"); } _layerService = layerService; _geoprocessingService = geoprocessingService; _context = context; plugin.ItemClicked += Plugin_ItemClicked; }
private async void btn_rotateLeft_Click(object sender, RoutedEventArgs e) { await Task.Run(() => { var editor = new ShapeEditor(); for (int i = 0; i < 500; ++i) { editor.RotateRange(Scene.SelectedShapes, 10, 10, 0); if (screen.Dispatcher.CheckAccess()) { Render(); } else { screen.Dispatcher.Invoke(new Action(Render)); } Thread.Sleep(500); } }); }
public override ActionResult DoAction() { ShapeEditor.MenuOpenShapeCreator(); return(new ActionResult(ActionResult.Status.Success, "Open Shape Editor")); }
public void open(string filename) { EditorGui EditorGui = "EditorGui"; ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow"; ShapeEdSelectWindow ShapeEdSelectWindow = "ShapeEdSelectWindow"; ShapeEdAdvancedWindow ShapeEdAdvancedWindow = "ShapeEdAdvancedWindow"; ShapeEdAnimWindow ShapeEdAnimWindow = "ShapeEdAnimWindow"; ShapeEditorToolbar ShapeEditorToolbar = "ShapeEditorToolbar"; ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView"; ShapeEditor.ShapeEdNodes ShapeEdNodes = "ShapeEdNodes"; Settings EditorSettings = "EditorSettings"; EWorldEditor EWorldEditor = "EWorldEditor"; GizmoProfile GlobalGizmoProfile = "GlobalGizmoProfile"; ShapeEditor.ShapeEdShapeTreeView ShapeEdShapeTreeView = "ShapeEdShapeTreeView"; ShapeEditor.ShapeEdPreviewGui ShapeEdPreviewGui = "ShapeEdPreviewGui"; ShapeEditorActions.ShapeEdUndoManager ShapeEdUndoManager = "ShapeEdUndoManager"; SimGroup MissionGroup = "MissionGroup"; GuiDynamicCtrlArrayControl ToolsPaletteArray = "ToolsPaletteArray"; editor Editor = "Editor"; ShapeEditor.ShapeEdMaterials ShapeEdMaterials = "ShapeEdMaterials"; ShapeEditor ShapeEditor = "ShapeEditor"; GuiBitmapButtonCtrl wireframeMode = ShapeEditorToolbar.FOT("wireframeMode"); GuiBitmapButtonCtrl showAdvanced = ShapeEditorToolbar.FOT("showAdvanced"); GuiIconButtonCtrl worldTransform = ShapeEdNodes.FOT("worldTransform"); GuiIconButtonCtrl objectTransform = ShapeEdNodes.FOT("objectTransform"); GuiCheckBoxCtrl highlightMaterial = ShapeEdMaterials.FOT("highlightMaterial"); GuiCanvas Canvas = "Canvas"; if (!this["isActivated"].AsBool()) { // Activate the Shape Editor EditorGui.setEditor(this, false); // Get editor settings (note the sun angle is not configured in the settings // dialog, so apply the settings here instead of in readSettings) this.readSettings(); ShapeEdShapeView["sunAngleX"] = EditorSettings.value("ShapeEditor/SunAngleX"); ShapeEdShapeView["sunAngleZ"] = EditorSettings.value("ShapeEditor/SunAngleZ"); EWorldEditor["forceLoadDAE"] = EditorSettings.value("forceLoadDAE"); bGlobal["$wasInWireFrameMode"] = bGlobal["$gfx::wireframe"]; wireframeMode.setStateOn(bGlobal["$gfx::wireframe"]); if (GlobalGizmoProfile.getFieldValue("alignment", -1) == "Object") { objectTransform.setStateOn(true); } else { worldTransform.setStateOn(true); } // Initialise and show the shape editor ShapeEdShapeTreeView.open(MissionGroup); ShapeEdShapeTreeView.buildVisibleTree(true); ShapeEdPreviewGui.setVisible(true); ShapeEdSelectWindow.setVisible(true); ShapeEdPropWindow.setVisible(true); ShapeEdAnimWindow.setVisible(true); ShapeEdAdvancedWindow.setVisible(showAdvanced.getValue().AsBool()); ShapeEditorToolbar.setVisible(true); EditorGui.bringToFront(ShapeEdPreviewGui); ((GuiBitmapButtonCtrl)ToolsPaletteArray.FOT("WorldEditorMove")).performClick(); this.map.push(); // Switch to the ShapeEditor UndoManager this["oldUndoMgr"] = Editor.getUndoManager(); Editor.setUndoManager(ShapeEdUndoManager); ShapeEdShapeView.setDisplayType(EditorGui["currentDisplayType"].AsInt()); this.initStatusBar(); // Customise menu bar this["oldCamFitCmd"] = this.replaceMenuCmd("Camera", "8", "ShapeEdShapeView.fitToShape();"); this["oldCamFitOrbitCmd"] = this.replaceMenuCmd("Camera", "9", "ShapeEdShapeView.fitToShape();"); base.onActivated(); } // Select the new shape if (ShapeEditor.shape.isObject() && (ShapeEditor.shape["baseShape"] == filename)) { // Shape is already selected => re-highlight the selected material if necessary ShapeEdMaterials.updateSelectedMaterial(highlightMaterial.getValue().AsBool()); } else if (filename != "") { ShapeEditor.selectShape(filename, ShapeEditor.isDirty()); // 'fitToShape' only works after the GUI has been rendered, so force a repaint first Canvas.repaint(0); ShapeEdShapeView.fitToShape(); } }
protected override void DoAlternateAction() { ShapeEditor.MenuOpenShapeCreator(); }
public override ActionResult DoAction() { ShapeEditor.CreateActiveShape(); return(new ActionResult(ActionResult.Status.Success, "Create Shape")); }