📄 placebox.mc
字号:
//
// This file was generated by the Bentley MFC Application Wizard
//
///////////////////////////////////////////////////////////////////////////////
#include <cmdlist.h>
#include <toolsubs.h>
#include <string.h>
#include <msrsrc.fdf>
#include <msparse.fdf>
#include <msoutput.fdf>
#include <mselemen.fdf>
#include <msvar.fdf>
#include <msstate.fdf>
#include <mssystem.fdf>
#include <msdialog.fdf>
#include <mscell.fdf>
#include <mselmdsc.fdf>
#include "PlaceBox.h"
#include "PlaceBoxcmd.h"
static char textin [128];
Dpoint3d pntP[2];
/*--------------------------------------------------------------------------+
| name generateImage – dynamic function for box. |
+--------------------------------------------------------------------------*/
Private int generateImage
(
Dpoint3d*pt,
int view,
int drawMode
)
{
MSElementUnion el;
Dpoint3d origin;
Dpoint3d shapeP[5];
MSElementDescr * pDescr = NULL;
pntP[1]=origin=*pt;
mdlCell_create (&el, "BOX", &pntP[0], FALSE);
mdlElmdscr_new (&pDescr,NULL,&el);
/*create Text in dgnBuf for Microstation Dymamics to display */
mdlText_create (&el,NULL,textin,&pntP[1],NULL,NULL,NULL,NULL);
mdlElement_display(&el,drawMode);
mdlElmdscr_appendElement(pDescr,&el);
mdlText_extractShape(shapeP,NULL,&el,TRUE,view);
mdlShape_create(&el, NULL, shapeP, 5, -1);
mdlElement_display(&el, drawMode);
mdlElmdscr_appendElement(pDescr,&el);
if (pntP[0].x < origin.x)
{
if (pntP[0].y < origin.y)
{
pntP [1] .x=shapeP [0] .x;
pntP[ 1] .y=shapeP[0] .y;
} else {
pntP[1] .x=shapeP [3].x;
pntP [1] .y=shapeP [3].y;
}
}else {
if (pntP[0].y < origin.y)
{
pntP[1] .x=shapeP[1] .x;
pntP[1].y=shapeP[1].y;
} else {
pntP[1] .x=shapeP[2] .x;
pntP [1] .y=shapeP[2] .y;
}
}
/* Place the modified leader line */
mdlLine_create(&el, NULL, pntP);
mdlElement_display (&el, drawMode);
mdlElmdscr_appendElement(pDescr,&el);
if (drawMode==NORMALDRAW)
{
mdlElmdscr_add(pDescr);
}
mdlElmdscr_freeAll(&pDescr);
return SUCCESS;
}
/*--------------------------------------------------------------------------+
| name keyinText |
+--------------------------------------------------------------------------*/
Private void keyinText(char *cmdStringP)
{
strcpy(textin,cmdStringP);
}
/*--------------------------------------------------------------------------+
| name placeBox_done |
+--------------------------------------------------------------------------*/
Private void placeBox_done()
{
mdlOutput_rscPrintf(MSG_PROMPT,NULL,0,4);
mdlState_restartCurrentCommand();
}
/*--------------------------------------------------------------------------+
| name placeBox_seconPoint |
+--------------------------------------------------------------------------*/
Private void placeBox_secondpoint
(
Dpoint3d *pt,
int view
)
{
generateImage(pt,view,NORMALDRAW);
}
/*--------------------------------------------------------------------------+
| name placeBox_firstPoint |
+--------------------------------------------------------------------------*/
Private void placeBox_firstpoint
(
Dpoint3d*pt,
int view
)
{
pntP[0]=*pt;
/*Set the datapoint state function for the second point.*/
mdlState_setKeyinPrompt ("KEY IN TEXT:");
mdlState_setFunction (STATE_KEYIN,keyinText);
mdlState_setFunction (STATE_DATAPOINT,placeBox_secondpoint);
mdlState_setFunction (STATE_RESET,placeBox_done);
mdlOutput_rscPrintf (MSG_PROMPT,NULL,0,3);
/*Setup Rubber Banding function*/
mdlState_setFunction (STATE_COMPLEX_DYNAMICS,generateImage);
}
/*---------------------------------------------------------------------------------**//**
* @description Calls into the Native Code Library
* @param unparsed
* @bsimethod BSI 06/03
+---------------+---------------+---------------+---------------+---------------+------*/
void placeBox_start()
cmdNumber CMD_PLACE_BOX
{
mdlState_startPrimitive(placeBox_firstpoint,placeBox_start,1,2);
}
/*---------------------------------------------------------------------------------**//**
* @description PlaceBox_unloadFunction
* @param unloadType Reason for the unload of the app
* @return SUCCESS to allow the unload; ERROR to disallow the unload
* @bsimethod BSI 06/03
+---------------+---------------+---------------+---------------+---------------+------*/
Private int PlaceBox_unloadFunction
(
int unloadType
)
{
BoolInt disallow = FALSE;
/*------------------------------------------------------------------
| If the value of unloadType is negative, then MicroStation ignores
| the return value of this function. In this case, we can assume
| that MicroStation is shutting down or was terminated so this
| function should not attempt to abort the unload.
+------------------------------------------------------------------*/
if (unloadType < 0)
{
return FALSE;
}
/*
** Your processing, which may include setting the disallow flag to TRUE
*/
return (disallow ? ERROR : SUCCESS);
}
/*---------------------------------------------------------------------------------**//**
* Dialog/Item Hooks; Command Numbers and Command Names
+---------------+---------------+---------------+---------------+---------------+------*/
typedef void (*Handler)(char *);
typedef void (*Hook)();
/*---------------------------------------------------------------------------------**//**
* @description MdlMain
* @param argc Count of arguments into the function
* @param argv Array of arguments
* @return Return code from the application
*
* @bsimethod BSI 06/03
+---------------+---------------+---------------+---------------+---------------+------*/
Public int main
(
int argc,
char *argv[]
)
{
RscFileHandle rscFileH;
/*-----------------------------------------------------------------------
mdlResource_openFile:
This function opens a resource file, thus making its contents
available to the application. In this case, we need to open
treexmpl.ma as a resource file so that we have access to the the
string lists for our messages.
-----------------------------------------------------------------------*/
if (SUCCESS != mdlResource_openFile (&rscFileH, NULL, 0))
{
mdlOutput_rscPrintf (MSG_ERROR, 0l, MESSAGELISTID_Messages,
MESSAGEID_ResourceLoadError);
/* unload the application */
mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD,
mdlSystem_getCurrTaskID (), TRUE);
}
/* --- Set up function to get called at unload time --- */
mdlSystem_setFunction (SYSTEM_UNLOAD_PROGRAM, PlaceBox_unloadFunction);
mdlState_registerStringIds (MESSAGELISTID_Commands, MESSAGELISTID_Commands);
mdlParse_loadCommandTable (NULL);
mdlOutput_prompt("Key-in PLACE BOX to execute");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -