⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pbdscr.mc

📁 microstation MDL入门指导手册!
💻 MC
字号:
/*----------------------------------------------------------------------------+
|  Copyright (C) 1991 Mach N. Dinh-Vu, All Rights Reserved                   |
|  Program    : pbdscr.mc                                                    |
|  Revision   : 1. 0.a                                                       |
|  UpgradeToV8: MicroStationFan 2006/05                                      |
+-----------------------------------------------------------------------------+
|Example MDL function to place box around a text string with a leader        |
|line using element descriptors.                                             |
+-----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------+
|    Include Files                                                         |
+----------------------------------------------------------------------------*/
#include <mdl.h>         /* system include files */
#include <global.h>
#include <msrmgr.h>
#include <userfnc.h>
#include <stdlib/string.h>
#include <mscell.fdf>
#include <mselemen.fdf>
#include <mselmdsc.fdf>
#include <msoutput.fdf>
#include <msparse.fdf>
#include <msstate.fdf>
#include "pbdscr.h"

/*----------------------------------------------------------------------------+
|    Private Global variables                                                |
+----------------------------------------------------------------------------*/
static char textin[128];
Dpoint3d    pntP[2];

/*----------------------------------------------------------------------------+
|    name        main                                                        |
+----------------------------------------------------------------------------*/
Private void main(void)
{
   RscFileHandle   rfHandle;

   /* load our command table */
   if (mdlParse_loadCommandTable (NULL) == NULL)
       mdlOutput_error ("Unable to load command table. ");
   mdlResource_openFile (&rfHandle, NULL, FALSE);
   mdlOutput_prompt ("Key-in PLACE DBOX to execute");
 }
/*----------------------------------------------------------------------------+  
|  name          generateImage - dynamic function for box.                   |
+----------------------------------------------------------------------------*/
Private int    generateImage
(
 Dpoint3d     *pt,
 int          view,
 int      drawMode
)
{
   MSElementDescr  *elmDP;
   MSElementUnion  el;
   Dpoint3d        origin;
   Dpoint3d        shapeP[5];
  
   pntP[1] = origin = *pt;
   /* create new descriptor using cell header */
   mdlCell_create (&el, L"pbdscr", &origin, FALSE);
   mdlElmdscr_new (&elmDP, NULL, &el);
   mdlText_create (&el, NULL, textin, &pntP[1], NULL, NULL, NULL, NULL);
   mdlElmdscr_appendElement (elmDP, &el);
   mdlText_extractShape (shapeP, NULL, &el, TRUE, view);
   mdlShape_create (&el, NULL, shapeP, 5, -1);
   mdlElmdscr_appendElement (elmDP, &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);
   mdlElmdscr_appendElement (elmDP, &el);
   mdlElmdscr_display (elmDP, 0, drawMode);
   if (drawMode == NORMALDRAW)
      mdlElmdscr_add (elmDP);
   mdlElmdscr_freeAll (&elmDP);
   return SUCCESS;
}
/*----------------------------------------------------------------------------+
|  name         keyinText                                                    |
+----------------------------------------------------------------------------*/
Private void  keyinText (char *cmdStrP)
{
   if (!*statedata.cmdstring)
      return;
   strncpy (textin, statedata.cmdstring, sizeof(textin));
}
/*----------------------------------------------------------------------------+
|  name         placeBox_done                                                |
+----------------------------------------------------------------------------*/
Private void   placeBox_done (void)
{
   mdlOutput_rscPrintf (MSG_PROMPT, NULL, 0, 4);
}
/*----------------------------------------------------------------------------+
|  name         placeBox_secondPoint                                         |
+----------------------------------------------------------------------------*/
Private void   placeBox_secondPoint
(
Dpoint3d  *pt,
int       view
)
{
   generateImage (pt, view, NORMALDRAW);
}
/*----------------------------------------------------------------------------+
|   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_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);
}
/*----------------------------------------------------------------------------+
|  name         placeBox_start                                               |
+----------------------------------------------------------------------------*/
cmdName  placeBox_start (void)
cmdNumber  CMD_PLACE_DBOX
{
  mdlState_startPrimitive (placeBox_firstPoint, placeBox_start, 1, 2);
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -