📄 pbdlg.mc
字号:
//
// This file was generated by the Bentley MFC Application Wizard
//
///////////////////////////////////////////////////////////////////////////////
#include <cmdlist.h>
#include <toolsubs.h>
#include <string.h>
#include <math.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 <mscurrtr.fdf>
#include <mscexpr.fdf>
#include <ditemlib.fdf>
#include "Pbdlg.h"
#include "Pbdlgcmd.h"
#define GRAPHIC 1160
Dpoint3d pntP [2];
PlaceBoxInfo placeBoxInfo;
/*---------------------------------------------------------------------+
| name generateImage - dynamic function for complex case. |
+---------------------------------------------------------------------*/
Private int generateImage
(
Dpoint3d *pt,
int view,
int drawMode
)
{
MSElementUnion el;
Dpoint3d tPts[3];
Dpoint3d origin;
Dpoint3d shapep [5];
double zangle;
long cellFilePos;
unsigned long arrowsize;
arrowsize = 100;///tcb->chheight / 2;
pntP[1] = *pt;
mdlCurrTrans_begin();
mdlCurrTrans_identity();
mdlCurrTrans_translateOrigin(&pntP[0]);
mdlCurrTrans_invtransPointArray(tPts, pntP, 2);
origin = tPts[1]; /* origin of text */
/* Create Text in dgnBuf for MicroStation Dynamics to display */
mdlText_create(&el, NULL, placeBoxInfo.String, &tPts[1],NULL,NULL,NULL,NULL);
mdlElement_display (&el,drawMode);
if (drawMode == NORMALDRAW)
{
if (placeBoxInfo.groupMode == 1){
///cellFilePos=mdlCell_begin(plBoxInfo->cellName,NULL,NULL,0);
}
mdlElement_add(&el);
}
mdlText_extractShape(shapep, NULL, &el, TRUE, view);
if (tPts[0].x < origin.x)
{
if (tPts[0].y < origin.y)
{
tPts[1].x=shapep[0].x;
tPts[1].y=shapep[0].y;
} else {
tPts[1].x=shapep[3].x;
tPts[1].y=shapep[3].y;
}
} else {
if (tPts[0].y < origin.y)
{
tPts[1].x=shapep[1].x;
tPts[1].y=shapep[1].y;
tPts[1].x=shapep[2].x;
tPts[1].y=shapep[2].y;
}
}
mdlShape_create(&el, NULL, shapep, 5, -1);
mdlElement_display (&el, drawMode);
if (drawMode == NORMALDRAW)
mdlElement_add(&el);
/* Create shape in dgnBuf for MicroStation Dynamics to display */
if (placeBoxInfo.leaderLine)
{
mdlLine_create (&el, NULL, tPts);
mdlElement_display (&el, drawMode);
if (drawMode == NORMALDRAW)
mdlElement_add(&el);
/* calculate angle of line */
zangle = atan2 ((tPts[0].y-tPts[1].y), (tPts[0].x-tPts[1].x));
mdlCurrTrans_rotateByAngles ( 0.0, 0.0, zangle);
/* Create arrowhead */
tPts[1] = tPts[0];
tPts[2].x = tPts[0].x - arrowsize;
tPts[2].y = tPts[0].y - (arrowsize/2);
tPts[0].x -= arrowsize;
tPts[0].y += arrowsize/2;
mdlLineString_create (&el, NULL, tPts, 3);
mdlElement_display (&el, drawMode);
if (drawMode == NORMALDRAW)
mdlElement_add (&el);
}
if (drawMode == NORMALDRAW && placeBoxInfo.groupMode == 1)
{
mdlElement_add(&el);
///mdlCell_end(cellFilePos);
}
return SUCCESS;
}
/*---------------------------------------------------------------------+
| name placeBox_done |
+---------------------------------------------------------------------*/
Private void placeBox_done()
{
mdlState_clear();
mdlOutput_rscPrintf(MSG_PROMPT, NULL, 0, 4);
}
/*---------------------------------------------------------------------+
| name placeBox_secondPoint |
+---------------------------------------------------------------------*/
Private void placeBox_secondPoint
(
Dpoint3d *pt,
int view
)
{
int size=1, offset=GRAPHIC;
if (placeBoxInfo.groupMode = 2)
{
tcb->cugraf=tcb->graphic;
tcb->graphic++;
}
generateImage(pt, view, NORMALDRAW);
if (placeBoxInfo.groupMode = 2 )
{
///mdlParams_storeType9Variable(&tcb->graphic, size, offset);
tcb->cugraf=0;
}
placeBox_done ( );
}
/*---------------------------------------------------------------------+
| name placeBox_firstPoint |
+---------------------------------------------------------------------*/
Private void placeBox_firstPoint
(
Dpoint3d *pt,
int view
)
{
/* save first point */
pntP[0] = *pt;
/* Set the datapoint state function for the second point. */
mdlState_setFunction (STATE_DATAPOINT, placeBox_secondPoint);
mdlState_setFunction (STATE_RESET, placeBox_done);
mdlOutput_rscPrintf (MSG_PROMPT, NULL, 0, 3);
///mdlState_setFunction (STATE_DYNAMICS, generateImage);
}
/*---------------------------------------------------------------------+
│ name unloadFunction │
+---------------------------------------------------------------------*/
Private int unloadFunction()
{
RscFileHandle userPrefsH;
///PlaceBoxInfo *boxRscP;
/*Open userpref.rsc to hold our small pref resource*/
///mdlDialog_userPrefFileOpen(&userPrefsH);
///boXRscP = (PlaceBoxInfo *)mdlResource_load(NULL,RTYPE_plBox,RSCID_plboxprefs);
///if (! boxRscP)
///{
/* Our pref resource does not exist,so add it */
///mdlResource_add(userPrefsH,RTYPE_plBox,RSCID_PlBoxPrefs,placeBoxInfo,sizeof(placeBoxInfo),NULL);
///}
///else
///{
///*boxRscP=*placeBoxInfo;
/*Write out and free the updated resource*/
///mdlResource_write(boxRscP);
///mdlResource_free(boxRscP);
///}
/*Clean up*/
mdlResource_closeFile(userPrefsH);
///free(placeBoxInfo);
return(FALSE);
}
/*---------------------------------------------------------------------------------**//**
* @description Calls into the Native Code Library
* @param unparsed
* @bsimethod BSI 06/03
+---------------+---------------+---------------+---------------+---------------+------*/
Public void placeBox_start
(
char *unparsed
)
cmdNumber CMD_PLACE_BOX
{
if (!mdlDialog_find (DIALOGID_PlaceBox, NULL))
mdlDialog_open (NULL, DIALOGID_PlaceBox);
}
/*---------------------------------------------------------------------+
| name plButtonHook |
+---------------------------------------------------------------------*/
Private int plButtonHook
(
DialogItemMessage *dimP /* => a ptr to a dialog item message */
)
{
dimP->msgUnderstood = TRUE;
switch (dimP->messageType)
{
case DITEM_MESSAGE_BUTTON:
{
mdlState_startPrimitive (placeBox_firstPoint, placeBox_done, 1, 2);
break;
}
default:
{
/* tell the dialog manager that we don't handle this message */
dimP->msgUnderstood = FALSE;
break;
}
}
return 1;
}
/*---------------------------------------------------------------------------------**//**
* @description Pbdlg_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 Pbdlg_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)();
Public DialogHookInfo uHooks [] =
{
{HOOKITEMID_Button_Place,plButtonHook}
};
/*---------------------------------------------------------------------------------**//**
* @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;
char *setP;
/*-----------------------------------------------------------------------
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))
{
/* exit this program and unload it */
mdlSystem_exit( ERROR, /* => status for parent task */
1); /* => 1 to unload the program */
}
/*-----------------------------------------------------------------+
| mdlParse_loadCommandTable:
|
| This function is going to load the entire command tree into memory.
| The NULL argument means to use the same resource file that the
| application was from.
+-----------------------------------------------------------------*/
if (mdlParse_loadCommandTable (NULL) == NULL)
{
mdlOutput_error ("Unable to load command table.");
mdlSystem_exit( ERROR,1);
}
else
mdlOutput_error ("Key-in PLACE BOX to execute.");
/*-----------------------------------------------------------------+
| mdlState_registerStringIds () takes two arguments. The first is the
| id of the stringlist holding the Command messages, the second is the id
| of the stringlist holding the prompt messages.
+-----------------------------------------------------------------*/
mdlState_registerStringIds (MESSAGELISTID_Commands, MESSAGELISTID_Commands);
/*-----------------------------------------------------------------+
| mdlDialog_hookPublish:
|
| To make the Dialog Box Manager aware of the function pointers
| that we have equated to our hook ids we need to publish the
| DialogHookInfo structure, uHooks (declared at the top of this file).
+-----------------------------------------------------------------*/
mdlDialog_hookPublish (sizeof (uHooks)/sizeof (DialogHookInfo), uHooks);
/*-----------------------------------------------------------------+
| To setup variables evaluated within C expression strings:
|
| Since we are using a pointer to a structure we need to allocate
| memory for it. Because this symbol will be used in a Dialog Box
| we specify VISIBILITY_DIALOG_BOX. Then we publish the pointer to
| our structure so that the Dialog Box Manager becomes aware of it.
+-----------------------------------------------------------------*/
setP = mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX, 0, TRUE);
mdlDialog_publishComplexVariable (setP, "placeboxinfo", "placeBoxInfo",
&placeBoxInfo);
/* --- Set up function to get called at unload time --- */
mdlSystem_setFunction (SYSTEM_UNLOAD_PROGRAM, Pbdlg_unloadFunction);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -