/*
Copyright (c) 2019 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*-------------------------- Pro/Toolkit includes ---------------------------*/
#include <ProToolkit.h>
#include <ProMdl.h>
#include <ProCsys.h>
#include <PTApplsUnicodeUtils.h>
#include <ProDrawing.h>
#include <ProWindows.h>
#include <ProSelection.h>
/*-------------------------- Application includes ---------------------------*/
#include <TestError.h>
/*--------------------------- Function Prototypes----------------------------*/
extern ProError UserTreeExpand();
extern ProError UserTreeCollapse();
extern ProError UserTreeRefresh();
ProError status;
ProDrawing drawing;
ProMdlType mdl_type;
ProCharLine astr;
int win_id = -1;
ProFileName WMSGFIL = {'m','s','g','_','u','g','d','w','g','.','t','x','t','\0'};
/*================================================================*\
FUNCTION : UserTreeExpand
PURPOSE : Expand the drawing tree in the current drawing.
\*================================================================*/
ProError UserTreeExpand ()
{
/*------------------------------------------------------------*\
Get the current drawing
\*------------------------------------------------------------*/
status = ProMdlCurrentGet((ProMdl*)&drawing);
ERROR_CHECK ("UserTreeExpand","ProMdlCurrentGet",status);
if (status != PRO_TK_NO_ERROR)
return (status);
/*------------------------------------------------------------*\
Check the type of current drawing
\*------------------------------------------------------------*/
status = ProMdlTypeGet((ProMdl)drawing, &mdl_type);
ERROR_CHECK ("UserTreeExpand","ProMdlTypeGet",status);
if (status != PRO_TK_NO_ERROR || (mdl_type != PRO_MDL_DRAWING))
{
ProTKSprintf (astr, "Current model is not drawing", status);
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
ERROR_CHECK("UserTreeExpand","ProMessageDisplay",status);
return(PRO_TK_GENERAL_ERROR);
}
status = ProDrawingtreeExpand(drawing, win_id);
ERROR_CHECK ("UserTreeExpand","ProDrawingtreeExpand",status);
return (status);
}
/*================================================================*\
FUNCTION : UserTreeCollapse
PURPOSE : Collapse the drawing tree in the current drawing.
\*================================================================*/
ProError UserTreeCollapse ()
{
/*------------------------------------------------------------*\
Get the current drawing
\*------------------------------------------------------------*/
status = ProMdlCurrentGet((ProMdl*)&drawing);
ERROR_CHECK ("UserTreeExpand","ProMdlCurrentGet",status);
if (status != PRO_TK_NO_ERROR)
return (status);
status = ProMdlTypeGet((ProMdl)drawing, &mdl_type);
ERROR_CHECK ("UserTreeExpand","ProMdlTypeGet",status);
if (status != PRO_TK_NO_ERROR || (mdl_type != PRO_MDL_DRAWING))
{
ProTKSprintf (astr, "Current model is not drawing", status);
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
ERROR_CHECK("UserTreeExpand","ProMessageDisplay",status);
return(PRO_TK_GENERAL_ERROR);
}
status = ProDrawingtreeCollapse(drawing, win_id);
ERROR_CHECK ("UserTreeExpand","ProDrawingtreeExpand",status);
return (status);
}
/*================================================================*\
FUNCTION : UserTreeRefresh
PURPOSE : Refresh the current drawing tree.
\*================================================================*/
ProError UserTreeRefresh ()
{
/*------------------------------------------------------------*\
Get the current drawing
\*------------------------------------------------------------*/
status = ProMdlCurrentGet((ProMdl*)&drawing);
ERROR_CHECK ("UserTreeExpand","ProMdlCurrentGet",status);
if (status != PRO_TK_NO_ERROR)
return (status);
status = ProMdlTypeGet((ProMdl)drawing, &mdl_type);
ERROR_CHECK ("UserTreeExpand","ProMdlTypeGet",status);
if (status != PRO_TK_NO_ERROR || (mdl_type != PRO_MDL_DRAWING))
{
ProTKSprintf (astr, "Current model is not drawing", status);
status = ProMessageDisplay (WMSGFIL,"USER %0s", astr);
ERROR_CHECK("UserTreeExpand","ProMessageDisplay",status);
return(PRO_TK_GENERAL_ERROR);
}
status = ProDrawingtreeRefresh(drawing, win_id);
ERROR_CHECK ("UserTreeExpand","ProDrawingtreeExpand",status);
return (status);
}