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

📄 locele.mc

📁 microstation MDL入门指导手册!
💻 MC
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------+
|             Copyright (c) 1991 Math Dinh-Vu, All Rights Reserved              |
|              locele.mc  - Display an element in a view, according to          |
|                               the search criteria.                            |
|                               LOCATE ELEMENT                                  |
|  UpgradeToV8 : MicroStationFan    2005/06                                     |
+------------------------------------------------------------------------------*/
#include <cmdlist.h>
#include <mdl.h>
#include <msrmgr.h>
#include <tcb.h>
#include <stdlib/math.h>
#include <stdlib/string.h>
#include <ditemlib.fdf>
#include <mscell.fdf>
#include <mscexpr.fdf>
#include <mscurrtr.fdf>
#include <msdialog.fdf>
#include <mselemen.fdf>
#include <mslocate.fdf>
#include <mstmatrx.fdf>
#include <msmisc.fdf>
#include <msoutput.fdf>
#include <msparse.fdf>
#include <msrmatrx.fdf>
#include <msscan.fdf>
#include <mssystem.fdf>
#include <msstate.fdf>
#include <msvec.fdf>
#include <msview.fdf>
#include    "locelcmd.h"  /*  Generated by resource compiler (rcomp) */
#include    "loceldlg.h"  /*  Need to know dialog id to open */

/*------------------------------------------------------------------------------+
|      Local function declarations                                              |
+------------------------------------------------------------------------------*/
void    locele_dummyItemHook(DialogItemMessage *), locele_dialogHook(DialogMessage *),
        locele_buttonHook(DialogItemMessage *), locele_scrollBarHook(DialogItemMessage *);
void    locateElem (void);

/*------------------------------------------------------------------------------+
|      Private Global variables                                                 |
+------------------------------------------------------------------------------*/
static LocElemInfo   *locElemInfoP;
static int            commandName;
static ULong          filePos;
static DialogBox     *dbP;
ExtScanlist           scanList;
static DialogHookInfo uHooks[] =
      {
      {HOOKITEMID_Button_Locele, locele_buttonHook},
      {HOOKITEMID_ScrollBar,     locele_scrollBarHook},
      {HOOKITEMID_Dummy,         locele_dummyItemHook},
      {HOOKDIALOGID_Level,       locele_dialogHook},
      };

