-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Parametric curve plot #4313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
devviktoria
wants to merge
8
commits into
GraphiteEditor:master
Choose a base branch
from
devviktoria:function-plot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Parametric curve plot #4313
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6e977fd
Add Plot Function node
devviktoria a728217
Code refactor
devviktoria 45f0ed5
Add Function Plot to the Shape menu
devviktoria 8de2a96
Corrections
devviktoria 0d20794
Add more functions to DEFAULT_FUNCTIONS
devviktoria e057fb1
Update node documentation
devviktoria 5fca961
Add adaptive sampling, discontinuity detection
devviktoria 27e4632
Add simple axes plot
devviktoria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
editor/src/messages/tool/common_functionality/shapes/function_plot.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,63 @@ | ||||||||||||
| use super::shape_utility::ShapeToolModifierKey; | ||||||||||||
| use super::*; | ||||||||||||
| use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn; | ||||||||||||
| use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_proto_node_type; | ||||||||||||
| use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier; | ||||||||||||
| use crate::messages::portfolio::document::utility_types::network_interface::{InputConnector, NodeTemplate}; | ||||||||||||
| use crate::messages::tool::common_functionality::graph_modification_utils; | ||||||||||||
| use crate::messages::tool::tool_messages::tool_prelude::*; | ||||||||||||
| use glam::DAffine2; | ||||||||||||
| use graph_craft::document::NodeInput; | ||||||||||||
| use graph_craft::document::value::TaggedValue; | ||||||||||||
| use std::collections::VecDeque; | ||||||||||||
|
|
||||||||||||
| #[derive(Default)] | ||||||||||||
| pub struct FunctionPlot; | ||||||||||||
|
|
||||||||||||
| impl FunctionPlot { | ||||||||||||
| pub fn create_node() -> NodeTemplate { | ||||||||||||
| let node_type = resolve_proto_node_type(graphene_std::vector::plot_nodes::function_plot::IDENTIFIER).expect("Function Plot node can't be found"); | ||||||||||||
| node_type.node_template_input_override([None, Some(NodeInput::value(TaggedValue::F64(0.5), false)), Some(NodeInput::value(TaggedValue::F64(0.5), false))]) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub fn update_shape( | ||||||||||||
| document: &DocumentMessageHandler, | ||||||||||||
| ipp: &InputPreprocessorMessageHandler, | ||||||||||||
| viewport: &ViewportMessageHandler, | ||||||||||||
| layer: LayerNodeIdentifier, | ||||||||||||
| shape_tool_data: &mut ShapeToolData, | ||||||||||||
| modifier: ShapeToolModifierKey, | ||||||||||||
| responses: &mut VecDeque<Message>, | ||||||||||||
| ) { | ||||||||||||
| let [center, lock_ratio, _] = modifier; | ||||||||||||
|
|
||||||||||||
| if let Some([start, end]) = shape_tool_data.data.calculate_points(document, ipp, viewport, center, lock_ratio) { | ||||||||||||
| let Some(node_id) = graph_modification_utils::get_function_plot_id(layer, &document.network_interface) else { | ||||||||||||
| return; | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
| // We want viewport zoom independent size and 1 scalefactor | ||||||||||||
| let document_to_viewport = document | ||||||||||||
| .navigation_handler | ||||||||||||
| .calculate_offset_transform(viewport.center_in_viewport_space().into(), &document.document_ptz); | ||||||||||||
|
|
||||||||||||
| let start = document_to_viewport.inverse().transform_point2(start); | ||||||||||||
| let end = document_to_viewport.inverse().transform_point2(end); | ||||||||||||
|
Comment on lines
+44
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can avoid computing the inverse of
Suggested change
|
||||||||||||
|
|
||||||||||||
| responses.add(NodeGraphMessage::SetInput { | ||||||||||||
| input_connector: InputConnector::node(node_id, 1), | ||||||||||||
| input: NodeInput::value(TaggedValue::F64((start.x - end.x).abs()), false), | ||||||||||||
| }); | ||||||||||||
| responses.add(NodeGraphMessage::SetInput { | ||||||||||||
| input_connector: InputConnector::node(node_id, 2), | ||||||||||||
| input: NodeInput::value(TaggedValue::F64((start.y - end.y).abs()), false), | ||||||||||||
| }); | ||||||||||||
| responses.add(GraphOperationMessage::TransformSet { | ||||||||||||
| layer, | ||||||||||||
| transform: DAffine2::from_translation(start.midpoint(end)), | ||||||||||||
| transform_in: TransformIn::Local, | ||||||||||||
| skip_rerender: false, | ||||||||||||
| }); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the fully qualified path
graphene_std::vector::plot_nodes::function_plot::IDENTIFIERis unnecessary and inconsistent with other shapes. Sinceplot_nodesis re-exported at the root ofvector, we can usegraphene_std::vector::function_plot::IDENTIFIERdirectly.