Skip to content

Commit 1d8a8ce

Browse files
committed
Adds a presentation mode
1 parent 13d6cd7 commit 1d8a8ce

File tree

20 files changed

+88
-64
lines changed

20 files changed

+88
-64
lines changed

distribution/ReleaseNotes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Release Notes
22

33
HEAD, planned as v0.30
4+
- Adds a presentation mode.
45
- The remote server is now disabled by default.
56
It must be enabled in the settings.
67

src/main/java/de/neemann/digital/core/element/Keys.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ private static File getATMISPPath() {
736736
static {
737737
String language = Locale.getDefault().getLanguage();
738738
SETTINGS_USE_EQUALS_KEY = new Key<>("equalsInsteadOfPlus",
739-
language.equals("en") || language.equals("fr")).setSecondary();
739+
language.equals("en") || language.equals("fr"));
740740
}
741741

742742
/**
@@ -832,12 +832,6 @@ private static File getATMISPPath() {
832832
public static final Key<File> SETTINGS_IVERILOG_PATH
833833
= new Key.KeyFile("iverilogPath", new File("iverilog")).setSecondary();
834834

835-
/**
836-
* Avoid component tooltips in the main panel
837-
*/
838-
public static final Key<Boolean> SETTINGS_NOTOOLTIPS =
839-
new Key<>("noComponentToolTips", false);
840-
841835
/**
842836
* Shape used to represent a visual element
843837
*/

src/main/java/de/neemann/digital/draw/elements/Circuit.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,25 @@ public ElementAttributes getAttributes() {
257257
}
258258

259259
/**
260-
* Draws tis circuit using the given graphic instance
260+
* Draws this circuit using the given graphic instance
261261
*
262262
* @param graphic the graphic instance used
263263
*/
264264
public void drawTo(Graphic graphic) {
265265
drawTo(graphic, EMPTY_SET, null, SyncAccess.NOSYNC);
266266
}
267267