/*------------------------------------------------------------------------------+
|       name    unloadFunction                                                  |
+------------------------------------------------------------------------------*/
Private int unloadFunction ()
{
   RscFileHandle   userPrefsH;
   LocElemInfo    *boxRscP;

   /* Open userpref.rsc to hold our small pref resource */
   mdlDialog_userPrefFileOpen (&userPrefsH, RSC_READWRITE);
   boxRscP = (LocElemInfo *)mdlResource_load (NULL, RTYPE_LocElem, 
                                              RSCID_LocElemPrefs);
   if (!boxRscP)
   {
      /* Our pref resource does not exist, so add it */
      mdlResource_add (userPrefsH, RTYPE_LocElem, RSCID_LocElemPrefs,
                       locElemInfoP, sizeof(LocElemInfo), NULL);
   }else{
      *boxRscP = *locElemInfoP;
      /* Write out and free the updated resource */
      mdlResource_write (boxRscP);
      mdlResource_free (boxRscP);
   }
   /* Clean up */
   mdlResource_closeFile (userPrefsH);
   free (locElemInfoP);
   return (FALSE);
}
/*------------------------------------------------------------------------+
|   name  main                                                            |
+------------------------------------------------------------------------*/
int   main (char *pArgument)
{
   RscFileHandle   rfHandle, userPrefsH;
   LocElemInfo    *elemRscP;
   char           *setP;
   
   /* Open our file for access to command table and dialog */
   mdlResource_openFile (&rfHandle, NULL, FALSE);
   /* Load the command table */
   if (mdlParse_loadCommandTable(NULL) == NULL)
      mdlOutput_error ( "Unable to load command table." );
   /* Publish the dialog item hooks */
   mdlDialog_hookPublish (sizeof(uHooks)/sizeof(DialogHookInfo), uHooks);
   /* Commands start in string list 0, prompts start in string 1 */
   mdlState_registerStringIds (0, 0);
   locElemInfoP = malloc (sizeof(LocElemInfo));
   /* Prepare to read resource */
   elemRscP = NULL;
   userPrefsH = NULL;
   mdlDialog_userPrefFileOpen (&userPrefsH, RSC_READWRITE);
   if (userPrefsH)
      elemRscP = (LocElemInfo *)mdlResource_load (NULL, RTYPE_LocElem,
                                                  RSCID_LocElemPrefs );
   if (!elemRscP)
   {
      /* No resource was found */
      locElemInfoP->eleType = 3;
      locElemInfoP->color = 0;
      locElemInfoP->weight = 0;
      locElemInfoP->style = 0;
      locElemInfoP->level[0] = 0x0000;
      locElemInfoP->level[1] = 0x0000;
      locElemInfoP->level[2] = 0x0000;
      locElemInfoP->level[3] = 0x0000;
   }else{
      /* Copy resource into internal structure */
      *locElemInfoP = *elemRscP;
      /* This is unnecessary because the closeFile will free all resources,
         but it is recommended practice */
      mdlResource_free (elemRscP);
   }
   if (userPrefsH)
      mdlResource_closeFile (userPrefsH);
   /* Set up and Publish locElemInfoP for access by the dialog manager */
   setP = mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX |
                                        VISIBILITY_DEBUGGER, 0, FALSE);
   mdlDialog_publishComplexPtr (setP, "loceleminfo", "locElemInfoP",
                                &locElemInfoP);
   /* Make sure our function gets called at unload time */
   mdlSystem_setFunction (SYSTEM_UNLOAD_PROGRAM, unloadFunction);
   locateElem ();
   return  SUCCESS;
}
/*------------------------------------------------------------------------+
|   name      showElement                                                 |
+------------------------------------------------------------------------*/
Private int showElement ( MSElement *element )
{
   Dpoint3d     viewRange[2];
   RotMatrix    rMatrix;
   double       range;
   int          stdViewNum;
   
   if (!mdlView_isVisible (locElemInfoP->view - 1))
   {
      mdlDialog_openAlert ("View is inactive" );
      return -1;
   }
   if (tcb->ndices == 3)
      stdViewNum = STDVIEW_ISO;
   else
      stdViewNum = STDVIEW_TOP;
   mdlView_getStandard (&rMatrix, stdViewNum);
   mdlElement_extractRange ((DVector3d *)viewRange, element);
   mdlRMatrix_multiplyRange (&viewRange[0], &viewRange[1 ], &rMatrix);
   mdlRMatrix_multiplyTransposePointArray (viewRange, &rMatrix, 2);
   range = fabs (viewRange[0].z - viewRange[1].z);
   mdlView_setArea (locElemInfoP->view-1, viewRange, &viewRange[0],
                    range, range/2.0, &rMatrix);
   mdlView_updateSingle (locElemInfoP->view-1);
   mdlElement_display (element, HILITE);
   return  SUCCESS;
}
/*------------------------------------------------------------------------+
|  name           showTextElement                                         |
+------------------------------------------------------------------------*/
Private int showTextElement (MSElement  *element)
{
   Dpoint3d    elemOrigin, viewRange[2];
   TextSize    elemSize;
   RotMatrix   elemRMatrix, invElemMatrix;
   
   /* Find elem element's position and orientation */
   mdlText_extract (&elemOrigin, NULL, NULL, NULL, NULL, &elemRMatrix,
                    NULL, NULL, NULL, &elemSize, element);
   /* Set up view to show elem element */
   viewRange[0].x = viewRange[0].y = -2.0 * elemSize.height;
   viewRange[1].x = elemSize.width + 2.0 * elemSize.height;
   viewRange[1].y = elemSize.height * 3.0;
   viewRange[0].z = viewRange[1] .z = 0.0;
   mdlRMatrix_rotatePointArray (viewRange, &elemRMatrix, 2);
   mdlVec_addPointArray (viewRange, &elemOrigin, 2);
   /* Display Text element */
   mdlRMatrix_transpose (&invElemMatrix, &elemRMatrix);
   mdlView_setArea (locElemInfoP->view-1, viewRange, &viewRange[0],
                    elemSize.width, elemSize.width/2.0, &invElemMatrix);
   mdlView_updateSingle (locElemInfoP->view-1);
   mdlElement_display (element, HILITE);
   return  SUCCESS;
}
/*------------------------------------------------------------------------+
|   name          locateElemString                                        |
+------------------------------------------------------------------------*/
Private void   locateElemString ( void )
{
   int            scanWords=0, status;
   int            elemMask, style;

⌨️ 快捷键说明

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