diff --git a/ActionPopupPanel.gd b/ActionPopupPanel.gd index f95f391..7413146 100644 --- a/ActionPopupPanel.gd +++ b/ActionPopupPanel.gd @@ -55,6 +55,9 @@ func _ready(): action_tree_root = action_tree.create_item() action_tree_root.set_text(0, "Actions") + # The sketch control does not need to be taking up space by default + $VBoxContainer/HBoxContainer/CanvasMarginContainer.hide() + """ Sets the Action control based on what is selected in the option button. @@ -294,23 +297,6 @@ func _on_VBoxContainer_resized(): hide() -""" -Allows an image to be loaded into the 2D preview. -""" -func _load_image(path, globalize): - var texture = ImageTexture.new() - var image = Image.new() - - # Static images will not be exported correctly unless the path is globalized - if globalize: - image.load(ProjectSettings.globalize_path(path)) - else: - image.load(path) - - texture.create_from_image(image) - $VBoxContainer/HBoxContainer/Preview.set_texture(texture) - - """ Called when the user clicks the 3D button and toggles it. """ @@ -368,8 +354,7 @@ func _on_SketchButton_toggled(_button_pressed): # Show preview controls $VBoxContainer/HBoxContainer/ActionContainer/ActionButtonContainer/AddButton.show() $VBoxContainer/HBoxContainer/ActionContainer/ActionTree.show() - $VBoxContainer/HBoxContainer/Preview.show() - _load_image("res://assets/samples/sample_2D_render.svg", true) + $VBoxContainer/HBoxContainer/CanvasMarginContainer.show() # Make sure the dialog is sized correctly _on_VBoxContainer_resized() @@ -440,7 +425,7 @@ any previously displayed sketch controls. func _hide_sketch_controls(): $VBoxContainer/HBoxContainer/ActionContainer/ActionButtonContainer/AddButton.hide() $VBoxContainer/HBoxContainer/ActionContainer/ActionTree.hide() - $VBoxContainer/HBoxContainer/Preview.hide() + $VBoxContainer/HBoxContainer/CanvasMarginContainer.hide() $VBoxContainer/HBoxContainer/ActionContainer/ActionButtonContainer/ItemSelectedContainer.hide() @@ -476,7 +461,7 @@ func _on_AddButton_button_down(): """ Collects all of the completed templates in the Action tree and -renders them as an SVG image. +renders them on the 2D canvas. """ func _render_action_tree(): # Start to build the preview string based on what is in the actions list @@ -494,22 +479,28 @@ func _render_action_tree(): script_text += ".consolidateWires()\nshow_object(result)" - # Protect against edge cases that will result in misleading errors - var rgx = RegEx.new() - rgx.compile("\\.pushPoints\\(\\[.*\\]\\)\\.consolidateWires") - var res = rgx.search(script_text) - if res: - return - # Export the file to the user data directory temporarily - var ret = cqgipy.export(script_text, "svg", OS.get_user_data_dir(), "width:400;height:400;marginLeft:50;marginTop:50;showAxes:False;projectionDir:(0,0,1);strokeWidth:0.5;strokeColor:(255,255,255);hiddenColor:(0,0,255);showHidden:False;") + var json_string = cqgipy.build(script_text) - if ret.begins_with("error~"): + if json_string.begins_with("error~"): # Let the user know there was an error - var err = ret.split("~")[1] + var err = json_string.split("~")[1] emit_signal("error", err) else: - _load_image(ret, false) + var component_json = JSON.parse(json_string).result + + for component in component_json["components"]: + # If we've found a larger dimension, save the safe scaling, which is the maximum dimension of any component + var max_dim = component["largestDim"] + $VBoxContainer/HBoxContainer/CanvasMarginContainer/Canvas2D.set_max_dim(max_dim) + + # Add the edge representations + for edge in component["cqEdges"]: + # Add the current line + $VBoxContainer/HBoxContainer/CanvasMarginContainer/Canvas2D.lines.append([Vector2(edge[0], edge[1]), Vector2(edge[3], edge[4])]) + + # Have the 2D canvas re-render the lines that are set for it + $VBoxContainer/HBoxContainer/CanvasMarginContainer/Canvas2D.update() """ @@ -521,9 +512,9 @@ func _on_ActionTree_item_activated(): var action_key = item_text.split(".")[1].split("(")[0] # Make sure the correct item is selected - Common.set_option_btn_by_text($VBoxContainer/ActionOptionButton, action_key) +# Common.set_option_btn_by_text($VBoxContainer/ActionOptionButton, action_key) - _set_action_control() +# _set_action_control() """ @@ -540,13 +531,33 @@ func _on_UpdateButton_button_down(): Common.update_tree_item(action_tree, orig_text, new_text) # Re-render everything in the action tree - _render_action_tree() + _update_preview() """ Called when an item is selected in the Action tree. """ func _on_ActionTree_item_selected(): + var selected = action_tree.get_selected() + + # Make sure there is an item to work with + if selected == null: + return + + # Figure out which control needs to be loaded from the operations list + var selected_text = selected.get_text(0) + var ctrl_text = "(" + selected_text.split(".")[1].split("(")[0] + ")" + + # Set the control in the operations drop down based on our partial text + Common.set_option_btn_by_partial_text($VBoxContainer/ActionOptionButton, ctrl_text) + + # Make sure the matching control is loaded + _on_ActionOptionButton_item_selected(0) + + # Repopulate the control with the previous settings + var cur_control = $VBoxContainer/HBoxContainer/ActionContainer/DynamicContainer.get_children()[0] + cur_control.set_values_from_string(selected_text) + # Unhide the item editing controls so the user can change the selected tree item $VBoxContainer/HBoxContainer/ActionContainer/ActionButtonContainer/ItemSelectedContainer.show() @@ -570,14 +581,14 @@ func _on_DeleteButton_button_down(): return # Remove the item from the history tree + action_tree_root.remove_child(selected) selected.free() - # Make sure there is something left to render - if action_tree_root.get_children() == null: - _load_image("res://assets/samples/sample_2D_render.svg", true) - else: - self._render_action_tree() + # Force an update of the tree + action_tree.update() + # Updated the 2D preview + _update_preview() """ Called when the move action item up button is pressed. @@ -607,6 +618,15 @@ func _on_MoveDownButton_button_down(): Common.move_tree_item_down(action_tree, selected) +""" +Called whenever the 2D preview needs to be updated. +""" +func _update_preview(): + # Reset and update the 2D preview + $VBoxContainer/HBoxContainer/CanvasMarginContainer/Canvas2D.reset() + $VBoxContainer/HBoxContainer/CanvasMarginContainer/Canvas2D.update() + self._render_action_tree() + """ Called when the control loaded in the dynamic contrainer is changed. diff --git a/Canvas2D.gd b/Canvas2D.gd new file mode 100644 index 0000000..67d41c9 --- /dev/null +++ b/Canvas2D.gd @@ -0,0 +1,45 @@ +extends Node2D + +var lines = [] # Array of line start-end points to use to draw the line segments +var line_width = 5 # Line width can be adjusted for the size of the object +var max_dim = 1 # Largest dimension of the object being rendered + + +""" +Called when the node is asked to redraw its contents. +""" +func _draw(): + var par_size = get_parent().rect_size + var par_loc = get_parent().rect_position + + # Draw all the lines that have been stored for the canvas + for line in lines: + var l0x = (line[0].x / (max_dim * 2)) * 550 + var l1x = (line[1].x / (max_dim * 2)) * 550 + var l0y = (line[0].y / (max_dim * 2)) * -550 + var l1y = (line[1].y / (max_dim * 2)) * -550 + + # Line start and end points + var v1 = Vector2(l0x + par_loc.x + par_size.x / 4.0, l0y + par_loc.y + par_size.y / 2.0) + var v2 = Vector2(l1x + par_loc.x + par_size.x / 4.0, l1y + par_loc.y + par_size.y / 2.0) + + # Draw the line + self.draw_line(v1, v2, Color(255, 255, 255), line_width) + + +""" +Used to set the maximum dimension for the sketch. +""" +func set_max_dim(dim): + # Only save this if it is bigger than what we had before + if dim > max_dim: + max_dim = dim + + +""" +Resets the 2D sketch canvas back to the default values +""" +func reset(): + self.lines = [] # Array of line start-end points to use to draw the line segments + self.line_width = 5 # Line width can be adjusted for the size of the object + self.max_dim = 1 # Largest dimension of the object being rendered diff --git a/ExportDXFDialog.gd b/ExportDXFDialog.gd index 5047cfe..738bb64 100644 --- a/ExportDXFDialog.gd +++ b/ExportDXFDialog.gd @@ -102,7 +102,7 @@ func _on_OkButton_button_down(): for i in range(0, steps): var file_name = pt.get_text().replace(".dxf", "_" + str(i) + ".dxf") _export_to_file(file_name, cur_height) - print(str(cur_height) + " : " + str(layer_height)) + cur_height += layer_height # Do a final export right at the end height diff --git a/GUI.tscn b/GUI.tscn index 80371d1..9a0a0bb 100644 --- a/GUI.tscn +++ b/GUI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=65 format=2] +[gd_scene load_steps=66 format=2] [ext_resource path="res://assets/icons/folder_button_flat_ready.svg" type="Texture" id=1] [ext_resource path="res://GUI.gd" type="Script" id=2] @@ -31,6 +31,7 @@ [ext_resource path="res://AddParameterDialog.gd" type="Script" id=29] [ext_resource path="res://controls/NumberEdit.gd" type="Script" id=30] [ext_resource path="res://ExportDXFDialog.gd" type="Script" id=31] +[ext_resource path="res://Canvas2D.gd" type="Script" id=32] [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.145098, 0.145098, 0.164706, 1 ) @@ -488,11 +489,11 @@ size_flags_horizontal = 5 size_flags_vertical = 5 [node name="ActionGroupsVBoxContainer" type="VBoxContainer" parent="ActionPopupPanel/VBoxContainer"] -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 43.0 [node name="HBoxContainer" type="HBoxContainer" parent="ActionPopupPanel/VBoxContainer/ActionGroupsVBoxContainer"] -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 43.0 [node name="WorkplaneButton" type="Button" parent="ActionPopupPanel/VBoxContainer/ActionGroupsVBoxContainer/HBoxContainer"] @@ -524,23 +525,23 @@ icon = ExtResource( 23 ) [node name="HSeparator3" type="HSeparator" parent="ActionPopupPanel/VBoxContainer"] margin_top = 47.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 51.0 [node name="ActionOptionButton" type="OptionButton" parent="ActionPopupPanel/VBoxContainer"] margin_top = 55.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 75.0 [node name="HSeparator" type="HSeparator" parent="ActionPopupPanel/VBoxContainer"] margin_top = 79.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 83.0 custom_styles/separator = SubResource( 28 ) [node name="HBoxContainer" type="HBoxContainer" parent="ActionPopupPanel/VBoxContainer"] margin_top = 87.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 319.0 [node name="ActionContainer" type="VBoxContainer" parent="ActionPopupPanel/VBoxContainer/HBoxContainer"] @@ -595,29 +596,30 @@ margin_bottom = 232.0 rect_min_size = Vector2( 100, 200 ) hide_root = true -[node name="Preview" type="TextureRect" parent="ActionPopupPanel/VBoxContainer/HBoxContainer"] -margin_left = 170.0 -margin_right = 170.0 +[node name="CanvasMarginContainer" type="MarginContainer" parent="ActionPopupPanel/VBoxContainer/HBoxContainer"] +margin_left = 174.0 +margin_right = 274.0 margin_bottom = 232.0 -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 600, 600 ) + +[node name="Canvas2D" type="Node2D" parent="ActionPopupPanel/VBoxContainer/HBoxContainer/CanvasMarginContainer"] +script = ExtResource( 32 ) [node name="HSeparator2" type="HSeparator" parent="ActionPopupPanel/VBoxContainer"] margin_top = 323.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 327.0 custom_styles/separator = SubResource( 29 ) [node name="OkButton" type="Button" parent="ActionPopupPanel/VBoxContainer"] margin_top = 331.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 351.0 text = "OK" [node name="CancelButton" type="Button" parent="ActionPopupPanel/VBoxContainer"] margin_top = 355.0 -margin_right = 208.0 +margin_right = 274.0 margin_bottom = 375.0 text = "Cancel" __meta__ = { diff --git a/Triggers.gd b/Triggers.gd index e4c3c0d..154278a 100644 --- a/Triggers.gd +++ b/Triggers.gd @@ -10,7 +10,7 @@ static func get_triggers(): var triggers = { "Workplane": { "trigger": "cq$", - "edit_trigger": "^\\.Workplane(.*).*", + "edit_trigger": "^\\.Workplane\\(.*\\).*", "action": { "name": "Workplane", "group": "WP", @@ -19,7 +19,7 @@ static func get_triggers(): }, "center": { "trigger": "cq$", - "edit_trigger": "^\\.center(.*).*", + "edit_trigger": "^\\.center\\(.*\\).*", "action": { "name": "Center (center)", "group": "WP", @@ -28,7 +28,7 @@ static func get_triggers(): }, "rotate": { "trigger": "cq$", - "edit_trigger": "^\\.rotate(.*).*", + "edit_trigger": "^\\.rotate\\(.*\\).*", "action": { "name": "Rotate (rotate)", "group": "WP", @@ -37,7 +37,7 @@ static func get_triggers(): }, "rotateAboutCenter": { "trigger": "cq$", - "edit_trigger": "^\\.rotateAboutCenter(.*).*", + "edit_trigger": "^\\.rotateAboutCenter\\(.*\\).*", "action": { "name": "Rotate About Center (rotateAboutCenter)", "group": "WP", @@ -46,7 +46,7 @@ static func get_triggers(): }, "translate": { "trigger": "cq$", - "edit_trigger": "^\\.translate(.*).*", + "edit_trigger": "^\\.translate\\(.*\\).*", "action": { "name": "Translate (translate)", "group": "WP", @@ -55,7 +55,7 @@ static func get_triggers(): }, "faces": { "trigger": "cq$", - "edit_trigger": "^\\.faces(.*).*", + "edit_trigger": "^\\.faces\\(.*\\).*", "action": { "name": "selectors", "group": "SELECTORS", @@ -64,7 +64,7 @@ static func get_triggers(): }, "edges": { "trigger": "cq$", - "edit_trigger": "^\\.edges(.*).*", + "edit_trigger": "^\\.edges\\(.*\\).*", "action": { "name": "selectors", "group": "SELECTORS", @@ -73,7 +73,7 @@ static func get_triggers(): }, "vertices": { "trigger": "cq$", - "edit_trigger": "^\\.vertices(.*).*", + "edit_trigger": "^\\.vertices\\(.*\\).*", "action": { "name": "selectors", "group": "SELECTORS", @@ -82,7 +82,7 @@ static func get_triggers(): }, "cutBlind": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.cutBlind(.*)$", + "edit_trigger": "^\\.cutBlind\\(.*\\)$", "action": { "name": "Blind Cut (cutBlind)", "group": "3D", @@ -100,7 +100,7 @@ static func get_triggers(): }, "chamfer": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.chamfer(.*)$", + "edit_trigger": "^\\.chamfer\\(.*\\)$", "action": { "name": "Chamfer (chamfer)", "group": "3D", @@ -109,7 +109,7 @@ static func get_triggers(): }, "cboreHole": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.cboreHole(.*)$", + "edit_trigger": "^\\.cboreHole\\(.*\\)$", "action": { "name": "Counter-Bore Hole (cboreHole)", "group": "3D", @@ -118,7 +118,7 @@ static func get_triggers(): }, "cskHole": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.cskHole(.*)$", + "edit_trigger": "^\\.cskHole\\(.*\\)$", "action": { "name": "Counter-Sink Hole (cskHole)", "group": "3D", @@ -127,7 +127,7 @@ static func get_triggers(): }, "extrude": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.extrude(.*)$", + "edit_trigger": "^\\.extrude\\(.*\\)$", "action": { "name": "Extrude (extrude)", "group": "3D", @@ -136,7 +136,7 @@ static func get_triggers(): }, "fillet": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.fillet(.*)$", + "edit_trigger": "^\\.fillet\\(.*\\)$", "action": { "name": "Fillet (fillet)", "group": "3D", @@ -145,7 +145,7 @@ static func get_triggers(): }, "hole": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.hole(.*)$", + "edit_trigger": "^\\.hole\\(.*\\)$", "action": { "name": "Hole (hole)", "group": "3D", @@ -154,7 +154,7 @@ static func get_triggers(): }, "revolve": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.revolve(.*)$", + "edit_trigger": "^\\.revolve\\(.*\\)$", "action": { "name": "Revolve (revolve)", "group": "3D", @@ -163,7 +163,7 @@ static func get_triggers(): }, "section": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.section(.*)$", + "edit_trigger": "^\\.section\\(.*\\)$", "action": { "name": "Section (section)", "group": "3D", @@ -172,7 +172,7 @@ static func get_triggers(): }, "shell": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.shell(.*)$", + "edit_trigger": "^\\.shell\\(.*\\)$", "action": { "name": "Shell (shell)", "group": "3D", @@ -181,7 +181,7 @@ static func get_triggers(): }, "sphere": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.sphere(.*)$", + "edit_trigger": "^\\.sphere\\(.*\\)$", "action": { "name": "Sphere (sphere)", "group": "3D", @@ -190,7 +190,7 @@ static func get_triggers(): }, "split": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.split(.*)$", + "edit_trigger": "^\\.split\\(.*\\)$", "action": { "name": "Split (split)", "group": "3D", @@ -199,7 +199,7 @@ static func get_triggers(): }, "text": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.text(.*)$", + "edit_trigger": "^\\.text\\(.*\\)$", "action": { "name": "Text (text)", "group": "3D", @@ -208,7 +208,7 @@ static func get_triggers(): }, "cutThruAll": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.cutThruAll(.*)$", + "edit_trigger": "^\\.cutThruAll\\(.*\\)$", "action": { "name": "Thru Cut (cutThruAll)", "group": "3D", @@ -217,7 +217,7 @@ static func get_triggers(): }, "twistExtrude": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.twistExtrude(.*)$", + "edit_trigger": "^\\.twistExtrude\\(.*\\)$", "action": { "name": "Twist Extrude (twistExtrude)", "group": "3D", @@ -226,7 +226,7 @@ static func get_triggers(): }, "wedge": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.wedge(.*)$", + "edit_trigger": "^\\.wedge\\(.*\\)$", "action": { "name": "Wedge (wedge)", "group": "3D", @@ -235,7 +235,7 @@ static func get_triggers(): }, "circle": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.circle(.*)$", + "edit_trigger": "^\\.circle\\(.*\\)$", "action": { "name": "Circle (circle)", "group": "2D", @@ -244,7 +244,7 @@ static func get_triggers(): }, "close": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.close(.*)$", + "edit_trigger": "^\\.close\\(.*\\)$", "action": { "name": "Close (close)", "group": "2D", @@ -253,7 +253,7 @@ static func get_triggers(): }, "ellipseArc": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.ellipseArc(.*)$", + "edit_trigger": "^\\.ellipseArc\\(.*\\)$", "action": { "name": "Ellipse Arc (ellipseArc)", "group": "2D", @@ -262,7 +262,7 @@ static func get_triggers(): }, "ellipse": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.ellipse(.*)$", + "edit_trigger": "^\\.ellipse\\(.*\\)$", "action": { "name": "Ellipse (ellipse)", "group": "2D", @@ -271,7 +271,7 @@ static func get_triggers(): }, "hLine": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.hLine(.*)$", + "edit_trigger": "^\\.hLine\\(.*\\)$", "action": { "name": "Horizontal Line (hLine)", "group": "2D", @@ -280,7 +280,7 @@ static func get_triggers(): }, "hLineTo": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.hLineTo(.*)$", + "edit_trigger": "^\\.hLineTo\\(.*\\)$", "action": { "name": "Horizontal Line To (hLineTo)", "group": "2D", @@ -289,7 +289,7 @@ static func get_triggers(): }, "line": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.line(.*)$", + "edit_trigger": "^\\.line\\(.*\\)$", "action": { "name": "Line (line)", "group": "2D", @@ -298,7 +298,7 @@ static func get_triggers(): }, "lineTo": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.lineTo(.*)$", + "edit_trigger": "^\\.lineTo\\(.*\\)$", "action": { "name": "Line To (lineTo)", "group": "2D", @@ -307,7 +307,7 @@ static func get_triggers(): }, "mirrorX": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.mirrorX(.*)$", + "edit_trigger": "^\\.mirrorX\\(.*\\)$", "action": { "name": "Mirror X (mirrorX)", "group": "2D", @@ -316,7 +316,7 @@ static func get_triggers(): }, "mirrorY": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.mirrorY(.*)$", + "edit_trigger": "^\\.mirrorY\\(.*\\)$", "action": { "name": "Mirror Y (mirrorY)", "group": "2D", @@ -325,7 +325,7 @@ static func get_triggers(): }, "move": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.move(.*)$", + "edit_trigger": "^\\.move\\(.*\\)$", "action": { "name": "Move (move)", "group": "2D", @@ -334,7 +334,7 @@ static func get_triggers(): }, "moveTo": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.moveTo(.*)$", + "edit_trigger": "^\\.moveTo\\(.*\\)$", "action": { "name": "Move To (moveTo)", "group": "2D", @@ -343,7 +343,7 @@ static func get_triggers(): }, "offset2D": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.offset2D(.*)$", + "edit_trigger": "^\\.offset2D\\(.*\\)$", "action": { "name": "Offset (offset2D)", "group": "2D", @@ -352,7 +352,7 @@ static func get_triggers(): }, "polarArray": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.polarArray(.*)$", + "edit_trigger": "^\\.polarArray\\(.*\\)$", "action": { "name": "Polar Array (polarArray)", "group": "2D", @@ -361,7 +361,7 @@ static func get_triggers(): }, "polarLine": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.polarLine(.*)$", + "edit_trigger": "^\\.polarLine\\(.*\\)$", "action": { "name": "Polar Line (polarLine)", "group": "2D", @@ -370,7 +370,7 @@ static func get_triggers(): }, "polarLineTo": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.polarLineTo(.*)$", + "edit_trigger": "^\\.polarLineTo\\(.*\\)$", "action": { "name": "Polar Line To (polarLineTo)", "group": "2D", @@ -379,7 +379,7 @@ static func get_triggers(): }, "polygon": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.polygon(.*)$", + "edit_trigger": "^\\.polygon\\(.*\\)$", "action": { "name": "Polygon (polygon)", "group": "2D", @@ -388,7 +388,7 @@ static func get_triggers(): }, "polyline": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.polyline(.*)$", + "edit_trigger": "^\\.polyline\\(.*\\)$", "action": { "name": "Polyline (polyline)", "group": "2D", @@ -397,7 +397,7 @@ static func get_triggers(): }, "pushPoints": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.pushPoints(.*)$", + "edit_trigger": "^\\.pushPoints\\(.*\\)$", "action": { "name": "Push Points (pushPoints)", "group": "2D", @@ -406,7 +406,7 @@ static func get_triggers(): }, "radiusArc": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.radiusArc(.*)$", + "edit_trigger": "^\\.radiusArc\\(.*\\)$", "action": { "name": "Radius Arc (radiusArc)", "group": "2D", @@ -415,7 +415,7 @@ static func get_triggers(): }, "rarray": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.rarray(.*)$", + "edit_trigger": "^\\.rarray\\(.*\\)$", "action": { "name": "Rectangular Array (rarray)", "group": "2D", @@ -424,7 +424,7 @@ static func get_triggers(): }, "rect": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.rect(.*)$", + "edit_trigger": "^\\.rect\\(.*\\)$", "action": { "name": "Rectangle (rect)", "group": "2D", @@ -433,7 +433,7 @@ static func get_triggers(): }, "sagittaArc": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.sagittaArc(.*)$", + "edit_trigger": "^\\.sagittaArc\\(.*\\)$", "action": { "name": "Sagitta Arc (sagittaArc)", "group": "2D", @@ -442,7 +442,7 @@ static func get_triggers(): }, "slot2D": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.slot2D(.*)$", + "edit_trigger": "^\\.slot2D\\(.*\\)$", "action": { "name": "Slot (slot2D)", "group": "2D", @@ -451,7 +451,7 @@ static func get_triggers(): }, "spline": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.spline(.*)$", + "edit_trigger": "^\\.spline\\(.*\\)$", "action": { "name": "Spline (spline)", "group": "2D", @@ -460,7 +460,7 @@ static func get_triggers(): }, "tangentArcPoint": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.tangentArcPoint(.*)$", + "edit_trigger": "^\\.tangentArcPoint\\(.*\\)$", "action": { "name": "Tangent Arc Point (tangentArcPoint)", "group": "2D", @@ -469,7 +469,7 @@ static func get_triggers(): }, "threePointArc": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.threePointArc(.*)$", + "edit_trigger": "^\\.threePointArc\\(.*\\)$", "action": { "name": "Three Point Arc (threePointArc)", "group": "2D", @@ -478,7 +478,7 @@ static func get_triggers(): }, "vLine": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.vLine(.*)$", + "edit_trigger": "^\\.vLine\\(.*\\)$", "action": { "name": "Vertical Line (vLine)", "group": "2D", @@ -487,7 +487,7 @@ static func get_triggers(): }, "vLineTo": { "trigger": "\\..*(.*)$", - "edit_trigger": "^\\.vLineTo(.*)$", + "edit_trigger": "^\\.vLineTo\\(.*\\)$", "action": { "name": "Vertical Line To (vLineTo)", "group": "2D", diff --git a/controls/CloseControl.gd b/controls/CloseControl.gd index c0c8c1d..5c6db78 100644 --- a/controls/CloseControl.gd +++ b/controls/CloseControl.gd @@ -34,3 +34,10 @@ Loads values into the control's sub-controls based on a code string. """ func set_values_from_string(_text_line): pass + + +""" +Checks whether or not all the values in the controls are valid. +""" +func is_valid(): + return true diff --git a/controls/Common.gd b/controls/Common.gd index faa04db..1c6d6d2 100644 --- a/controls/Common.gd +++ b/controls/Common.gd @@ -3,7 +3,7 @@ extends Reference class_name Common """ -If the option button has matching text in an item, sets that to be the +If the option button has matching text in an item, set that to be the selected item. """ static func set_option_btn_by_text(opt_btn, name): @@ -15,6 +15,18 @@ static func set_option_btn_by_text(opt_btn, name): opt_btn.select(i) +""" +If the option button has partially matching text in an item, set that to be the +selected item. +""" +static func set_option_btn_by_partial_text(opt_btn, name): + for i in range(0, opt_btn.get_item_count()): + var txt = opt_btn.get_item_text(i) + + # If the item matches, set it to be the selected id + if txt.find(name) > 0: + opt_btn.select(i) + """ Loads an option button up with an array of items. """ diff --git a/controls/HLineControl.gd b/controls/HLineControl.gd index df5fdc1..e43ea00 100644 --- a/controls/HLineControl.gd +++ b/controls/HLineControl.gd @@ -23,6 +23,7 @@ func _ready(): dist_lbl.set_text("Distance: ") dist_group.add_child(dist_lbl) dist_ctrl = NumberEdit.new() + dist_ctrl.CanBeNegative = true dist_ctrl.set_text("1.0") dist_ctrl.hint_tooltip = tr("HLINE_DIST_CTRL_HINT_TOOLTIP") dist_group.add_child(dist_ctrl) diff --git a/controls/HLineToControl.gd b/controls/HLineToControl.gd index 824481c..563e9c6 100644 --- a/controls/HLineToControl.gd +++ b/controls/HLineToControl.gd @@ -24,6 +24,7 @@ func _ready(): x_coord_lbl.set_text("X Coordinate: ") x_coord_group.add_child(x_coord_lbl) x_coord_ctrl = NumberEdit.new() + x_coord_ctrl.CanBeNegative = true x_coord_ctrl.set_text("1.0") x_coord_ctrl.hint_tooltip = tr("HLINETO_X_COORD_CTRL_HINT_TOOLTIP") x_coord_group.add_child(x_coord_ctrl) diff --git a/controls/MoveControl.gd b/controls/MoveControl.gd index 2ce1491..f53ea26 100644 --- a/controls/MoveControl.gd +++ b/controls/MoveControl.gd @@ -20,6 +20,7 @@ func _ready(): x_dist_lbl.set_text("X Distance: ") x_dims_group.add_child(x_dist_lbl) x_dist_ctrl = NumberEdit.new() + x_dist_ctrl.CanBeNegative = true x_dist_ctrl.set_text("1.0") x_dist_ctrl.hint_tooltip = tr("MOVE_X_DIST_CTRL_HINT_TOOLTIP") x_dims_group.add_child(x_dist_ctrl) @@ -31,6 +32,7 @@ func _ready(): y_dist_lbl.set_text("Y Distance: ") y_dims_group.add_child(y_dist_lbl) y_dist_ctrl = NumberEdit.new() + y_dist_ctrl.CanBeNegative = true y_dist_ctrl.set_text("1.0") y_dist_ctrl.hint_tooltip = tr("MOVE_Y_DIST_CTRL_HINT_TOOLTIP") y_dims_group.add_child(y_dist_ctrl) diff --git a/controls/MoveToControl.gd b/controls/MoveToControl.gd index 5f71068..eacc5bc 100644 --- a/controls/MoveToControl.gd +++ b/controls/MoveToControl.gd @@ -20,6 +20,7 @@ func _ready(): x_dist_lbl.set_text("X Distance: ") x_dims_group.add_child(x_dist_lbl) x_dist_ctrl = NumberEdit.new() + x_dist_ctrl.CanBeNegative = true x_dist_ctrl.set_text("1.0") x_dist_ctrl.hint_tooltip = tr("MOVETO_X_DIST_CTRL_HINT_TOOLTIP") x_dims_group.add_child(x_dist_ctrl) @@ -31,6 +32,7 @@ func _ready(): y_dist_lbl.set_text("Y Distance: ") y_dims_group.add_child(y_dist_lbl) y_dist_ctrl = NumberEdit.new() + y_dist_ctrl.CanBeNegative = true y_dist_ctrl.set_text("1.0") y_dist_ctrl.hint_tooltip = tr("MOVETO_Y_DIST_CTRL_HINT_TOOLTIP") y_dims_group.add_child(y_dist_ctrl) diff --git a/controls/SketchControl.gd b/controls/SketchControl.gd index c3cbef8..b5a67de 100644 --- a/controls/SketchControl.gd +++ b/controls/SketchControl.gd @@ -99,7 +99,6 @@ func _process(delta): if executing: var file = File.new() if file.file_exists(OS.get_user_data_dir() + "/temp.svg"): - print("HERE") load_image(OS.get_user_data_dir() + "/temp.svg") @@ -224,7 +223,6 @@ Clears the control to get it ready for the next use. func _clear_controls(): if op_list != null: for i in range(0, op_list.get_item_count()): - print(op_list.get_item_text(i)) op_list.remove_item(i) diff --git a/controls/ThreePointArcControl.gd b/controls/ThreePointArcControl.gd index 04ab153..fdf7fca 100644 --- a/controls/ThreePointArcControl.gd +++ b/controls/ThreePointArcControl.gd @@ -6,8 +6,8 @@ var prev_template = null var template = ".threePointArc(point1=({point_1_x},{point_1_y}),point2=({point_2_x},{point_2_y}),forConstruction={for_construction})" -const point1_edit_rgx = "(?<=point1\\=)(.*?)(?=,point2)" -const point2_edit_rgx = "(?<=point2\\=)(.*?)(?=\\,forConstruction)" +const point1_edit_rgx = "(?<=point1\\=\\()(.*?)(?=\\),point2)" +const point2_edit_rgx = "(?<=point2\\=\\()(.*?)(?=\\),forConstruction)" const const_edit_rgx = "(?<=forConstruction\\=)(.*?)(?=\\))" var point_1_x_ctrl = null diff --git a/controls/VLineControl.gd b/controls/VLineControl.gd index d725a75..c0c6164 100644 --- a/controls/VLineControl.gd +++ b/controls/VLineControl.gd @@ -23,6 +23,7 @@ func _ready(): dist_lbl.set_text("Distance: ") dist_group.add_child(dist_lbl) dist_ctrl = NumberEdit.new() + dist_ctrl.CanBeNegative = true dist_ctrl.set_text("1.0") dist_ctrl.hint_tooltip = tr("VLINE_DIST_CTRL_HINT_TOOLTIP") dist_group.add_child(dist_ctrl) diff --git a/controls/VLineToControl.gd b/controls/VLineToControl.gd index 24f37a7..efa2ac6 100644 --- a/controls/VLineToControl.gd +++ b/controls/VLineToControl.gd @@ -23,6 +23,7 @@ func _ready(): y_coord_lbl.set_text("Y Coordinate: ") y_coord_group.add_child(y_coord_lbl) y_coord_ctrl = NumberEdit.new() + y_coord_ctrl.CanBeNegative = true y_coord_ctrl.set_text("1.0") y_coord_ctrl.hint_tooltip = tr("VLINE_TO_Y_COORD_CTRL_HINT_TOOLTIP") y_coord_group.add_child(y_coord_ctrl)