📄 truesize.cpp
字号:
//
// else
//
} else {
//
// done = 1;
//
done = _mxarray0_;
}
//
// end
//
}
//
// end
//
}
//
//
// newFigWidth = max(newFigWidth, minFigWidth);
//
newFigWidth
= max(
mwVv(newFigWidth, "newFigWidth"), mwVv(minFigWidth, "minFigWidth"));
//
// newFigHeight = max(newFigHeight, minFigHeight);
//
newFigHeight
= max(
mwVv(newFigHeight, "newFigHeight"),
mwVv(minFigHeight, "minFigHeight"));
//
//
// figPos(1) = max(1, figPos(1) - floor((newFigWidth - figPos(3))/2));
//
mclIntArrayAssign(
&figPos,
max(
_mxarray0_,
mclIntArrayRef(mwVv(figPos, "figPos"), 1)
- floor(
(mwVv(newFigWidth, "newFigWidth")
- mclIntArrayRef(mwVv(figPos, "figPos"), 3))
/ _mxarray1_)),
1);
//
// figPos(2) = max(1, figPos(2) - floor((newFigHeight - figPos(4))/2));
//
mclIntArrayAssign(
&figPos,
max(
_mxarray0_,
mclIntArrayRef(mwVv(figPos, "figPos"), 2)
- floor(
(mwVv(newFigHeight, "newFigHeight")
- mclIntArrayRef(mwVv(figPos, "figPos"), 4))
/ _mxarray1_)),
2);
//
// figPos(3) = newFigWidth;
//
mclIntArrayAssign(&figPos, mwVv(newFigWidth, "newFigWidth"), 3);
//
// figPos(4) = newFigHeight;
//
mclIntArrayAssign(&figPos, mwVv(newFigHeight, "newFigHeight"), 4);
//
//
// % Translate figure position if necessary
// deltaX = (screenSize(3) - figRightBorder) - (figPos(1) + figPos(3));
//
deltaX
= mclIntArrayRef(mwVv(screenSize, "screenSize"), 3)
- mwVv(figRightBorder, "figRightBorder")
- (mclIntArrayRef(mwVv(figPos, "figPos"), 1)
+ mclIntArrayRef(mwVv(figPos, "figPos"), 3));
//
// if (deltaX < 0)
//
if (mclLtBool(mwVv(deltaX, "deltaX"), _mxarray53_)) {
//
// figPos(1) = figPos(1) + deltaX;
//
mclIntArrayAssign(
&figPos,
mclIntArrayRef(mwVv(figPos, "figPos"), 1) + mwVv(deltaX, "deltaX"),
1);
//
// end
//
}
//
// deltaY = (screenSize(4) - figTopBorder) - (figPos(2) + figPos(4));
//
deltaY
= mclIntArrayRef(mwVv(screenSize, "screenSize"), 4)
- mwVv(figTopBorder, "figTopBorder")
- (mclIntArrayRef(mwVv(figPos, "figPos"), 2)
+ mclIntArrayRef(mwVv(figPos, "figPos"), 4));
//
// if (deltaY < 0)
//
if (mclLtBool(mwVv(deltaY, "deltaY"), _mxarray53_)) {
//
// figPos(2) = figPos(2) + deltaY;
//
mclIntArrayAssign(
&figPos,
mclIntArrayRef(mwVv(figPos, "figPos"), 2) + mwVv(deltaY, "deltaY"),
2);
//
// end
//
}
//
//
// % Figure out where to place the axes object in the
// % resized figure. Make sure axes width and height are at least 1.
// gutterWidth = figPos(3) - imageWidth;
//
gutterWidth
= mclIntArrayRef(mwVv(figPos, "figPos"), 3)
- mwVv(imageWidth, "imageWidth");
//
// gutterHeight = figPos(4) - imageHeight;
//
gutterHeight
= mclIntArrayRef(mwVv(figPos, "figPos"), 4)
- mwVv(imageHeight, "imageHeight");
//
// gutterLeft = floor(gutterWidth/2);
//
gutterLeft = floor(mwVv(gutterWidth, "gutterWidth") / _mxarray1_);
//
// gutterBottom = floor(gutterHeight/2);
//
gutterBottom = floor(mwVv(gutterHeight, "gutterHeight") / _mxarray1_);
//
//
// axPos(1) = gutterLeft + 1;
//
mclIntArrayAssign(&axPos, mwVv(gutterLeft, "gutterLeft") + _mxarray0_, 1);
//
// axPos(2) = gutterBottom + 1;
//
mclIntArrayAssign(
&axPos, mwVv(gutterBottom, "gutterBottom") + _mxarray0_, 2);
//
// axPos(3) = max(imageWidth,1);
//
mclIntArrayAssign(
&axPos, max(mwVv(imageWidth, "imageWidth"), _mxarray0_), 3);
//
// axPos(4) = max(imageHeight,1);
//
mclIntArrayAssign(
&axPos, max(mwVv(imageHeight, "imageHeight"), _mxarray0_), 4);
//
//
// set(figHandle, 'Position', figPos)
//
ans.EqPrintAns(
Nset(
0,
mwVarargin(
mwVv(figHandle, "figHandle"), _mxarray58_, mwVv(figPos, "figPos"))));
//
// set(axHandle, 'Position', axPos);
//
ans.EqAns(
Nset(
0,
mwVarargin(
mwVa(axHandle, "axHandle"), _mxarray58_, mwVv(axPos, "axPos"))));
//
//
// % Restore the units
// drawnow; % necessary to work around HG bug -SLE
//
drawnow(mwArray::DIN);
//
// set(figHandle, 'Units', figUnits);
//
ans.EqAns(
Nset(
0,
mwVarargin(
mwVv(figHandle, "figHandle"),
_mxarray54_,
mwVv(figUnits, "figUnits"))));
//
// set(axHandle, 'Units', axUnits);
//
ans.EqAns(
Nset(
0,
mwVarargin(
mwVa(axHandle, "axHandle"), _mxarray54_, mwVv(axUnits, "axUnits"))));
//
// set(0, 'Units', rootUnits);
//
ans.EqAns(
Nset(
0, mwVarargin(_mxarray53_, _mxarray54_, mwVv(rootUnits, "rootUnits"))));
//
//
// % Set the nextplot property of the figure so that the
// % axes object gets deleted and replaced for the next plot.
// % That way, the new plot gets drawn in the default position.
// set(figHandle, 'NextPlot', 'replacechildren');
//
ans.EqAns(
Nset(
0, mwVarargin(mwVv(figHandle, "figHandle"), _mxarray69_, _mxarray71_)));
//
//
// % Warn if the display is not truesize, unless warning is disabled
// % according to toolbox preference setting.
// if ((scale < 100) & strcmp(iptgetpref('TruesizeWarning'), 'on'))
//
{
mwArray a_ = mwVv(scale, "scale") < _mxarray61_;
if (tobool(a_)
&& tobool(a_ & strcmp(iptgetpref(_mxarray73_), _mxarray45_))) {
//
// message = ['Image is too big to fit on screen; ', ...
//
message
= horzcat(
mwVarargin(
_mxarray75_,
sprintf(
_mxarray77_, mwVarargin(floor(mwVv(scale, "scale"))))));
//
// sprintf('displaying at %d%% scale.', floor(scale))];
// warning(message);
//
ans.EqAns(Nwarning(0, NULL, mwVarargin(mwVv(message, "message"))));
} else {
}
//
// end
//
}
//
//
// %--------------------------------------------
// % Subfunction Resize2
// %--------------------------------------------
// % Resize figure containing multiple axes or
// % other objects. Basically we're going to
// % compute a global figure scaling factor
// % that will bring the target image into
// % truesize mode. This works reasonably well
// % for subplot-type figures as long as all
// % the images have the same size. This is
// % basically the guts of truesize.m from IPT
// % version 1.
//
return_:;
}
//
// The function "Mtruesize_Resize2" is the implementation version of the
// "truesize/Resize2" M-function from file
// "e:\matlab6.5\toolbox\images\images\truesize.m" (lines 316-438). It contains
// the actual compiled code for that M-function. It is a static function and
// must only be called from one of the interface functions, appearing below.
//
//
// function Resize2(axHandle, imHandle, imSize)
//
static void Mtruesize_Resize2(mwArray axHandle,
mwArray imHandle,
mwArray imSize) {
mwLocalFunctionTable save_local_function_table_
= &_local_function_table_truesize;
mwArray message = mwArray::UNDEFINED;
mwArray deltaY = mwArray::UNDEFINED;
mwArray deltaX = mwArray::UNDEFINED;
mwArray scale = mwArray::UNDEFINED;
mwArray scaleY = mwArray::UNDEFINED;
mwArray scaleX = mwArray::UNDEFINED;
mwArray minFigHeight = mwArray::UNDEFINED;
mwArray minFigWidth = mwArray::UNDEFINED;
mwArray figTopBorder = mwArray::UNDEFINED;
mwArray figBottomBorder = mwArray::UNDEFINED;
mwArray figRightBorder = mwArray::UNDEFINED;
mwArray figLeftBorder = mwArray::UNDEFINED;
mwArray newFigHeight = mwArray::UNDEFINED;
mwArray newFigWidth = mwArray::UNDEFINED;
mwArray dy = mwArray::UNDEFINED;
mwArray dx = mwArray::UNDEFINED;
mwArray screenSize = mwArray::UNDEFINED;
mwArray figPosition = mwArray::UNDEFINED;
mwArray rootUnits = mwArray::UNDEFINED;
mwArray figUnits = mwArray::UNDEFINED;
mwArray figHandle = mwArray::UNDEFINED;
mwArray axPosition = mwArray::UNDEFINED;
mwArray ans = mwArray::UNDEFINED;
mwArray axUnits = mwArray::UNDEFINED;
//
//
// if (isempty(imSize))
//
if (tobool(isempty(mwVa(imSize, "imSize")))) {
//
// imSize = size(get(imHandle, 'CData'));
//
imSize
= size(
mwValueVarargout(),
Nget(1, mwVarargin(mwVa(imHandle, "imHandle"), _mxarray51_)));
//
// end
//
}
//
//
// if (prod(imSize) == 0)
//
if (mclEqBool(prod(mwVa(imSize, "imSize")), _mxarray53_)) {
//
// % Don't try to handle the degenerate case.
// return;
//
goto return_;
//
// end
//
}
//
//
// axUnits = get(axHandle, 'Units');
//
axUnits = Nget(1, mwVarargin(mwVa(axHandle, "axHandle"), _mxarray54_));
//
// set(axHandle, 'Units', 'pixels');
//
ans.EqAns(
Nset(
0, mwVarargin(mwVa(axHandle, "axHandle"), _mxarray54_, _mxarray56_)));
//
// axPosition = get(axHandle, 'Position');
//
axPosition = Nget(1, mwVarargin(mwVa(axHandle, "axHandle"), _mxarray58_));
//
// % Do we need to do anything?
// if norm(axPosition(3:4) - [imSize([2 1])]) < sqrt(eps)
//
if (mclLtBool(
norm(
mclArrayRef(
mwVv(axPosition, "axPosition"), colon(_mxarray2_, _mxarray68_))
- mclArrayRef(mwVa(imSize, "imSize"), _mxarray79_)),
sqrt(_mxarray81_))) {
//
// set(axHandle, 'Units', axUnits)
//
ans.EqPrintAns(
Nset(
0,
mwVarargin(
mwVa(axHandle, "axHandle"),
_mxarray54_,
mwVv(axUnits, "axUnits"))));
//
// return;
//
goto return_;
//
// end
//
}
//
//
// figHandle = get(axHandle, 'Parent');
//
figHandle = Nget(1, mwVarargin(mwVa(axHandle, "axHandle"), _mxarray19_));
//
// figUnits = get(figHandle, 'Units');
//
figUnits = Nget(1, mwVarargin(mwVv(figHandle, "figHandle"), _mxarray54_));
//
// rootUnits = get(0,'Units');
//
rootUnits = Nget(1, mwVara
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -