@@ -11,7 +11,7 @@ use editor::consts::FILE_SAVE_SUFFIX;
1111use editor:: messages:: input_mapper:: utility_types:: input_keyboard:: ModifierKeys ;
1212use editor:: messages:: input_mapper:: utility_types:: input_mouse:: { EditorMouseState , ScrollDelta , ViewportBounds } ;
1313use editor:: messages:: portfolio:: document:: utility_types:: document_metadata:: LayerNodeIdentifier ;
14- use editor:: messages:: portfolio:: document:: utility_types:: network_interface:: { ImportOrExport , NodeTemplate } ;
14+ use editor:: messages:: portfolio:: document:: utility_types:: network_interface:: ImportOrExport ;
1515use editor:: messages:: portfolio:: utility_types:: Platform ;
1616use editor:: messages:: prelude:: * ;
1717use editor:: messages:: tool:: tool_messages:: tool_prelude:: WidgetId ;
@@ -734,227 +734,6 @@ impl EditorHandle {
734734 } ;
735735 self . dispatch ( message) ;
736736 }
737-
738- // #[wasm_bindgen(js_name = injectImaginatePollServerStatus)]
739- // pub fn inject_imaginate_poll_server_status(&self) {
740- // self.dispatch(PortfolioMessage::ImaginatePollServerStatus);
741- // }
742-
743- // TODO: Eventually remove this document upgrade code
744- #[ wasm_bindgen( js_name = triggerUpgradeDocumentToVectorManipulationFormat) ]
745- pub async fn upgrade_document_to_vector_manipulation_format (
746- & self ,
747- document_id : u64 ,
748- document_name : String ,
749- document_is_auto_saved : bool ,
750- document_is_saved : bool ,
751- document_serialized_content : String ,
752- ) {
753- use editor:: messages:: portfolio:: document:: graph_operation:: transform_utils:: * ;
754- use editor:: messages:: portfolio:: document:: graph_operation:: utility_types:: * ;
755- use editor:: messages:: portfolio:: document:: node_graph:: document_node_definitions:: resolve_document_node_type;
756- use editor:: node_graph_executor:: NodeRuntime ;
757- use editor:: node_graph_executor:: replace_node_runtime;
758- use graph_craft:: document:: DocumentNodeImplementation ;
759- use graph_craft:: document:: NodeInput ;
760- use graph_craft:: document:: value:: TaggedValue ;
761- use graphene_std:: vector:: * ;
762-
763- let ( _, request_receiver) = std:: sync:: mpsc:: channel ( ) ;
764- let ( response_sender, _) = std:: sync:: mpsc:: channel ( ) ;
765- let old_runtime = replace_node_runtime ( NodeRuntime :: new ( request_receiver, response_sender) ) . await ;
766-
767- let mut editor = Editor :: new ( ) ;
768- let document_id = DocumentId ( document_id) ;
769- editor. handle_message ( PortfolioMessage :: OpenDocumentFileWithId {
770- document_id,
771- document_name : document_name. clone ( ) ,
772- document_is_auto_saved,
773- document_is_saved,
774- document_serialized_content : document_serialized_content. clone ( ) ,
775- to_front : false ,
776- } ) ;
777-
778- let Some ( document) = editor. dispatcher . message_handlers . portfolio_message_handler . active_document_mut ( ) else {
779- warn ! ( "Document wasn't loaded" ) ;
780- return ;
781- } ;
782- for node in document
783- . network_interface
784- . document_network_metadata ( )
785- . persistent_metadata
786- . node_metadata
787- . iter ( )
788- . filter ( |( _, d) | d. persistent_metadata . reference . as_ref ( ) . is_some_and ( |reference| reference == "Artboard" ) )
789- . map ( |( id, _) | * id)
790- . collect :: < Vec < _ > > ( )
791- {
792- let Some ( document_node) = document. network_interface . document_network ( ) . nodes . get ( & node) else {
793- log:: error!( "Could not get document node in document network" ) ;
794- return ;
795- } ;
796- if let Some ( network) = document_node. implementation . get_network ( ) {
797- let mut nodes_to_upgrade = Vec :: new ( ) ;
798- for ( node_id, _) in network. nodes . iter ( ) . collect :: < Vec < _ > > ( ) {
799- if document
800- . network_interface
801- . reference ( node_id, & [ ] )
802- . is_some_and ( |reference| * reference == Some ( "To Artboard" . to_string ( ) ) )
803- && document
804- . network_interface
805- . document_network ( )
806- . nodes
807- . get ( node_id)
808- . is_some_and ( |document_node| document_node. inputs . len ( ) != 6 )
809- {
810- nodes_to_upgrade. push ( * node_id) ;
811- }
812- }
813- for node_id in nodes_to_upgrade {
814- document
815- . network_interface
816- . replace_implementation ( & node_id, & [ ] , DocumentNodeImplementation :: proto ( "graphene_core::ToArtboardNode" ) ) ;
817- document. network_interface . add_import ( TaggedValue :: IVec2 ( glam:: IVec2 :: default ( ) ) , false , 2 , "" , "" , & [ node_id] ) ;
818- }
819- }
820- }
821-
822- let portfolio = & mut editor. dispatcher . message_handlers . portfolio_message_handler ;
823- portfolio
824- . executor
825- . submit_node_graph_evaluation (
826- portfolio. documents . get_mut ( & portfolio. active_document_id ( ) . unwrap ( ) ) . unwrap ( ) ,
827- glam:: UVec2 :: ONE ,
828- Default :: default ( ) ,
829- None ,
830- true ,
831- )
832- . unwrap ( ) ;
833- editor:: node_graph_executor:: run_node_graph ( ) . await ;
834-
835- let mut messages = VecDeque :: new ( ) ;
836- if let Err ( err) = editor. poll_node_graph_evaluation ( & mut messages) {
837- log:: warn!(
838- "While attempting to upgrade the old document format, the graph evaluation failed which is necessary for the upgrade process:\n {:#?}" ,
839- err
840- ) ;
841-
842- replace_node_runtime ( old_runtime. unwrap ( ) ) . await ;
843-
844- let document_name = document_name. clone ( ) + "__DO_NOT_UPGRADE__" ;
845- self . dispatch ( PortfolioMessage :: OpenDocumentFileWithId {
846- document_id,
847- document_name,
848- document_is_auto_saved,
849- document_is_saved,
850- document_serialized_content,
851- to_front : false ,
852- } ) ;
853- return ;
854- }
855-
856- let mut updated_nodes = HashSet :: new ( ) ;
857- let document = editor. dispatcher . message_handlers . portfolio_message_handler . active_document_mut ( ) . unwrap ( ) ;
858- document. network_interface . load_structure ( ) ;
859- for node in document
860- . network_interface
861- . document_network_metadata ( )
862- . persistent_metadata
863- . node_metadata
864- . iter ( )
865- . filter ( |( _, d) | d. persistent_metadata . reference . as_ref ( ) . is_some_and ( |reference| reference == "Merge" ) )
866- . map ( |( id, _) | * id)
867- . collect :: < Vec < _ > > ( )
868- {
869- let layer = LayerNodeIdentifier :: new ( node, & document. network_interface , & [ ] ) ;
870- if layer. has_children ( document. metadata ( ) ) {
871- continue ;
872- }
873-
874- let bounds = LayerBounds :: new ( document. metadata ( ) , layer) ;
875-
876- let mut responses = VecDeque :: new ( ) ;
877- let mut shape = None ;
878-
879- if let Some ( mut modify_inputs) = ModifyInputsContext :: new_with_layer ( layer, & mut document. network_interface , & mut responses) {
880- let Some ( transform_node_id) = modify_inputs. existing_node_id ( "Transform" , true ) else {
881- return ;
882- } ;
883- if !updated_nodes. insert ( transform_node_id) {
884- return ;
885- }
886- let Some ( inputs) = modify_inputs. network_interface . document_network ( ) . nodes . get ( & transform_node_id) . map ( |node| & node. inputs ) else {
887- log:: error!( "Could not get transform node in document network" ) ;
888- return ;
889- } ;
890- let transform = get_current_transform ( inputs) ;
891- let upstream_transform = modify_inputs. network_interface . document_metadata ( ) . upstream_transform ( transform_node_id) ;
892- let pivot_transform = glam:: DAffine2 :: from_translation ( upstream_transform. transform_point2 ( bounds. local_pivot ( get_current_normalized_pivot ( inputs) ) ) ) ;
893-
894- update_transform ( & mut document. network_interface , & transform_node_id, pivot_transform * transform * pivot_transform. inverse ( ) ) ;
895- }
896- if let Some ( mut modify_inputs) = ModifyInputsContext :: new_with_layer ( layer, & mut document. network_interface , & mut responses) {
897- let Some ( shape_node_id) = modify_inputs. existing_node_id ( "Shape" , true ) else {
898- return ;
899- } ;
900- if !updated_nodes. insert ( shape_node_id) {
901- return ;
902- }
903- let Some ( shape_node) = modify_inputs. network_interface . document_network ( ) . nodes . get ( & shape_node_id) else {
904- log:: error!( "Could not get shape node in document network" ) ;
905- return ;
906- } ;
907- let path_data = match & shape_node. inputs [ 0 ] . as_value ( ) {
908- Some ( TaggedValue :: Subpaths ( translation) ) => translation,
909- _ => & Vec :: new ( ) ,
910- } ;
911-
912- let colinear_manipulators = match & shape_node. inputs [ 1 ] . as_value ( ) {
913- Some ( TaggedValue :: PointIds ( translation) ) => translation,
914- _ => & Vec :: new ( ) ,
915- } ;
916-
917- let mut vector_data = VectorData :: from_subpaths ( path_data, false ) ;
918- vector_data. colinear_manipulators = colinear_manipulators
919- . iter ( )
920- . filter_map ( |& point| ManipulatorPointId :: Anchor ( point) . get_handle_pair ( & vector_data) )
921- . collect ( ) ;
922-
923- shape = Some ( ( shape_node_id, VectorModification :: create_from_vector ( & vector_data) ) ) ;
924- }
925-
926- if let Some ( ( node_id, modification) ) = shape {
927- let node_type = resolve_document_node_type ( "Path" ) . unwrap ( ) ;
928- let document_node = node_type
929- . node_template_input_override ( [ None , Some ( NodeInput :: value ( TaggedValue :: VectorModification ( Box :: new ( modification) ) , false ) ) ] )
930- . document_node ;
931-
932- let node_metadata = document. network_interface . node_metadata ( & node_id, & [ ] ) . cloned ( ) . unwrap_or_default ( ) ;
933-
934- document. network_interface . insert_node (
935- node_id,
936- NodeTemplate {
937- document_node,
938- persistent_node_metadata : node_metadata. persistent_metadata ,
939- } ,
940- & [ ] ,
941- ) ;
942- }
943- }
944-
945- let document_serialized_content = editor. dispatcher . message_handlers . portfolio_message_handler . active_document_mut ( ) . unwrap ( ) . serialize_document ( ) ;
946-
947- replace_node_runtime ( old_runtime. unwrap ( ) ) . await ;
948-
949- self . dispatch ( PortfolioMessage :: OpenDocumentFileWithId {
950- document_id,
951- document_name,
952- document_is_auto_saved,
953- document_is_saved,
954- document_serialized_content,
955- to_front : false ,
956- } ) ;
957- }
958737}
959738
960739// ============================================================================
0 commit comments