.. | .. |
---|
282 | 282 | client = inClient; |
---|
283 | 283 | copy = client; |
---|
284 | 284 | |
---|
| 285 | + if (copy.versions == null) |
---|
| 286 | + { |
---|
| 287 | + copy.versions = new byte[100][]; |
---|
| 288 | + copy.versionindex = -1; |
---|
| 289 | + } |
---|
| 290 | + |
---|
285 | 291 | // "this" is not called: SetupUI2(objEditor); |
---|
286 | 292 | } |
---|
287 | 293 | |
---|
.. | .. |
---|
295 | 301 | client = inClient; |
---|
296 | 302 | copy = client; |
---|
297 | 303 | |
---|
| 304 | + if (copy.versions == null) |
---|
| 305 | + { |
---|
| 306 | + copy.versions = new byte[100][]; |
---|
| 307 | + copy.versionindex = -1; |
---|
| 308 | + } |
---|
| 309 | + |
---|
298 | 310 | SetupUI2(callee.GetEditor()); |
---|
299 | 311 | } |
---|
300 | 312 | |
---|
.. | .. |
---|
327 | 339 | copy = localCopy; |
---|
328 | 340 | copy.editWindow = this; |
---|
329 | 341 | |
---|
| 342 | + if (copy.versions == null) |
---|
| 343 | + { |
---|
| 344 | + copy.versions = new byte[100][]; |
---|
| 345 | + copy.versionindex = -1; |
---|
| 346 | + } |
---|
| 347 | + |
---|
330 | 348 | SetupMenu(); |
---|
331 | 349 | |
---|
332 | 350 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
816 | 834 | frame.validate(); |
---|
817 | 835 | } |
---|
818 | 836 | |
---|
| 837 | + private byte[] CompressCopy() |
---|
| 838 | + { |
---|
| 839 | + boolean temp = CameraPane.SWITCH; |
---|
| 840 | + CameraPane.SWITCH = false; |
---|
| 841 | + |
---|
| 842 | + copy.ExtractBigData(versiontable); |
---|
| 843 | + // if (copy == client) |
---|
| 844 | + |
---|
| 845 | + byte[] versions[] = copy.versions; |
---|
| 846 | + copy.versions = null; |
---|
| 847 | + |
---|
| 848 | + byte[] compress = Compress(copy); |
---|
| 849 | + |
---|
| 850 | + copy.versions = versions; |
---|
| 851 | + |
---|
| 852 | + copy.RestoreBigData(versiontable); |
---|
| 853 | + |
---|
| 854 | + CameraPane.SWITCH = temp; |
---|
| 855 | + |
---|
| 856 | + return compress; |
---|
| 857 | + } |
---|
| 858 | + |
---|
819 | 859 | private JTextPane createTextPane() |
---|
820 | 860 | { |
---|
821 | 861 | // TEXTAREA String[] initString = |
---|
.. | .. |
---|
1174 | 1214 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1175 | 1215 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1176 | 1216 | |
---|
| 1217 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1218 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1219 | + |
---|
1177 | 1220 | if (Globals.ADVANCED) |
---|
1178 | 1221 | { |
---|
1179 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1180 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1181 | 1222 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1182 | 1223 | speedupCB.setToolTipText("Option motion capture"); |
---|
1183 | 1224 | } |
---|
.. | .. |
---|
3480 | 3521 | try |
---|
3481 | 3522 | { |
---|
3482 | 3523 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3483 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3484 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3524 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3525 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3485 | 3526 | |
---|
3486 | 3527 | Object3D parent = o.parent; |
---|
3487 | 3528 | o.parent = null; |
---|
.. | .. |
---|
3492 | 3533 | |
---|
3493 | 3534 | out.flush(); |
---|
3494 | 3535 | |
---|
3495 | | - zstream.close(); |
---|
| 3536 | + baos //zstream |
---|
| 3537 | + .close(); |
---|
3496 | 3538 | out.close(); |
---|
3497 | 3539 | |
---|
3498 | | - return baos.toByteArray(); |
---|
| 3540 | + byte[] bytes = baos.toByteArray(); |
---|
| 3541 | + |
---|
| 3542 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3543 | + return bytes; |
---|
3499 | 3544 | } catch (Exception e) |
---|
3500 | 3545 | { |
---|
3501 | 3546 | System.err.println(e); |
---|
.. | .. |
---|
3505 | 3550 | |
---|
3506 | 3551 | static public Object Uncompress(byte[] bytes) |
---|
3507 | 3552 | { |
---|
3508 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3553 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3509 | 3554 | try |
---|
3510 | 3555 | { |
---|
3511 | 3556 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3512 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3513 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3557 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3558 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3514 | 3559 | Object obj = in.readObject(); |
---|
| 3560 | + |
---|
| 3561 | + bais //istream |
---|
| 3562 | + .close(); |
---|
3515 | 3563 | in.close(); |
---|
3516 | 3564 | |
---|
3517 | 3565 | return obj; |
---|
.. | .. |
---|
3566 | 3614 | return null; |
---|
3567 | 3615 | } |
---|
3568 | 3616 | |
---|
3569 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3570 | 3617 | |
---|
3571 | 3618 | public void Save() |
---|
3572 | 3619 | { |
---|
3573 | | - // Default reduces the probability of heuristics errors. |
---|
3574 | | - Save(true); |
---|
| 3620 | + //Save(true); |
---|
| 3621 | + Replace(); |
---|
3575 | 3622 | } |
---|
3576 | 3623 | |
---|
3577 | 3624 | private boolean Equal(byte[] compress, byte[] name) |
---|
.. | .. |
---|
3590 | 3637 | return true; |
---|
3591 | 3638 | } |
---|
3592 | 3639 | |
---|
| 3640 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3641 | + |
---|
3593 | 3642 | public boolean Save(boolean user) |
---|
3594 | 3643 | { |
---|
3595 | 3644 | System.err.println("Save"); |
---|
3596 | 3645 | |
---|
3597 | 3646 | cRadio tab = GetCurrentTab(); |
---|
3598 | 3647 | |
---|
3599 | | - boolean temp = CameraPane.SWITCH; |
---|
3600 | | - CameraPane.SWITCH = false; |
---|
3601 | | - |
---|
3602 | | - copy.ExtractBigData(hashtable); |
---|
3603 | | - |
---|
3604 | | - byte[] compress = Compress(copy); |
---|
3605 | | - |
---|
3606 | | - CameraPane.SWITCH = temp; |
---|
| 3648 | + byte[] compress = CompressCopy(); |
---|
3607 | 3649 | |
---|
3608 | 3650 | boolean thesame = false; |
---|
3609 | 3651 | |
---|
3610 | 3652 | // Quick heuristic using length. Works only when stream is compressed. |
---|
3611 | | - if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) |
---|
| 3653 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
3612 | 3654 | { |
---|
3613 | 3655 | thesame = true; |
---|
3614 | 3656 | } |
---|
.. | .. |
---|
3616 | 3658 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3617 | 3659 | if (!thesame) |
---|
3618 | 3660 | { |
---|
3619 | | - tab.user[tab.undoindex] = user; |
---|
3620 | | - tab.graphs[tab.undoindex++] = compress; |
---|
| 3661 | + //tab.user[tab.versionindex] = user; |
---|
| 3662 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3663 | + |
---|
| 3664 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3665 | + |
---|
| 3666 | + // if (increment) |
---|
| 3667 | + // tab.versionindex++; |
---|
3621 | 3668 | } |
---|
3622 | 3669 | |
---|
3623 | | - copy.RestoreBigData(hashtable); |
---|
| 3670 | + //copy.RestoreBigData(versiontable); |
---|
3624 | 3671 | |
---|
3625 | 3672 | //assert(hashtable.isEmpty()); |
---|
3626 | 3673 | |
---|
3627 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3674 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3628 | 3675 | { |
---|
3629 | | - tab.user[i] = false; |
---|
3630 | | - tab.graphs[i] = null; |
---|
| 3676 | + //tab.user[i] = false; |
---|
| 3677 | + copy.versions[i] = null; |
---|
3631 | 3678 | } |
---|
3632 | 3679 | |
---|
3633 | 3680 | SetUndoStates(); |
---|
.. | .. |
---|
3637 | 3684 | { |
---|
3638 | 3685 | try |
---|
3639 | 3686 | { |
---|
3640 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3687 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3641 | 3688 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3642 | 3689 | |
---|
3643 | 3690 | p.writeObject(copy); |
---|
.. | .. |
---|
3661 | 3708 | boolean temp = CameraPane.SWITCH; |
---|
3662 | 3709 | CameraPane.SWITCH = false; |
---|
3663 | 3710 | |
---|
3664 | | - copy.ExtractBigData(hashtable); |
---|
| 3711 | + copy.ExtractBigData(versiontable); |
---|
3665 | 3712 | |
---|
3666 | 3713 | copy.clear(); |
---|
3667 | 3714 | |
---|
.. | .. |
---|
3670 | 3717 | copy.add(obj.get(i)); |
---|
3671 | 3718 | } |
---|
3672 | 3719 | |
---|
3673 | | - copy.RestoreBigData(hashtable); |
---|
| 3720 | + copy.RestoreBigData(versiontable); |
---|
3674 | 3721 | |
---|
3675 | 3722 | CameraPane.SWITCH = temp; |
---|
3676 | 3723 | |
---|
.. | .. |
---|
3698 | 3745 | } |
---|
3699 | 3746 | |
---|
3700 | 3747 | cButton undoButton; |
---|
| 3748 | + cButton restoreButton; |
---|
| 3749 | + cButton replaceButton; |
---|
3701 | 3750 | cButton redoButton; |
---|
3702 | 3751 | |
---|
| 3752 | + boolean muteSlider; |
---|
| 3753 | + |
---|
| 3754 | + int VersionCount() |
---|
| 3755 | + { |
---|
| 3756 | + int count = 0; |
---|
| 3757 | + |
---|
| 3758 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3759 | + { |
---|
| 3760 | + if (copy.versions[i] != null) |
---|
| 3761 | + count++; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
| 3764 | + return count; |
---|
| 3765 | + } |
---|
| 3766 | + |
---|
3703 | 3767 | void SetUndoStates() |
---|
3704 | 3768 | { |
---|
3705 | 3769 | cRadio tab = GetCurrentTab(); |
---|
3706 | 3770 | |
---|
3707 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3708 | | - redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3771 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3772 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3773 | + |
---|
| 3774 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3775 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3776 | + |
---|
| 3777 | + muteSlider = true; |
---|
| 3778 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3779 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3780 | + muteSlider = false; |
---|
3709 | 3781 | } |
---|
3710 | 3782 | |
---|
3711 | 3783 | public boolean Undo() |
---|
3712 | 3784 | { |
---|
| 3785 | + // Option? |
---|
| 3786 | + Replace(); |
---|
| 3787 | + |
---|
3713 | 3788 | System.err.println("Undo"); |
---|
3714 | 3789 | |
---|
3715 | 3790 | cRadio tab = GetCurrentTab(); |
---|
3716 | 3791 | |
---|
3717 | | - if (tab.undoindex == 0) |
---|
| 3792 | + if (copy.versionindex == 0) |
---|
3718 | 3793 | { |
---|
3719 | 3794 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3720 | 3795 | return false; |
---|
3721 | 3796 | } |
---|
3722 | 3797 | |
---|
3723 | | - if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex]) |
---|
| 3798 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3799 | +// { |
---|
| 3800 | +// if (Save(false)) |
---|
| 3801 | +// tab.versionindex -= 1; |
---|
| 3802 | +// else |
---|
| 3803 | +// { |
---|
| 3804 | +// if (tab.versionindex <= 0) |
---|
| 3805 | +// return false; |
---|
| 3806 | +// else |
---|
| 3807 | +// tab.versionindex -= 1; |
---|
| 3808 | +// } |
---|
| 3809 | +// } |
---|
| 3810 | + |
---|
| 3811 | + copy.versionindex -= 1; |
---|
| 3812 | + |
---|
| 3813 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3814 | + |
---|
| 3815 | + return true; |
---|
| 3816 | + } |
---|
| 3817 | + |
---|
| 3818 | + public boolean Restore() |
---|
| 3819 | + { |
---|
| 3820 | + System.err.println("Restore"); |
---|
| 3821 | + |
---|
| 3822 | + cRadio tab = GetCurrentTab(); |
---|
| 3823 | + |
---|
| 3824 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3724 | 3825 | { |
---|
3725 | | - if (Save(false)) |
---|
3726 | | - tab.undoindex -= 1; |
---|
3727 | | - else |
---|
3728 | | - { |
---|
3729 | | - if (tab.undoindex <= 0) |
---|
3730 | | - return false; |
---|
3731 | | - else |
---|
3732 | | - tab.undoindex -= 1; |
---|
3733 | | - } |
---|
| 3826 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3827 | + return false; |
---|
3734 | 3828 | } |
---|
3735 | 3829 | |
---|
3736 | | - tab.undoindex -= 1; |
---|
| 3830 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3831 | + |
---|
| 3832 | + return true; |
---|
| 3833 | + } |
---|
3737 | 3834 | |
---|
3738 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3835 | + public boolean Replace() |
---|
| 3836 | + { |
---|
| 3837 | + System.err.println("Replace"); |
---|
| 3838 | + |
---|
| 3839 | + cRadio tab = GetCurrentTab(); |
---|
| 3840 | + |
---|
| 3841 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3842 | + { |
---|
| 3843 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3844 | + return false; |
---|
| 3845 | + } |
---|
| 3846 | + |
---|
| 3847 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
3739 | 3848 | |
---|
3740 | 3849 | return true; |
---|
3741 | 3850 | } |
---|
3742 | 3851 | |
---|
3743 | 3852 | public void Redo() |
---|
3744 | 3853 | { |
---|
| 3854 | + // Option? |
---|
| 3855 | + Replace(); |
---|
| 3856 | + |
---|
3745 | 3857 | cRadio tab = GetCurrentTab(); |
---|
3746 | 3858 | |
---|
3747 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3859 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3748 | 3860 | { |
---|
3749 | 3861 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3750 | 3862 | return; |
---|
3751 | 3863 | } |
---|
3752 | 3864 | |
---|
3753 | | - tab.undoindex += 1; |
---|
| 3865 | + copy.versionindex += 1; |
---|
3754 | 3866 | |
---|
3755 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3867 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
3756 | 3868 | |
---|
3757 | | - if (!tab.user[tab.undoindex]) |
---|
3758 | | - tab.graphs[tab.undoindex] = null; |
---|
| 3869 | + //if (!tab.user[tab.versionindex]) |
---|
| 3870 | + // tab.graphs[tab.versionindex] = null; |
---|
3759 | 3871 | } |
---|
3760 | 3872 | |
---|
3761 | 3873 | void ImportGFD() |
---|
.. | .. |
---|
4051 | 4163 | //copy.Touch(); |
---|
4052 | 4164 | } |
---|
4053 | 4165 | |
---|
| 4166 | + cNumberSlider versionSlider; |
---|
| 4167 | + |
---|
4054 | 4168 | public void stateChanged(ChangeEvent e) |
---|
4055 | 4169 | { |
---|
4056 | 4170 | // assert(false); |
---|
| 4171 | + if (e.getSource() == versionSlider) |
---|
| 4172 | + { |
---|
| 4173 | + if (muteSlider) |
---|
| 4174 | + return; |
---|
| 4175 | + |
---|
| 4176 | + int version = versionSlider.getInteger(); |
---|
| 4177 | + |
---|
| 4178 | + if (copy.versions[version] != null) |
---|
| 4179 | + { |
---|
| 4180 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4181 | + } |
---|
| 4182 | + |
---|
| 4183 | + return; |
---|
| 4184 | + } |
---|
4057 | 4185 | |
---|
4058 | 4186 | if (freezematerial) |
---|
4059 | 4187 | { |
---|
.. | .. |
---|
4402 | 4530 | |
---|
4403 | 4531 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4404 | 4532 | { |
---|
4405 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4533 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4406 | 4534 | Save(); |
---|
4407 | 4535 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4408 | 4536 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4718 | 4846 | |
---|
4719 | 4847 | if (readobj != null) |
---|
4720 | 4848 | { |
---|
4721 | | - if (Globals.SAVEONMAKE) |
---|
4722 | | - Save(); |
---|
| 4849 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4850 | + // Save(); |
---|
4723 | 4851 | try |
---|
4724 | 4852 | { |
---|
4725 | 4853 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4774 | 4902 | c.addChild(csg); |
---|
4775 | 4903 | } |
---|
4776 | 4904 | |
---|
| 4905 | + copy.versions = readobj.versions; |
---|
| 4906 | + copy.versionindex = readobj.versionindex; |
---|
| 4907 | + |
---|
| 4908 | + if (copy.versions == null) |
---|
| 4909 | + { |
---|
| 4910 | + copy.versions = new byte[100][]; |
---|
| 4911 | + copy.versionindex = -1; |
---|
| 4912 | + } |
---|
| 4913 | + |
---|
| 4914 | + //? SetUndoStates(); |
---|
| 4915 | + |
---|
4777 | 4916 | ResetModel(); |
---|
4778 | 4917 | copy.HardTouch(); // recompile? |
---|
4779 | 4918 | refreshContents(); |
---|