Merge pull request #967 from jlassahn/fix-954
More improvements for Bug #954
This commit is contained in:
commit
53e1454173
@ -615,6 +615,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
||||
}
|
||||
|
||||
fireUndoRedoChangeEvent();
|
||||
fireDocumentChangeEvent(new DocumentChangeEvent(e.getSource()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,8 @@ import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -72,6 +74,17 @@ public class PhotoFrame extends JFrame {
|
||||
setJMenuBar(getMenu(app));
|
||||
setContentPane(photoPanel);
|
||||
|
||||
if (!app)
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
closeAction();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
GUIUtil.rememberWindowSize(this);
|
||||
this.setLocationByPlatform(true);
|
||||
GUIUtil.rememberWindowPosition(this);
|
||||
@ -305,6 +318,11 @@ public class PhotoFrame extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
private boolean closeAction() {
|
||||
photoPanel.clearDoc();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
LoggingSystemSetup.setupLoggingAppender();
|
||||
|
@ -46,6 +46,7 @@ import net.sf.openrocket.gui.figure3d.photo.exhaust.FlameRenderer;
|
||||
import net.sf.openrocket.gui.main.Splash;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||
@ -75,6 +76,11 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
|
||||
private List<ImageCallback> imageCallbacks = new java.util.Vector<PhotoPanel.ImageCallback>();
|
||||
|
||||
private RocketRenderer rr;
|
||||
private PhotoSettings p;
|
||||
private OpenRocketDocument document;
|
||||
private DocumentChangeListener changeListener;
|
||||
|
||||
interface ImageCallback {
|
||||
public void performAction(BufferedImage i);
|
||||
}
|
||||
@ -84,32 +90,38 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
repaint();
|
||||
}
|
||||
|
||||
private RocketRenderer rr;
|
||||
private PhotoSettings p;
|
||||
|
||||
void setDoc(final OpenRocketDocument doc) {
|
||||
document = doc;
|
||||
cachedBounds = null;
|
||||
this.configuration = doc.getSelectedConfiguration();
|
||||
|
||||
changeListener = new DocumentChangeListener() {
|
||||
@Override
|
||||
public void documentChanged(DocumentChangeEvent event) {
|
||||
log.debug("Repainting on document change");
|
||||
needUpdate = true;
|
||||
PhotoPanel.this.repaint();
|
||||
}
|
||||
};
|
||||
document.addDocumentChangeListener(changeListener);
|
||||
|
||||
((GLAutoDrawable) canvas).invoke(false, new GLRunnable() {
|
||||
@Override
|
||||
public boolean run(final GLAutoDrawable drawable) {
|
||||
PhotoPanel.this.configuration = doc.getSelectedConfiguration();
|
||||
cachedBounds = null;
|
||||
rr = new RealisticRenderer(doc);
|
||||
rr.init(drawable);
|
||||
|
||||
doc.addDocumentChangeListener(new DocumentChangeListener() {
|
||||
@Override
|
||||
public void documentChanged(DocumentChangeEvent event) {
|
||||
log.debug("Repainting on document change");
|
||||
needUpdate = true;
|
||||
PhotoPanel.this.repaint();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void clearDoc() {
|
||||
document.removeDocumentChangeListener(changeListener);
|
||||
changeListener = null;
|
||||
document = null;
|
||||
}
|
||||
|
||||
PhotoSettings getSettings() {
|
||||
return p;
|
||||
}
|
||||
@ -406,7 +418,11 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
||||
rr.render(drawable, configuration, new HashSet<RocketComponent>());
|
||||
|
||||
//Figure out the lowest stage shown
|
||||
final int bottomStageNumber = configuration.getBottomStage().getStageNumber();
|
||||
|
||||
AxialStage bottomStage = configuration.getBottomStage();
|
||||
int bottomStageNumber = 0;
|
||||
if (bottomStage != null)
|
||||
bottomStage.getStageNumber();
|
||||
//final int currentStageNumber = configuration.getActiveStages()[configuration.getActiveStages().length-1];
|
||||
//final AxialStage currentStage = (AxialStage)configuration.getRocket().getChild( bottomStageNumber);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user