-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathImageEnhancements.js
More file actions
275 lines (216 loc) · 10.7 KB
/
ImageEnhancements.js
File metadata and controls
275 lines (216 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
// ****************************************************************************
// ImageEnhancements — Standalone version of AutoIntegrate image enhancements
// ****************************************************************************
#feature-id AutoIntegrate > Image Enhancements
#feature-info Image Enhancements using AutoIntegrate tools.
#ifndef NO_SOLVER_LIBRARY
#define NO_SOLVER_LIBRARY
#endif
#ifndef AUTOINTEGRATE_STANDALONE
#define AUTOINTEGRATE_STANDALONE
#endif
#include "AutoIntegrateGlobal.js"
#include "AutoIntegrateUtil.js"
#include "AutoIntegrateGUITools.js"
#include "AutoIntegrateEnhancementsGUI.js"
#include "AutoIntegrateEngine.js"
#include "AutoIntegratePreview.js"
// =============================================================================
// Dummy flowchart routines
// =============================================================================
#ifndef AUTOINTEGRATEDUMMYFLOWCHART
#define AUTOINTEGRATEDUMMYFLOWCHART
function AutoIntegrateDummyFlowchart()
{
this.__base__ = Object;
this.__base__();
this.flowchartOperation = function () {};
this.flowchartOperationEnd = function () {};
this.flowchartParentBegin = function () {};
this.flowchartParentEnd = function () {};
this.flowchartChildBegin = function () {};
this.flowchartChildEnd = function () {};
this.flowchartMaskBegin = function () {};
this.flowchartMaskEnd = function () {};
this.flowchartInit = function () {};
this.flowchartDone = function () {};
this.flowchartReset = function () {};
this.flowchartPrint = function () {};
}
AutoIntegrateDummyFlowchart.prototype = new Object;
#endif /* AUTOINTEGRATEDUMMYFLOWCHART */
// =============================================================================
// DIALOG WITH PREVIEW
// =============================================================================
function AutoIntegrateImageEnhancementsDialog() {
this.__base__ = Dialog;
this.__base__();
var self = this;
var debug = false;
this.TITLE = "Image Enhancements";
this.VERSION = "1.00";
this.windowTitle = this.TITLE + " v" + this.VERSION;
// this.minWidth = 1000;
var global = new AutoIntegrateGlobal();
this.global = global;
global.debug = debug;
for (let i = 0; i < jsArguments.length; i++) {
if (jsArguments[i] == "do_not_read_settings") {
console.writeln("do_not_read_settings");
global.do_not_read_settings = true;
}
}
var util = new AutoIntegrateUtil(global);
this.util = util;
var flowchart = new AutoIntegrateDummyFlowchart();
var engine = new AutoIntegrateEngine(global, util, flowchart);
var guitools = new AutoIntegrateGUITools(this, global, util, engine);
// Read parameter default settings from persistent module settings.
// These can be saved using the AutoIntegrate script.
util.initStandalone();
// -------------------------------------------------------------------------
// Status
// -------------------------------------------------------------------------
this.statusLabel = new Label(this);
this.statusLabel.text = "";
this.statusLabel.textAlignment = TextAlign_Center;
this.statusLabel.styleSheet = "color: #AAAAAA;";
// -------------------------------------------------------------------------
// Preview functions
// -------------------------------------------------------------------------
function setPreviewIdReset(id, keep_zoom, histogramInfo)
{
if (debug) console.writeln("AutoIntegrateImageEnhancementsDialog::updatePreviewIdReset: id = " + id);
var win = ImageWindow.windowById(id);
self.previewControl.SetImage(win.mainView.image, win.mainView.id + " [Preview]");
}
function updatePreviewIdReset(id, keep_zoom, histogramInfo)
{
if (debug) console.writeln("AutoIntegrateImageEnhancementsDialog::updatePreviewIdReset: id = " + id);
updatePreviewWin(ImageWindow.windowById(id));
}
function updatePreviewNoImage()
{
if (debug) console.writeln("AutoIntegrateImageEnhancementsDialog::updatePreviewNoImage");
self.statusLabel.text = "No image available for preview.";
}
function updatePreviewTxt(txt)
{
if (debug) console.writeln("AutoIntegrateImageEnhancementsDialog::updatePreviewTxt: " + txt);
}
function updatePreviewWin(imgWin)
{
if (debug) console.writeln("AutoIntegrateImageEnhancementsDialog::updatePreviewWin: imgWin = " + imgWin);
self.previewControl.UpdateImage(imgWin.mainView.image);
}
function updatePreviewWinTxt(imgWin, txt)
{
if (debug) console.writeln("AutoIntegrateImageEnhancementsDialog::updatePreviewWinTxt: imgWin = " + imgWin);
updatePreviewWin(imgWin);
}
var preview_functions = {
setPreviewIdReset: setPreviewIdReset,
updatePreviewIdReset: updatePreviewIdReset,
updatePreviewTxt: updatePreviewTxt,
updatePreviewNoImage: updatePreviewNoImage,
createCombinedMosaicPreviewWin: null,
updatePreviewWin: updatePreviewWin,
updatePreviewWinTxt: updatePreviewWinTxt,
};
// -------------------------------------------------------------------------
// Left Side: Preview Control
// -------------------------------------------------------------------------
this.previewControl = new AutoIntegratePreviewControl(this, "enhancements_preview", engine, util, global, 600, 600, false);
this.leftSizer = new VerticalSizer;
this.leftSizer.spacing = 4;
this.leftSizer.add(this.previewControl, 600);
// -------------------------------------------------------------------------
// Right Side: Title and Controls
// -------------------------------------------------------------------------
this.titleLabel = new Label(this);
this.titleLabel.text = this.TITLE + " v" + this.VERSION;
this.titleLabel.textAlignment = TextAlign_Center;
this.titleLabel.styleSheet = "font-size: 14pt; font-weight: bold; color: #4488FF;";
this.subtitleLabel = new Label(this);
this.subtitleLabel.text = "Select image and apply enhancements";
this.subtitleLabel.textAlignment = TextAlign_Center;
this.subtitleLabel.styleSheet = "font-size: 9pt; color: #888888; font-style: italic;";
this.enhancements_gui = new AutoIntegrateEnhancementsGUI(this, guitools, util, global, engine, preview_functions);
this.enhancements_gui.setPreviewControl(this.previewControl);
this.enhancementsGUIControls = this.enhancements_gui.createEnhancementsGUIControls(this);
this.GraXpertPathSizerSectionLabel = guitools.newSectionLabel(this, "GraXpert path");
this.GraXpertPathSizer = guitools.createGraXpertPathSizer(this);
this.toolsControl = guitools.createImageToolsControl(this);
this.toolsControl.sizer.add( this.GraXpertPathSizerSectionLabel );
this.toolsControl.sizer.add( this.GraXpertPathSizer );
this.toolsControl.visible = false;
// -------------------------------------------------------------------------
// Load and save JSON controls
// -------------------------------------------------------------------------
var obj = guitools.newJsonSizerObj(this, null, "ImageEnhancementsSettings.json");
this.loadSaveSizer = obj.sizer;
// -------------------------------------------------------------------------
// Enhancements Group Box
// -------------------------------------------------------------------------
if (global.debug) console.writeln("AutoIntegrateImageEnhancementsDialog:: creating enhancementsGroupBox");
this.enhancementsGroupBox = guitools.newGroupBoxSizer(this);
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.enhancementsGUIControls.targetImageControl, "Target image for enhancements", "EnhancementsTarget");
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.enhancementsGUIControls.optionsControl, "Misc options", "EnhancementsOptions");
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.enhancementsGUIControls.narrowbandControl, "Narrowband enhancements", "Enhancements2");
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.enhancementsGUIControls.selectiveColorControl, "Selective Color", "Enhancements3");
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.enhancementsGUIControls.genericControl, "Generic enhancements", "Enhancements1");
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.enhancementsGUIControls.starsControl, "Stars enhancements", "EnhancementsStars");
guitools.newSectionBarAdd(this, this.enhancementsGroupBox, this.toolsControl, "Tools", "EnhancementsTools");
this.enhancementsGroupBox.sizer.addStretch();
// -------------------------------------------------------------------------
// Buttons
// -------------------------------------------------------------------------
this.resetButton = new PushButton(this);
this.resetButton.text = "Reset";
this.resetButton.toolTip = "Reset all parameters to defaults.";
this.resetButton.onClick = function() {
util.setParameterDefaults();
};
this.closeButton = new PushButton(this);
this.closeButton.text = "Close";
this.closeButton.icon = this.scaledResource(":/icons/close.png");
this.closeButton.onClick = function() {
self.ok();
};
this.buttonsSizer = new HorizontalSizer;
this.buttonsSizer.spacing = 6;
this.buttonsSizer.add(this.resetButton);
this.buttonsSizer.addStretch();
this.buttonsSizer.add(this.closeButton);
// -------------------------------------------------------------------------
// Right Side Layout
// -------------------------------------------------------------------------
this.rightSizer = new VerticalSizer;
this.rightSizer.spacing = 8;
this.rightSizer.add(this.titleLabel);
this.rightSizer.add(this.subtitleLabel);
this.rightSizer.add(this.statusLabel);
this.rightSizer.add(this.loadSaveSizer);
this.rightSizer.add(this.enhancementsGroupBox);
this.rightSizer.add(this.buttonsSizer);
// -------------------------------------------------------------------------
// Main Layout (Preview on Left, Controls on Right)
// -------------------------------------------------------------------------
this.sizer = new HorizontalSizer;
this.sizer.margin = 8;
this.sizer.spacing = 8;
this.sizer.add(this.leftSizer);
this.sizer.add(this.rightSizer);
}
AutoIntegrateImageEnhancementsDialog.prototype = new Dialog;
// =============================================================================
// MAIN ENTRY POINT
// =============================================================================
#ifndef AUTOINTEGRATE_NO_MAIN
function main() {
console.show();
var dialog = new AutoIntegrateImageEnhancementsDialog();
dialog.execute();
}
main();
#endif // AUTOINTEGRATE_NO_MAIN