home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 January
/
Chip_1997-01_cd.bin
/
ms95
/
disk22
/
dir02
/
f014380.re_
/
f014380.re
Wrap
Text File
|
1996-04-02
|
9KB
|
247 lines
/*----------------------------------------------------------------------+
| |
| Copyright (1995) Bentley Systems, Inc., All rights reserved. |
| |
| "MicroStation" is a registered trademark and "MDL" and "MicroCSL" |
| are trademarks of Bentley Systems, Inc. |
| |
| Limited permission is hereby granted to reproduce and modify this |
| copyrighted material provided that the resulting code is used only |
| in conjunction with Bentley Systems products under the terms of the |
| license agreement provided therein, and that this notice is retained |
| in its entirety in any such reproduction or modification. |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| $Logfile: J:/mdl/examples/doc/locate.mcv $
| $Workfile: locate.mc $
| $Revision: 1.2 $
| $Date: 20 Jun 1995 08:49:52 $
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| locate.mc - examples for the mdlLocate_ functions. |
| |
| This file is intended as an adjunct to the MDL manual to |
| illustrate MDL built-in function calling conventions and parameter |
| values. While it can be compiled, it does NOT, on its own, |
| constitute a workable MDL example. |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| Include Files |
| |
+----------------------------------------------------------------------*/
#include <mdl.h>
#include <mselems.h>
#include <userfnc.h>
/*----------------------------------------------------------------------+
| |
| Local function declarations |
| |
+----------------------------------------------------------------------*/
int editText(), replaceComponentDone();
/*----------------------------------------------------------------------+
| |
| name setTextSearchType |
| |
| author BSI 7/90 |
| |
+----------------------------------------------------------------------*/
Private void setTextSearchType
(
void
)
{
static int searchType[] = {TEXT_ELM, TEXT_NODE_ELM};
/* set search criteria to find nothing */
mdlLocate_noElemNoLocked ();
/* then add text elements and text nodes to list */
mdlLocate_setElemSearchMask (sizeof(searchType)/sizeof(searchType[0]),
searchType);
}
/*----------------------------------------------------------------------+
| |
| name changeText_accept - called for data point on change |
| text single command |
| |
| author BSI 3/89 |
| |
+----------------------------------------------------------------------*/
Private void changeText_accept
(
void
)
{
ULong filePos, compOffset;
int currFile;
filePos = mdlElement_getFilePos (FILEPOS_CURRENT, &currFile);
/* If there is a selection set active, process all elements in the set.
Of course, this processes all component text elements of a text node.
If no selection set is active, process ONLY the identified element.
This makes this command not apply to graphic groups (by design).
*/
if (mdlSelect_isActive())
{
mdlModify_elementMulti (currFile, filePos, MODIFY_REQUEST_NOHEADERS,
MODIFY_ORIG, editText, NULL, TRUE);
}
else
{
compOffset = mdlElement_getFilePos(FILEPOS_COMPONENT, NULL) - filePos;
mdlModify_elementSingle (currFile, filePos, MODIFY_REQUEST_ONLYONE,
MODIFY_ORIG, editText, NULL, compOffset);
}
/* restart the element location process */
mdlLocate_restart (FALSE);
}
/*----------------------------------------------------------------------+
| |
| name doChangeSingle |
| |
| author BSI 8/89 |
| |
+----------------------------------------------------------------------*/
Private void doChangeSingle
(
void
)
{
/* set up the MicroStation search mask to find only text elements */
setTextSearchType();
/* tell MicroStation we want to start a "modification" command */
mdlState_startModifyCommand (doChangeSingle, changeText_accept, NULL,
NULL, NULL, 0, 1, TRUE, FALSE);
/* set the internal locate pointers to start at beginning of file */
mdlLocate_init ();
}
/*----------------------------------------------------------------------+
| |
| name irrigationComponentsFilter |
| |
| Locate filter for REPLACE COMPONENT command. Permits |
| only irrigation elements to be selected. The |
| user attribute data on the element is checked to |
| see if the element is an irrigation component. |
| |
| author BSI 4/91 |
| |
+----------------------------------------------------------------------*/
Private int irrigationComponentsFilter
(
int preLocate, /* => TRUE if pre-locate */
MSElementUnion *elementP /* => current element */
)
{
UShort *wordOffsetP;
int componentData;
/* check for irrigation component element */
if (!irrattr_extractComponentUserData (&componentData,
&wordOffsetP, elementP))
return LOCATE_ELEMENT_NEUTRAL;
return LOCATE_ELEMENT_REJECT;
}
/*----------------------------------------------------------------------+
| |
| name replaceComponentStart |
| |
| Start function for REPLACE COMPONENT command. |
| |
| author BSI 4/91 |
| |
+----------------------------------------------------------------------*/
Private void replaceComponentStart
(
char *unparsedP /* => unparsed part of command */
)
{
/* we need to locate any existing irrigation component */
mdlState_startModifyCommand (replaceComponentStart, replaceComponentDone,
NULL, NULL, NULL, 0, 0, TRUE, 0);
initializeComponentLocate ();
/* filter elements based on user attribute data */
mdlLocate_setFunction (LOCATE_POSTLOCATE, irrigationComponentsFilter);
if (!mdlSelect_isActive ())
util_displayPrompt (122);
}
/*----------------------------------------------------------------------+
| |
| name dataButtonHit |
| |
| author BSI 2/91 |
| |
+----------------------------------------------------------------------*/
Private void dataButtonHit
(
Dpoint3d *point,
int view
)
{
Dpoint3d closestPoint;
int segment;
if (!mdlLocate_findElement (point, view, 0, 0, FALSE))
mdlOutput_printf (MSG_STATUS, "Element not found");
else
{
mdlOutput_printf (MSG_STATUS, "ELEMENT FOUND: type=%d",
dgnBuf->ehdr.type);
if (dgnBuf->ehdr.type == LINE_STRING_ELM)
{
mdlLocate_getProjectedPoint (&closestPoint, &segment, NULL);
mdlOutput_printf (MSG_PROMPT,
"Locate point=[%d,%d,%d], segment=%d",
closestPoint.x, closestPoint.y, closestPoint.z, segment);
}
}
}
/*----------------------------------------------------------------------+
| |
| name locateElement - print out element type of elements pointed |
| to by user. |
| |
| author BSI 10/90 |
| |
+----------------------------------------------------------------------*/
cmdName locateElement
(
void
)
{
mdlState_startPrimitive (dataButtonHit, locateElement, 0, 0);
/* reset the location logic */
mdlLocate_init();
/* allow any element */
mdlLocate_allowLocked();
/* change the cursor to be the "locate" cursor */
mdlLocate_setCursor();
}