[#1926] Switch to match fore diameter when nose cone is flipped

This commit is contained in:
SiboVG 2022-12-26 14:23:03 +01:00
parent 4d65a65a30
commit f9bd7e672c
3 changed files with 17 additions and 2 deletions

View File

@ -2151,7 +2151,9 @@ ExportDecalDialog.source.exception = Could not find decal source file ''{0}''.<b
ComponentPresetChooserDialog.title = Choose component preset
ComponentPresetChooserDialog.filter.label = Filter by text:
ComponentPresetChooserDialog.checkbox.filterAftDiameter = Match aft diameter
ComponentPresetChooserDialog.checkbox.filterAftDiameter.ttip = Search for components with the same aft diameter as the next component
ComponentPresetChooserDialog.checkbox.filterForeDiameter = Match fore diameter
ComponentPresetChooserDialog.checkbox.filterForeDiameter.ttip = Search for components with the same fore diameter as the previous component
ComponentPresetChooserDialog.menu.sortAsc = Sort Ascending
ComponentPresetChooserDialog.menu.sortDesc = Sort Descending
ComponentPresetChooserDialog.menu.units = Units

View File

@ -270,9 +270,12 @@ public class NoseCone extends Transition implements InsideColorComponent {
@Override
protected void loadFromPreset(ComponentPreset preset) {
// We first need to unflip, because the preset loading always applies settings for a normal nose cone (e.g. aft diameter)
boolean flipped = isFlipped;
setFlipped(false);
//Many parameters are handled by the super class Transition.loadFromPreset
super.loadFromPreset(preset);
setFlipped(flipped);
}
/**

View File

@ -35,6 +35,7 @@ import net.sf.openrocket.gui.util.SwingPreferences;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.preset.TypedKey;
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
import net.sf.openrocket.startup.Application;
@ -257,6 +258,7 @@ public class ComponentPresetChooserDialog extends JDialog {
* Add filter by fore diameter
*/
foreDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterForeDiameter"));
foreDiameterFilterCheckBox.setToolTipText(trans.get("ComponentPresetChooserDialog.checkbox.filterForeDiameter.ttip"));
final SymmetricComponent prevSym = curSym.getPreviousSymmetricComponent();
if (prevSym != null && foreDiameterColumnIndex >= 0) {
foreDiameterFilterCheckBox.setSelected(preferences.isMatchForeDiameter());
@ -274,8 +276,16 @@ public class ComponentPresetChooserDialog extends JDialog {
/*
* Add filter by aft diameter
*/
aftDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterAftDiameter"));
final SymmetricComponent nextSym = curSym.getNextSymmetricComponent();
final SymmetricComponent nextSym;
if (curSym instanceof NoseCone && ((NoseCone) curSym).isFlipped()) {
aftDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterForeDiameter"));
aftDiameterFilterCheckBox.setToolTipText(trans.get("ComponentPresetChooserDialog.checkbox.filterForeDiameter.ttip"));
nextSym = curSym.getPreviousSymmetricComponent();
} else {
aftDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterAftDiameter"));
aftDiameterFilterCheckBox.setToolTipText(trans.get("ComponentPresetChooserDialog.checkbox.filterAftDiameter.ttip"));
nextSym = curSym.getNextSymmetricComponent();
}
if (nextSym != null && aftDiameterColumnIndex >= 0) {
aftDiameterFilterCheckBox.setSelected(preferences.isMatchAftDiameter());
aftDiameterFilter = new ComponentPresetRowFilter(nextSym.getForeRadius() * 2.0, aftDiameterColumnIndex);