Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
GroupEditor.java
....@@ -84,6 +84,10 @@
8484
8585 void CloneSelection(boolean supports)
8686 {
87
+ if (Globals.REPLACEONMAKE)
88
+ Save();
89
+ boolean keep = Globals.REPLACEONMAKE;
90
+ Globals.REPLACEONMAKE = false;
8791 // Object3D keep = GrafreeD.clipboard;
8892 //Object3D obj;
8993 for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
....@@ -94,6 +98,7 @@
9498
9599 makeSomething(clone, i==group.selection.size()-1);
96100 }
101
+ Globals.REPLACEONMAKE = keep;
97102 }
98103
99104 void CloneClipboard(boolean supports)
....@@ -220,7 +225,7 @@
220225 // toggleSwitchItem.addItemListener(this);
221226 // toggleSwitchItem.setState(CameraPane.SWITCH);
222227
223
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
228
+ cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Show Handles"));
224229 toggleHandleItem.addItemListener(this);
225230 toggleHandleItem.setState(CameraPane.HANDLES);
226231
....@@ -380,13 +385,14 @@
380385 shadowYItem.addActionListener(this);
381386 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
382387 shadowZItem.addActionListener(this);
388
+ attributeItem = menu.add(new MenuItem("Attribute"));
389
+ attributeItem.addActionListener(this);
390
+
383391 if (Globals.ADVANCED)
384392 {
385393 menu.add("-");
386394 linkerItem = menu.add(new MenuItem("Linker"));
387395 linkerItem.addActionListener(this);
388
- attributeItem = menu.add(new MenuItem("Attribute"));
389
- attributeItem.addActionListener(this);
390396 templateItem = menu.add(new MenuItem("Template"));
391397 templateItem.addActionListener(this);
392398 pointflowItem = menu.add(new MenuItem("Point Flow"));
....@@ -538,6 +544,7 @@
538544 buildToolsMenu(menu);
539545 }
540546
547
+
541548 void SetupUI2(ObjEditor oe)
542549 {
543550 // June 2019
....@@ -582,7 +589,7 @@
582589 */
583590 cGridBag copyOptionsPanel = new cGridBag();
584591
585
- copyOptionsPanel.preferredHeight = 2;
592
+ copyOptionsPanel.preferredHeight = 1;
586593
587594 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
588595
....@@ -590,50 +597,66 @@
590597 //minButton.setToolTipText("Minimize window");
591598 //minButton.addActionListener(this);
592599
593
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
594
- maxButton.setToolTipText("Maximize window");
595
- maxButton.addActionListener(this);
600
+ if (Globals.ADVANCED)
601
+ {
602
+ oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
603
+ maxButton.setToolTipText("Maximize window");
604
+ maxButton.addActionListener(this);
605
+ }
596606
597607 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
598608 fullButton.setToolTipText("Full-screen window");
599609 fullButton.addActionListener(this);
600610
611
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
612
+ screenfitButton.setToolTipText("Screen fit");
613
+ screenfitButton.addActionListener(this);
614
+
601615 oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
602616 restoreCameraButton.setToolTipText("Restore viewpoint");
603617 restoreCameraButton.addActionListener(this);
604618
619
+ copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
620
+ saveButton.setToolTipText("New version");
621
+ saveButton.addActionListener(this);
622
+
605623 copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
606
- undoButton.setToolTipText("Undo changes");
624
+ undoButton.setToolTipText("Previous version");
607625 undoButton.addActionListener(this);
608626 undoButton.setEnabled(false);
609627
628
+ cGridBag updown = new cGridBag().setVertical(true);
629
+ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
630
+ restoreButton.setToolTipText("Restore current");
631
+ restoreButton.addActionListener(this);
632
+ restoreButton.setEnabled(false);
633
+
634
+ updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
635
+ replaceButton.setToolTipText("Replace current");
636
+ replaceButton.addActionListener(this);
637
+ replaceButton.setEnabled(false);
638
+
639
+ copyOptionsPanel.add(updown);
640
+
610641 copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
611
- redoButton.setToolTipText("Redo changes");
642
+ redoButton.setToolTipText("Next version");
612643 redoButton.addActionListener(this);
613644 redoButton.setEnabled(false);
614645
615
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
616
- saveButton.setToolTipText("Save changes");
617
- saveButton.addActionListener(this);
618
-
619
- copyOptionsPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
646
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
620647 liveCB.setToolTipText("Enable animation");
621648 liveCB.addItemListener(this);
622649
623
- copyOptionsPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
624651 oneStepButton.setToolTipText("Animate one step forward");
625652 oneStepButton.addActionListener(this);
626653
627
- copyOptionsPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
654
+ oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
628655 fastCB.setToolTipText("Fast mode");
629656 fastCB.addItemListener(this);
630657
631658 //oe.toolboxPanel.Return();
632659
633
- copyOptionsPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
634
- screenfitButton.setToolTipText("Screen fit");
635
- screenfitButton.addActionListener(this);
636
-
637660 // copyOptionsPanel.add(trackCB = GetToggleButton("icons/track.png", CameraPane.TRACK)); //, oe.aConstraints);
638661 // trackCB.setToolTipText("Enable tracking");
639662 // trackCB.addItemListener(this);
....@@ -726,7 +749,7 @@
726749 compositeButton.addActionListener(this);
727750
728751 oe.toolboxPanel.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
729
- switchButton.setToolTipText("Create switch");
752
+ switchButton.setToolTipText("Create item switcher");
730753 switchButton.addActionListener(this);
731754
732755 oe.toolboxPanel.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -811,6 +834,9 @@
811834
812835 oe.treePanel.add(copyOptionsPanel);
813836 oe.treePanel.Return();
837
+ cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 10, 0);
838
+ versionField = (cNumberSlider)sliderPane.getComponent(1);
839
+ sliderPane.preferredHeight = 1;
814840
815841 // mainPanel.setDividerLocation(0.5); //1.0);
816842 // mainPanel.setResizeWeight(0.5);
....@@ -863,9 +889,13 @@
863889
864890 if (true) // Globals.ADVANCED)
865891 {
866
- panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
867
- supportCB.setToolTipText("Enable rigging");
868
- supportCB.addItemListener(this);
892
+// panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT)); //, constraints);
893
+// supportCB.setToolTipText("Enable rigging");
894
+// supportCB.addItemListener(this);
895
+
896
+ panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints);
897
+ freezeCB.setToolTipText("Fast moving camera");
898
+ freezeCB.addItemListener(this);
869899
870900 // panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
871901 // localCB.addItemListener(this);
....@@ -929,12 +959,12 @@
929959 toggleTextureCB.addItemListener(this);
930960
931961 panel.add(toggleSwitchCB = new cCheckBox("Switch", CameraPane.SWITCH)); //, constraints);
932
- toggleSwitchCB.setToolTipText("Use switch");
962
+ toggleSwitchCB.setToolTipText("Choose a single item");
933963 toggleSwitchCB.addItemListener(this);
934964
935
- panel.add(autosaveCB = new cCheckBox("Auto-save", Globals.SAVEONMAKE)); //, constraints);
936
- autosaveCB.setToolTipText("On structure change");
937
- autosaveCB.addItemListener(this);
965
+ panel.add(autokeepCB = new cCheckBox("Auto-replace", Globals.REPLACEONMAKE)); //, constraints);
966
+ autokeepCB.setToolTipText("On structure change");
967
+ autokeepCB.addItemListener(this);
938968
939969 panel.Return();
940970 if (Globals.ADVANCED)
....@@ -963,7 +993,7 @@
963993 {
964994 cRadio radioButton = new cRadio(obj.name);
965995
966
- // Patch to avoid bug with transparency.
996
+ // June 2019. Patch to avoid bug with transparency.
967997 radioButton.hadMaterial = obj.material != null;
968998 if (!radioButton.hadMaterial)
969999 {
....@@ -1000,6 +1030,7 @@
10001030 cCheckBox slowCB;
10011031 cCheckBox boxCB;
10021032 cCheckBox zoomBoxCB;
1033
+ cCheckBox freezeCB;
10031034 //cToggleButton trackCB;
10041035 cCheckBox trackCB;
10051036 cCheckBox smoothfocusCB;
....@@ -1010,7 +1041,7 @@
10101041
10111042 cCheckBox oeilCB;
10121043 cCheckBox shadowCB;
1013
- cCheckBox autosaveCB;
1044
+ cCheckBox autokeepCB;
10141045 cCheckBox lookAtCB;
10151046
10161047 // static int COLOR = 1;
....@@ -1118,9 +1149,13 @@
11181149 {
11191150 Globals.COMPUTESHADOWWHENLIVE ^= true;
11201151 }
1121
- else if(e.getSource() == autosaveCB)
1152
+ else if(e.getSource() == freezeCB)
11221153 {
1123
- Globals.SAVEONMAKE ^= true;
1154
+ Globals.FREEZEONMOVE ^= true;
1155
+ }
1156
+ else if(e.getSource() == autokeepCB)
1157
+ {
1158
+ Globals.REPLACEONMAKE ^= true;
11241159 }
11251160 else if(e.getSource() == lookAtCB)
11261161 {
....@@ -1202,8 +1237,6 @@
12021237 }
12031238 }
12041239
1205
- String string = (String) object;
1206
-
12071240 System.out.println("Transfer = " + object + "; drop : " + target);
12081241 // if( object instanceof java.io.File[])
12091242 // {
....@@ -1211,6 +1244,8 @@
12111244 // objEditor.DropFile((java.io.File[]) object, true);
12121245 // return;
12131246 // }
1247
+
1248
+ String string = object.toString();
12141249
12151250 // File path for Mac and Windows
12161251 if (string.charAt(0) == '/' || string.charAt(1) == ':')
....@@ -1460,6 +1495,9 @@
14601495 animationItem.addItemListener(this);
14611496 animationItem.setState(Globals.ANIMATION);
14621497
1498
+ menu.add(archiveItem = new MenuItem("Archive3D..."));
1499
+ archiveItem.addActionListener(this);
1500
+
14631501 menu.add("-");
14641502 parseverticesItem = menu.add(new MenuItem("Multiplicity"));
14651503 parseverticesItem.addActionListener(this);
....@@ -1472,6 +1510,8 @@
14721510 reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
14731511 reduce34MorphItem.addActionListener(this);
14741512 menu.add("-");
1513
+ menu.add(memoryItem = new MenuItem("Memory Usage"));
1514
+ memoryItem.addActionListener(this);
14751515 menu.add(computeAOItem = new MenuItem("Compute AO"));
14761516 computeAOItem.addActionListener(this);
14771517
....@@ -1480,8 +1520,6 @@
14801520 mirrorItem = menu.add(new MenuItem("Mirror Poses"));
14811521 mirrorItem.addActionListener(this);
14821522 menu.add("-");
1483
- menu.add(memoryItem = new MenuItem("Memory Usage"));
1484
- memoryItem.addActionListener(this);
14851523 menu.add(analyzeItem = new MenuItem("Analyze"));
14861524 analyzeItem.addActionListener(this);
14871525 menu.add(dumpItem = new MenuItem("Print"));
....@@ -2122,25 +2160,25 @@
21222160 Composite csg = new GroupLeaf();
21232161 csg.count = 5;
21242162 group(csg);
2125
- Composite child = new cGroup();
2163
+ Composite child = new cGroup("Branch");
21262164 csg.addChild(child);
21272165 child.addChild(csg);
21282166 } else
21292167 if (source == doubleItem)
21302168 {
2131
- Composite csg = new GroupLeaf();
2169
+ Composite csg = new GroupLeaf("Fork");
21322170 csg.count = 5;
21332171 group(csg);
2134
- Composite child = new cGroup();
2172
+ Composite child = new cGroup("Branch A");
21352173 csg.addChild(child);
21362174 child.addChild(csg);
2137
- child = new cGroup();
2175
+ child = new cGroup("Branch B");
21382176 csg.addChild(child);
21392177 child.addChild(csg);
21402178 } else
21412179 if (source == tripleItem)
21422180 {
2143
- Composite csg = new GroupLeaf();
2181
+ Composite csg = new GroupLeaf("Trident");
21442182 csg.count = 4;
21452183 group(csg);
21462184 Composite child = new cGroup();
....@@ -2204,15 +2242,31 @@
22042242 } else
22052243 if (source == undoButton)
22062244 {
2245
+ // Go to previous version
2246
+ //if (!Undo())
2247
+ //java.awt.Toolkit.getDefaultToolkit().beep();
22072248 Undo();
2249
+ } else
2250
+ if (source == restoreButton)
2251
+ {
2252
+ // Restore current version
2253
+ Restore();
2254
+ } else
2255
+ if (source == replaceButton)
2256
+ {
2257
+ // Overwrite current version
2258
+ Replace();
22082259 } else
22092260 if (source == redoButton)
22102261 {
2262
+ // Go to next version
22112263 Redo();
22122264 } else
22132265 if (source == saveButton)
22142266 {
2215
- Save();
2267
+ // Save a new version
2268
+ if (!Save(true))
2269
+ java.awt.Toolkit.getDefaultToolkit().beep();
22162270 } else
22172271 if (source == oneStepButton)
22182272 {
....@@ -2221,17 +2275,14 @@
22212275 } else
22222276 if (source == screenfitButton)
22232277 {
2224
- //Reload(lastConverter, lastFilename, true);
22252278 ScreenFit();
22262279 } else
22272280 if (source == screenfitpointButton)
22282281 {
2229
- //Reload(lastConverter, lastFilename, true);
22302282 ScreenFitPoint();
22312283 } else
22322284 if (source == snapobjectButton)
22332285 {
2234
- //Reload(lastConverter, lastFilename, true);
22352286 SnapObject();
22362287 } else
22372288 // if (event.getSource() == recompileButton)
....@@ -2755,15 +2806,28 @@
27552806 } else
27562807 if (source == ungroupItem || source == ungroupButton)
27572808 {
2758
- //ungroup();
2809
+ boolean hasRoot = false;
2810
+
27592811 for (int i=0; i<group.selection.size(); i++)
27602812 {
2761
- Ungroup(group.selection.get(i));
2813
+ if (group.selection.get(i) == group)
2814
+ {
2815
+ hasRoot = true;
2816
+ break;
2817
+ }
27622818 }
27632819
2764
- ClearSelection(false);
2765
-
2766
- refreshContents();
2820
+ if (!hasRoot)
2821
+ {
2822
+ for (int i=0; i<group.selection.size(); i++)
2823
+ {
2824
+ Ungroup(group.selection.get(i));
2825
+ }
2826
+
2827
+ ClearSelection(false);
2828
+
2829
+ refreshContents();
2830
+ }
27672831 } else
27682832 if (source == genUVItem)
27692833 {
....@@ -3446,6 +3510,9 @@
34463510 }
34473511
34483512 copy = group;
3513
+
3514
+ SetUndoStates();
3515
+
34493516 //Globals.theRenderer.object = group;
34503517 if(!useclient)
34513518 {
....@@ -4706,7 +4773,7 @@
47064773 void refreshContents(boolean cp)
47074774 {
47084775 if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Info"))
4709
- if (!Globals.MOUSEDRAGGED) // && !Globals.TIMERRUNNING)
4776
+ if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
47104777 {
47114778 objEditor.ClearInfo(); // .GetMaterial());
47124779
....@@ -4805,8 +4872,8 @@
48054872
48064873 if (cut)
48074874 {
4808
- if (Globals.SAVEONMAKE)
4809
- Save();
4875
+// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save.
4876
+// Save();
48104877 //int indices[] = jList.getSelectedIndices();
48114878 //for (int i = indices.length - 1; i >= 0; i--)
48124879 //jList.remove(indices[i]);
....@@ -4909,6 +4976,10 @@
49094976
49104977 void paste(boolean expand)
49114978 {
4979
+ if (Globals.REPLACEONMAKE)
4980
+ Save();
4981
+ boolean keep = Globals.REPLACEONMAKE;
4982
+ Globals.REPLACEONMAKE = false;
49124983 // if (GrafreeD.clipboard == null)
49134984 // return;
49144985 boolean first = true;
....@@ -4968,6 +5039,7 @@
49685039 Grafreed.clipboard.get(0).parent = keepparent;
49695040 }
49705041
5042
+ Globals.REPLACEONMAKE = keep;
49715043 ResetModel();
49725044 refreshContents();
49735045 }
....@@ -5103,6 +5175,10 @@
51035175
51045176 void group(Object3D csg, boolean grab)
51055177 {
5178
+ if (Globals.REPLACEONMAKE)
5179
+ Save();
5180
+ boolean keep = Globals.REPLACEONMAKE;
5181
+ Globals.REPLACEONMAKE = false;
51065182 if (//false) // why??
51075183 !group.selection.isEmpty())
51085184 {
....@@ -5216,10 +5292,15 @@
52165292 //node.add(csg);
52175293 //makeSomething(node);
52185294 makeSomething(csg);
5295
+ Globals.REPLACEONMAKE = keep;
52195296 }
52205297
52215298 void Ungroup(Object3D g)
52225299 {
5300
+ if (Globals.REPLACEONMAKE)
5301
+ Save();
5302
+ boolean keep = Globals.REPLACEONMAKE;
5303
+ Globals.REPLACEONMAKE = false;
52235304 if (g instanceof HiddenObject)
52245305 {
52255306 HiddenObject h = (HiddenObject) g;
....@@ -5236,6 +5317,7 @@
52365317 objEditor.makeSomething(g.get(i), false);
52375318 }
52385319 }
5320
+ Globals.REPLACEONMAKE = keep;
52395321 }
52405322
52415323 void ungroup()
....@@ -5526,9 +5608,6 @@
55265608
55275609 cButton restoreCameraButton;
55285610
5529
- cButton minButton;
5530
- cButton maxButton;
5531
- cButton fullButton;
55325611 cButton saveButton;
55335612 cButton oneStepButton;
55345613