|
hipp
1.0
|
00001 /* 00002 Copyright 2011 Certec, Lund University, Sweden 00003 00004 This file is part of HIPP. 00005 00006 HIPP is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 HIPP is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with HIPP. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #ifndef __H3DViewerTreeViewDialog__ 00022 #define __H3DViewerTreeViewDialog__ 00023 00024 #include <H3D/Node.h> 00025 #include <map> 00026 #include <list> 00032 #include "H3DViewer.h" 00033 00034 #define DEFAULT_VALUES 00035 00036 using namespace H3D; 00038 class H3DViewerTreeViewDialog : public TreeViewDialog 00039 { 00040 public: 00042 H3DViewerTreeViewDialog( wxWindow* parent ); 00043 00046 virtual void OnClose( wxCloseEvent& event ); 00047 00048 // Callback for when a node is selected in the tree view. 00049 // It updates the node field view. 00050 virtual void OnNodeSelected( wxTreeEvent& event ); 00051 00052 // Callback for when a cell in the node field view is changed. 00053 virtual void OnCellEdit( wxGridEvent& event ); 00054 00056 virtual void OnTreeRightClick( wxTreeEvent& event ); 00057 00059 virtual void OnTreeViewCollapseAll( wxCommandEvent& event ); 00060 00062 virtual void OnTreeViewExpandAll( wxCommandEvent& event ); 00063 00065 virtual void OnTreeViewCollapseChildren( wxCommandEvent& event ); 00066 00068 virtual void OnTreeViewNodeWatch( wxCommandEvent& event ); 00069 00071 virtual void OnTreeViewSaveX3D( wxCommandEvent& event ); 00072 00074 virtual void OnTreeViewSaveSTL( wxCommandEvent& event ); 00075 00076 // Callback for idle. Does dynamic updates of field values and tree view. 00077 void OnIdle( wxIdleEvent& event ); 00078 00079 // Update the node field view with the given node. 00080 void displayFieldsFromNode( Node * ); 00081 00082 // Update the tree view of the entire scene. The expand_new argument 00083 // determines if hew nodes should be added with the tree expanded 00084 // or not. 00085 void showEntireSceneAsTree( bool expand_new = true ); 00086 00087 // Clear all data from the tree view. Releases all references 00088 // to any node in the dialog. 00089 void clearTreeView(); 00090 00091 protected: 00092 // Update the specified row in the field values grid with 00093 // values from the node and filed into given. 00094 void updateRowFromFieldDB( int row, 00095 Node *n, 00096 FieldDBElement *db, 00097 bool new_node ); 00098 00099 // Expand the item and all children below it. 00100 void expandTree( const wxTreeItemId &id ); 00101 00102 // Collapse the item and all children below it. 00103 void collapseTree( const wxTreeItemId &id ); 00104 00105 // Delete a part of a wx tree, both from the wx widget and from 00106 // the map of nodes. 00107 void deleteTree( const wxTreeItemId &id ); 00108 00109 // true if this dialog was shown last loop. 00110 bool shown_last_loop; 00111 00112 // Add a view of the node as a child to the tree. expand determines 00113 // if the tree should be expanded from the start or node. 00114 void addNodeToTree( wxTreeItemId tree_id, H3D::Node *n, bool expand = true ); 00115 00116 // Update a current tree. The list of nodes is a list of all the nodes 00117 // that are supposed to be children to tree_id. All nodes that are already 00118 // there are updated, new nodes are added and parts that are nod in the list 00119 // are deleted. 00120 void updateNodeTree( wxTreeItemId tree_id, 00121 list< H3D::Node *> nodes, 00122 bool expand_new = true ); 00123 00124 // The time of the last update to the tree view. 00125 TimeStamp last_tree_update; 00126 00127 typedef std::map< wxTreeItemIdValue, H3D::AutoRef< H3D::Node > > TreeIdMap; 00128 // A map from tree id to node to be able to lookup what Node a part of the 00129 // tree view refers to. 00130 TreeIdMap node_map; 00131 00132 // The id of the tree node that holds bindable node info. 00133 wxTreeItemId bindable_tree_id; 00134 00135 // The time of the last update of the selected node field values. 00136 TimeStamp last_fields_update; 00137 #ifdef DEFAULT_VALUES 00138 auto_ptr< Node > default_values_node; 00139 #endif 00140 // The node which values are currently being displayed. 00141 AutoRef< Node > displayed_node; 00142 00143 // The node that was last selected. This will be used to 00144 // set the displayed node in isIdle. Cannot use only displayed_node 00145 // since we have to divide it into two parts, selecting and displaying 00146 // in order to work around a crash that happens in a choice editor. 00147 AutoRef< Node > selected_node; 00148 }; 00149 00150 #endif // __H3DViewerTreeViewDialog__
1.7.5.1