/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ /*--------------------------------------------------------------------*\ Pro/TOOLKIT includes \*--------------------------------------------------------------------*/ #include "ProToolkit.h" #include "ProMenu.h" #include "ProUtil.h" #include "ProColor.h" /* line style */ #include "ProGraphic.h" /*--------------------------------------------------------------------*\ Pro/DEVELOP includes \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ C System includes \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include "TestError.h" #include "UtilString.h" #include <ProTKRunTime.h> /*--------------------------------------------------------------------*\ Macros \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Data types \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Application global/external data \*--------------------------------------------------------------------*/ /*---------------------------------------------------------------------*\ Functions declaration \*---------------------------------------------------------------------*/ int ProTestLinestyleGet( int ); int ProTestLinestyleDataPrint( ProLinestyle, ProLinestyleData* ); int ProTestLineSetMenu( void*, int ); int ProTestLinestyleSet( ProLinestyle*, ProLinestyle ); /*===========================================================================*\ Function : user_get_line_style Purpose : To get line style definitions \*===========================================================================*/ /*---------------------------------------------------------------------*\ Function: ProTestLinestyleGet() Purpose: Get line style data, then call ProTestLinestyleDataPrint() to print out 'em. Returns: 0 - success; -1 - error. \*---------------------------------------------------------------------*/ int ProTestLinestyleGet( int style ) /* (In) Style to get data */ { ProError status; ProLinestyleData style_data; /* Get data */ status = ProLinestyleDataGet( (ProLinestyle)style, &style_data ); TEST_CALL_REPORT( "ProLinestyleDataGet()", "ProTestLinestyleGet()", status, status != PRO_TK_NO_ERROR ); if( status != PRO_TK_NO_ERROR ) return -1; /* Print out data */ ProTestLinestyleDataPrint( (ProLinestyle)style, &style_data ); return 0; } /*===========================================================================*\ Function : user_printf_line_style Purpose : To printf line style definitions \*===========================================================================*/ /*---------------------------------------------------------------------*\ Function: ProTestLinestyleDataPrint() Purpose: Print out the specified line style info. Returns: 0 - success; Now ignored. \*---------------------------------------------------------------------*/ int ProTestLinestyleDataPrint( ProLinestyle style, /* (In) Line style to print out */ ProLinestyleData* p_style_data ) /* (In) Style data to print out */ { char name[32]; char line_style_name[32]; char line_def[32]; char cap_style[32]; char join_style[32]; char fill_style[32]; char fill_rule[32]; int len_of_dash_list; double dash_offset; int i; switch( style ) { case PRO_LINESTYLE_SOLID: ProUtilstrcpy( name, "PRO_SOLIDFONT" ); break; case PRO_LINESTYLE_DOT: ProUtilstrcpy( name, "PRO_DOTFONT" ); break; case PRO_LINESTYLE_CENTERLINE: ProUtilstrcpy( name, "PRO_CTRLFONT" ); break; case PRO_LINESTYLE_PHANTOM: ProUtilstrcpy( name, "PRO_PHANTOMFONT" ); break; default: ProUtilstrcpy( name, "Unrecognized Type" ); break; } ProTKPrintf( "\n" ); ProWstringToString( line_style_name, p_style_data->line_style_name ); ProTKPrintf( " line_style_name = %s ", line_style_name ); ProWstringToString( line_def, p_style_data->line_definition ); ProTKPrintf( " line_def = %s \n", line_def ); ProWstringToString(cap_style, p_style_data->cap_style ); ProTKPrintf( " cap_style = %s ", cap_style); ProWstringToString(join_style, p_style_data->join_style ); ProTKPrintf( " join_style = %s \n", join_style); ProWstringToString(fill_style, p_style_data->fill_style ); ProTKPrintf( " fill_style = %s ", fill_style); ProWstringToString(fill_rule, p_style_data->fill_rule ); ProTKPrintf( " fill_rule = %s \n", fill_rule ); len_of_dash_list = p_style_data->len_of_dash_list; dash_offset = p_style_data->dash_offset; ProTKPrintf( " len_of_dash_list = %d dash_offset = %lf \n", len_of_dash_list, dash_offset ); ProTKPrintf( " p_style_data->dash_list = " ); for( i=0; i<len_of_dash_list; i++ ) ProTKPrintf( " %lf ",p_style_data->dash_list[i] ); ProTKPrintf( "\n" ); return 0; } /*===========================================================================*\ Function : user_set_line Purpose : To set-up the user's line_style menu \*===========================================================================*/ /*---------------------------------------------------------------------*\ Function: ProTestLineSetMenu() Purpose: On-button function. Set up the line style menu. Returns: 0 - success. \*---------------------------------------------------------------------*/ int ProTestLineSetMenu( void* p_dummy, int int_dummy ) { ProError status; int menu_id; /* The identifier of the created menu */ int action; int style; /*-----------------------------*\ Create new menu Linestyle \*-----------------------------*/ /* Load base menu from file */ status = ProMenuFileRegister((char*) "Linestyle",(char*) "tklinestyle.mnu", &menu_id ); TEST_CALL_REPORT( "ProMenuFileRegister()", "ProTestEntityDrawMenu()", status, status != PRO_TK_NO_ERROR ); /* Define menu buttons */ ProMenubuttonActionSet((char*) "Linestyle",(char*) "Solid", (ProMenubuttonAction)ProTestLinestyleSet, &style, PRO_LINESTYLE_SOLID ); ProMenubuttonActionSet((char*) "Linestyle",(char*) "Dot", (ProMenubuttonAction)ProTestLinestyleSet, &style, PRO_LINESTYLE_DOT ); ProMenubuttonActionSet((char*) "Linestyle",(char*) "Ctrl", (ProMenubuttonAction)ProTestLinestyleSet, &style, PRO_LINESTYLE_CENTERLINE ); ProMenubuttonActionSet((char*) "Linestyle",(char*) "Phantom", (ProMenubuttonAction)ProTestLinestyleSet, &style, PRO_LINESTYLE_PHANTOM ); ProMenubuttonActionSet((char*) "Linestyle",(char*)"Linestyle", (ProMenubuttonAction)ProMenuDelete, NULL, 0 ); /*-----------------------*\ Run menu Linestyle \*-----------------------*/ status = ProMenuCreate( PROMENUTYPE_MAIN,(char*) "Linestyle", &menu_id ); TEST_CALL_REPORT( "ProMenuCreate()", "ProTestEntityDrawMenu()", status, status != PRO_TK_NO_ERROR ); if( status == PRO_TK_NO_ERROR ) { status = ProMenuProcess((char*) "Linestyle", &action ); TEST_CALL_REPORT( "ProMenuProcess()", "ProTestEntityDrawMenu()", status, status != PRO_TK_NO_ERROR ); } return 0; } /*===========================================================================*\ Function : user_set_line_style Purpose : To set the user's line style \*===========================================================================*/ /*---------------------------------------------------------------------*\ Function: ProTestLinestyleSet() Purpose: On-button function. Set the specified line style, then call ProTestLinestyleGet() to get & print out set style. Returns: Line style - success; -1 - error. \*---------------------------------------------------------------------*/ int ProTestLinestyleSet( ProLinestyle* p_line_style, ProLinestyle line_style ) { ProError status; ProLinestyle old_line_style; /* Set the specified line style */ status = ProLinestyleSet( line_style, &old_line_style ); TEST_CALL_REPORT( "ProLinestyleSet()", "ProTestLinestyleSet()", status, ((status!=PRO_TK_NO_ERROR)&&(status!=PRO_TK_NO_CHANGE)) ); *p_line_style = line_style; if( (status != PRO_TK_NO_ERROR) && (status != PRO_TK_NO_CHANGE) ) return -1; /* get & print out the specified style */ ProTestLinestyleGet( line_style ); status = ProMenuDelete(); TEST_CALL_REPORT( "ProMenuDelete()", "ProTestLinestyleSet()", status, status!=PRO_TK_NO_ERROR ); return line_style; }