Skip to content

Commit

Permalink
More doc?
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Sep 23, 2013
1 parent 9084fe1 commit cddbc42
Show file tree
Hide file tree
Showing 20 changed files with 1,052 additions and 284 deletions.
1 change: 0 additions & 1 deletion src/dicom/dicomParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ dwv.dicom.DataReader = function(buffer, isLittleEndian)
* @param {Number} nChars The numner of characters to read.
* @return {String} The read data.
*/
//! Read data as a string.
this.readString = function(byteOffset, nChars) {
var result = "";
for(var i=byteOffset; i<byteOffset + nChars; ++i){
Expand Down
2 changes: 1 addition & 1 deletion src/html/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ dwv.html.Layer = function(name)
/**
* Set the line color for the layer.
* @method setLineColor
* @input {Layer} color The line color.
* @input {String} color The line color.
*/
this.setLineColor = function(color)
{
Expand Down
129 changes: 72 additions & 57 deletions src/html/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,81 @@ dwv.html = dwv.html || {};
*/
dwv.html.Style = function()
{
// immutable
this.fontSize = 12;
this.fontStr = "normal "+this.fontSize+"px sans-serif";
this.lineHeight = this.fontSize + this.fontSize/5;
this.textColor = "#fff";
// mutable
this.lineColor = 0;
};

/**
* Get the font size.
* @method getFontSize
* @return {Number} The font size.
*/
dwv.html.Style.prototype.getFontSize = function() {
return this.fontSize;
};
/**
* Font size.
* @property fontSize
* @private
* @type Number
*/
var fontSize = 12;
/**
* Font definition string.
* @property fontStr
* @private
* @type String
*/
var fontStr = "normal "+this.fontSize+"px sans-serif";
/**
* Line height.
* @property lineHeight
* @private
* @type Number
*/
var lineHeight = this.fontSize + this.fontSize/5;
/**
* Text color.
* @property textColor
* @private
* @type String
*/
var textColor = "#fff";
/**
* Line color.
* @property lineColor
* @private
* @type String
*/
var lineColor = 0;

/**
* Get the font size.
* @method getFontSize
* @return {Number} The font size.
*/
dwv.html.Style.prototype.getFontSize = function() { return fontSize; };

/**
* Get the font definition string.
* @method getFontStr
* @return {String} The font definition string.
*/
dwv.html.Style.prototype.getFontStr = function() {
return this.fontStr;
};
/**
* Get the font definition string.
* @method getFontStr
* @return {String} The font definition string.
*/
dwv.html.Style.prototype.getFontStr = function() { return fontStr; };

/**
* Get the line height.
* @method getLineHeight
* @return {Number} The line height.
*/
dwv.html.Style.prototype.getLineHeight = function() {
return this.lineHeight;
};
/**
* Get the line height.
* @method getLineHeight
* @return {Number} The line height.
*/
dwv.html.Style.prototype.getLineHeight = function() { return lineHeight; };

/**
* Get the text color.
* @method getTextColor
* @return {String} The text color.
*/
dwv.html.Style.prototype.getTextColor = function() {
return this.textColor;
};
/**
* Get the text color.
* @method getTextColor
* @return {String} The text color.
*/
dwv.html.Style.prototype.getTextColor = function() { return textColor; };

/**
* Get the line color.
* @method getLineColor
* @return {String} The line color.
*/
dwv.html.Style.prototype.getLineColor = function() {
return this.lineColor;
};
/**
* Get the line color.
* @method getLineColor
* @return {String} The line color.
*/
dwv.html.Style.prototype.getLineColor = function() { return lineColor; };

/**
* Set the line color.
* @method setLineColor
* @param {String} color The line color.
*/
dwv.html.Style.prototype.setLineColor = function(color) {
this.lineColor = color;
/**
* Set the line color.
* @method setLineColor
* @param {String} color The line color.
*/
dwv.html.Style.prototype.setLineColor = function(color) { lineColor = color; };
};

14 changes: 7 additions & 7 deletions src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,29 +162,29 @@ dwv.image.Image = function(size, spacing, buffer, slicePositions)
* Photometric interpretation (MONOCHROME, RGB...).
* @property photometricInterpretation
* @private
* @type {String}
* @type String
*/
var photometricInterpretation = "MONOCHROME2";
/**
* Planar configuration for RGB data (0:RGBRGBRGBRGB... or 1:RRR...GGG...BBB...).
* @property planarConfiguration
* @private
* @type {Number}
* @type Number
*/
var planarConfiguration = 0;
/**
* Meta information.
* @property meta
* @private
* @type {Object}
* @type Object
*/
var meta = {};

/**
* Original buffer.
* @property originalBuffer
* @private
* @type {Array}
* @type Array
*/
var originalBuffer = new Int16Array(buffer);

Expand All @@ -195,14 +195,14 @@ dwv.image.Image = function(size, spacing, buffer, slicePositions)
* Data range.
* @property dataRange
* @private
* @type {Object}
* @type Object
*/
var dataRange = null;
/**
* Histogram.
* @property histogram
* @private
* @type {Object}
* @type Array
*/
var histogram = null;

Expand Down Expand Up @@ -414,7 +414,7 @@ dwv.image.Image = function(size, spacing, buffer, slicePositions)
/**
* Get the histogram.
* @method getHistogram
* @return {Object} The histogram.
* @return {Array} The histogram.
*/
this.getHistogram = function() {
if( !histogram ) histogram = this.calculateHistogram();
Expand Down
2 changes: 1 addition & 1 deletion src/image/luts.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dwv.image.lut.Rescale = function(slope_,intercept_)
* @namespace dwv.image.lut
* @constructor
* @param {Number} rescaleLut_ The associated rescale LUT.
* @param {Number} isSigned_ Flag to know if the data is signed.
* @param {Boolean} isSigned_ Flag to know if the data is signed.
*/
dwv.image.lut.Window = function(rescaleLut_, isSigned_)
{
Expand Down
6 changes: 3 additions & 3 deletions src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ dwv.image.View = function(image, isSigned)
* Window presets.
* @property windowPresets
* @private
* @type {Object}
* @type Object
*/
var windowPresets = null;
/**
* Color map
* @property colorMap
* @private
* @type {Object}
* @type Object
*/
var colorMap = dwv.image.lut.plain;
/**
* Current position
* @property currentPosition
* @private
* @type {Object}
* @type Object
*/
var currentPosition = {"i":0,"j":0,"k":0};

Expand Down
2 changes: 1 addition & 1 deletion src/math/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dwv.math.FastPoint2D.prototype.toString = function() {
* @namespace dwv.math
* @constructor
* @param {Object} centre A Point2D representing the centre of the circle.
* @param {Object} radius The radius of the circle.
* @param {Number} radius The radius of the circle.
*/
dwv.math.Circle = function(centre, radius)
{
Expand Down
79 changes: 60 additions & 19 deletions src/tools/circle.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
//! @namespace Main DWV namespace.
/**
* Tool module.
* @module tool
*/
var dwv = dwv || {};
//! @namespace Tool classes.
dwv.tool = dwv.tool || {};

/**
* @class Draw circle command.
* @param points The points from which to extract the circle.
* @param app The application to draw the circle on.
* @param style The drawing style.
* Draw circle command.
* @class DrawCircleCommand
* @namespace dwv.tool
* @constructor
* @param {Array} points The points from which to extract the circle.
* @param {Object} app The application to draw the circle on.
* @param {Style} style The drawing style.
*/
dwv.tool.DrawCircleCommand = function(points, app, style)
{
// radius
// calculate radius
var a = Math.abs(points[0].getX() - points[points.length-1].getX());
var b = Math.abs(points[0].getY() - points[points.length-1].getY());
var radius = Math.round( Math.sqrt( a * a + b * b ) );
Expand All @@ -21,17 +26,54 @@ dwv.tool.DrawCircleCommand = function(points, app, style)
// silent fail...
return;
}
// create circle

/**
* Circle object.
* @property circle
* @private
* @type Circle
*/
var circle = new dwv.math.Circle(points[0], radius);

/**
* Line color.
* @property lineColor
* @private
* @type String
*/
var lineColor = style.getLineColor();
/**
* HTML context.
* @property context
* @private
* @type Object
*/
var context = app.getTempLayer().getContext();

// command name
/**
* Command name.
* @property name
* @private
* @type String
*/
var name = "DrawCircleCommand";
this.setName = function(str) { name = str; };
/**
* Get the command name.
* @method getName
* @return {String} The command name.
*/
this.getName = function() { return name; };
/**
* Set the command name.
* @method setName
* @param {String} str The command name.
*/
this.setName = function(str) { name = str; };

// main method
/**
* Execute the command.
* @method execute
*/
this.execute = function()
{
// style
Expand All @@ -40,23 +82,22 @@ dwv.tool.DrawCircleCommand = function(points, app, style)
// path
context.beginPath();
context.arc(
circle.getCenter().getX(),
circle.getCenter().getY(),
circle.getRadius(),
0, 2*Math.PI);
circle.getCenter().getX(),
circle.getCenter().getY(),
circle.getRadius(),
0, 2*Math.PI);
context.stroke();
// surface
var surf = circle.getWorldSurface(
app.getImage().getSpacing().getColumnSpacing(),
app.getImage().getSpacing().getRowSpacing() );
context.font = style.getFontStr();
context.fillText( Math.round(surf) + "mm2",
circle.getCenter().getX() + style.getFontSize(),
circle.getCenter().getY() + style.getFontSize());
circle.getCenter().getX() + style.getFontSize(),
circle.getCenter().getY() + style.getFontSize());
};
}; // DrawCircleCommand class

//Shape list
// Add the shape command to the command list
dwv.tool.shapes = dwv.tool.shapes || {};
//Add the shape command to the list
dwv.tool.shapes.circle = dwv.tool.DrawCircleCommand;
Loading

0 comments on commit cddbc42

Please sign in to comment.