.. | .. |
---|
816 | 816 | frame.validate(); |
---|
817 | 817 | } |
---|
818 | 818 | |
---|
| 819 | + private byte[] CompressCopy() |
---|
| 820 | + { |
---|
| 821 | + boolean temp = CameraPane.SWITCH; |
---|
| 822 | + CameraPane.SWITCH = false; |
---|
| 823 | + |
---|
| 824 | + copy.ExtractBigData(versiontable); |
---|
| 825 | + // if (copy == client) |
---|
| 826 | + |
---|
| 827 | + byte[] versions[] = copy.versions; |
---|
| 828 | + copy.versions = null; |
---|
| 829 | + |
---|
| 830 | + byte[] compress = Compress(copy); |
---|
| 831 | + |
---|
| 832 | + copy.versions = versions; |
---|
| 833 | + |
---|
| 834 | + copy.RestoreBigData(versiontable); |
---|
| 835 | + |
---|
| 836 | + CameraPane.SWITCH = temp; |
---|
| 837 | + |
---|
| 838 | + return compress; |
---|
| 839 | + } |
---|
| 840 | + |
---|
819 | 841 | private JTextPane createTextPane() |
---|
820 | 842 | { |
---|
821 | 843 | // TEXTAREA String[] initString = |
---|
.. | .. |
---|
1174 | 1196 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1175 | 1197 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1176 | 1198 | |
---|
| 1199 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1200 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1201 | + |
---|
1177 | 1202 | if (Globals.ADVANCED) |
---|
1178 | 1203 | { |
---|
1179 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1180 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1181 | 1204 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1182 | 1205 | speedupCB.setToolTipText("Option motion capture"); |
---|
1183 | 1206 | } |
---|
.. | .. |
---|
3480 | 3503 | try |
---|
3481 | 3504 | { |
---|
3482 | 3505 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3483 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3484 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3506 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3507 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3485 | 3508 | |
---|
3486 | 3509 | Object3D parent = o.parent; |
---|
3487 | 3510 | o.parent = null; |
---|
.. | .. |
---|
3492 | 3515 | |
---|
3493 | 3516 | out.flush(); |
---|
3494 | 3517 | |
---|
3495 | | - zstream.close(); |
---|
| 3518 | + baos //zstream |
---|
| 3519 | + .close(); |
---|
3496 | 3520 | out.close(); |
---|
3497 | 3521 | |
---|
3498 | | - return baos.toByteArray(); |
---|
| 3522 | + byte[] bytes = baos.toByteArray(); |
---|
| 3523 | + |
---|
| 3524 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3525 | + return bytes; |
---|
3499 | 3526 | } catch (Exception e) |
---|
3500 | 3527 | { |
---|
3501 | 3528 | System.err.println(e); |
---|
.. | .. |
---|
3505 | 3532 | |
---|
3506 | 3533 | static public Object Uncompress(byte[] bytes) |
---|
3507 | 3534 | { |
---|
3508 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3535 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3509 | 3536 | try |
---|
3510 | 3537 | { |
---|
3511 | 3538 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3512 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3513 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3539 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3540 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3514 | 3541 | Object obj = in.readObject(); |
---|
| 3542 | + |
---|
| 3543 | + bais //istream |
---|
| 3544 | + .close(); |
---|
3515 | 3545 | in.close(); |
---|
3516 | 3546 | |
---|
3517 | 3547 | return obj; |
---|
.. | .. |
---|
3566 | 3596 | return null; |
---|
3567 | 3597 | } |
---|
3568 | 3598 | |
---|
3569 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3570 | 3599 | |
---|
3571 | 3600 | public void Save() |
---|
3572 | 3601 | { |
---|
3573 | | - // Default reduces the probability of heuristics errors. |
---|
3574 | | - Save(true); |
---|
| 3602 | + //Save(true); |
---|
| 3603 | + Replace(); |
---|
3575 | 3604 | } |
---|
3576 | 3605 | |
---|
3577 | 3606 | private boolean Equal(byte[] compress, byte[] name) |
---|
.. | .. |
---|
3590 | 3619 | return true; |
---|
3591 | 3620 | } |
---|
3592 | 3621 | |
---|
| 3622 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3623 | + |
---|
3593 | 3624 | public boolean Save(boolean user) |
---|
3594 | 3625 | { |
---|
3595 | 3626 | System.err.println("Save"); |
---|
3596 | 3627 | |
---|
3597 | 3628 | cRadio tab = GetCurrentTab(); |
---|
3598 | 3629 | |
---|
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; |
---|
| 3630 | + byte[] compress = CompressCopy(); |
---|
3607 | 3631 | |
---|
3608 | 3632 | boolean thesame = false; |
---|
3609 | 3633 | |
---|
3610 | 3634 | // 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])) |
---|
| 3635 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
3612 | 3636 | { |
---|
3613 | 3637 | thesame = true; |
---|
3614 | 3638 | } |
---|
.. | .. |
---|
3616 | 3640 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3617 | 3641 | if (!thesame) |
---|
3618 | 3642 | { |
---|
3619 | | - tab.user[tab.undoindex] = user; |
---|
3620 | | - tab.graphs[tab.undoindex++] = compress; |
---|
| 3643 | + //tab.user[tab.versionindex] = user; |
---|
| 3644 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3645 | + |
---|
| 3646 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3647 | + |
---|
| 3648 | + // if (increment) |
---|
| 3649 | + // tab.versionindex++; |
---|
3621 | 3650 | } |
---|
3622 | 3651 | |
---|
3623 | | - copy.RestoreBigData(hashtable); |
---|
| 3652 | + //copy.RestoreBigData(versiontable); |
---|
3624 | 3653 | |
---|
3625 | 3654 | //assert(hashtable.isEmpty()); |
---|
3626 | 3655 | |
---|
3627 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3628 | 3657 | { |
---|
3629 | | - tab.user[i] = false; |
---|
3630 | | - tab.graphs[i] = null; |
---|
| 3658 | + //tab.user[i] = false; |
---|
| 3659 | + copy.versions[i] = null; |
---|
3631 | 3660 | } |
---|
3632 | 3661 | |
---|
3633 | 3662 | SetUndoStates(); |
---|
.. | .. |
---|
3637 | 3666 | { |
---|
3638 | 3667 | try |
---|
3639 | 3668 | { |
---|
3640 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3669 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3641 | 3670 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3642 | 3671 | |
---|
3643 | 3672 | p.writeObject(copy); |
---|
.. | .. |
---|
3661 | 3690 | boolean temp = CameraPane.SWITCH; |
---|
3662 | 3691 | CameraPane.SWITCH = false; |
---|
3663 | 3692 | |
---|
3664 | | - copy.ExtractBigData(hashtable); |
---|
| 3693 | + copy.ExtractBigData(versiontable); |
---|
3665 | 3694 | |
---|
3666 | 3695 | copy.clear(); |
---|
3667 | 3696 | |
---|
.. | .. |
---|
3670 | 3699 | copy.add(obj.get(i)); |
---|
3671 | 3700 | } |
---|
3672 | 3701 | |
---|
3673 | | - copy.RestoreBigData(hashtable); |
---|
| 3702 | + copy.RestoreBigData(versiontable); |
---|
3674 | 3703 | |
---|
3675 | 3704 | CameraPane.SWITCH = temp; |
---|
3676 | 3705 | |
---|
.. | .. |
---|
3698 | 3727 | } |
---|
3699 | 3728 | |
---|
3700 | 3729 | cButton undoButton; |
---|
| 3730 | + cButton restoreButton; |
---|
| 3731 | + cButton replaceButton; |
---|
3701 | 3732 | cButton redoButton; |
---|
3702 | 3733 | |
---|
3703 | 3734 | void SetUndoStates() |
---|
3704 | 3735 | { |
---|
3705 | 3736 | cRadio tab = GetCurrentTab(); |
---|
3706 | 3737 | |
---|
3707 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3708 | | - redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3738 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3739 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3740 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3741 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
3709 | 3742 | } |
---|
3710 | 3743 | |
---|
3711 | 3744 | public boolean Undo() |
---|
.. | .. |
---|
3714 | 3747 | |
---|
3715 | 3748 | cRadio tab = GetCurrentTab(); |
---|
3716 | 3749 | |
---|
3717 | | - if (tab.undoindex == 0) |
---|
| 3750 | + if (copy.versionindex == 0) |
---|
3718 | 3751 | { |
---|
3719 | 3752 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3720 | 3753 | return false; |
---|
3721 | 3754 | } |
---|
3722 | 3755 | |
---|
3723 | | - if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex]) |
---|
| 3756 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3757 | +// { |
---|
| 3758 | +// if (Save(false)) |
---|
| 3759 | +// tab.versionindex -= 1; |
---|
| 3760 | +// else |
---|
| 3761 | +// { |
---|
| 3762 | +// if (tab.versionindex <= 0) |
---|
| 3763 | +// return false; |
---|
| 3764 | +// else |
---|
| 3765 | +// tab.versionindex -= 1; |
---|
| 3766 | +// } |
---|
| 3767 | +// } |
---|
| 3768 | + |
---|
| 3769 | + copy.versionindex -= 1; |
---|
| 3770 | + |
---|
| 3771 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3772 | + |
---|
| 3773 | + return true; |
---|
| 3774 | + } |
---|
| 3775 | + |
---|
| 3776 | + public boolean Restore() |
---|
| 3777 | + { |
---|
| 3778 | + System.err.println("Restore"); |
---|
| 3779 | + |
---|
| 3780 | + cRadio tab = GetCurrentTab(); |
---|
| 3781 | + |
---|
| 3782 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3724 | 3783 | { |
---|
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 | | - } |
---|
| 3784 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3785 | + return false; |
---|
3734 | 3786 | } |
---|
3735 | 3787 | |
---|
3736 | | - tab.undoindex -= 1; |
---|
| 3788 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3789 | + |
---|
| 3790 | + return true; |
---|
| 3791 | + } |
---|
3737 | 3792 | |
---|
3738 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3793 | + public boolean Replace() |
---|
| 3794 | + { |
---|
| 3795 | + System.err.println("Replace"); |
---|
| 3796 | + |
---|
| 3797 | + cRadio tab = GetCurrentTab(); |
---|
| 3798 | + |
---|
| 3799 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3800 | + { |
---|
| 3801 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3802 | + return false; |
---|
| 3803 | + } |
---|
| 3804 | + |
---|
| 3805 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
3739 | 3806 | |
---|
3740 | 3807 | return true; |
---|
3741 | 3808 | } |
---|
.. | .. |
---|
3744 | 3811 | { |
---|
3745 | 3812 | cRadio tab = GetCurrentTab(); |
---|
3746 | 3813 | |
---|
3747 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3814 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3748 | 3815 | { |
---|
3749 | 3816 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3750 | 3817 | return; |
---|
3751 | 3818 | } |
---|
3752 | 3819 | |
---|
3753 | | - tab.undoindex += 1; |
---|
| 3820 | + copy.versionindex += 1; |
---|
3754 | 3821 | |
---|
3755 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3822 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
3756 | 3823 | |
---|
3757 | | - if (!tab.user[tab.undoindex]) |
---|
3758 | | - tab.graphs[tab.undoindex] = null; |
---|
| 3824 | + //if (!tab.user[tab.versionindex]) |
---|
| 3825 | + // tab.graphs[tab.versionindex] = null; |
---|
3759 | 3826 | } |
---|
3760 | 3827 | |
---|
3761 | 3828 | void ImportGFD() |
---|
.. | .. |
---|
4051 | 4118 | //copy.Touch(); |
---|
4052 | 4119 | } |
---|
4053 | 4120 | |
---|
| 4121 | + cNumberSlider versionField; |
---|
| 4122 | + |
---|
4054 | 4123 | public void stateChanged(ChangeEvent e) |
---|
4055 | 4124 | { |
---|
4056 | 4125 | // assert(false); |
---|
| 4126 | + if (e.getSource() == versionField) |
---|
| 4127 | + { |
---|
| 4128 | + int version = versionField.getInteger(); |
---|
| 4129 | + |
---|
| 4130 | + if (copy.versions[version] != null) |
---|
| 4131 | + { |
---|
| 4132 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4133 | + } |
---|
| 4134 | + |
---|
| 4135 | + return; |
---|
| 4136 | + } |
---|
4057 | 4137 | |
---|
4058 | 4138 | if (freezematerial) |
---|
4059 | 4139 | { |
---|
.. | .. |
---|
4402 | 4482 | |
---|
4403 | 4483 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4404 | 4484 | { |
---|
4405 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4485 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4406 | 4486 | Save(); |
---|
4407 | 4487 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4408 | 4488 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4718 | 4798 | |
---|
4719 | 4799 | if (readobj != null) |
---|
4720 | 4800 | { |
---|
4721 | | - if (Globals.SAVEONMAKE) |
---|
4722 | | - Save(); |
---|
| 4801 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4802 | + // Save(); |
---|
4723 | 4803 | try |
---|
4724 | 4804 | { |
---|
4725 | 4805 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4774 | 4854 | c.addChild(csg); |
---|
4775 | 4855 | } |
---|
4776 | 4856 | |
---|
| 4857 | + copy.versions = readobj.versions; |
---|
| 4858 | + copy.versionindex = readobj.versionindex; |
---|
| 4859 | + |
---|
| 4860 | + SetUndoStates(); |
---|
| 4861 | + |
---|
4777 | 4862 | ResetModel(); |
---|
4778 | 4863 | copy.HardTouch(); // recompile? |
---|
4779 | 4864 | refreshContents(); |
---|