268+
/**
269+
* Draws this circuit using the given graphic instance
270+
*
271+
* @param graphic the graphic instance used
272+
* @param presentingMode if true the test cases are not drawn
273+
*/
274+
public void drawTo(Graphic graphic, boolean presentingMode) {
275+
drawTo(graphic, EMPTY_SET, null, SyncAccess.NOSYNC, presentingMode);
276+
}
277+
278+
268279
/**
269280
* Draws this circuit using the given graphic instance
270281
*
@@ -274,6 +285,19 @@ public void drawTo(Graphic graphic) {
274285
* @param modelSync sync interface to access the model. Is locked while drawing circuit
275286
*/
276287
public void drawTo(Graphic graphic, Collection<Drawable> highLighted, Style highlight, SyncAccess modelSync) {
288+
drawTo(graphic, highLighted, highlight, modelSync, false);
289+
}
290+
291+
/**
292+
* Draws this circuit using the given graphic instance
293+
*
294+
* @param graphic the graphic instance used
295+
* @param highLighted a list of Drawables to highlight
296+
* @param highlight style used to draw the highlighted elements
297+
* @param modelSync sync interface to access the model. Is locked while drawing circuit
298+
* @param presentingMode if true the test cases are omitted
299+
*/
300+
public void drawTo(Graphic graphic, Collection<Drawable> highLighted, Style highlight, SyncAccess modelSync, boolean presentingMode) {
277301
if (!dotsPresent) {
278302
new DotCreator(wires).applyDots();
279303
dotsPresent = true;
@@ -293,9 +317,11 @@ public void drawTo(Graphic graphic, Collection<Drawable> highLighted, Style high
293317
w.drawTo(graphic, highLighted.contains(w) ? highlight : null);
294318
graphic.closeGroup();
295319
for (VisualElement p : visualElements) {
296-
graphic.openGroup();
297-
p.drawTo(graphic, highLighted.contains(p) ? highlight : null);
298-
graphic.closeGroup();
320+
if (!presentingMode || !p.equalsDescription(TestCaseElement.DESCRIPTION)) {
321+
graphic.openGroup();
322+
p.drawTo(graphic, highLighted.contains(p) ? highlight : null);
323+
graphic.closeGroup();
324+
}
299325
}
300326
}
301327

src/main/java/de/neemann/digital/draw/graphics/Export.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Export {
2323

2424
private final Circuit circuit;
2525
private final ExportFactory factory;
26+
private final boolean hideTests;
2627

2728
/**
2829
* Creates a new instance
@@ -31,8 +32,20 @@ public class Export {
3132
* @param factory the factory to create the graphics instance
3233
*/
3334
public Export(Circuit circuit, ExportFactory factory) {
35+
this(circuit, factory, false);
36+
}
37+
38+
/**
39+
* Creates a new instance
40+
*
41+
* @param circuit the circuit to export
42+
* @param factory the factory to create the graphics instance
43+
* @param hideTests if true tests are hidden
44+
*/
45+
public Export(Circuit circuit, ExportFactory factory, boolean hideTests) {
3446
this.circuit = circuit;
3547
this.factory = factory;
48+
this.hideTests = hideTests;
3649
}
3750

3851
/**
@@ -61,16 +74,16 @@ public void export(File file) throws IOException {
6174
public void export(OutputStream out) throws IOException {
6275
try (Graphic gr = factory.create(out)) {
6376
GraphicMinMax minMax = new GraphicMinMax(gr);
64-
circuit.drawTo(minMax);
77+
circuit.drawTo(minMax, hideTests);
6578

6679
if (minMax.isValid()) {
6780
gr.setBoundingBox(minMax.getMin(), minMax.getMax());
6881

6982
GraphicLineCollector glc = new GraphicLineCollector();
70-
circuit.drawTo(glc);
83+
circuit.drawTo(glc, hideTests);
7184
glc.drawTo(gr);
7285

73-
circuit.drawTo(new GraphicSkipLines(gr));
86+
circuit.drawTo(new GraphicSkipLines(gr), hideTests);
7487
} else
7588
throw new IOException(Lang.get("err_circuitContainsNoComponents"));
7689
}

src/main/java/de/neemann/digital/draw/library/JarComponentManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* Used to attach custom components
2424
*/
2525
public class JarComponentManager implements ComponentManager, Iterable<JarComponentManager.AdditionalShape> {
26-
private ElementLibrary library;
27-
private ArrayList<AdditionalShape> additionalShapes;
26+
private final ElementLibrary library;
27+
private final ArrayList<AdditionalShape> additionalShapes;
2828

2929
JarComponentManager(ElementLibrary library) {
3030
this.library = library;

src/main/java/de/neemann/digital/gui/Main.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ public void actionPerformed(ActionEvent e) {
413413
});
414414
treeCheckBox.setAccelerator(KeyStroke.getKeyStroke("F5"));
415415

416+
JCheckBoxMenuItem presentingMode = new JCheckBoxMenuItem(Lang.get("menu_presentingMode"));
417+
presentingMode.setToolTipText(Lang.get("menu_presentingMode_tt"));
418+
presentingMode.addActionListener(actionEvent -> circuitComponent.setPresentingMode(presentingMode.isSelected()));
419+
presentingMode.setAccelerator(KeyStroke.getKeyStroke("F4"));
420+
416421
ToolTipAction tutorial = new ToolTipAction(Lang.get("menu_tutorial")) {
417422
@Override
418423
public void actionPerformed(ActionEvent e) {
@@ -450,6 +455,7 @@ public void actionPerformed(ActionEvent actionEvent) {
450455
view.add(scaleMenu);
451456
view.addSeparator();
452457
view.add(treeCheckBox);
458+
view.add(presentingMode);
453459
view.addSeparator();
454460
view.add(tutorial.createJMenuItem());
455461
view.addSeparator();
@@ -1885,7 +1891,8 @@ public void actionPerformed(ActionEvent e) {
18851891
new SaveAsHelper(Main.this, fc, suffix).checkOverwrite(
18861892
file -> {
18871893
settings.setFile("exportDirectory", file.getParentFile());
1888-
new Export(circuitComponent.getCircuitOrShallowCopy(), exportFactory).export(file);
1894+
new Export(circuitComponent.getCircuitOrShallowCopy(), exportFactory,
1895+
circuitComponent.getPresentingMode()).export(file);
18891896
}
18901897
);
18911898
}

src/main/java/de/neemann/digital/gui/Settings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ private static List<Key> createKeyList() {
4848
intList.add(Keys.SETTINGS_DEFAULT_TREESELECT);
4949
intList.add(Keys.SETTINGS_GRID);
5050
intList.add(Keys.SETTINGS_SHOW_WIRE_BITS);
51-
intList.add(Keys.SETTINGS_NOTOOLTIPS);
5251
intList.add(Keys.SETTINGS_WIRETOOLTIP);
5352
intList.add(Keys.SETTINGS_LIBRARY_PATH);
5453
intList.add(Keys.SETTINGS_JAR_PATH);

src/main/java/de/neemann/digital/gui/components/CircuitComponent.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
9191
ATTR_LIST.add(Keys.IS_GENERIC);
9292
}
9393

94+
9495
/**
9596
* @return returns the list of circuit attributes
9697
*/
@@ -148,6 +149,7 @@ public static ArrayList<Key> getAttrList() {
148149
private boolean toolTipHighlighted = false;
149150
private NetList toolTipNetList;
150151
private String lastUsedTunnelName;
152+
private boolean presentingMode;
151153

152154
/**
153155
* Creates a new instance
@@ -589,13 +591,13 @@ public String getToolTipText(MouseEvent event) {
589591
Vector pos = getPosVector(event);
590592
VisualElement ve = circuit.getElementAt(pos);
591593
if (ve != null) {
594+
if (presentingMode)
595+
return null;
596+
592597
Pin p = ve.getPinAt(raster(pos));
593598
if (p != null)
594599
return createPinToolTip(p);
595600

596-
if (Settings.getInstance().get(Keys.SETTINGS_NOTOOLTIPS))
597-
return null;
598-
599601
try {
600602
ElementTypeDescription etd = library.getElementType(ve.getElementName());
601603
String tt = etd.getDescription(ve.getElementAttributes());
@@ -880,13 +882,13 @@ protected void paintComponent(Graphics g) {
880882
gr2.setColor(ColorScheme.getSelected().getColor(ColorKey.BACKGROUND));
881883
gr2.fillRect(0, 0, getWidth(), getHeight());
882884

883-
if (scaleX > 0.3 && Settings.getInstance().get(Keys.SETTINGS_GRID))
885+
if (scaleX > 0.3 && Settings.getInstance().get(Keys.SETTINGS_GRID) && !presentingMode)
884886
drawGrid(gr2);
885887

886888
gr2.transform(transform);
887889

888890
long time = System.currentTimeMillis();
889-
getCircuitOrShallowCopy().drawTo(gr, highLighted, highLightStyle, modelSync);
891+
getCircuitOrShallowCopy().drawTo(gr, highLighted, highLightStyle, modelSync, presentingMode);
890892
time = System.currentTimeMillis() - time;
891893

892894
boolean scaleHasChanged = lastScaleX != scaleX;
@@ -1037,7 +1039,7 @@ public void setCircuit(Circuit circuit) {
10371039
*/
10381040
public void fitCircuit() {
10391041
GraphicMinMax gr = new GraphicMinMax();
1040-
getCircuitOrShallowCopy().drawTo(gr);
1042+
getCircuitOrShallowCopy().drawTo(gr, presentingMode);
10411043

10421044
AffineTransform newTrans = new AffineTransform();
10431045
if (gr.getMin() != null && getWidth() != 0 && getHeight() != 0) {
@@ -1503,6 +1505,23 @@ public void setCopy(Circuit circuit) {
15031505
shallowCopy = circuit;
15041506
}
15051507

1508+
/**
1509+
* Sets the hide tests flag
1510+
*
1511+
* @param presentingMode if true, tests are hidden
1512+
*/
1513+
public void setPresentingMode(boolean presentingMode) {
1514+
this.presentingMode = presentingMode;
1515+
graphicHasChanged();
1516+
}
1517+
1518+
/**
1519+
* @return the "tests are hidden" flag
1520+
*/
1521+
public boolean getPresentingMode() {
1522+
return presentingMode;
1523+
}
1524+
15061525
private final class PlusMinusAction extends ToolTipAction {
15071526
private final int delta;
15081527

src/main/resources/lang/lang_de.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,9 +1534,6 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
15341534
<string name="key_dipDefault_tt">Der Vorgabewert des DIP-Schalters, wenn die Simulation gestartet wird.</string>
15351535
<string name="key_macMouse">Die MacOS Mausklicks verwenden.</string>
15361536
<string name="key_macMouse_tt">Das unter MacOS übliche STRG-Klick anstelle von Rechtsklick verwenden.</string>
1537-
<string name="key_noComponentToolTips">Keine ToolTips für Bauteile auf der Arbeitsfläche.</string>
1538-
<string name="key_noComponentToolTips_tt">Wenn gesetzt, werden keine ToolTips für die Bauteile auf der Arbeitsfläche angezeigt.
1539-
Vor allem in einer Präsentation können diese ToolTips sehr störend sein.</string>
15401537
<string name="key_tunnelRenameDialog">Dialog zum automatischen umbenennen von Tunneln anzeigen</string>
15411538
<string name="key_tunnelRenameDialog_tt">Wenn gesetzt, wird nach dem Umbenennen eines Tunnels ein Dialog für automatisches Umbenennen
15421539
aller gleichnamigen Tunnel angezeigt.</string>
@@ -1978,6 +1975,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
19781975
<string name="menu_insertAsNew_tt">Der Inhalt der Zwischenablage wird in einem neuen Fenster geöffnet.</string>
19791976
<string name="menu_treeSelect">Baumansicht der Bauteile</string>
19801977
<string name="menu_treeSelect_tt">Zeigt am linken Rand des Fensters eine Baumansicht der verfügbaren Bauteile.</string>
1978+
<string name="menu_presentingMode">Präsentationsmodus</string>
1979+
<string name="menu_presentingMode_tt">Eine vereinfachte Darstellung, die z.B. die Testfälle auslässt, was für Präsentationen hilfreich sein kann.</string>
19811980

19821981
<string name="menu_special">Sonderfunktionen 74xx</string>
19831982
<string name="menu_addPrefix">IO-Präfix anfügen</string>

src/main/resources/lang/lang_en.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,9 +1522,6 @@
15221522

15231523
<string name="key_macMouse">Use macOS mouse clicks.</string>
15241524
<string name="key_macMouse_tt">Uses CTRL-click instead of right-click.</string>
1525-
<string name="key_noComponentToolTips">No tool tips for components on the main panel.</string>
1526-
<string name="key_noComponentToolTips_tt">If set, no tool tips for the components on the main panel are displayed.
1527-
Especially in a presentation, these tool tips can be very annoying.</string>
15281525
<string name="key_tunnelRenameDialog">Show dialog for automatic renaming of tunnels.</string>
15291526
<string name="key_tunnelRenameDialog_tt">If set, a dialog for automatically renaming all tunnels of the same name is displayed after a
15301527
tunnel has been renamed.</string>
@@ -1959,6 +1956,9 @@
19591956
<string name="menu_probe_memory_tt">Shows the content of memory components.</string>
19601957
<string name="menu_treeSelect">Component Tree View</string>
19611958
<string name="menu_treeSelect_tt">Shows a tree view of available components at the left side.</string>
1959+
<string name="menu_presentingMode">Presentation mode</string>
1960+
<string name="menu_presentingMode_tt">A simplified view that, for example, omits the test cases, which can be useful for presentations.</string>
1961+
19621962
<string name="menu_karnaughMap">K-Map</string>
19631963
<string name="menu_karnaughMap_tt">Shows a K-map representation of the table!</string>
19641964

0 commit comments

Comments
 (0)