Skip to content

Commit aa32122

Browse files
committed
Tool cleanup
1 parent e1ee786 commit aa32122

File tree

4 files changed

+22
-36
lines changed

4 files changed

+22
-36
lines changed

index.html

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,22 @@
5757
$("#test-scroll").click(function() {
5858
testscroll(0, app.files.length);
5959
});
60+
// Setup cluts
6061
for(clut in cluts) {
6162
$("#clut-select optgroup").append($("<option>").val(clut).text(clut));
6263
}
6364

65+
// Setup tools
66+
for(tool in tools) {
67+
var button = $("<div>").addClass("tool-button").text(tool);
68+
$("#button-bar-horz").prepend(button);
69+
$(button).click(function() {
70+
$(this).parent().find("div").removeClass("butt-selected");
71+
$(this).addClass("butt-selected");
72+
app.activate_tool(tool);
73+
});
74+
}
75+
6476
$("#slider").slider();
6577

6678
$("button").button();
@@ -141,22 +153,6 @@
141153
});
142154
*/
143155

144-
$("#butt-measure").click(function() {
145-
//$(this).parent().find("div").removeClass("butt-selected");
146-
//$(this).addClass("butt-selected");
147-
//app.activate_measure_tool();
148-
});
149-
150-
$("#butt-windowing").click(function() {
151-
$(this).parent().find("div").removeClass("butt-selected");
152-
$(this).addClass("butt-selected");
153-
app.activate_window_level_tool();
154-
});
155-
$("#butt-zooming").click(function() {
156-
$(this).parent().find("div").removeClass("butt-selected");
157-
$(this).addClass("butt-selected");
158-
app.activate_zoom_pan();
159-
});
160156
$("#butt-reset").click(function() {
161157
app.reset_levels();
162158
});
@@ -209,14 +205,8 @@ <h2>Viewer</h2>
209205
</optgroup>
210206
</select>
211207
<div id="button-bar-horz">
212-
<!--<div id="butt-measure" class="tool-button">Measure</div>-->
213-
<div id="butt-windowing" class="tool-button butt-selected">Windowing</div>
214-
<div id="butt-zooming" class="tool-button">Zoom/Pan</div>
215208
<div id="butt-reset" class="tool-button">Reset</div>
216209
</div>
217-
<!-- jj<div id="info" >
218-
Density: <div id="density"></div>
219-
</div>-->
220210
</div>
221211

222212
<div class="slider-holder">

js/app.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,25 +267,14 @@ DcmApp.prototype.draw_image = function() {
267267
this.painter.draw_image();
268268
}
269269

270-
271270
DcmApp.prototype.fill_metadata_table = function() {
272271
if(this.files.length == 0)
273272
return;
274273
fill_metadata_table(this.files[this.curr_file_idx]);
275274
}
276275

277-
DcmApp.prototype.activate_measure_tool = function() {
278-
this.curr_tool = new MeasureTool(this);
279-
this.curr_tool.set_file(this.files[this.curr_file_idx]);
280-
}
281-
282-
DcmApp.prototype.activate_window_level_tool = function() {
283-
this.curr_tool = new WindowLevelTool(this);
284-
this.curr_tool.set_file(this.files[this.curr_file_idx]);
285-
}
286-
287-
DcmApp.prototype.activate_zoom_pan = function() {
288-
this.curr_tool = new ZoomPanTool(this);
276+
DcmApp.prototype.activate_tool = function(tool_identifier) {
277+
this.curr_tool = new tools[tool_identifier](this);
289278
this.curr_tool.set_file(this.files[this.curr_file_idx]);
290279
}
291280

js/glpainter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ GLPainter.prototype.draw_image = function() {
367367

368368

369369
}
370-
off = (1 << (15 - 1));
371370

372371
GLPainter.prototype.init = function(canvasid) {
373372

js/tools.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function MeasureTool(app) {
7777
this.set_file = function(file) {
7878
this.file = file;
7979
}
80+
return this;
8081
}
8182

8283
function WindowLevelTool(app) {
@@ -117,6 +118,7 @@ function WindowLevelTool(app) {
117118

118119
this.set_file = function(file) {
119120
}
121+
return this;
120122
}
121123

122124
function ZoomPanTool(app) {
@@ -164,4 +166,10 @@ function ZoomPanTool(app) {
164166

165167
this.set_file = function(file) {
166168
}
169+
return this;
170+
}
171+
172+
tools = {
173+
'Windowing': WindowLevelTool,
174+
'Zoom/Pan': ZoomPanTool,
167175
}

0 commit comments

Comments
 (0)