mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2024-11-20 10:47:22 +01:00
update point signals
This commit is contained in:
parent
cb8c52ac35
commit
d648b5d228
@ -1,6 +1,9 @@
|
||||
extends Chart
|
||||
class_name ScatterChart
|
||||
|
||||
signal point_entered(point)
|
||||
signal point_exited(point)
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@ -16,12 +19,14 @@ func plot(x: Array, y: Array) -> void:
|
||||
|
||||
func _draw_point(point: Point, function_index: int) -> void:
|
||||
var point_container: PointContainer = point_container_scene.instance()
|
||||
$"%Points".add_child(point_container)
|
||||
$Points.add_child(point_container)
|
||||
point_container.set_point(
|
||||
point,
|
||||
drawing_options.colors.functions[function_index],
|
||||
drawing_options.shapes[function_index]
|
||||
)
|
||||
point_container.connect("point_entered", self, "_on_point_entered")
|
||||
point_container.connect("point_exited", self, "_on_point_exited")
|
||||
|
||||
func _draw_points() -> void:
|
||||
var validation: int = _validate_sampled_axis(x_sampled, y_sampled)
|
||||
@ -40,5 +45,11 @@ func _draw_points() -> void:
|
||||
for i in y_sampled.values.size():
|
||||
var real_point_val: Pair = Pair.new(x[i], y[i])
|
||||
var sampled_point_pos: Vector2 = Vector2(x_sampled.values[i], y_sampled.values[i])
|
||||
var point: Point = Point.new(sampled_point_pos, real_point_val)
|
||||
var point: Point = Point.news(sampled_point_pos, real_point_val)
|
||||
_draw_point(point, i)
|
||||
|
||||
func _on_point_entered(point: Point) -> void:
|
||||
emit_signal("point_entered", point)
|
||||
|
||||
func _on_point_exited(point: Point) -> void:
|
||||
emit_signal("point_exited", point)
|
||||
|
@ -6,8 +6,14 @@
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="Points" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func _draw_points() -> void:
|
||||
pass
|
||||
|
||||
func _draw_background() -> void:
|
||||
draw_rect(node_box, Color.white, true, 1.0, true)
|
||||
draw_rect(node_box, Color.white, true, 1.0, false)
|
||||
|
||||
func _draw_grid() -> void:
|
||||
var validation: int = _validate_sampled_axis(x_sampled, y_sampled)
|
||||
|
@ -1,6 +1,9 @@
|
||||
extends Control
|
||||
class_name PointContainer
|
||||
|
||||
signal point_entered(point)
|
||||
signal point_exited(point)
|
||||
|
||||
enum PointShape {
|
||||
CIRCLE,
|
||||
TRIANGLE,
|
||||
@ -45,13 +48,15 @@ func _draw_point() -> void:
|
||||
PointShape.CIRCLE:
|
||||
draw_circle(point_rel_pos, self.radius, self.color)
|
||||
PointShape.SQUARE:
|
||||
draw_rect(Rect2(point_rel_pos * 0.5, point_rel_pos), self.color, true, 1.0, true)
|
||||
draw_rect(Rect2(point_rel_pos * 0.5, point_rel_pos), self.color, true, 1.0, false)
|
||||
|
||||
func _draw():
|
||||
# _draw_bounding_box()
|
||||
_draw_point()
|
||||
# _draw_label()
|
||||
|
||||
func _on_PointContainer_mouse_entered():
|
||||
emit_signal("point_entered", self.point)
|
||||
|
||||
func _on_Control_mouse_entered():
|
||||
print("hello %s " % point)
|
||||
func _on_PointContainer_mouse_exited():
|
||||
emit_signal("point_exited", self.point)
|
||||
|
@ -9,4 +9,5 @@ margin_right = 8.0
|
||||
margin_bottom = 8.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_Control_mouse_entered"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_PointContainer_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_PointContainer_mouse_exited"]
|
||||
|
Loading…
Reference in New Issue
Block a user