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

📄 rotcell.mc

📁 microstation MDL入门指导手册!
💻 MC
字号:
/*------------------------------------------------------------------+
| Copyright(c)1991 Mach Dinh-Vu,All Rights Reserved                |
| rotcell.mc - rotate the cell so that it aligns with the           |
| active angle                                                      |
|                     ROTATE CELL                                   |
| UpgradeToV8: MicroStationFan           2006/06                    |
+------------------------------------------------------------------*/
#include <mdl.h>
#include <msrmgr.h>
#include <tcb.h>
#include <mscell.fdf>
#include <mscurrtr.fdf>
#include <mselemen.fdf>
#include <mslocate.fdf>
#include <mstmatrx.fdf>
#include <msmisc.fdf>
#include <msoutput.fdf>
#include <msparse.fdf>
#include <msrmatrx.fdf>
#include <msselect.fdf>
#include <msstate.fdf>
#include <msvec.fdf>
#include "rotcell.h"

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

   /*------load our command table  --------*/
   if (mdlParse_loadCommandTable(NULL) == NULL)
      mdlOutput_error ("Unable to load command table.");
   mdlOutput_prompt ("to execute,key-in ROTATE CELL");
   mdlResource_openFile (&rfHandle, NULL, FALSE);
}
/*-----------------------------------------------------------------------+
|    name         setSearchType                                          |
+-----------------------------------------------------------------------*/
Private void setSearchType (void)
{
   static int searchType[] = {CELL_HEADER_ELM, LINE_ELM, LINE_STRING_ELM,
                     SHAPE_ELM, TEXT_NODE_ELM, CURVE_ELM, CMPLX_STRING_ELM,
                     CONIC_ELM, CMPLX_SHAPE_ELM, ELLIPSE_ELM,
                     TEXT_ELM, SURFACE_ELM, SOLID_ELM};

   /* initialize search criteria to find nothing */
   mdlLocate_noElemNoLocked ();
   /* add elements to search to list */
   mdlLocate_setElemSearchMask (sizeof(searchType)/sizeof(int), searchType);
}
/*-------------------------------------------------------------------------------+
|name          rotCell                                                           |
+-------------------------------------------------------------------------------*/
Private int rotCell ( MSElementUnion *el )
{
   Dpoint3d    rotPoint;
   RotMatrix   rMatrix;
   Transform   tMatrix;
   int         status;

   /*   build transformation matrix from the cell header
     for each component element.                     */
   if (mdlElement_isComplexHeader (el))
   {
      if (mdlElement_getType(el) != CELL_HEADER_ELM)
         return MODIFY_STATUS_NOCHANGE;
      /* get origin for the rotation point, and rotation matrix */
      mdlCell_extract (&rotPoint, NULL, &rMatrix, NULL, NULL, 0, el);
      /* build transformation matrix with the rotation component
         of the cell.                                          */
      mdlTMatrix_getIdentity (&tMatrix);
      mdlRMatrix_transpose (&rMatrix, &rMatrix);
      mdlTMatrix_rotateByRMatrix (&tMatrix, &tMatrix, &rMatrix);
      /* compensate for view rotation so the transformation is local */
      mdlRMatrix_fromView (&rMatrix, rotView, FALSE);
      mdlRMatrix_transpose (&rMatrix, &rMatrix);
      mdlTMatrix_rotateByRMatrix (&tMatrix, &tMatrix, &rMatrix);
      mdlTMatrix_rotateByAngles (&tMatrix, &tMatrix, 0.0, 0.0,
                                 tcb->actangle* fc_piover180);
   }
   mdlCurrTrans_begin ();
   mdlCurrTrans_identity ();
   mdlCurrTrans_translateOriginWorld (&rotPoint);
   status = mdlElement_transform (el, el, &tMatrix);
   mdlCurrTrans_end ();
   return (status ? 0 : MODIFY_STATUS_REPLACE);
}
/*-----------------------------------------------------------------------+
|   name   mod_accept                                                    |
+-----------------------------------------------------------------------*/
Private void     mod_accept
(
Dpoint3d  *pt,
int       view
)
{
   ULong          filePos;
   DgnModelRefP   modelRef;

   rotView = view;
   filePos = mdlElement_getFilePos (FILEPOS_CURRENT, &modelRef);
   if (mdlSelect_isActive())
   {
      mdlModify_elementMulti (modelRef,      // modelRef to process
                              filePos,       // file position for element
                     MODIFY_REQUEST_HEADERS, // process complex headers
                     MODIFY_ORIG,            // modify original element
                     rotCell,      // modify routine for each element
                     NULL,         // parameters for rotCell
                     TRUE);        // process graphic group
   } else {
      mdlModify_elementSingle (modelRef,
                               filePos,      // file position for element
                     MODIFY_REQUEST_HEADERS, // process complex headers
                     MODIFY_ORIG,            // modify original element
                     rotCell,      // modify routine for each element
                     NULL,         // parameters for rotCell
                     FALSE);       // offset for component element
   }
   /* restart the element location process */
   mdlLocate_restart (FALSE);
}
/*-----------------------------------------------------------------------+
| name        change_cell                                                |
+-----------------------------------------------------------------------*/
Private void change_cell (void)
{
   setSearchType ();
   mdlState_startModifyCommand (
            change_cell,   /* function to call on RESET */
            mod_accept,    /* function to call on DATA */
            NULL,          /* function to call for DYNAMIC */
            NULL,          /* function to call on SHOW */
            NULL,          /* function to call on CLEAN */
            1,             /* index into MESSAGE LIST */
            2,             /* index into PROMPT LIST */
            TRUE,          /* Modify SELECTION SET ? */
            FALSE);      /* additional data points required */
   /* start element search from the beginning of file */
   mdlLocate_init ();
}
/*-----------------------------------------------------------------------+
|    name         rotcell                                                |
+-----------------------------------------------------------------------*/
cmdName  void rotcell (void)
cmdNumber  CMD_ROTATE_CELL
{
   change_cell ();
}

⌨️ 快捷键说明

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