From bc829f47837b5a001f911542140b0b8e63c2bb0c Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 14 Jul 2019 19:47:03 -0400 Subject: [PATCH] Fix extract big data. --- ObjEditor.java | 174 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 129 insertions(+), 45 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index b7cf47d..b1bbdf6 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -309,7 +309,7 @@ //localCopy.parent = null; frame = new JFrame(); - frame.setUndecorated(true); + frame.setUndecorated(false); objEditor = this; this.callee = callee; @@ -350,7 +350,7 @@ frame.setMenuBar(menuBar = new MenuBar()); menuBar.add(fileMenu = new Menu("File")); fileMenu.add(newItem = new MenuItem("New")); - fileMenu.add(loadItem = new MenuItem("Open...")); + fileMenu.add(openItem = new MenuItem("Open...")); //oe.menuBar.add(menu = new Menu("Include")); Menu menu = new Menu("Import"); @@ -382,7 +382,7 @@ } newItem.addActionListener(this); - loadItem.addActionListener(this); + openItem.addActionListener(this); saveItem.addActionListener(this); saveAsItem.addActionListener(this); exportAsItem.addActionListener(this); @@ -449,7 +449,7 @@ // TEXTAREA infoarea.setLineWrap(true); // TEXTAREA infoarea.setWrapStyleWord(true); infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); - //infoPanel.setPreferredSize(new Dimension(50, 200)); + infoPanel.setPreferredSize(new Dimension(1, 1)); infoPanel.setName("Info"); //infoPanel.setLayout(new BorderLayout()); //infoPanel.add(createTextPane()); @@ -699,8 +699,8 @@ } } -static GraphicsDevice device = GraphicsEnvironment - .getLocalGraphicsEnvironment().getScreenDevices()[0]; +//static GraphicsDevice device = GraphicsEnvironment +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; Rectangle keeprect; cRadio radio; @@ -741,10 +741,11 @@ else { keeprect = frame.getBounds(); - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); - Dimension rect2 = frame.getToolkit().getScreenSize(); - frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); +// Dimension rect2 = frame.getToolkit().getScreenSize(); +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); // frame.setState(Frame.MAXIMIZED_BOTH); + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); } maximized ^= true; @@ -758,12 +759,17 @@ void ToggleFullScreen() { +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); + cameraView.ToggleFullScreen(); if (!CameraPane.FULLSCREEN) { device.setFullScreenWindow(null); + frame.dispose(); + frame.setUndecorated(false); frame.validate(); + frame.setVisible(true); //frame.setVisible(false); // frame.removeNotify(); @@ -774,7 +780,7 @@ // X frame.getContentPane().remove(/*"Center",*/bigThree); // X framePanel.add(bigThree); // X frame.getContentPane().add(/*"Center",*/framePanel); - framePanel.setDividerLocation(1); + framePanel.setDividerLocation(46); //frame.setVisible(true); radio.layout = keepButton; @@ -789,8 +795,12 @@ // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, // frame.getToolkit().getScreenSize().height); //frame.setVisible(false); + + frame.dispose(); + frame.setUndecorated(true); device.setFullScreenWindow(frame); frame.validate(); + frame.setVisible(true); // frame.removeNotify(); // frame.setUndecorated(true); // frame.addNotify(); @@ -1164,10 +1174,11 @@ randomCB = AddCheckBox(setupPanel2, "Random", copy.random); randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); + link2masterCB.setToolTipText("Attach to support"); + if (Globals.ADVANCED) { - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); - link2masterCB.setToolTipText("Attach to support"); speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); speedupCB.setToolTipText("Option motion capture"); } @@ -1483,7 +1494,10 @@ // north.add(ctrlPanel, BorderLayout.NORTH); // objectPanel.add(north); objectPanel.add(editPanel); - objectPanel.add(infoPanel); + + //if (Globals.ADVANCED) + objectPanel.add(infoPanel); + objectPanel.add(toolboxPanel); /* @@ -1592,9 +1606,9 @@ // aConstraints.gridheight = 1; framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); - framePanel.setContinuousLayout(true); - framePanel.setOneTouchExpandable(true); - framePanel.setDividerLocation(0.8); + framePanel.setContinuousLayout(false); + framePanel.setOneTouchExpandable(false); + //.setDividerLocation(0.8); //framePanel.setDividerSize(15); //framePanel.setResizeWeight(0.15); framePanel.setName("Frame"); @@ -1613,12 +1627,13 @@ frame.setSize(1280, 860); - frame.validate(); - frame.setVisible(true); - cameraView.requestFocusInWindow(); gridPanel.setDividerLocation(1.0); + + frame.validate(); + + frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() @@ -1965,8 +1980,9 @@ // 3D models if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) { - lastConverter = new com.jmex.model.converters.MaxToJme(); - LoadFile(filename, lastConverter); + //lastConverter = new com.jmex.model.converters.MaxToJme(); + //LoadFile(filename, lastConverter); + LoadObjFile(filename); // New 3ds loader continue; } if (filename.endsWith(".dae") || filename.endsWith(".DAE")) @@ -2692,6 +2708,7 @@ LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); } + //cJME.count++; //cJME.count %= 12; if (gc) @@ -2875,6 +2892,7 @@ } } } + cFileSystemPane FSPane; void SetMaterial(cMaterial mat, Object3D.cVector2[] others) @@ -2928,6 +2946,7 @@ } } } + freezematerial = false; } @@ -3380,9 +3399,9 @@ { Close(); //return true; - } else if (source == loadItem) + } else if (source == openItem) { - load(); + Open(); //return true; } else if (source == newItem) { @@ -3407,6 +3426,10 @@ { generatePOV(); //return true; + } else if (event.getSource() == archiveItem) + { + cTools.Archive(frame); + return; } else if (source == zBufferItem) { try @@ -3458,8 +3481,8 @@ try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); - ObjectOutputStream out = new ObjectOutputStream(zstream); +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); Object3D parent = o.parent; o.parent = null; @@ -3470,10 +3493,14 @@ out.flush(); - zstream.close(); + baos //zstream + .close(); out.close(); - return baos.toByteArray(); + byte[] bytes = baos.toByteArray(); + + System.out.println("save #bytes = " + bytes.length); + return bytes; } catch (Exception e) { System.err.println(e); @@ -3483,13 +3510,16 @@ static public Object Uncompress(byte[] bytes) { - System.out.println("#bytes = " + bytes.length); + System.out.println("restore #bytes = " + bytes.length); try { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); - ObjectInputStream in = new ObjectInputStream(istream); + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); + ObjectInputStream in = new ObjectInputStream(bais); // istream); Object obj = in.readObject(); + + bais //istream + .close(); in.close(); return obj; @@ -3548,6 +3578,27 @@ public void Save() { + Save(true); + } + + private boolean Equal(byte[] compress, byte[] name) + { + if (compress.length != name.length) + { + return false; + } + + for (int i=compress.length; --i>=0;) + { + if (compress[i] != name[i]) + return false; + } + + return true; + } + + public boolean Save(boolean user) + { System.err.println("Save"); cRadio tab = GetCurrentTab(); @@ -3558,19 +3609,37 @@ copy.ExtractBigData(hashtable); byte[] compress = Compress(copy); - - //EditorFrame.m_MainFrame.requestFocusInWindow(); - tab.graphs[tab.undoindex++] = compress; - - copy.RestoreBigData(hashtable); CameraPane.SWITCH = temp; + boolean thesame = false; + + // Quick heuristic using length. Works only when stream is compressed. + if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) + { + thesame = true; + } + + //EditorFrame.m_MainFrame.requestFocusInWindow(); + if (!thesame) + { + //tab.user[tab.undoindex] = user; + boolean increment = tab.graphs[tab.undoindex] == null; + + tab.graphs[tab.undoindex] = compress; + + if (increment) + tab.undoindex++; + } + + copy.RestoreBigData(hashtable); + //assert(hashtable.isEmpty()); for (int i = tab.undoindex; i < tab.graphs.length; i++) { - tab.graphs[i] = null; + //tab.user[i] = false; + // tab.graphs[i] = null; } SetUndoStates(); @@ -3593,6 +3662,8 @@ e.printStackTrace(); } } + + return !thesame; } void CopyChanged(Object3D obj) @@ -3649,7 +3720,7 @@ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); } - public void Undo() + public boolean Undo() { System.err.println("Undo"); @@ -3658,18 +3729,27 @@ if (tab.undoindex == 0) { java.awt.Toolkit.getDefaultToolkit().beep(); - return; + return false; } - if (tab.graphs[tab.undoindex] == null) + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) { - Save(); - tab.undoindex -= 1; + if (Save(false)) + tab.undoindex -= 1; + else + { + if (tab.undoindex <= 0) + return false; + else + tab.undoindex -= 1; + } } tab.undoindex -= 1; CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); + + return true; } public void Redo() @@ -3685,6 +3765,9 @@ tab.undoindex += 1; CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); + + //if (!tab.user[tab.undoindex]) + // tab.graphs[tab.undoindex] = null; } void ImportGFD() @@ -4647,8 +4730,8 @@ if (readobj != null) { - if (Globals.SAVEONMAKE) - Save(); + //if (Globals.SAVEONMAKE) // A new object cannot share meshes + // Save(); try { //readobj.deepCopySelf(copy); @@ -4709,7 +4792,7 @@ } } - void load() // throws ClassNotFoundException + void Open() // throws ClassNotFoundException { if (Grafreed.standAlone) { @@ -4994,7 +5077,7 @@ MenuBar menuBar; Menu fileMenu; MenuItem newItem; - MenuItem loadItem; + MenuItem openItem; MenuItem saveItem; MenuItem saveAsItem; MenuItem exportAsItem; @@ -5017,6 +5100,7 @@ CheckboxMenuItem toggleSwitchItem; CheckboxMenuItem toggleRootItem; CheckboxMenuItem animationItem; + MenuItem archiveItem; CheckboxMenuItem toggleHandleItem; CheckboxMenuItem togglePaintItem; JSplitPane mainPanel; -- Gitblit v1.6.2