📄 textrms.mc
字号:
/*--------------------------------------------------------------------------+
| Copyright (C) 199l,Mach N. Dinh-Vu,All Rights Reserved. |
| Program : textrms.mc |
| Revision : 1.0.a |
| UpgradeToV8: MicroStationFan 2006/05 |
+---------------------------------------------------------------------------+
| This program will rotate,scale and move the identified |
| text or text node by the active angle and active scale. |
+--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------+
| Include Files |
+--------------------------------------------------------------------------*/
#include <mdl.h> /* system include files */
#include <msrmgr.h>
#include <tcb.h>
#include <mscurrtr.fdf>
#include <mselemen.fdf>
#include <mslocate.fdf>
#include <mstmatrx.fdf>
#include <msmisc.fdf>
#include <msoutput.fdf>
#include <msparse.fdf>
#include <msstate.fdf>
#include <msvec.fdf>
#include "textrms.h"
/*--------------------------------------------------------------------------+
| Private Global,variables |
+--------------------------------------------------------------------------*/
int currFile;
ULong filepos;
Transform tMatrix;
void rotMove_start (void);
/*--------------------------------------------------------------------------+
| name main |
+--------------------------------------------------------------------------*/
Private void main (void)
{
RscFileHandle rfHandle;
/* load our command tabla */
if (mdlParse_loadCommandTable (NULL) == NULL)
mdlOutput_error ("Unable to load command table.");
mdlResource_openFile (&rfHandle, NULL, FALSE);
mdlOutput_prompt ("Key-in TEXT RMS to execute");
}
/*--------------------------------------------------------------------------+
| name getMoveDistance |
+--------------------------------------------------------------------------*/
Private void getMoveDistance
(
Dpoint3d *distance, /* <= distance from anchor */
Dpoint3d *pt /* => current point */
)
{
Dpoint3d anchor = statedata.dPointStack[0];
/* subtract anchor point from current point to get the distance */
mdlVec_subtractPoint (distance, pt, &anchor);
}
/*--------------------------------------------------------------------------+
| name transformElement |
+--------------------------------------------------------------------------*/
Private void transformElement
(
Dpoint3d *pt /* => current location of cursor */
)
{
DPoint3d distance;
getMoveDistance (&distance, pt);
mdlCurrTrans_begin ();
mdlCurrTrans_identity ();
mdlCurrTrans_translateOrigin (pt);
mdlTMatrix_getIdentity (&tMatrix);
mdlTMatrix_scale (&tMatrix, &tMatrix, tcb->xactscle,
tcb->yactscle, tcb->zactscle);
mdlTMatrix_rotateByAngles (&tMatrix, &tMatrix, 0.0, 0.0,
tcb->actangle*fc_piover180);
mdlTMatrix_translate (&tMatrix, &tMatrix, distance.x,
distance.y, distance.z);
mdlElement_transform (dgnBuf, dgnBuf, &tMatrix);
mdlCurrTrans_end ();
}
/*--------------------------------------------------------------------------+
| name elementModify_move |
+--------------------------------------------------------------------------*/
Private int elementModify_move
(
MSElementUnion *el, /* <> element to be modified */
Dpoint3d *pt /* => fram params in mdlModify_element... */
)
{
Dpoint3d distance;
getMoveDistance (&distance, pt);
mdlCurrTrans_begin ();
mdlCurrTrans_identity ();
mdlCurrTrans_translateOrigin (pt);
/* start from a known matrix */
mdlTMatrix_getIdentity (&tMatrix);
/* scale it by current active scale */
mdlTMatrix_scale(&tMatrix, &tMatrix, tcb->xactscle,
tcb->yactscle, tcb->xactscle);
/* rotate it by current active angle */
mdlTMatrix_rotateByAngles(&tMatrix, &tMatrix, 0.0, 0.0,
tcb->actangle*fc_piover180);
mdlTMatrix_translate (&tMatrix, &tMatrix, distance.x,
distance.y, distance.z);
if (mdlElement_transform (el, el, &tMatrix))
return MODIFY_STATUS_ERROR;
mdlCurrTrans_end ();
return MODIFY_STATUS_REPLACE;
}
/*--------------------------------------------------------------------------+
| name rotMove_accept |
+--------------------------------------------------------------------------*/
Private void rotMove_accept
(
Dpoint3d *pt /* => final point for move element */
)
{
DgnModelRefP modelRef;
ULong filePos;
/* Get the file position and modelRef of the element to move. */
filePos = mdlElement_getFilePos (FILEPOS_CURRENT, &modelRef);
/* Now move each element, no selection set */
mdlModify_elementSingle (modelRef, filePos, MODIFY_REQUEST_HEADERS,
MODIFY_ORIG, elementModify_move, pt, NULL);
/* Save new anchor point (the current acceptance point) */
statedata.dPointStack[0] = *pt;
/* Reload the dynamic buffer with the new element. */
mdlDynamic_loadElement (NULL, modelRef, filePos);
/* a RESET will restart this command */
mdlState_setFunction (STATE_RESET, rotMove_start);
/* if in singleshot mode then restart default command */
mdlState_checkSingleShot ();
}
/*--------------------------------------------------------------------------+
| name rotMove_start |
+--------------------------------------------------------------------------*/
cmdName void rotMove_start (void)
cmdNumber CMD_TEXT_RMS
{
static int searchType[] = {
TEXT_ELM,
TEXT_NODE_ELM
};
mdlLocate_noElemNoLocked ();
mdlLocate_setElemSearchMask (sizeof(searchType)/sizeof(int), searchType);
mdlState_startModifyCommand (rotMove_start, rotMove_accept,
transformElement, NULL, NULL, 1, 0, TRUE, 0);
mdlLocate_init ();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -