[#1999] Add checkbox to show/hide warnings

This commit is contained in:
SiboVG 2023-02-01 15:51:49 +00:00
parent a7e094311b
commit b718c5a0e1
3 changed files with 62 additions and 17 deletions

View File

@ -69,6 +69,9 @@ RocketPanel.btn.Stages.Toggle.ttip = Toggle this button to activate/deactivate t
RocketPanel.btn.Stages.NoChildren.ttip = <html>This stage does not have child components and is therefore marked as inactive.<br>Add components to the stage to activate it.</html> RocketPanel.btn.Stages.NoChildren.ttip = <html>This stage does not have child components and is therefore marked as inactive.<br>Add components to the stage to activate it.</html>
RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view) RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view)
RocketPanel.check.showWarnings = Show warnings
RocketPanel.check.showWarnings.ttip = Show/hide geometry warnings in the rocket design view.
! BasicFrame ! BasicFrame
BasicFrame.tab.Rocketdesign = Rocket design BasicFrame.tab.Rocketdesign = Rocket design
BasicFrame.tab.Flightconfig = Motors & Configuration BasicFrame.tab.Flightconfig = Motors & Configuration
@ -1781,6 +1784,7 @@ RocketInfo.apogeeValue = N/A
RocketInfo.Mach = (Mach RocketInfo.Mach = (Mach
RocketInfo.velocityValue = N/A RocketInfo.velocityValue = N/A
RocketInfo.accelerationValue = N/A RocketInfo.accelerationValue = N/A
RocketInfo.lbl.warnings = %d warning(s)
! FinSet ! FinSet
FinSet.CrossSection.SQUARE = Square FinSet.CrossSection.SQUARE = Square

View File

@ -53,6 +53,7 @@ public class RocketInfo implements FigureElement {
private double massWithoutMotors = 0; private double massWithoutMotors = 0;
private WarningSet warnings = null; private WarningSet warnings = null;
private boolean showWarnings = true;
private boolean calculatingData = false; private boolean calculatingData = false;
private FlightData flightData = null; private FlightData flightData = null;
@ -124,6 +125,14 @@ public class RocketInfo implements FigureElement {
this.warnings = warnings.clone(); this.warnings = warnings.clone();
} }
/**
* Set whether warnings should be shown. If false, the warnings are not shown.
* @param showWarnings whether to show warnings.
*/
public void setShowWarnings(boolean showWarnings) {
this.showWarnings = showWarnings;
}
public void setAOA(double aoa) { public void setAOA(double aoa) {
this.aoa = aoa; this.aoa = aoa;
} }
@ -329,9 +338,12 @@ public class RocketInfo implements FigureElement {
if (warnings == null || warnings.isEmpty()) if (warnings == null || warnings.isEmpty())
return; return;
GlyphVector[] texts = new GlyphVector[warnings.size()+1]; final GlyphVector[] texts;
double max = 0; double max = 0;
if (showWarnings) {
texts = new GlyphVector[warnings.size()+1];
//// Warning: //// Warning:
texts[0] = createText(trans.get("RocketInfo.Warning")); texts[0] = createText(trans.get("RocketInfo.Warning"));
int i = 1; int i = 1;
@ -345,9 +357,15 @@ public class RocketInfo implements FigureElement {
if (rect.getWidth() > max) if (rect.getWidth() > max)
max = rect.getWidth(); max = rect.getWidth();
} }
} else {
texts = new GlyphVector[1];
texts[0] = createText(String.format(trans.get("RocketInfo.lbl.warnings"), warnings.size()));
Rectangle2D rect = texts[0].getVisualBounds();
max = rect.getWidth();
}
float y = y2 - line * warnings.size(); float y = y2 - line * (texts.length-1);
g2.setColor(Color.RED); g2.setColor(Color.RED);
for (GlyphVector v: texts) { for (GlyphVector v: texts) {

View File

@ -9,6 +9,8 @@ import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -133,6 +135,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
private final JPanel figureHolder; private final JPanel figureHolder;
private JLabel infoMessage; private JLabel infoMessage;
private JCheckBox showWarnings;
private TreeSelectionModel selectionModel = null; private TreeSelectionModel selectionModel = null;
@ -423,11 +426,28 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
}); });
rotationSlider.setToolTipText(trans.get("RocketPanel.ttip.Rotation")); rotationSlider.setToolTipText(trans.get("RocketPanel.ttip.Rotation"));
// Bottom row
JPanel bottomRow = new JPanel(new MigLayout("fill, gapy 0, ins 0"));
//// <html>Click to select &nbsp;&nbsp; Shift+click to select other &nbsp;&nbsp; Double-click to edit &nbsp;&nbsp; Click+drag to move //// <html>Click to select &nbsp;&nbsp; Shift+click to select other &nbsp;&nbsp; Double-click to edit &nbsp;&nbsp; Click+drag to move
infoMessage = new JLabel(trans.get("RocketPanel.lbl.infoMessage")); infoMessage = new JLabel(trans.get("RocketPanel.lbl.infoMessage"));
infoMessage.setFont(new Font("Sans Serif", Font.PLAIN, 9)); infoMessage.setFont(new Font("Sans Serif", Font.PLAIN, 9));
add(infoMessage, "skip, span, gapleft 25, wrap"); bottomRow.add(infoMessage);
//// Show warnings
this.showWarnings = new JCheckBox(trans.get("RocketPanel.check.showWarnings"));
showWarnings.setSelected(true);
showWarnings.setToolTipText(trans.get("RocketPanel.check.showWarnings.ttip"));
bottomRow.add(showWarnings, "pushx, right");
showWarnings.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updateExtras();
updateFigures();
}
});
add(bottomRow, "skip, growx, span, gapleft 25");
addExtras(); addExtras();
} }
@ -782,6 +802,9 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
extraText.setMassWithMotors(cg.weight); extraText.setMassWithMotors(cg.weight);
extraText.setMassWithoutMotors( emptyInfo.getMass() ); extraText.setMassWithoutMotors( emptyInfo.getMass() );
extraText.setWarnings(warnings); extraText.setWarnings(warnings);
if (this.showWarnings != null) {
extraText.setShowWarnings(showWarnings.isSelected());
}
if (length > 0) { if (length > 0) {
figure3d.setCG(cg); figure3d.setCG(cg);