home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 January
/
Chip_1997-01_cd.bin
/
ms95
/
disk21
/
dir04
/
f017370.re_
/
f017370.re
Wrap
Text File
|
1996-04-02
|
14KB
|
397 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. |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| $Workfile: tagdisp.mc $
| $Revision: 6.3 $
| $Date: 03 Oct 1995 10:54:16 $
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| tagdisp.mc - Tag display source code. |
| Illustrates basic tag element manipulation concepts. |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| Include Files |
| |
+----------------------------------------------------------------------*/
#include <mdl.h> /* MDL Library funcs structures & constants */
#include <dlogitem.h> /* Dialog Box Manager structures & constants */
#include <mselems.h> /* structures that define MicroStation elements */
#include <rscdefs.h> /* resource mgr structure definitions & constants */
#include <scanner.h> /* typedefs and defines for design file scanner */
#include <mdlio.h> /* File I/O definitions and data structs for MDL */
#include <stdlib.h>
#include <dlogman.fdf> /* Dialog Box Manager Function Prototypes */
#include <mstagdat.fdf> /* Tag data function prototypes */
#include <mselemen.fdf>
#include <mselmdsc.fdf>
#include <msmisc.fdf>
#include <msoutput.fdf>
#include <mslocate.fdf>
#include <msstate.fdf>
#include "tagexmpl.h" /* Contains Dialog Box IDs for this app */
#include "tagexcmd.h" /* Contains Command numbers for this app */
/*----------------------------------------------------------------------+
| |
| Local Function Declarations |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| Private Global variables |
| |
+----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
The following variable is referenced in C expression strings used
by the toggle button item defined in tagdata.r.
-----------------------------------------------------------------------*/
extern DlogBoxInfo *dlogBoxInfo;
/*----------------------------------------------------------------------+
| |
| Tagddisp Code Section |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| Functions for Locate logic |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| name tagdisp_setElmSearchType |
| |
| author BSI 8/94 |
| |
+----------------------------------------------------------------------*/
Private void tagdisp_setElmSearchType
(
void
)
{
mdlLocate_normal ();
}
/*----------------------------------------------------------------------+
| |
| name tagdisp_changeDisplay |
| |
| author BSI 8/94 |
| |
+----------------------------------------------------------------------*/
Private int tagdisp_changeDisplay
(
MSElementDescr *tagElmDescrP
)
{
char buf[100];
UShort tagProps;
int status = SUCCESS;
MSElement newTagElm;
TagValue value;
TagSpec tagSpec;
boolean displayable, createTag;
createTag = FALSE;
/*
// Extract the tag specification, tag value, and displayable flag.
// I have extracted the tag value because I want to check the data
// type of the tag to determine whether or not it should be
// displayed. For example, I don't want to display binary data.
//
// If I did not extract the value here, I could have also called
// mdlTag_getTagDef() to get the tag's type from the tag definition.
*/
if (SUCCESS != mdlTag_extract(
NULL, /* <= origin of associated element */
NULL, /* <= snap point */
NULL, /* <= tag specification */
&displayable, /* <= TRUE for displayable tag */
&value, /* <= value for the tag */
NULL, /* <= target element's assocation id */
NULL, /* <= offset */
NULL, /* <= size for the text */
NULL, /* <= rotation matrix */
NULL, /* <= text parameters */
&tagElmDescrP->el, /* => tag element */
MASTERFILE)) /* => file number for the tag */
{
mdlOutput_rscPrintf(MSG_ERROR, NULL, MESSAGELISTID_Messages,
MESSAGEID_TagExtractErr);
return ERROR;
}
/*
// Note:
// The only tag property that is stored with the tag element is
// the display flag. Therefore, there is no need to retrieve the
// existing property mask for the tag definition using
// mdlTag_getTagDef() before modifying the tag properties.
// When I recreate the tag using mdlTag_create(), I can simply
// pass the display flag for the property parameter.
*/
/*
// If the tag is currently displayed and the user wants to
// turn the display OFF then (display toggle is OFF)
*/
if ((TRUE == displayable) && (0 == dlogBoxInfo->display))
{
/* Turn OFF the display of this tag */
tagProps = TAG_PROP_DISPOFF;
createTag = TRUE;
}
/*
// Else if the tag is NOT currently displayed and the user
// wants to turn ON the display then (display toggle is ON)
*/
else if ((FALSE == displayable) && (-1 == dlogBoxInfo->display))
{
/* Turn ON the display of the flag */
tagProps = ~TAG_PROP_DISPOFF;
createTag = TRUE;
}
/*******************************************************************
//
// When the value parameter is returned from mdlTag_extract(),
// MicroStation has allocated memory for the stringVal and binaryVal
// members of the TagValue structure. You are responsible for
// freeing this memory.
//
********************************************************************/
switch (value.type)
{
case MS_TAGTYPE_CHAR:
{
/* Free the memory allocated by mdlTag_extract() */
free(value.val.stringVal);
break;
}
case MS_TAGTYPE_BINARY:
{
/* Free the memory allocated by mdlTag_extract() */
free(value.val.binaryVal);
/*
// Do not change the display flag for the binary type since
// the data is not readable anyway
*/
createTag = FALSE;
break;
}
default:
break;
}
if (TRUE == createTag)
{
status = mdlTag_create(
&newTagElm, /* output area for new tag element */
&tagElmDescrP->el, /* template element */
NULL, /* specification for tag definition */
&tagProps, /* display flag */
NULL, /* value extracted from text element */
NULL, /* tag id from mdlAssoc_tagElement */
NULL, /* computed location offset */
NULL, /* rest are special text properties */
NULL, /* ... */
NULL,
NULL
);
if (SUCCESS != status)
{
mdlOutput_rscPrintf(MSG_ERROR, NULL, MESSAGELISTID_Messages,
MESSAGEID_TagCreateErr);
}
else
{
/*******************************************************************
// The file position of the tag element is contained in the
// userData1 member in the element descriptor header.
//
// For example:
//
// MSElementDescr *tagElmDescrP;
//
// tagElmDescrP->h.userData1 contains the file position of the tag
//
// This file position is needed since I intend to modify the tag
// element and rewrite the element to the design file at the file
// position contained in tagElmDescrP->h.userData1
//
//********************************************************************/
mdlElement_rewrite(&newTagElm, &tagElmDescrP->el, tagElmDescrP->h.userData1);
mdlElement_display(&tagElmDescrP->el, ERASE);
mdlElement_display(&newTagElm, NORMALDRAW);
}
} /* if (TRUE == createTag) */
return status;
}
/*----------------------------------------------------------------------+
| |
| name tagdisp_modElm |
| |
| author BSI 8/94 |
| |
+----------------------------------------------------------------------*/
Private int tagdisp_modElm
(
MSElementUnion *elP
)
{
int numTags, status;
MSElementDescr *elmDescrP, *tempP, *prevP;
/* Extract all tag elements from the selected element */
if ((status = mdlTag_getElementTags(
&elmDescrP, /* <= linked list of tags */
&numTags, /* <= number of tags */
elP, /* => element to get tags for*/
MASTERFILE, /* => file number */
0)) /* => future arg, always 0 */
!= SUCCESS)
{
mdlOutput_rscPrintf(MSG_ERROR, NULL, MESSAGELISTID_Messages,
MESSAGEID_GetTagsErr);
}
else
{
tempP = elmDescrP;
while (tempP != NULL)
{
/* change the display of this tag if necessary */
tagdisp_changeDisplay(tempP);
/*******************************************************************
// After successfully calling mdlTag_getElementTags(), MicroStation
// has allocated memory for a linked list of element descriptors
// and has returned a pointer to that list in the first parameter
// to this function.
//
// You need to call mdlElmdscr_freeAll() to deallocate this memory.
*******************************************************************/
prevP = tempP;
tempP = tempP->h.next;
mdlElmdscr_freeAll(&prevP);
}
}
/* Do not change the select element */
return MODIFY_STATUS_NOCHANGE;
}
/*----------------------------------------------------------------------+
| |
| name tagdisp_acceptElm |
| |
| author BSI 8/94 |
| |
+----------------------------------------------------------------------*/
Private void tagdisp_acceptElm
(
Dpoint3d *ptP,
int view
)
{
ULong filePos;
int currFile;
/*-----------------------------------------------------------------------
The located element was accepted using a data point so get the
accepted element and call mdlModify_elementMulti to change the
display of any tags associated to this element.
-----------------------------------------------------------------------*/
filePos = mdlElement_getFilePos (FILEPOS_CURRENT, &currFile);
mdlModify_elementMulti (currFile, filePos, MODIFY_REQUEST_HEADERS,
MODIFY_ORIG, tagdisp_modElm, NULL, TRUE);
/*-----------------------------------------------------------------------
Restart the locate logic
-----------------------------------------------------------------------*/
mdlLocate_restart (FALSE);
}
/*----------------------------------------------------------------------+
| |
| Command Functions |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| name tagdisp_changeDisplayCmd |
| |
| author BSI 8/94 |
| |
+----------------------------------------------------------------------*/
Private void tagdisp_changeDisplayCmd
(
char *unparsedP /* => unparsed part of command */
)
cmdNumber CMD_CHANGE_TAG_DISPLAY
{
/* Setup search mask with the type of elements we are looking for */
tagdisp_setElmSearchType();
mdlState_startModifyCommand (tagdisp_changeDisplayCmd, /*reset func */
tagdisp_acceptElm, /* datapoint func */
NULL, /* dynamics func */
NULL, /* show func */
NULL, /* clean func */
MESSAGEID_TagDisplay, /* command field message */
0, /* accept prompt message */
TRUE, /* use selection sets */
0); /* pts required for accept */
/* output a prompt asking user to select a graphic element */
mdlOutput_rscPrintf(MSG_PROMPT, NULL,
MESSAGELISTID_Messages, MESSAGEID_SelectElement);
/* Start search at beginning of file */
mdlLocate_init ();
}