Home

PDF file

image

Contents

1. eese 39 Parsing the Code eee The Get Token Function The GetVars Function Chapter 8 Introduction eene ee ee eene Creating Help Chapter 9 Creating a Data Loader 97 Loaders Versus Converters eee eese eee esee eren neret nnn 57 How a Data Loader Add on Works ese 57 Creating the Data Loader Creating the Dialog sssssssssessssssssssessesescessis ssssrosssssssssosessssssss Implementing Dialog Callbacks eere 61 The FileName Text Field Callback eese 61 The Browse Button Callback ecce eee eee The OK Button Callback eese eee eese eee tnn nnn Registering Callbacks 4 eere eee eese eese nete nennen Loading the Data Using Auto Load on Demand Using Custom Load 70 Using Immediate Loading eere eret 75 G Chapter 10 Extending Interactive User Interface Capabilities 79 Introduction to SumProbe Add on 79 The MenuCallback Function e eee eere eene enue 80 The MyProbeCallback Function eee eere rennen 81 e 83 Chapter 1 JAnimalinpaiusss
2. eere 11 Creating a New Add on eese eee eese eene 12 Creating the Graphical User Interface for Your Add on 13 Compiling the Add on ssissssissrssssssossssssssessssssssssssossisusssssssoses 13 Using Runmake eee eee 13 Editing the CustomMake File eee eere 13 Hello World c eeecceeeeeeeeeeees 15 Introduction to the Equate Add on 17 Creating the Dialog eee eere eee eee nete sensn tns 18 GUI Source Code eere ee eee eee eese enses sensn ttn suat 21 Setting up State Variables and Initializing the Dialog Fields22 Writing the Compute Function eese eere eee eren 24 1868 28 Table of Contents Chapter 6 Extending the Equate Add on 29 Getting Started eee ee ee eee e eee seen eee esee eee 29 Editing EqQuate 29 Chapter 7 Creating a Data 35 Converters Versus Loaders eee eee ee eere e eerte eee 35 How do Converters work in Tecplot eene 35 Introduction to the Converter Add on 35 Modifying the ConverterCallback Function 36 Writing the DoConversion Function
3. Creative Computing July 1980 At least 3 points required for interpolation if fewer then use linear interpolation Data is treated as a 1 based array while 1x ly lxn lyn are treated as 0 base param npts number of original data points param Ix location of x data points param ly location of y data points param nptn number of points on the fitted curve param Jocation of fitted x points 9 param lyn Jocation of fitted y points param data working array 112 Source Files void PolyInt int npts int lx int ly int nptn int xn int lyn double data int jjl iix jx kx ixx jxx double xv yv dydx dydx1 s y0 dyj dyj1 Isolate the data x j and the data Ix4j 1 that bracket for G 1 i lt nptn i data Ixn i while xv gt data Ix4j1 j G 113 if npts 1 yv data ly j if npts 2 data ly 2 data 1x j1 xv data ly j1 data ly j data Ix4j1 data 1x j if npts gt 3 Calculate the slope at the jth point from fitting circle thru 3 points and getting slope of circle 10151 114 Source Files ix 1 kx 1 dydx data ly jx data ly rix pow data Ix kx data Ix4jx 2 4 pow data ly kx data ly jx 2 data ly kx data ly jx pow dat
4. 137 Introduction to the SimpAvg Extended Curve Fit 137 Getting Started 137 Designing the Add on tenente tann 138 What are the settings going to be eee 138 What are the default settings 138 What is the syntax for the CurveSettings string Handling the CurveSettings String eese The InitializeCurveParams Function Registering the Add on with Tecplot Creating the Dialog eere reete eene eene entente nant Launching and Initializing the Dialog Initializing the Dialog eere eee eee Making the Dialog Operational eere Updating the Sensitivities eee e eee eene tnn Updating the Mapping Zone Style Dialog The Curve Fit MM The 5 Introduction Chapter 1 About Add ons 1 1 Introduction This manual describes strategies for creating Tecplot add ons Add ons are executable modules that extend Tecplot s basic functionality Add ons are implemented as compiled function libraries called variously shared objects shared libraries or dynamic link libraries DLLs Using the Tecplot application pr
5. Making the Dialog Operational CurveParams gt UselInd VarRange TecGUIToggleGet UseIndVarRan_TOG_D1 Note this function returns a boolean alerting user whether or not input value is legitimate Some error checking may be added here TecGUITextFieldGetDouble IndVarMin TF D1 amp CurveParams Ind VarMin TecGUITextFieldGetDouble IndVarMax TF Di amp CurveParams Ind VarMax The DialoglOkButton CB function to look as follows static void DialoglOkButton CB void Only unlock tecplot here because a modal dialog was launched When curve settings change Tecplot must be informed of the change char CurveSettings NULL CurveParams_s CurveParams Assign the new curve parameters from the dialog settings AssignCurveParams amp CurveParams G 157 Create the Curve Settings string from the new curve parameters CurveSettings CreateCurveSettingsString CurveParams if CurveSettings NULL EntIndex_t Map TecUtilSetForEachMember Map GlobalCurve X Y MapSet TecUtilCurveSetExtendedSettings Map 125 TecUtilStringDealloc amp CurveSettings TecGUIDialogDrop Dialog 1 Manager TecUtilLockFinish AddOnID At this point the dialog should be fully functional The dialog will be initialized with the correct values and sensitivities The sensitivities will be updated correctly and Tecplot will be informed when the CurveSettings s
6. TecUtilLockFinish AddOnID We collect the information from the dialog and then pass that information off to Ani matePlanes to carry out the animation Because ZoneSet is initialized to NULL we can tell if there were any selections If there were not we display an error message reading zones have been picked 11 5 Writing the AnimatePlanes Function This function will perform the actual animation It takes two parameters ZoneSet and Skip These parameters are collected in the AanimatePlanes button callback function in main c void AnimatePlanes Set pa ZoneSet int Skip 94 Writing the AnimatePlanes Function LgIndex_t MaxIndex 0 EntIndex t CurZone SetIndex t NumberOfZonesInSet SetIndex t Index Set IJKZoneSet TecUtilSetAlloc TRUE char strMacroCommand Get the number of zones in ZoneSet NumberOfZonesInSet TecUtilSetGetMemberCount ZoneSet if TecUtilMacroIsRecordingActive amp amp NumberOfZonesInSet gt 1 strMacroCommand TecUtilStringAlloc 2000 Macro Command strcpy strMacroCommand ZONESET G 95 Create a subset of ZoneSet that includes only IJK Ordered Zones Do this by looping through all the zones in ZoneSet check to see if the zone is IJK Ordered Then add the zone to IJKZoneSet for Index 1 Index lt NumberOfZonesInSet Index Get the current zone CurZone EntIndex_t
7. Calculate s slope between j and j 1 points y0 if linear interp used dyj delta y at the j th point 4 1 delta y at the j 1 point data ly j1 data ly j data 1x j1 data 1x j yO data ly j s xv data 1x j data ly j dydx xv data x j y0 data ly j1 dydx1 xv data 1x j1 y0 Calculate y 118 The XYDataPointsCallback Function if dyj dyjl 0 0 yv y0 if dyj dyjl gt 0 0 y0 dyj dyj1 dyj dyj1 if dyj dyjl lt 0 0 yO dyj dyj1 xv data x j xv data x j1 dyj dyj 1 data 1x j 1 data 1x j data lyn i yv 12 4 The XYDataPointsCallback Function Knowing that the PolyInt function uses a single array containing all the raw and calculated independent values we must prepare this array in the XYDataPointsCallback function and pass it on to the PolyInt function Once the array is passed on to PolyInt it will be returned with the calculated points filled in at which time we must extract those points from the working array and place them into the array that Tecplot passed to the XYDataPointsCallback function See TecUtilCurveRegisterExtCrvFit in the ADK Reference Manual for an explana tion of the parameters of this function The XYDataPointsCallback has the following structure lt 119 T Allocate and initialize the working array called Data 2 Fill the
8. Exercises 11 7 Exercises 1 Currently there is nothing to inform users they have entered an invalid number for the skip such as a negative number or zero Add error checking in the text field callback to check for a valid positive integer Check that the integer in the text field is less than or equal to the maximum I Max for the selected zones Allow the animation of J and K planes Adding an option menu to the inter face with the types of planes as options would be a good place to start Add code to make the add on remember the last skip value entered such that when the dialog is closed and reopened the last skip value is the default in the text field Allow input of start and end planes This would allow animation from a larger plane index to a smaller index and allow a specific range of planes to animate 105 106 Introduction to the PolyInt Extended Curve Fit Chapter 12 Polynomial Integer Add on 12 1 Introduction to the PolyInt Extended Curve Fit PolyInt the Tecplot add on you will build in this tutorial is an example of an extended curve fit add on that does not have any settings which may be configured This add on will add an option to the single selection list that is launched by the Curve Type Extended option on the Curves page of the Mapping Style dialog This add on will perform three operations The only required operation is to calculate the curve fit
9. ENCSA Hierarchical Data Format HDF Software Library and Utilities 1988 1998 The Board of Trustees of the University of Illi nois All rights reserved Contributors include National Center for Supercomputing Applications NCSA at the University of Illinois Fortner Software Windows and Mac Unidata Program Center netCDF The Independent JPEG Group JPEG Jean loup Gailly and Mark Adler gzip Bmptopnm Netpbm 1992 David Sanderson Dlcompat 2002 Jorge Acereda additions and modifications by Peter O Gorman Ppmtopict 1990 Ken Yap TRADEMARKS Tecplot Tecplot 360 Preplot Enjoy the View and Framer are registered trademarks or trademarks of Tecplot Inc in the United States and other countries Encapsulated PostScript PostScript Premier are registered trademarks or trademarks of Adobe Systems Incorporated in the U S and or other countries Ghostscript is a registered trademark of Aladdin Enterprises in the U S and or other countries Linotronic Helvetica Times are registered trademarks or trademarks of Allied Corporation in the U S and other countries AutoCAD DXF are registered trademarks or trademarks of Autodesk Incorporated in the U S and other countries lan License Manager is a trademark of lan Com puter Group Incorporated in the U S and or other countries DEC Digital LaserJet HP GL HP GL 2 PaintJet are registered trade marks or trademarks of Hewlett Packard Company in the U S and
10. IsOk FALSE G 65 1 TecUtilDialogErrMsg Invalid file name IsOk FALSE else TecUtilDialogErrMsg Invalid command IsOk FALSE TecUtilStringDealloc amp Name TecUtilStringDealloc amp ValueString End parsing Instructions String list Data files often contain header information that must be read by the loader to correctly load the file Files loaded by this example loader are binary files in block format and all variable values are in double precision Each file has the following information in the header Imax Jmax Kmax num ber of variables and number of zones Add the following code to LoaderCallback after End parsing Instructions String list if IsOk TRUE MyFile is still open LgIndex_t LgIndex_t LgIndex_t LgIndex_t LgIndex_t LgIndex_t char Boolean t NumZones NumVars IMax JMax KMax NumPoints MyVar 20 DeferVarCreation TRUE FieldDataType e VarDataTypes 66 G Registering Callbacks FileOffset_t EntIndex t EntIndex t int int StringList pa CurOffset 0 VarIndex ZoneIndex ZoneOffset DataOffset 5 sizeof int Data values begin after the 5 integer values in the header VarNames TecUtilStringListAlloc Read data set information from file header fread fread fread fread fread amp IMax sizeof int 1 MyFile amp JMax sizeof
11. Ix Start of the raw Independent data ly Start of the raw Dependent data Ixn Start of the calculated independent data lyn Start of the calculated dependent data Note the following function above the XYDataPointsCallback function static void PrepareWorkingArray FieldData pa RawIndV FieldData pa RawDepV LgIndex_t NumRawPts Lglndex t NumCurvePts int int ly int int lyn 124 The PrepareWorkingArray Function double Data double First ValidPoint double Last ValidPoint double StepSize int ii The followint are indices to start points of the data blocks in the 1 based arrray Data Ix Start of the raw Independent data ly Start of the raw Dependent data xn Start of the calculated independent data lyn Start of the calculated dependent data The PolyInt function treats Ix ly Ixn lyn as 0 base indices but treats Data as 1 base array lx 0 ly NumRawPts Ixn 2 NumRawPts 125 lyn 2 NumRawPts NumCurvePts Fill the first blocks of the Data array with the Raw Data Values for Gi 1 ii lt NumRawPts 1i Data Ix4ii TecUtilData ValueGetB yRef RawIndV 11 Data ly ii TecUtilData ValueGetByRef RawDepV 11 Calculate the size of steps to take while stepping along the independent variable range TecUtilData ValueGetMinMaxByRef RawIndV amp Fi
12. C C C Bex Coder Ml C C 2 TES fet DHE 8 AmxhwZeeM A Abe 422 Frames Maceo Function VsNsve Hatiun Types EA 6 You can now build the source for this layout From the TGB dialog click Go Build If you wish to preview what your dialog will look like when run click Preview Layout from TGB 7 Rename the file guicb tmp to be guicb c replacing the original guicb c then compile the source code 20 GUI Source Code Multiply By Edit Current Frame Frame Dimensions Paper Ruler Units Size and Position Left Side 4 4 Width 4 791057 Top Side 0 7 Height 1 576367 Show Border Thickness 2 o Show Header 2015 Green z Show Background Color Custom 2 Frame Name ODE MODELESS TITLE Equate 5 3 GUI Source Code Now we will examine the source code files generated by TGB e Files guidefs c GUIDEFS h If you are using C be sure that GUIDEFS h is included at the top of the main cpp and add this code in the MenuCallback function BuildDialogl MAINDIALOGID TecGUIDialogLaunch DialoglManager GUIDEFS h contains the variable names of all of the controls added to the dia log TGB has taken the variable names specified in the Macro Function Com mand field and decorated them as follows int DialoglManager BADDIALOGID
13. Tecplot Enjoy the View 360 Getting Results with the Add on Developer s Kit Tecplot Inc Bellevue WA 2006 COPYRIGHT NOTICE Tecplot 360 Add on Developers Kit Getting Results Manual is for use with Tecplot 360 2006 Copyright 1988 2006 Tecplot Inc All rights reserved worldwide Except for personal use this manual may not be reproduced trans mitted transcribed stored in a retrieval system or translated in any form in whole or in part without the express written permission of Tecplot Inc 3535 Factoria Blvd Ste 550 Bellevue Washington 98006 U S A The software discussed in this documentation and the documentation itself are furnished under license for utilization and duplication only according to the license terms The copyright for the software is held by Tecplot Inc Documentation is provided for information only It is subject to change without notice It should not be interpreted as a commitment by Tecplot Inc Tecplot Inc assumes no liabil ity or responsibility for documentation errors or inaccuracies Tecplot Inc PO Box 52708 Bellevue WA 98015 2708 U S A Tel 1 800 763 7005 within the U S or Canada 00 1 425 653 1200 internationally email sales tecplot com support tecplot com Questions comments or concerns regarding this documentation documentation tecplot com For more information visit http www tecplot com THIRD PARTY SOFTWARE COPYRIGHT NOTICES
14. TempFName amp Debug amp VIsDouble 0 strcpy MessageString Could not create data set lt 43 IsOk FALSE Use TecUtilTecZne to add the first zone Tn this case it is the only zone if ISOk amp amp TecUtilTecZne Zone 1 amp IMax amp JMax amp KMax POINT NULL 0 strcpy MessageString Could not add zone IsOk FALSE Now add the data if ISOk LgIndex_t PointIndex 1 int Skip 0 44 Writing the DoConversion Function Allocate space to temporarily store the values double LineValues double calloc NumValues sizeof double Get the values into the array LineValues for 1 0 i lt NumValues i get_token f LineValues i atof _token Use the function TecUtilTecDat to fill the temporary file with the values stored in the Line Values if TecUtilTecDat amp Num Values void LineValues amp VIsDouble 0 strcpy MessageString Error loading data IsOk FALSE Free LineValues now that we are done using it lt 45 free Line Values Calling TecUtil TecEnd closes the temporary file if TecUtilTecEnd 0 IsOk FALSE strcpy MessageString Error closing temporary file could not create data set TecUtilStringListDealloc amp VarList return IsOk 7 5 Parsing the Code A discussion of the pa
15. To set the sensitivities we create the following function in guicb c Be sure this function is placed above the D aloglInit function static void UpdateMainDialogSensitivities void Boolean t Sensitive TecGUIToggleGet UseIndVarRan D1 TecGUlISetSensitivity IndVarMin TF Dl Sensitive TecGUlISetSensitivity IndVarMax TF Dl Sensitive TecGUlISetSensitivity Min Sensitive TecGUlISetSensitivity Max LBL Sensitive If only one XY map is selected the XYMapSettings string list will have only one member and that member will be the CurveSettings for that mapping However when there is more than one mapping selected and they have different curve settings how do we decide to initialize the fields on the dialog Use the following method f all mappings have the same values for any particular field that value will be used the selected mappings have different values for any particular field the default value is used To help initialize the fields we will create a function that will determine the proper value for each variable The function will then return the appropriate value the default value if the maps have dif ferent settings for that value or the value that is set if all maps have the same setting for that value The function is defined below The following function is in guicb c G 151 static void InitializeGUICurveParams CurveParams CurveParamsPtr char
16. 1 TecUtilDataValueSetByRef FieldData PointIndex Value else IsOk FALSE TecUtilDialogErrMsg Binary Value not read MyClientData gt DataType MyClientData gt NumPoints correctly if MyFile NULL fclose MyFile ENSURE VALID BOOLEAN IsOk G 73 return IsOk static Boolean t STDCALL LoadOnDemandVarUnload FieldData pa FieldData Boolean t Result TRUE REQUIRE FieldData NULL REQUIRE VALID REF ClientDataValues s TecUtilDataValueGetClientData FieldData TRACE Load on Demand Var Unload callback n ENSURE VALID BOOLEAN Result return Result static void STDCALL LoadOnDemandVarCleanup FieldData pa FieldData ClientDataValues_s MyClientData REQUIRE FieldData NULL REQUIRE VALID REF ClientDataValues s TecUtilDataValueGetClientData FieldData MyClientData ClientDataValues s TecUtilDataValueGetClientData FieldData free MyClientData gt FileName free MyClientData TRACE Load on Demand Var Cleanup callback Wn 74 G Using Immediate Loading This completes the coding for this add on using Custom Load On Demand It is recommended that you add error checking each time you send and receive parameters to a function Other enhance ments Check byte order Add a parameter to ClientData that would allow the loader to skip over values to load data in Point
17. LgIndex t IMax JMax KMax TecUtilZoneGetInfo ZoneNum 100 Writing the AnimatePlanes Function amp amp JMax amp KMax NULL XVar NULL Y Var NULL ZVar NULL NMap NULL UVar NULL V Var NULL W Var NULL B Var NULL CVar NULL SVar IsOk IMax gt 1 amp amp JMax gt 1 amp amp KMax gt 1 return IsOk This function is added for convenience so as to not clutter AnimatePlanes static LgIndex t GetIMaxFromCurZone EntIndex t ZoneNum LglIndex t IMax G 101 TecUtilZoneGetInfo ZoneNum amp IMax NULL JMax NULL KMax NULL XVar NULL YVar NULL ZVar NULL NMap NULL UVar NULL VVar NULL WVar NULL BVar NULL CVar NULL SVar return Compile the add on and make sure that it runs properly If you have two frames with different data sets the zone list will not be updated when switching between frames 11 6 Monitoring State Changes Now we will add functionality to allow the zone list to update properly To do this we will need to listen for state changes When something in Tecplot changes such as a new top frame Tecplot 102 Monitoring State Changes broadcasts a message saying that there is a new top frame We are going to add code to our add on to allow it to listen for these messages Thi
18. NumValuesRead fread amp Value sizeof double 1 MyFile TecUtilDataValueSetByRef FieldData PointIndex Value End of Point for loop End of Var for loop if MyFile NULL fclose MyFile End of Zone for loop if KMax 1 TecUtilFrameSetPlotType PlotType Cartesian3D else TecUtilFrameSetPlotType PlotType Cartesian2D TecUtilRedraw TRUE TecUtilImportSetLoaderInstr ADDON_NAME Instructions 76 IS Using Immediate Loading End of if IsOk TecUtilLockFinish AddOnID return IsOk End of LoaderCallback This completes the coding for using Immediate Loading 77 78 Introduction to the SumProbe Add on Chapter10 Extending Interactive User Interface Capabilities 10 1 Introduction to the SumProbe Add on SumProbe the add on you will create in this chapter is an example of an add on which can sum up the probed values of a selected variable It will appear in Tecplot s Tools menu as Sum Probed Val ues When selected a dialog will appear allowing you to specify which variable you wish to sum All of the examples of the source code shown in this manual are included in the Tecplot distribution and are found in the adk samples sub directory below the Tecplot home directory SumProbe uses source code files created by the CreateNewAddon script UNIX or Tecplot Add on Wizard Windows When running CreateNewAddoOn or Tecplot
19. s Kit was installed on your computer look in your Tecplot Home Directory for the ADK sub directory If the ADK sub directory is not present you will need to re install Tecplot Version 360 If you plan on using Tecplot GUI Builder TGB make sure the following line is in the tec plot add file in the Tecplot Home Directory LoadAddon guibld Tecplot GUI Builder is discussed in detail in Section 2 3 as well as in the Tecplot Add On Devel opers Kit Users Manual 2 2 Creating an Add on with Visual C Tecplot Add on Wizard is included in the Tecplot installation and is fully integrated with Visual C Version 5 0 or higher To begin select New from Visual C s File menu then click on the Projects tab For the project type select Tecplot 360 Add on Wizard and follow the prompts Since Tecplot add ons are DLLs Tecplot Add on Wizard will automatically create a DLL work space set the proper link libraries include paths and generate default source code files Note FORTRAN under Windows is only supported if you are using Compaq Visual FORTRAN After running Tecplot Add on Wizard you must complete the following steps 1 Select Settings from the Visual C Project menu 2 Click on Debug 3 Select General 4 Set Executable for debug session to be tecplot exe including the full path if necessary G 9 5 Set the working directory to Debug 6 Set the program arguments to be projectname dll Projec
20. 111 164 166 StateChangeCallback 103 TecIO 35 TecUtil 39 80 TecUtilCurveRegisterExtCrvFit 108 119 TecUtilCurveSetExtendedSettings 146 TecUtilDataSetAddZone 67 TecUtilDataSetCreate 67 TecUtilDialogGetFileName 61 TecUtilDialogGetVariables 80 TecUtilHelp 55 TecUtilImportAddLoader 57 TecUtilMenuAddOption 16 80 TecUtilProbeInstallCallback 81 TecUtilStringAlloc 141 TecUtilStringDealloc 62 TecUtilTecDat 40 TecUtilTecEnd 40 TecUtilTecIni 40 TecUtilTecZne 40 TecUtilVarIsEnabled 28 TecUtilZoneIsEnabled 28 UpdateMainDialogSensitivities 155 writing Compute 24 XYDataPointsCallback 119 124 127 161 Further reading 7 173 INDEX G Get_token function 40 46 Get_Vars function about 50 GetVars function 40 Graphical User Interface 13 GUI builder 13 GUI Source Code 21 Gui lay 18 in LoadTxt 59 GUI_TextFieldGetString function 63 GUI_TextFieldSetString function 23 Guibld c 18 description 22 in Equate 22 Guicb c 18 description 22 in AnimIPlanes 89 91 in Equate 22 23 in LoadTxt 61 62 guicb c in SimpAvg 148 149 151 156 Guicb tmp description 22 in AnimIPlanes 89 guicb tmp in SimpAvg 148 Guidefs c 18 description 21 in Equate 21 GUIDEFS h 18 description 21 in Equate 21 H Hello World 15 Help 55 adding to Equate Add on 55 equate html 55 TecUtilHelp 55 I IndCurveValues array 124 InitializeCurveParams function 146 InitializeGUICurveParams 155 InitTecAddOn function 16 36 57 80
21. Add on Wizard answer the questions as follows Project Name SumProbe Add on name Sum Probe Company name Your company name Type of add on General Purpose Language C Use TGB to create a platform independent GUI Yes Add a menu callback to the Tecplot Tools menu Yes Menu text Sum Probed Values Menu callback option Launch a modeless dialog Dialogue Title Sum Probe lt 79 We will use TecUtil function to get the variable name to sum and TGB to create a dialog to dis play the total number of summed points After running CreateNewAddoOn or Tecplot Add on Wizard you have the following files guibld c guicb c guidefs c main c ADDONGBL h GUIDEFS h gui lay You will also have other files specific to your platform but we will only modify those above The purpose of each file will be explained in detail as we proceed Verify that you can compile your project add on and load it into Tecplot If you cannot refer to Chapter 2 Creating Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 10 2 The MenuCallback Function Most add ons contain a callback function named MenuCallback This is called by Tecplot each time the add on is selected from the Tools menu MenuCallback stores the code that performs all functions of the add on This callback function is specified in TecUtilMenuAd dOption function is passed to Tecplot in InitTecAddO
22. Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 before proceeding 13 3 Designing the Add on Since this curve fit will have settings which may be configured we will need to make some decisions before writing the add on 13 3 1 What are the settings going to be Use an Independent Variable Range e What is the IndVarMin What is the IndVarMax 13 3 2 What are the default settings UseIndVarRange FALSE e IndVarMin LARGEDOUBLE 1E 150 138 Q G Handling the CurveSettings String IndVarMax LARGEDOUBLE 1 150 13 3 3 What is the syntax for the CurveSettings string Newline delimited spaces delimiting the are required Example UseIndVarRange TRUE n IndVarMin 2 n IndVarMax 7 n 13 3 4 How to maintain the values of the settings The settings string will be maintained by Tecplot however we will create a struct as follows to hold the values that are contained in the settings string typedef struct Boolean_t UseIndVarRange double IndVarMin double IndVarMax CurveParams_s e This structure will be placed in ADDGLBL h 13 4 Handling the CurveSettings String The first thing we will do is lay some groundwork for how to handle the CurveSettings string Since this string is maintained by Tecplot and is updated by the add on our add on must know how to parse the string We will start with the function that creates the
23. D1 CB void char SelectedFileName NULL char Type My Data char Filter m oW s TecUtilLockStart AddOnID if TecUtilDialogGetFileName SelectFileOption ReadSingleFile amp SelectedFileName Filter TecGUITextFieldSetString FileName TF D1 SelectedFileName TecUtilStringDealloc amp SelectedFileName TecUtilLockFinish AddOnID The TecUtilDialogGetFileName function will display file dialog and allow the user to select a file If you click OK the function will return TRUE otherwise you have clicked Cancel We pass TecUtilDialogGetFileName the address of a char which receives the file G 61 name Only if the function returns TRUE are we required to release the string using TecUtil StringDealloc When you click OK in the browse dialog the File Name text field in the main dialog should be filled in with the name of the selected file by the function TecGUIText FieldSetString 9 5 3 The OK Button Callback If a valid file name was entered we will call LoaderCallback with the Instructions string list which contains the file name This loader will use Tecplot standard syntax so that if the data loaded is saved in a layout Tecplot will be able to save the layout with a relative path to the data Standard syntax requires that the information needed to load the file be stored in pairs in the string list Instructions where the first string defines the function of the pair an
24. String if Str_ustremp Command USEINDVARRANGE 0 Boolean_t UseRange IsOk Macro_GetBooleanArg Command ValueString amp UseRange amp ErrMsg if IsOk CurveParams UseIndVarRange UseRange else if Str_ustremp Command INDVARMIN 0 double Min IsOk Macro_GetDoubleArg Command ValueString LARGEDOUBLE LARGEDOUBLE amp Min amp ErrMsg if IsOk G 143 CurveParams gt Ind VarMin Min else if Str_ustremp Command 0 double Max IsOk Macro_GetDoubleArg Command ValueString LARGEDOUBLE LARGEDOUBLE amp Max amp ErrMsg if ISOk CurveParams gt Ind VarMax Max else ErrMsg TecUtilStringAlloc strlen Command 100 error message sprintf ErrMsg Unknown argument Command IsOk FALSE 144 Handling the CurveSettings String else GetArgPair Failed IsOk FALSE else CurveSettings is an invalid string IsOk FALSE Repair the string Display the Error Message if needed if char NewCurveSettings NULL InitializeCurveParams CurveParams NewCurveSettings CreateCurveSettingsString CurveParams if NewCurveSettings NULL TecUtilCurveSetExtendedSettings X YMapNum NewCurveSettings TecUtilStringDealloc amp NewCurveSettings if ErrMsg NULL G 145 TecUtilDialogErrMsg ErrMsg TecUtilStringDealloc a
25. TecUtilSetGetMember ZoneSet Index Make sure the current zone is enabled if TecUtilZoneIsEnabled CurZone Only add the zone if it is IJK ordered if ZoneIsIJKOrdered CurZone TecUtilSetAddMember IJKZoneSet CurZone TRUE Find the greatest Max of all the valid IJK ordered zones MaxIndex MAX MaxIndex GetIMaxFromCurZone CurZone 96 Writing the AnimatePlanes Function if TecUtilMacroIsRecordingActive sprintf amp strMacroCommand strlen strMacroCommand 904 CurZone if Index NumberOfZonesInSet strcat strMacroCommand Only proceed if there is at least one IJK ordered zone if TecUtilSetGetMemberCount IJKZoneSet gt 1 Boolean_t IsOk TRUE Setup the zones for animation of I Planes Change the cell type to planes TecUtilZoneSetIJKMode SV CELLTYPE NULL IJKZoneSet G 97 ArbParam_t IJKCellType_Planes Display only the I Planes TecUtilZoneSetIJK Mode SV PLANES NULL IJKZoneSet ArbParam t Planes D Make sure that the Skip is greater than or equal to one if Skip 1 Skip 1 Do the actual animation TecUtilDoubleBuffer DoubleBufferAction On for Index 1 ISOk amp amp Index lt MaxIndex Index Skip Set the range of the I Planes so that the minimum I Plane to display is the same as the maximum displayed Then increment by Skip This wil
26. basic form of a conversion function is G 39 Get variable names from the file into a comma separated string Call TecUtilTecIni to initialize the temporary file e Call TecUtilTecZne to add a zone Get data points into an array Call TecUtilTecDat to add the data points to the temporary file e Call TecUtilTecEnd to close the temporary file There are other things that our conversion function will do however the steps listed above are the minimum required There are two functions used for parsing the income file These Get Vars and get_token GetVars takes two parameters a FILE and a StringList_pa Be sure that you understand the StringList_pa data type before continu ing For a discussion of StringList_pa see the ADK User s Manual GetVars will parse the text file for the variable names and place them in the string list get token takes a FILE and will parse a text file for items which are separated by commas or spaces There is no checking to make sure that the item is a valid number get token will update a global variable called token which is used in DoConversion static Boolean t DoConversion FILE f char TempFName char MessageString Boolean t ISOk TRUE StringList pa VarList TecUtilStringListAlloc Variable list int i int Num Values int NumVars int 40 Writing the DoConversion Function First we nee
27. c define NUMPTSFORPROBING 3000 This functions follows a similar process as the XYDataPointsCallback except it manually inserts ProbeIndValue in the list of the independent curve points It stores the index in the Data array for that value and uses that relative location to find the calculated ProbeDepValue Boolean t STDCALL Probe ValueCallback FieldData_pa RawIndV FieldData_pa RawDepV CoordScale_e IndVCoordScale lt 129 CoordScale_e DepVCoordScale LgIndex_t NumRawPts LgIndex_t NumCurvePts EntIndex_t XYMapNum char CurveSettings double ProbelInd Value double ProbeDepValue Boolean t IsOk TRUE int ii double FirstValidPoint double LastValidPoint double Data NULL int TotalNumDataPts TecUtilLockStart AddOnID Make sure the probe is within the bounds of the data TecUtilData ValueGetMinMaxByRef RawIndV amp FirstValidPoint amp LastValidPoint 130 The ProbeValueCallback Function IsOk ProbeIndValue gt FirstValidPoint amp amp ProbeIndValue lt LastValidPoint if IsOk Tf the Curve has too few points crank the number of points on the curve up so we get a good approximation of the curve NumCurvePts MAX NUMPTSFORPROBING NumCurvePts TotalNumDataPts 2 NumRawPts NumCurvePts Data malloc TotalNumDataPts 1 sizeof double if Data NULL Initialize Data to con
28. c static Boolean t InsertProbeValueInWorkingArray double ProbeIndValue LgIndex_t NumCurvePts int Ixn int Probe ValueIndex double Data Boolean_t Found FALSE int ii for Gi 1 ii lt NumCurvePts ii Tf the probed value is between the data points record its location if ProbeIndValue gt Data Ixn ii amp amp ProbeInd Value lt Data xn ii 1 134 The CurveInfoStringCallback Function ProbeValuelIndex ii Data Ixn 1i ProbeIndValue Found TRUE break return Found Compile and load the add on into Tecplot Now you should be able to probe and have a real curve value be returned rather than the linear interpolation computed by Tecplot 12 9 The CurvelnfoStringCallback Function The CurveInfoStringCallback function will pass a string to the XY Plot Curve Info dialog This string can be any information you wish to present to the dialog Typical information in this dialogs are the curve coefficients Since it is beyond the scope of this tutorial to calculate the coefficients of the curve we will simply present a string to the dialog Examine the following code in engine c Boolean t STDCALL CurveInfoStringCallback FieldData pa RawIndV FieldData pa RawDepV CoordScale e IndVCoordScale CoordScale e DepVCoordScale Lglndex t NumRawPts EntIndex t XYMapNum G 135 char CurveSettings char CurvelnfoString Boolean_t IsOk T
29. c or main cpp When Tecplot starts up it scans the tecdev add file loads named shared object libraries and makes a call to the InitTecAddoOn function The initialization function typically includes call to add a converter add a loader register a curve fit or add an item to the Tools menu so the add on can be accessed from the Tecplot interface e Make calls to the TecUtil functions available from the ADK via the libtec shared object library These functions allow you to do a wider range of tasks than can be done through the Tecplot interface itself 12 Creating the Graphical User Interface for Your Add on If your add on does not require a custom built GUI you will at this point have a source file named main c and perhaps a source file named engine c The latter file contains callback functions for data loaders data convertors or curve fits 3 3 Creating the Graphical User Interface for Your Add on The Tecplot Add on Developers Kit includes a simple GUI builder called Tecplot GUI Builder TGB You are not restricted to this GUI builder You may use a commercial GUI builder like Builder Xcessory or X Designer Chapter 8 of the ADK User s manual outlines how to use the Tec plot GUI Builder It is provided on the Tecplot CD When you run CreateNewAddoOn and choose to use the TGB a starter set of TGB files are created for you 3 4 Compiling the Add on 3 4 1 Using Runmake If you used CreateNewAddoOn
30. compiling the add on is straightforward Go to the subdirectory where your add on source code is located and type Runmake You will be prompted for the plat form type and the type of executable to create If you know the platform name and the build option ahead of time then you can run Runmake without the questions For example To compile on an SGI machine under IRIX 6 5 and create a debug version use Runmake sgix 65 debug To make a release version use Runmake sgix 65 release If all goes well with the compile you will end up with a shared object library located in lib platform buildtype Running Tecplot with the develop flag automatically directs it to look for your library in this directory Note If the Tecplot Home Directory and your Add on Development Directory are located in direc tories that can be remotely mounted by other UNIX computers then you can log on to those com puters and use Runmake as described earlier The resulting shared library will be stored in the appropriate subdirectory for the computer platform 3 4 2 Editing the CustomMake File The Runmake command used to build your add on actually invokes the UNIX make program with a large list of flags that customize the make process for your platform Just prior to calling lt 13 make the Runmake shell script checks to see if a local file called Cus tomMake exists and is exe cutable If so it runs the CustomMake shell script in place and th
31. completes the coding for using Auto Load On Demand 9 7 2 Using Custom Load on Demand Custom Load On Demand is ideal for large binary data files if your add on needs to be informed or to control when Tecplot loads and unloads variables To revise your add on to use Auto Load on Demand remove all code specific to Custom Load On Demand everything after the command in LoaderCallback to deallocate the argument list ArgList 9 7 2 1 Defining the ClientData structure for Custom Load On Demand For Custom Load on Demand you must place necessary information into the structure ClientData Values The structure provides information about the original file and the how to load the data requested by Tecplot This structure must be defined in a header file Edit ENGINE h and add the following code before the endif command typedef struct char FileName int CurOffset int DataType int NumPoints ClientDataValues s 70 Loading the Data 9 7 2 2 Revising LoaderCallback for Custom Load on Demand The information to place in ClientData includes the file name the number of points the data type and the off set in the file for the first value of the current variable The call to TecUtilDataValueCustom LOD includes parameters for the zone number and variable number the ClientData and three callbacks used with loading data Tecplot will store this information for each variable and use it each time it needs to l
32. format Allow other data types besides double 9 8 Using Immediate Loading Using Immediate Loading is less efficient than either method of Load on Demand and will make it slow or impossible to load large data files To revise your add on to use Immediate Loading first find the section of code shown below and set DeferVarCreation FALSE if IsOk TRUE MyFile is still open LgIndex_t NumZones LglIndex t NumVars LgIndex t IMax LglIndex t JMax LglIndex t KMax LgIndex_t NumPoints char MyVar 20 Boolean_t DeferVarCreation FALSE Remove all code specific to Auto Load on Demand or Custom Load On Demand everything after the command to deallocate the argument list ArgList in LoaderCallback plus the Custom Load on Demand functions Add the code below after the command in LoaderCallback to deallocate the argument list ArgList MyFile fopen FileName rb if MyFile NULL G 75 TecUtilDialogErrMsg Cannot open file for LoadBlock IsOk FALSE else for VarIndex 1 VarIndex lt NumVars LgIndex_t PointIndex 1 int NumValuesRead CurOffset sizeof double VarIndex 1 NumPoints ZoneOffset DataOffset FieldData TecUtilDataValueGetRef ZoneIndex VarIndex Go to the file position for the first value of the variable fseek MyFile long CurOffset 0 for PointIndex 1 PointIndex lt NumPoints PointIndex
33. from this point on is plat form independent and you can work through the tutorial using either a Win dows or UNIX environment It is also assumed that you have created an add on that has a dialog If you have not done so see Chapter 5 The Equate Add on 13 2 Getting Started SimpAvg will use the following source code files Each one will be automatically created by the CreateNewAddoOn script UNIX or the Tecplot Add on Wizard Windows The project and add on names will both be SimpAvg When running CreateNewAddoOn the Tecplot Add on Wizard answer the questions as fol lows Project Name Base name SimpAvg Add on Name SimpAvg Company Name Your company name G 137 Type of Add on Extended Curve Fit Language Allow Configurable Settings Yes Create Callback Function for More Accurate Probing No After running CreateNewAddOn script or Tecplot Add on Wizard you should have the fol lowing files engine c main c guibld c guicb c guidefs c ADDGLBL h ENGINE h GUIDEFS h You will also have other files specific to your platform but the files above are the only ones we will be dealing with The purpose of each file will be explained in detail as we proceed through the tuto rial At this point you should verify that you can compile your add on and load it into Tecplot If you are unable to compile or load your add on we recommend that you refer to Chapter 2 ating
34. function This is called from the Init TecAddOn function in main c Exporting an interface callback function named LoaderSelectedCall back called by Tecplot when you select the Import option from the File menu This usually displays a dialog to collect loading parameters After collecting the parameters the add on will call the loader function to load the data Exporting a loading callback function LoaderCallback which is called by Tecplot to load the data This is used whenever a file is loaded by macro or by selecting the Import option from the File menu After it s been registered the loader add on waits for The user to select it from the Import option Then Tecplot calls the registered interface callback Tecplot to process the READDATASET macro command Then Tecplot calls the loader callback In this case the add on will not display a dialog G 57 9 3 Creating the Data Loader LoadMyFile the Tecplot add on you will build is a basic binary data loader It will appear under the Import option of Tecplot s File menu as My File Loader All of the examples of the source code shown in this manual are included in the Tecplot distribution and are found in the adk samples sub directory below the Tecplot home directory LoadMyFile uses source code files created by the CreateNewAddoOn script UNIX or Tecplot Add on Wizard Windows Our project and add on names will be LoadMyFile When running CreateNew
35. int 1 MyFile amp KMax sizeof int 1 MyFile amp NumVars sizeof int 1 MyFile amp NumZones sizeof int 1 MyFile fclose MyFile The general steps for adding field data to Tecplot are also in LoaderCallback They are 1 Call TecUtilDataSetCreate This requires a title for the dataset and a string list VarNames containing a name for each variable 2 Call TecUtilDataSetAddZoneX once for each zone For each zone create an argument list ArgList with any necessary information for TecUtil DataSetAddZoneX Add the code below to LoaderCallback after fclose MyFile NumPoints IMax JMax KMax VarDataTypes FieldDataType e TecUtilStringAlloc sizeof FieldDataType e NumVars Var Data Types for VarIndex 1 VarIndex lt NumVars VarIndex sprintf MyVar Var 54 VarIndex TecUtilStringListAppendString VarNames MyVar VarDataTypes VarIndex 1 FieldDataType Double G 67 Create the data set in Tecplot TecUtilDataSetCreate Data Set VarNames TRUE for ZoneIndex 1 ZoneIndex lt NumZones ZoneIndex For each zone create an argument list ArgList with any necessary information for TecUtilDataSetAddZonex DeferVarCreation is not necessary for immediate loading of variables ArgList pa ArgList char ZoneTitle 20 ZoneOffset ZoneIndex 1 NumPoints NumVars sizeof dou
36. of discrete XY data The second operation is to supply Tecplot with a dependent value when the plot is probed The third is to present a string to the XY Plot Curve Info dialog of the example of source code shown in this manual is included in the Tecplot distribution and are found in the adk samples sub directory below the Tecplot home directory Note For the purposes of this tutorial it is assumed that you EN have already read the chapters Creating Add ons Under Windows and or Creating Add ons Under UNIX in the ADK User s Manual and that you have successfully created and compiled a set of starter files All of the code from this point on is plat form independent and you can work through the tutorial using either a Win dows or UNIX environment 12 2 Getting Started PolyInt will use the following source code files Each one will be automatically created by the CreateNewAddoOn script UNIX or the Tecplot Add on Wizard Windows The project name and the add on name will both be PolyInt When running CreateNewAddoOn or the Tecplot 360 Add on Wizard answer the questions as follows Project Name Base name PolyInt G 107 Add on name PolyInt Company Name Your company name Type of add on Extended Curve Fit Language C Allow Configurable Settings No Create callback function for more accurate probing Yes After running the CreateNewAddOn script or the Tecplot 360 Add o
37. other countries X Designer is a registered trademark or trademark of Imperial Software Technology in the U S and or other countries Builder Xcessory is a registered trademark or trademark of Inte grated Computer Solutions Incorporated in the U S and other countries IBM RS6000 PC DOS are registered trademarks or trade marks of International Business Machines Corporation in the U S and or other countries Bookman is a registered trademark or trademark of ITC Corporation in the U S and or other countries VIP is a registered trademark or trademark of Landmark Graphics Corporation in the U S and or other countries X Windows is a registered trademark or trademark of Massachusetts Institute of Tech nology in the U S and or other countries ActiveX Excel MS DOS Microsoft Visual Basic Visual C Visual J Visual Studio Windows Windows Metafile are registered trademarks or trademarks of Microsoft Corporation in the U S and or other countries HDF NCSA are registered trademarks or trademarks of National Center for Supercomputing Applications in the U S and or other countries UNIX Motif are registered trademarks or trademarks of Open Software Foundation Incorporated in the U S and other countries Grid gen is a registered trademark or trademark of Pointwise Incorporated in the U S and or other countries Eclipse FrontSim are regis tered trademarks or trademarks of Schlumberger Limited in the U S and or other countries IRIS IRIX Open
38. tmp The reason for this is that TGB does not want to overwrite any code that you may have added to guicb c Thus whenever you add new controls you must cut and paste the new callback functions in guicb tmp into guicb c Note that in Step 7 we copied guicb tmp to guicb c This is what you want to do when you first start the project since at that time there is no custom code in guicb c To see the new dialog 1 Compile the add on and run Tecplot 2 Select Equate from the Tools menu 5 4 Setting up State Variables and Initializing the Dialog Fields When the dialog is first displayed we need to be sure that the MulNum text field has a reasonable default value To avoid using a global variable for MulNum the value will be read from the text field and passed to a function called Compute The text field will then be initialized in the DialoglInit CB function Note the following line in guicb c Setting up State Variables and Initializing the Dialog Fields This is a string because it is put in a dialog text field define DEFAULT_MULNUM 2 Find the following segment of code in guicb c and note the line beginning with TecGUIText Field static void DialoglInit_CB void TecUtilLockStart AddOnID lt lt lt Add init code if necessary here gt gt gt TecGUITextFieldSetString MulNum TF DI DEFAULT MULNUM TecUtilLockFinish AddOnID We have defined the default value to be a string since th
39. 1 Compute function writing 24 Converter 35 create LoadTxt 58 creating 12 creating under Windows 9 curve fit add on design 138 curve fit creation 160 data converters 35 data loaders 57 dialog callbacks 61 dialog creation with TGB 10 dialog field initialization 22 dialog initialization 148 dialog launch 148 dialogs 86 dynamic link libraries 7 Equate 17 Equate dialog creation 18 exercises 28 83 105 168 Hello Word 15 Help 55 implementation 7 LoadTxt dialog creation 59 MenuCallback modification 16 OK button 62 online help 55 PolyInt description 107 reference on loading 10 register in Tecplot 147 shared libraries 7 shared objects 7 SimpAvg description 137 G 169 INDEX state change callbacks 103 state changes 102 state variable set up 22 SumProbe 79 Visual C creation 9 Windows creation 9 Advanced topics 7 Equate exercises 28 Animate I Planes add on creating dialogs 86 AnimatePlanes function 92 94 100 101 AnimatePlanes_BTN_D1_CB function 92 Animation 85 double buffering 100 AnimIPlanes add on Animate I Planes button 92 desciption 85 exercises 105 B Browse button callback in LoadTxt 61 Code examples 7 15 17 35 58 79 85 107 Compiling debug 13 release 13 using Runmake 13 Compiling the add on 13 Compute writing 24 Compute function 22 23 Converter add on about 35 ConverterCallback function 36 modifying 37 CreateCurveSettingsString function 140 CreateNewAddOn 15 17 Creating a
40. 85 107 GUI source code 21 State change callbacks in add ons 103 State changes description 102 in add ons 102 monitoring 102 State variables 22 StateChangeCallback function 103 StringList pa about 40 SumProbe add on description 79 exercises 83 T TECADDONDEVDIR 11 TECADDONDEVPLATFORM 11 TecIO function 35 Tecplot register add ons 147 Tecplot GUI Builder 176 description 10 source code 21 using 9 Tecplot GUI Builder TGB 13 Tecplot add 9 TecUtil function 80 TecUtil functions 39 TecUtilCurveRegisterExtCrvFit function 108 119 TecUtilCurveSetExtendedSettings function 146 TecUtilDataSetAddZone function 67 TecUtilDataSetCreate function 67 TecUtilDialogGetFileName function 61 TecUtilDialogGetVariables function 80 TecUtilHelp function 55 TecUtilImportAddLoader function 57 TecUtilMenuAddOption function 16 80 TecUtilProbInstallCallback function 81 TecUtilStringAlloc function 141 TecUtilStringDealloc function 62 TecUtilTecDat function 40 TecUtilTecEnd function 40 TecUtilTecIni function 40 TecUtilTecZne function 40 TecUtilVarIsEnabled function 28 TecUtilZoneIsEnabled function 28 TGB description 10 used with Developer Studio 10 U UpdateMainDialogSensitivities function 155 V Variables CurveSettings 124 XYMapNum 124 Windows creating dialogs with TGB 10 how to build add ons 9 setting up to build add ons 9 x XYDataPointsCallback function 119 124 127 161 XYMapNum parameter 141 XYMapN
41. 90 109 InsertProbe ValueInWorkingArray function 134 L Libraries 174 libtec 12 libtec 12 LoaderCallback function 64 69 LoaderSelectedCallback function 63 Loading add ons further reading 10 LoadTxt dialog creation 59 LoadTxt add on adding field data 67 Browse button 61 creating 58 dialog callback implementation 61 OK button 62 M Main c 18 about 36 in AnimIPlanes 103 in Equate 25 in SumProbe 80 81 main c 15 in PolyInt 108 in SimpAvg 147 MenuCallback function 16 80 MessageString in Converter 39 MulNum about 22 MyProbeCallback function 81 OK button in LoadTxt 62 Online Help 55 Online help adding to Equate Add on 55 equate html 55 TecUtilHelp 55 Plot Attributes dialog 147 159 PolyInt add on arrays 119 DepCurveValues array 124 description 107 IndCurveValues array 124 PolyInt function 111 119 129 Polynomial Integer add on 107 PrepareWorkingArray function 124 175 INDEX Probe ValueCallback function 128 R Reference loading add ons 10 release flag 13 Runmake 13 5 Shared libraries 7 Shared objects 7 SimpAvg add on configuration 138 curve fit creation 160 Curve Fit dialog 161 description 137 dialog initialization 148 dialog launch 148 dialog work 155 register in Tecplot 147 SimpAvgadd on exercises 168 SimpleAverage function 111 164 166 Skip parameter in AnimIPlanes 92 Skip text field 89 Source code examples 7 15 17 35 58 79
42. ALL ProcessEquateCommand char CommandString char ErrMsg 30 Editing Equate Boolean_t IsOk TecUtilLockStart AddOnID IsOk TecUtilDataSetIsAvailable if ISOk Compute atof CommandString else ErrMsg TecUtilStringAlloc 2000 Error message strcpy ErrMsg No data set available TecUtilLockFinish AddOnID return IsOk 31 Functions that process macro commands may have any name you choose however they must have the parameters shown above This function mirrors to a certain extent the Compute_BTN_D1_CB function in guicb c There is no error checking of the value of CommandSt ring This is left as an exercise In order to process macros you must register a call back function Note that the second parameter of TecUtilMacroAddCommandCallback is the same as the name of our macro processing function In main c note the registration of the ProcessEquateCommand macro command callback from within the add on initialization code EXPORTFROMADDON void STDCALL InitTecAddOn void TecUtilLockOn AddOnID TecUtilAddOnRegister 100 ADDON NAME V ADDON VERSION TecVersionId ADDON DATE Joe Coder if TecUtilGetTecplotVersion MinTecplotVersionAllowed char buffer 256 sprintf buffer Add on s requires Tecplot version 908 or greater ADDON NAME Tec VersionId Editing Equate TecUtilDialogEr
43. AddoOn or Tecplot Add on Wizard use the following answers Choose the language C Base name of the add on loadmyfile Add on name for Import menu My File Loader Company Name Your company name Type of add on Data Loader Language C Add a menu callback to Tecplot No Use TGB to create a platform independent GUI Yes Data Loader Override No Dialog Title Load My File After running the CreateNewAddoOn script or Tecplot Add on Wizard you should have the fol lowing files engine c guibld c guicb c guidefs c main c ADDGLBL h GUIDEFS h ENGINE h gui lay You will also have other files specific to your platform but you only need to edit the files listed above Their purpose will be explained as we proceed At this point verify that you can compile your project and load it into Tecplot If not please see Chapter 2 Creating Add ons under Win dows or Chapter 3 Creating Add ons under UNIX 58 Creating the Dialog 9 4 Creating the Dialog Now create the dialog which will be displayed when users select the Import option from the File menu Complex data files may require several controls on the Loader dialog An example of this is the Fluent Data Loader However this tutorial is for a simpler format The dialog will be modal and have a field for the file name and a Browse button next to the file name field Since we are using Tecplot GUI Builder the dialog template is the Tecplo
44. CurveSettings NULL CurveParams_s OrigCurveParams Boolean_t UseIndVarRangeIsSame TRUE Boolean t IndVarMinIsSame TRUE Boolean t IndVarMaxIsSame TRUE int li int NumMembers Get the CurveParams associated with the first mapping CurveSettings TecUtilStringListGetString GlobalCurve X YMapSettings 1 GetValuesFromCurveSettings EntIndex_t TecUtilSetGetNextMember GlobalCurve X Y MapSet TECUTILSET NOTMEMBER CurveSettings amp OrigCurveParams if CurveSettings NULL TecUtilStringDealloc amp CurveSettings NumMembers TecUtilStringListGetCount GlobalCurve X Y MapSettings 152 Launching and Initializing the Dialog Compare the value of the first mapping with the other mappings This loop will not be done if there is only one mapping selected for ii 2 ii lt NumMembers ii CurveParams_s TmpParams CurveSettings TecUtilStringListGetString GlobalCurve X Y MapSettings 11 GetValuesFromCurveSettings EntIndex_t TecUtilSetGetNextMember GlobalCurve X YMapSet ii CurveSettings amp TmpParams if UseIndVarRangeIsSame UseIndVarRangeIsSame TmpParams UseInd VarRange OrigCurveParams UseInd VarRange if Ind VarMinIsSame IndVarMinIsSame TmpParams IndVarMin OrigCurveParams IndVarMin if IndVarMaxIsSame IndVarMaxIsSame TmpParams IndVarMax OrigCurveParams IndVarMax G 153 if CurveSettings NULL TecUti
45. E 0 TecUtilLockFinish AddOnID Place equate html in the help sub directory below the Tecplot Home Directory then recom pile and reload your add on When you click Help on the Equate dialog or press Fl equate html will be launched in the default browser G 55 56 Loaders Versus Converters Chapter 9 Creating a Data Loader 9 1 Loaders Versus Converters Data can be imported into Tecplot using loader or converter add ons A loader must display a dia log for the user to enter the parameters needed to load the data file name skip values and so forth A converter is used when simple proprietary data files need to be read into Tecplot and it is not nec essary to use complex options to decide which portions of the data should be loaded Converters are not as efficient as loaders because the creation of an intermediate file is a part of the operation 9 2 How a Data Loader Add on Works A data loader is a special type of add on which can load data into Tecplot in many customized ways Data can come from data files but this is not a requirement Tecplot provides loaders for sev eral popular file formats including Fluent and CGNS In Tecplot all data loaders appear under the Import option of the File menu Data loaders sometimes have custom dialogs for collecting loading parameters An add on informs Tecplot that it is a data loader by Registering as a data loader by calling the TecUtilImportAddLoader
46. GL are registered trademarks or trademarks of Silicon Graphics Incorporated in the U S and or other countries Solaris Sun Sun Raster are registered trademarks or trademarks of Sun MicroSystems Incorporated in the U S and or other countries All other product names mentioned herein are trademarks or registered trademarks of their respective owners NOTICE TO U S GOVERNMENT END USERS Use duplication or disclosure by the U S Government is subject to restrictions as set forth in subparagraphs a through d of the Commercial Computer Restricted Rights clause at FAR 52 227 19 when applicable or in subparagraph c 1 ii of the Rights in Tech nical Data and Computer Software clause at DFARS 252 227 7013 and or in similar or successor clauses in the DOD or NASA FAR Supplement Contractor manufacturer is Tecplot Inc Post Office Box 52708 Bellevue WA 98015 2708 06 360 05 1 Rev 03 2006 Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Table of Contents About Add ons ecce eee eee e eee eese eeeesssse 7 IntFOGUCtlOT sa ceo eo eros sa sa rao oe 6 pOa 7 Creating Add ons under Windows 9 Setting Up to Build Add ons under Windows 9 Creating an Add on with Visual 9 Dialog Creation with Tecplot GUI Builder 10 Creating Add ons under UNIX 11 Setting Up to Build Add ons
47. I planes of a selected set of zones It will appear in Tecplot s Tools menu as Animate I Planes AnimIPlanes will verify that the data is IJK ordered change the Volume mode to I planes and cycle through the I planes of the example source code shown in this manual is included in the Tecplot distribution and is found in the adk samples sub directory below the Tecplot home directory Note For the purposes of this tutorial it is assumed that you have already read the chapters Creating Add ons Under Windows and or Creating Add ons Under UNIX in the ADK User s Manual and that you have successfully created and compiled a set of starter files All of the code from this point on is plat form independent and you can work through the tutorial using either a Win dows or UNIX environment AnimIPlanes uses source code files created by the CreateNewAddOn script UNIX or Tecplot Add on Wizard Windows Our project name will be AnimIPlanes and the add on name will be Animate I Planes When running CreateNewAddoOn or Tecplot Add on Wizard answer the questions as follows Project Name Base name AnimIPlanes Add on name Animate I Planes Company name Your company name Type of add on General Purpose Language C G 85 e Use to create a platform independent GUI Yes Add a menu call back to the Tecplot Tools menu Yes Menu text Animate I Planes Menu callback option Launch a mo
48. IndV LgIndex_t NumRawPts double IndVarMin 164 The XYDataPointsCallback double IndVarMax int ii int Count 0 double Sum 20 for ii 0 lt NumRawPts 1 double IndV TecUtilDataValueGetByRef RawIndV ii 1 Only compute the average on values that fall in the specified range of the independent variable if IndV gt IndVarMin amp amp IndV lt IndVarMax Sum TecUtilData ValueGetByRef RawDepV 1 1 Count G 165 return Sum Count The SimpleAverage function is also used in the CurveInfoStringCallback so we will have to alter that function as well You will notice that the process in CurveInfoString Callback is very similar to the process used in XYDataPointsCallback The Cur velnfoStringCallback function looks as follows Boolean t STDCALL CurveInfoStringCallback FieldData pa RawIndV FieldData pa RawDepV CoordScale e IndVCoordScale CoordScale e DepVCoordScale Lglndex t NumRawPts EntIndex t XYMapNum char CurveSettings char CurvelnfoString Boolean t IsOk TRUE CurveParams_s CurveParams double Ind VarMin Ind VarMax double Average TecUtilLockStart AddOnID 166 The XYDataPointsCallback f this function is not registered with Tecplot no curve information will be displayed in X Y Curve Info dialog CurvelnfoString TecUtilStringAlloc 30 CurveInfoStrin
49. RUE CurvelInfoString TecUtilStringAlloc 1000 CurveInfoString strcpy CurveInfoString Information about the curve goes strcat CurvelInfoString Such as curve coefficients return IsOk Again compile and load the add on into Tecplot Upon running Tecplot load rainfall plt and change the curve type to Extended PolyInt Now call up the XY Plot Curve Info dialog Notice that the string we added is now in the dialog As an exercise add error messages to the XYDataPointsCallback and the ProbeValueCallback functions if they end up returning FALSE This will inform the user that there was an error 136 Introduction to the SimpAvg Extended Curve Fit Chapter 13 The Simple Average Add on 13 1 Introduction to the SimpAvg Extended Curve Fit SimpAvg the Tecplot add on you will build in this tutorial is an example of an extended curve fit add on that has settings which may be configured The setting that we will be configuring in this add on is the independent variable range This curve fit add on will compute the average of the data within the specified independent variable range Note For the purposes of this tutorial it is assumed that you aN have already read the chapters Creating Add ons Under Windows and or Creating Add ons Under UNIX in the ADK User s Manual and that you have successfully created and compiled a set of starter files All of the code
50. a 1x jx data 1x ix 2 pow data ly jx data ly ix 2 data 1x jx data 1x ix pow data Ix kx data 1x4jx 2 4 pow data ly kx data ly jx 2 data Ix kx data Ix4jx pow data Ix jx data 1x ix 2 pow data ly jx data ly ix 2 if G 1 1XX ix jx 115 data ly jxx data ly ixx data 1x jxx data 1x ixx if s 0 0 if 1 3 gt 0 0 amp amp s gt dydx Il s lt 0 0 amp amp s lt dydx dydx s fabs s s dydx fabs s fabs s dydx else dydx 2 0 s dydx Calculate the slope at j 1 point ix nptn 2 jx nptn 1 kx nptn if G1 nptn ix 2 jl l jx jls kx 1 1 116 Source Files dydx1 data ly jx data ly ix pow data Ix kx data x jx 2 pow data ly kx data ly jx 2 data ly kx data ly jx pow data 1x jx data 1x ix 2 pow data ly jx data ly ix 2 data 1x jx data Ix rix pow data Ix kx data 1x4jx 1 2 pow data ly kx data ly jx 2 data Ix kx data 1x jx pow data 1x jx data 1x ix 2 pow data ly jx data ly ix 2 if G1 nptn jx jxx kx data ly jxx data ly ixx data 1x jxx data 1x ixx if s 0 0 117 if 1 5 gt 0 0 amp amp s gt dydx1 II s lt 0 0 amp amp s lt dydx1 dydx1 s fabs s s dydx1 fabs s fabs s dydx1 else dydx1 2 0 s dydx1
51. ack Function The TecUtilProbeInstallCallback MyProbeCallback Summing Probed Values function calls the function MyProbeCallback each time a point is probed In main c note the function MyProbeCallback above MenuCallback G 81 static void STDCALL MyProbeCallback Boolean t IsNearestPoint TecUtilLockStart AddOnID if IsNearestPoint double ProbeValue TecUtilProbeFieldGet Value Variable char Msg 100 Total Total Probe Value sprintf Msg The total is 96 Total CHECK strlen Msg lt sizeof Msg TecGUILabelSetText ThetotalisOO_LBL_D1 Msg else TecUtilDialogErrMsg You must hold down the Ctrl key when probing TecUtilLockFinish AddOnID 82 Exercises Each time a point is probed the callback checks to see if it was probed while holding down Ctrl If it was it gets the value of the variable adds it to the running total and changes the text displayed on the dialog to reflect this SumProbe is complete Recompile and load it into Tecplot 10 4 Exercises 1 Enhance SumProbe to allow for interpolated values while probing 2 Add a Clear button to the dialog to zero out the summed values G 83 84 Introduction to the AnimIPlanes Add on Chapter 11 11 1 Introduction to the AnimIPlanes Add on AnimIPlanes the add on you will create in this chapter is an example of an add on which can ani mate the
52. ak _token index c fread amp c sizeof char 1 0 while 1 49 _token index 0 return strlen _token gt 0 7 7 The GetVars Function This function reads a line of comma or space separated variables from the top of the file to be imported The variables may optionally be enclosed in double quotes static fpos_t _DataStartPos Reads a line of comman or space separated variables from the top of the file to be imported The variables may optionally be enclosed in double quotes O param f Open file handle The file must be open for binary reading Qreturn 50 The GetVars Function TRUE if more a token was fetched FALSE otherwise static void GetVars FILE f StringList pa sl char c char buffer 5000 char Line buffer char Var 100 int Index 0 char Delimiter Read up to the first new line do if fread amp c sizeof char 1 f lt 1 break if c Ww amp amp amp amp 0 buffer Index c else 51 break while 1 buffer Index 0 Now get the variable names while Line Index 0 if Line Skip to next double quote Line while Line amp amp Line Var Index Line else Read to the next delimiter while Line amp amp Line Delim
53. ame TecUtilStringListDealloc amp Instructions if IsOk TecGUIDialogDrop DialoglManager else TecUtilDialogErrMsg Error loading the file TecUtilLockFinish AddOnID If there are any errors loading the file then LoaderCallback will return FALSE and we will not drop the dialog LoaderCallback will display any error message so we will not do that in the callback We have to release the string returned by TecGUITextFieldGetString 9 6 Registering Callbacks Two function prototypes are generated for you in ENGINE h extern Boolean t STDCALL LoaderCallback StringList pa Instructions extern void STDCALL LoaderSelectedCallback void LoaderSelectedCallback will be called only when the Import option is selected from the File menu Its job will be to launch a dialog where loading parameters can be set Revise LoaderSelectedCallback inengine c as follows void STDCALL LoaderSelectedCallback void G 63 Boolean_t OkToLoad TRUE TecUtilLockStart AddOnID if TecUtilDataSetIsAvailable OkToLoad TecUtilDialogMessageBox The current data set will be replaced Continue MessageBox YesNo if OkToLoad BuildDialogl MAINDIALOGID TecGUIDialogLaunch DialoglManager TecUtilLockFinish AddOnID LoaderCallback will be called when the loader is run from the Import menu by macro It is passed the Instructions string list which contains the loading inst
54. at is what TecGUITextFieldSet String expects The Compute function will be called when you click Compute The func tion will be prototyped as follows extern void Compute double MulNum Note the function call to Compute in guicb c This function will be written below Before calling this function check that a data set is available If there is then it is implied that at least one zone and one variable exist Edit guicb c as follows static void Compute BTN D1 CB void char strMulNum NULL G 23 TecUtilLockStart AddOnID strMulNum TecGUITextFieldGetString MulNum TF D1 if TecUtilDataSetIsAvailable Compute atof strMulNum else TecUtilDialogErrMs g No data set available TecUtilStringDealloc amp strMulNum TecUtilLockFinish AddOnID No error checking is done on the input string As an exercise use TecGUITextFieldGetDou ble TecGUITextFieldSetDouble and TecGUITextFieldValidateDouble to do error checking for you 5 5 Writing the Compute Function The final task is to write the Compute function This will multiply each data point of the first variable in the first zone by the input parameter then send a message to Tecplot that the data set has changed The recommended way for an add on to get and set field data is with FieldData pa 24 Writing the Compute Function handles See the ADK User s Manual for a complete discussion of getting and setting
55. ave off XYMapSettings and SelectedX Y Maps for use jn the functions in guicb c GlobalCurve XYMapSet XYMapSet GlobalCurve X YMapSettings X YMapSettings Build and Launch the dialog BuildDialog 1 MAINDIALOGID TecGUIDialogLaunch Dialog 1 Manager TecUtilLockFinish AddOnID lt 149 GlobalCurve is a global structure that maintains the curve settings when the dialog is launched This structure must be declared in ENGINE as follows typedef struct StringList pa XYMapSettings Set pa XYMapSet GlobalCurve_s Now declare the variable GLobalCurve in engine c Just below the include statements in engine c and guicb c type the following GlobalCurve_s GlobalCurve Finally make sure the line include ENGINE h exists in guicb c 13 8 1 Initializing the Dialog Initialization of the dialog is taken care of in guicb c in the function D aloglInit When initializing the dialog we must place the correct values into each field and we must also set the sensitivities of each field In the case of this dialog the sensitivities are as follows UseIndVarRange Toggle always active IndVarMin Text field active when UseIndVarRange is checked IndVarMax Text field active when UseIndVarRange is checked Min Label active when UseIndVarRange is checked 150 Launching and Initializing the Dialog Max Label active when UseIndVarRange is checked
56. ble sprintf ZoneTitle Zone 54 ZoneIndex ArgList TecUtilArgListAlloc TecUtilArgListAppendString ArgList SV NAME ZoneTitle TecUtilArgListAppendInt ArgList SV IMAX IMax TecUtilArgListAppendInt ArgList SV JMAX TecUtilArgListAppendInt ArgList SV KMAX KMax TecUtilArgListAppendInt ArgList SV DEFERVARCREATION DeferVarCreation TecUtilArgListAppendArray ArgList SV VARDATATYPE void VarDataTypes IsOk TecUtilDataSetAddZoneX ArgList if VarDataTypes TecUtilStringDealloc char amp VarDataTypes 68 G Loading the Data TecUtilArgListDealloc amp ArgList 9 7 Loading the Data You must enable your add on to load values for each variable in the zone The best method for add ing the variable values depends on your data and the requirements of your loader Up to this point the same basic code would be used regardless of the loading method The following code will show how to use Auto Load on Demand which is the preferred method for loading large binary files A later section called USING CUSTOM LOAD ON DEMAND will show how to revise Loader Callback and add other code for Custom Load on Demand The section USING IMMEDIATE LOADING will show how to revise LoaderCallback to use Immediate Loading 9 7 1 Using Auto Load on Demand If your add on doesn t need to control when variables are loaded and unloaded and if your cell centered variable values if any are l
57. cause we are not adding the ProbeValueCallback Notice the version checking code in main c as well This is required since the extended curve fit feature is unique to Tecplot Versions 9 and later At this point verify that the add on will compile and load into Tecplot 13 7 Creating the Dialog In this step we will create the dialog that will be displayed when the user clicks Curve Settings on the Mapping Zone Style Curves page when the Curve Type is of type SimpAvg Please note that we highly recommend that the curve fit dialog be modal The dialog will have five controls one toggle two text fields and two labels lt 147 1 Load gui lay into Tecplot select Tecplot GUI Builder from the Tools menu and edit the layout as follows Use Independent Variable Range There will be callbacks associated with each of the text fields and the toggle button So that TGB will create meaningful variable names for these controls we will change their properties in Tecplot Also notice that the CurveParams_s structure has members for each text field and the toggle Note Although the text fields and buttons are referred to as controls they are in reality Tecplot text field objects since they exist in a layout file Double click on the Use Independent Variable Range toggle and select Options In the Macro Function field type VarName UseIndVarRange This will give the callback a meaningful name 3 Appropr
58. ce code can be created and edited This directory will hereafter be called the Add on Development Root Direc tory You may create any number of add ons in the Add on Development Root Directory To set up for building add ons do the following 1 Install Tecplot if you have not done so already Make sure the Add on Devel opment Tools option was selected during the installation process 2 Create the Add on Development Root Directory if you have not done so already This can be anywhere you choose 3 Be sure that you have the TEC360HOME environment variable defined and assigned to the directory where Tecplot was installed 4 Be sure your PATH environment variable includes the following TEC360HOME bin TEC360HOME adk bin 5 Create a new file called tecdev add in the directory created in step 2 i e your Add on Development Root Directory Edit the file and add the following line MC 1100 6 Optional If you plan on using the Tecplot GUI builder then add the follow ing line to the tecdev add file in your Add on Development Root Direc tory LoadAddon TECHOME lib libguibld 7 Set the environment variable TECADDONDEVDIR to the path of the directory created in step 2 8 Set the environment variable TECADDONDEVPLATFORM to one of the fol lowing G 11 hp7xx 11 linuxg23 24 linux 24 macx 101 hp7xx64 65 linuxi64 24 linux64 26ibmx 43 sgix 65 sgix64 65 sun464 57 sun4 57 From this point on when you want
59. ction void FillZoneList void if TecUtilDataSetIsAvailable EntIndex_t NumZones 1 TecUtilDataSetGetInfo NULL amp NumZones NULL TecGUlListDeleteAllItems ZoneList MLST D1 for 1 1 1 lt NumZones i 90 lt Setting up State Variables Initializing Dialog Fields char ZoneName TecUtilZoneGetName i amp ZoneName TecGUIListA ppendItem ZoneList_MLST_D1 ZoneName TecUtilStringDealloc amp ZoneName else TecGUlIListDeleteAllItems ZoneList MLST D1 This function will fill the zone list with the zone names of the data set in the current frame If there is no data set the items in the list are deleted This function is called in the dialog initialization callback in guicb c The callback should now look like static void DialoglInit CB void TecUtilLockStart AddOnID lt lt lt Add init code if necessary here gt gt gt TecGUlITextFieldSetString Skip TF D1 DEFAULT SKIP FillZoneList TecUtilLockFinish AddOnID G 91 Since the function body of FillZoneList is in main c add the following line to ADDG LBL h EXTERN void FillZoneList void 11 4 The Animate I Planes button When the Animate I Planes button is clicked we want to animate the I planes We will create a function called AnimatePlanes and add a call to that function in the AnimatePlanes BTN CB callback function Before calling the AnimatePlanes function we need t
60. d the second string gives the value For example your loader could allow points to be skipped and if the user set Skip to 2 your string list would have a pair of SKIP and 2 Instructions for this loader will contain four strings STANDARDSYNTAX 1 0 FILENAME TOLOAD File Name If you re not familiar with string lists refer to the ADK User s Manual before proceeding In order to understand the loader callback function it is important to understand what string lists are and how they work In guicb c modify the D ialoglOkButtonCallback function as shown below static void DialoglOkButton CB void char FileName Boolean_t IsOk TRUE FileName TecGUITextFieldGetString FileName_TF_D1 check that the filename is valid if FileName NULL amp amp strlen FileName gt 0 You could do more checking here such as testing whether the file will open IsOk TRUE else TecUtilDialogErrMsg Choose a file name IsOk FALSE 62 Registering Callbacks if IsOk TRUE StringList_pa Instructions Instructions TecUtilStringListAlloc TecUtilStringListAppendString Instructions STANDARDSYNTAX TecUtilStringListAppendString Instructions 1 0 TecUtilStringListAppendString Instructions FILENAME TOLOAD TecUtilStringListAppendString Instructions FileName IsOk LoaderCallback Instructions TecUtilStringDealloc amp FileN
61. d to read all of the variables GetVars f VarList Make sure there is at least one variable if ISOk amp amp TecUtilStringListGetCount VarList lt 1 strcpy MessageString No variables defined IsOk FALSE if IsOk Debug and VIsDouble are flags used TecUtilTecIni int Debug 0 int VIsDouble 1 Set JMax and KMax to 1 because we are creating an ordered data set int JMax 1 KMax 1 G 41 char VarNames 5000 char s Num Values 0 VarList was filled by the function GetVars Num Vars TecUtilStringListGetCount VarList Count the number of data points while get_token f NumValues Get_token changed where the file pointer is pointing so we must rewind to the start of the data fsetpos f amp DataStartPos Compute the number of data points 42 Writing the DoConversion Function IMax NumValues NumVars FillVarNames with the variable names in VarList strcpy VarNames for G 1 i lt NumVars amp amp IsOk i TecUtilStringListGetString VarList i strcat VarNames s if i lt NumVars strcat VarNames TecUtilStringDealloc amp s Use the TecUtilTecIni function to initialize the TempFName file and fill it with the data set title and the variable name if TecUtilTecIni ConvertedDataset VarNames
62. data values within Tecplot Examine main c and note the following function void Compute double MulNum LglIndex t LgIndex t JMax LgIndex t KMax LglIndex t i LgIndex t MaxIndex FieldData_pa FD double Value Set set TecUtilLockStart AddOnID if TecUtilZoneIsEnabled 1 amp amp TecUtil VarIsEnabled 1 amp amp TecUtilZoneGetType 1 ZoneType Ordered amp amp TecUtilDataValueGetLocation 1 1 ValueLocation Get the number of data points TecUtilZoneGetInfo 1 Zone amp IMax amp JMax amp KMax NULL XVar NULL YVar NULL ZVar NULL NMap NULL UVar NULL VVar NULL WVar NULL BVar NULL CVar NULL SVar MaxIndex JMax KMax FD TecUtilDataValueGetRef 1 1 for 1 1 1 lt MaxlIndex i Get the value 26 Writing the Compute Function Value TecUtilData ValueGetB yRef FD ji Change it Value MulNum And set it back TecUtilDataValueSetB yRef FD i Value Inform Tecplot that we ve changed the data set TecUtilSetAlloc FALSE TecUtilSetAddMember set 1 FALSE Zone 1 TecUtilStateChanged StateChange VarsAltered ArbParam t set TecUtilSetDealloc amp set else TecUtilDialogErrMsg This sample add on only performs an equation on variable 1 of zone and only if the zone i
63. dd ons Add On Development Root Directory 11 creating add ons under UNIX 11 creating new add ons 12 setting up to build add ons under UNIX 11 Curve Fit dialog 161 CurvelnfoStringCallback function 135 166 CurveParams 156 CurveParams_s 141 148 description 139 170 CurveSettings variable 124 in SimpAvg 139 CurveSettingsCallback function 148 CustomMake editing the CustomMake file 13 D Data converters 35 Data loaders about 57 DataaFName in Converter 37 debug flag 13 DepCurveValues array 124 Developer Studio used with TGB 10 Dialog10kButton_CB function 156 Dialog1HelpButton function 55 DialoglInit CB function 22 89 90 155 Dialog1OkButtonCallback function 62 Dialogs callback implementation 61 creating 18 creating with TGB 10 creation 59 86 Curve Fit 161 fields 22 in SimpAvg 155 Plot Attributes 147 159 XY Plot Curve Info 107 135 DoConversion function 39 writing 39 DoLoadDelimitedText function 62 Double buffering in animation 100 Dynamic link libraries 7 E Engine c description 36 in Converter 36 46 in LoadTxt 63 64 in PolyInt 109 engine c in PolyInt 111 129 135 in SimpAvg 140 149 159 ENGINE h in LoadTxt 63 Engine h in PolyInt 109 171 INDEX in SimpAvg 141 146 Environment variables TECADDONDEVDIR 11 TECADDONDEVPLATFORM 11 Equate adding help 55 creating dialogs 18 writing Compute function 24 Equate add on 17 Exercises 28 equate html 55 E
64. deless dialog Dialog title Animate I Planes After running the CreateNewAddoOn script or Tecplot Add on Wizard you should have the fol lowing files guibld c guicb c guidefs c main c ADDGLBL h GUIDEFS h gui lay You will also have other files specific to your platform but we will only modify those above The purpose of each file will be explained in detail as we proceed Verify that you can compile your project add on and load it into Tecplot If you cannot refer to Chapter 2 Creating Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 11 2 Creating the Dialog Now create your main dialog This will be displayed when Animate I Planes is selected from Tec plot s Tools menu The dialog will have two labels one button one text field and a multi selection list You will be able to select a specific set of zones to animate from the list specify a skip level in the text field and clicking the button will perform the animation Before beginning be sure that Tecplot GUI Builder TGB is available from Tecplot s Tools menu If TGB is not available do the following 11 2 1 Windows In the Tecplot Home Directory edit the file tecplot add and add the line 4 LoadAddOn guibld 11 2 2 UNIX Edit the file tecdev add in your Add on Development Root Directory and add the line 86 Creating the Dialog LoadAddOn guibuild Resize the frame and edit the layout a
65. e Independent Vari able Range toggle off and the remaining controls should be insensitive Using the Use Independent Variable Range toggle will not change the sensitivities of the dialog at this point 13 9 Making the Dialog Operational To make the dialog fully operational there are two things that must be done The first is to update the sensitivities of the text field controls when Use Independent Variable Range toggle is clicked The second is to make the dialog set the values when OK is clicked 13 9 1 Updating the Sensitivities To be sure that the text field sensitivities are updated when the toggle button is pressed include the following code G 155 static void UseIndVarRan_TOG_D1_CB const int TecUtilLockStart AddOnID Make sure to update the sensitivities when the toggle button is pressed UpdateMainDialogSensitivities TecUtilLockFinish AddOnID The process to follow when OK is clicked is 1 Collect the information from the dialog 2 Create new CurveSettings string 3 Call TecUtilXYMapSetCurve with the appropriate parameters to set the extended curve settings for the set of XY maps 4 Drop the dialog The following function collects the information from the dialog and places it into the Curve Params structure The following function is in guicb c above the D alogiOkButton function static void AssignCurveParams CurveParams s CurveParams 156
66. e first variable in the first zone by a value entered in a dialog text field All of the examples of the source code shown in this manual are included in the Tecplot distribution and are found in the adk samples sub directory below the Tecplot home directory Equate uses source code files created by the CreateNewAddoOn script UNIX or Tecplot Add on Wizard Windows Our project and add on names will be Equate Note For the purposes of this tutorial it is assumed that you EN have already read the chapters Creating Add ons Under Windows and or Creating Add ons Under UNIX in the ADK User s Manual and that you have successfully created and compiled a set of starter files All of the code from this point on is plat form independent and you can work through the tutorial using either a Win dows or UNIX environment When running CreateNewAddoOn Tecplot Add on Wizard answer the questions as follows Project name base name Equate Add on name Equate Company name Your Company Name Type of Add on General Purpose Language C Use TGB to create a platform independent GUI Yes Add a menu callback to the Tecplot Tools menu Yes G 17 Menu Text Equate Menu Callback Option Launch a modeless dialog Dialog title Equate After running the CreateNewAddoOn script or Tecplot Add on Wizard you should have the fol lowing files ADDGLBL h guicb c guibld c guidefs c GUIDEFS
67. e name of that button to something more meaningful Double click on the button marked and select Options In the Macro Function Field after VarName replace the default name by typing Browse TGB will use this name when creating the callback function You can now build the source for this layout From the TGB dialog click Go Build Rename the file guicb tmp to be guicb c Add the following statement to the top of guicb c include ENGINE h 60 Implementing Dialog Callbacks 9 5 Implementing Dialog Callbacks In this step we will modify the callbacks in the dialog so that it collects the file name and verifies that it is valid From the dialog s OK callback the file name will be placed in a string list of instruc tions Finally we will add a call to the LoaderCallback function with the Instructions string list 9 5 1 The FileName Text Field Callback When a text field loses the focus a callback is received if the text has changed since the text field received the focus We could check that the file name is valid at that time but instead we will check the validity of the file name in the OK button callback Thus the callback FileName TF D1 CB will not be edited 9 5 2 The Browse Button Callback The browse button will display a file dialog and allow the user to select a file Make the following changes to the Browse BTN D1 CB callback function in guicb c static void Browse BTN
68. e the ADK Reference Manual for a defintion of the parameters 9 7 2 3 Registering Custom Load On Demand Functions The three functions used with Tec UtilDataValueCustomLOD must be defined The information that was registered with the command TecUtilDataValueCustomLOD is passed by Tecplot as part of a field data pointer to each function each time a variable is loaded or unloaded Add the code below to engine c LoadOnDemandVarLoad retrieves all values for one variable from a file in Block format As soon as a value is read it is added to the Tecplot dataset static Boolean t STDCALL LoadOnDemandVarLoad FieldData_pa FieldData LglIndex t PointIndex 1 int NumValuesRead ClientDataValues s MyClientData FILE MyFile Boolean t IsOk TRUE 72 IS Loading the Data REQUIRE FieldData NULL REQUIRE VALID REF ClientDataValues s TecUtilDataValueGetClientData FieldData MyClientData ClientDataValues s TecUtilDataValueGetClientData FieldData MyFile fopen MyClientData gt FileName rb IsOk MyFile NULL if IsOk Go to the position in the file for the first value of the variable IsOk fseek MyFile MyClientData CurOffset SEEK SET 0 if IsOk FieldDataType e DataType int NumPoints double Value for PointIndex 1 PointIndex lt NumPoints PointIndex NumValuesRead fread amp Value sizeof double 1 MyFile if NumValuesRead
69. ePts amp lx amp ly amp lxn amp lyn Data Perform the curve fit 122 The XYDataPointsCallback Function PolyInt NumRawPts Ix ly NumCurvePts Extract the values from Data that were placed there by the curve fit ExtractCurve ValuesFrom Working Array NumCurvePts Ixn lyn Data IndCurveValues DepCurve Values free Data TecUtilLockFinish AddOnID return IsOk 123 Notice that in this function the CurveSettings and XYMapNum variables are never referenced This is because there are no settings which may be configured for this curve fit The only informa tion in this function that is required by Tecplot is the return value TRUE or FALSE and that the Ind CurveValues and DepCurveValues arrays are filled Tecplot will plot whatever values are placed in these arrays If the values do not make sense the resulting plot will not make sense The burden is on the add on writer to make sure that the values placed in these arrays are correct Also notice that there are two functions we have referenced that must still be written These func tions take care of steps 2 and 4 as outlined in the function structure above 12 5 The PrepareWorkingArray Function This function will fill the working array Data with the raw data and the calculated independent curve points It will also return the indices within the Data array to the different blocks of data As stated above
70. ectory below the Tecplot Home Directory Hello World uses source code files created by the CreateNewAddon script UNIX or Tecplot Add on Wizard Windows Our project name will be hiwrld and the add on name will be Hello World When running CreateNewAddoOn Tecplot Add on Wizard answer the questions as follows Project name base name hiwrld Add on name Hello World Company name Your Company Name Type of Add on General Purpose Language C Use TGB to create a platform independent GUI No Add a menu callback to the Tecplot Tools menu Yes Menu Text Hello World The question Use to create a platform independent GUI option specifies that you will use Tecplot GUI Builder in your add on After running the CreateNewAddoOn script or Tecplot Add on Wizard you should have the following files ADDGLBL h and main c You will have other files specific to your platform but only those above will be modified Verify that you can compile your add on project and load it into Tecplot For UNIX this is done by running the Runmake script In Windows click Build Build hiworld dll For detailed information on compiling refer to G 15 Chapter 2 Creating Add ons under Windows page 9 or Chapter 3 Creating Add ons under UNIX on page 11 Once you have compiled Hello World you can run Tecplot and select Hello World from Tecplot s Tools menu Text is written to standard
71. en runs make This process allows you to add to or completely replace any assignments made by Runmake For example suppose you want to add an additional flag called xg to the compile command You could do so by editing the local CustomMake shell script in the sub directory of your add on and adding CFLAGS CFLAGS This replaces CFLAGS i e the flags used with the command with its old contents plus the xg flag The default CustomMake file created in your add on directory when you run CreateNewAd dOn contains edit instructions including an explanation of the flags available for you to change 14 Introduction to the Hello World Add on Chapter 4 Hello World 4 1 Introduction to the Hello World Add on Hello World the Tecplot add on you will create in this chapter is an example of how an add on per forms tasks or functions for you Hello World will appear under Tecplot s Tools menu as Hello World When selected a dialog displaying the text Hello World will appear To create this add on you should have first read Chapter 2 Creating Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 All of the code presented in this chapter is platform independent allowing you to work in either a UNIX or Windows environment All of the example source code shown in this manual is included in the Tecplot distribution and is found in the adk samples sub dir
72. function is not required since Tecplot will perform a linear interpolation on the points that your curve fit returns However if you have very few points in your curve the value returned by Tecplot s built in Probe function will return a value that is not on the actual curve but on the approximated curve To avoid this problem we will write the ProbeValueCallback This callback will return a value that is actually calculated by your curve fit The method we use for this particular curve fit is outlined below The ProbeValueCallback has the following structure 1 Check that the probed independent value is within the bounds of the raw data 2 If the number of curve points approximating the curve is small reassign the number of points approximating the curve to be larger 3 Allocate and initialize the working array called Data 4 Fill the working array with the raw data and the calculated independent values 128 The ProbeValueCallback Function 5 Insert the probed independent value into the working array so a curve fit is done at the actual probed independent value Save the relative location of this value within the working array 6 Pass the working array to the PolyInt function This will fill in the calcu lated dependent values 7 Extract the probed dependent value from the working array using the relative location saved in step 5 8 Free the working array Note the following code in engine
73. g Get the curve parameters Get ValuesFromCurveSettings X YMapNum CurveSettings amp CurveParams if CurveParams UseIndVarRange Adjust the Independent variable range to fall either within the range of the data or the range specified by the CurveParams structure IndVarMin CurveParams IndVarMin initialize these values IndVarMax CurveParams Ind VarMax IndVarMin MAX IndVarMin CurveParams IndVarMin IndVarMax MIN IndVarMax CurveParams IndVarMax G 167 Average SimpleAverage RawDepV RawlIndV NumRawPts IndVarMin IndVarMax sprintf CurveInfoString Average is G n Average TecUtilLockFinish AddOnID return IsOk The add on is now complete You should compile the add on at this time and verify that it works as expected As a further exercise add error checking to the dialog so that the minimum value is greater than the maximum value The process described in this manual is the preferred process for creating curve fit add ons with configurable settings When ever creating an add on of this type you should refer to this example as a template 168 INDEX Symbols _token variable 40 A AbbreviatedSettingsStringCallback function 159 ADDGLBL h 18 description 36 in SimpAvg 139 Add On Development Root Directory 11 ADDONGLB h 15 Add ons adding field data 67 Animate I Planes button 92 AnimlPlanes 85 Browse button 6
74. h main c gui lay You will have other files specific to your platform but only those above will be modified Verify that you can compile your add on project and load it into Tecplot For UNIX this is done by running the Runmake script In Windows you add on will appear in the Tools menu in Tecplot For detailed information on compiling refer to Chapter 2 Creating Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 5 2 Creating the Dialog Now create your main dialog This will be displayed when Equate is selected from Tecplot s Tools menu The dialog will be modeless with a text field label and button When a user enters a numeric value in the text field and clicks the button Equate will multiply each data point of the first variable in the first zone by that value Before beginning be sure that Tecplot GUI Builder TGB is available from Tecplot s Tools menu If TGB is not available do the following For Windows In the Tecplot Home Directory edit the file tecplot add and add the line LoadAddOn guibld For UNIX Edit the file tecdev add in your Add on Development Root Directory and add the line LoadAddOn guibld To create the main dialog perform the following steps 1 Run Tecplot and load the gui lay file for your project Select Tecplot GUI Builder TGB from the Tecplot Tools menu 18 Creating the Dialog 2 Resize the frame and edit the layout as foll
75. he string is newline delimited as discussed above Now that we have a function that creates the CurveSettings string create a function that will parse the newline delimited string and populate the CurveParams s structure The function that we will be writing will use several convenience functions that are defined in adkutil h Simple add the line include ADKUTIL h at the top of engine c The function that parses the CurveSettings string will take three parameters The first is XYMapNun which is the XY map that is currently being operated on The second is Curve Settings string The third is a pointer to the CurveParams s structure This function will not only parse the CurveSettings string but also repair the string if the syntax is incorrect The following code is in engine c This function makes use of functions found in the adkutil c module to parse the CurveSettings string lt 141 void Get ValuesFromCurveSettings EntIndex_t XYMapNum char CurveSettings CurveParams_s CurveParams Boolean_t IsOk TRUE define MAXCHARS 50 char Command MAXCHARS 1 char ValueStringI MAXCHARS 1 char CPtr char ErrMsg NULL if CurveSettings NULL amp amp strlen CurveSettings gt 0 CPtr CurveSettings while ISOk amp amp CPtr if GetArgPair amp CPtr Command ValueString MAXCHARS amp ErrMsg 142 Handling the CurveSettings
76. i ein osestepra dco russes vao OF Introduction to AnimIPlanes Add on 85 Creating the Dialog esee eese eese ettet 86 pnr D 86 hU qe 86 Setting up State Variables Initializing Dialog Fields 89 The Animate I Planes button eee eee eere eene enue 92 Writing the AnimatePlanes Function ees 94 Monitoring State Changes erect eee eene ene tnannn 102 1868 scsscessetsesesessecsosavesassondacecsssvasovacssoenstussendsscsssedesseus 105 Chapter 12 The Polynomial Integer Add on 107 Introduction to the PolyInt Extended Curve Fit 107 Getting Started eere eee eee eee 107 Nora 108 File nM ces 108 File ENGINE 109 ad L 111 The XYDataPointsCallback Function 119 The PrepareWorkingArray Function eere 124 The ExtractCurveValuesFromWorkingArray Function 127 The ProbeValueCallback Function 128 The InsertProbe ValueInWorkingArray Function 134 The CurvelInfoStringCallback Function 135 G Table of Contents Chapter 13 The Simple Average Add on
77. iate names for the text fields are IndVarMin and IndVarMax Although we will not be performing any operations in the text field callbacks giving them meaningful names is recommended Set labelnames to Var Name Min and VarName Max 4 Now double click on the dialog frame and verify that the frame name is as fol lows ID 1 MODE MODAL TITLE Simple Average 5 Click Go Build on the TGB dialog Now that TGB has created new stub files be sure to copy the toggle and text field callbacks from guicb tmp into guicb c 13 8 Launching and Initializing the Dialog The add on dialog is launched by the CurveSettingsCallback function in engine c The parameter XYMapSet is the set of XY maps that were selected in the Plot Attributes dialog at the time Curve Settings was clicked The parameter XYMapSettings is a string list containing the CurveSettings strings of all the XY maps in the set XYMapSet 148 Launching and Initializing the Dialog When Curve Settings is clicked the function CurveSettingsCallback is called by Tec plot In this function we will save the XYMapSet and XYMapSettings so we can use them later in the guicb c module These variables are needed in guicb c in order to properly initialize the dialog fields In engine c verify that CurveSettingsCallback is as follows void STDCALL CurveSettingsCallback Set pa XYMapSet StringList pa XYMapsSettings TecUtilLockStart AddOnID S
78. ing files engine c ENGINE h main c ADDGLBL h There will be other files specific to your platform however we will only be dealing with those above Verify that the add on will compile and that it can be loaded into Tecplot If any problems are encountered refer to Chapter 2 Creating Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 The file ADDGLBL h contains information specific to the add on such as its name version num ber and date The files ENGINE h and engine c contain the main converter function engine c currently has a short message saying that the converter is under construction Through out this tutorial code will be added to engine c so when Tecplot calls the ConverterCall back function it will perform of loading the file The file main c contains a function called InitTecAddOn This registers the add on with Tecplot Note that within this function there are other function calls which tell Tecplot the name of the add on and state that it is a converter The InitTecAddOn function is called by Tecplot exactly when the add on is first loaded and is not called again 7 3 Modifying the ConverterCallback Function When Converter is loaded by Tecplot an option called Simple Spreadsheet Converter will appear in the Import menu of Tecplot s File menu When Converter is launched Tecplot will ask for a file to convert This is the file name that is passed to the ConverterCa
79. int MulNum TF D1 BADDIALOGID int Compute 1 BADDIALOGID int MultiplyBy LBL D1 BADDIALOGID TF is text field and Dn is the dialog number Since there is only one dialog box nis 1 For example the name Mu1Num D1 can be decoded as This vari able represents the MulNum Text Field in Dialog 1 The variables are ini G 21 tialized to BADDIALOGID to ensure that they cannot be passed as parameters to any TecGUI library function until the dialog has actually been created At that time they will be assigned a valid identification Note Never edit these files directly TGB will generate them every time you click Go Build File guibld c Contains the code used to build the dialogs Note Never edit this file directly TGB will generate this file every time you click Go Build so any changes you make will be overwritten Also this file is never included directly in the project Instead the text of this source code file is included directly in guicb c witha include guibld c preprocessor statement at the end of guicb c File guicb tmp Contains all of the callbacks for the dialog controls A callback function is a function you define which is called by Tecplot when an event occurs for a control For example a button control will have a callback function for the button pressed event Initially TGB will generate empty callbacks but instead of writing them to guicb c it will write them to a file named guicb
80. isted in a form accepted by Tecplot you should use Auto Load on Demand Some platforms have a different byte order and you would need to check for this to make your loader platform independent However for this exercise we will assume that the byte order is Native You must specify the offset in the file for the first value of the current variable The parameter Stride is set to 1 for data in Block format greater than one for data in Point format A stride greater than one is allowed only if all variables are nodal For this exercise assume the Data Value Structure is ClassicPlus Add the code below after the command in LoaderCallback to deallocate the argument list ArgList int Stride Boolean t IsNativeByteOrder TRUE for VarIndex 1 VarIndex lt NumVars VarIndex Stride 1 CurOffset sizeof double VarIndex 1 NumPoints ZoneOffset DataOffset IsOk TecUtilDataValueAutoLOD ZoneIndex VarIndex DataValueStructure ClassicPlus FileName CurOffset Stride IsNativeByteOrder G 69 End of Index for loop End of Zone for loop TecUtilDataSetDefVarLoadFinish IsOk if KMax gt 1 TecUtilFrameSetPlotType PlotType Cartesian3D else TecUtilFrameSetPlotType PlotType Cartesian2D TecUtilRedraw TRUE TecUtilImportSetLoaderInstr ADDON_NAME Instructions End of if IsOk TecUtilLockFinish AddOnID return IsOk End of LoaderCallback This
81. iter Var Index Line 52 The GetVars Function Var Index 0 TecUtilStringListA ppendString sl Var Skip to the next non delimiter char while Line amp amp Line Delimiter Line fgetpos f amp DataStartPos Skip to next non delimiter char while Line amp amp Line Delimiter Line Line Converter is now complete Recompile and load it into Tecplot 53 54 Introduction Chapter 8 Adding Help 8 1 Introduction Once your add on is complete you will find that there are many details and instructions you would like to make available to users Online Help is an effective way to include necessary details and instructions It is the best way to ensure that needed information can be easily accessed from your add on Note The Help mechanism described in this chapter requires that you have a Web browser avail able on your platform 8 2 Creating Help Call TecUtilHelp to launch a help file Help can be called anywhere within your add on although the typical procedure is to start from a dialog s He lpButton callback To add help to the Equate add on create a simple HTML document to serve as your help file naming it equate html In guicb c note the call to launch the help in D aloglHelpButton CB static void DialoglHelpButton void TecUtilLockStart AddOnID TecUtilHelp equate html FALS
82. ize and Left Side 4 7801 Width 45 Top Side 0 84221 Height 55 Show Boder Thickness 2 Show Header Color E Green Show Background Color C3 Cust 2 Frame Name ELESS TITLE s Animate Planes O You can now build the source for this layout From the TGB dialog click Go Build Rename the file guicb tmp to be guicb c replacing the existing guicb c with guicb tmp 11 3 Setting up State Variables Initializing Dialog Fields When the dialog is launched we need to make sure that the Skip and ZoneList text fields are filled in properly To initialize Skip we will define the skip to be a reasonable default value and set it every time the dialog is launched This initialization will take place in the DialoglInit CB function This function is called every time the dialog is launched Note the following line in guicb c just below the include statements define DEFAULT SKIP 1 and the following code used as the dialog initialization callback static void DialoglInit_CB void TecUtilLockStart AddOnID lt lt lt Add init code if necessary here gt gt gt TecGUlITextFieldSetString Skip TF D1 DEFAULT SKIP TecUtilLockFinish AddOnID To initialize ZoneList we will write a separate function then call that function from the DialoglInit CB function This function will be called elsewhere in this exercise The following code is above the InitTecAddoOn fun
83. l make the I Planes move 98 Writing the AnimatePlanes Function TecUtilZoneSetIJKMode S V_IRANGE SV_MIN IJK ZoneSet ArbParam_t Index TecUtilZoneSetIJKMode S V_IRANGE SV_MAX IJK ZoneSet ArbParam_t Index IsOk TecUtilRedraw TRUE TecUtilDoubleBuffer DoubleBufferAction Swap TecUtilDoubleBuffer DoubleBufferAction Off if ISOk amp amp TecUtilMacroIsRecordingActive At this point we have all the ordered zones So all we need to add is the skip value Add a semi colon to the end to signify the end of the IJKZoneSet information strcat strMacroCommand G 99 sprintf amp strMacroCommand strlen strMacroCommand 4 Skip strMacroCommand strlen strMacroCommand 0 Record the command TecUtilMacroRecordAddOnCommand animiplanes strMacroCommand TecUtilStringDealloc amp strMacroCommand TecUtilSetDealloc amp IJKZoneSet Note the use of double buffering when we do the animation If we do not double buffer there will be a significant amount of flickering during animation This is due to the time it takes to draw the other zones There are a few functions called above that have not yet been defined they check to see if the zone passed is IJK ordered Note the following functions above the AnimatePlanes function static Boolean t ZoneIsIJKOrdered EntIndex t ZoneNum Boolean t IsOk
84. lStringDealloc amp CurveSettings Tnitialize the CurveParamsPtr to the default values Tf all mappings have the same value for a particular parameter use that value instead InitializeCurveParams CurveParamsPtr if UseIndVarRangeIsSame CurveParamsPtr gt UseInd VarRange OrigCurveParams UseIndVarRange if Ind VarMinIsSame CurveParamsPtr gt IndVarMin OrigCurveParams IndVarMin if Ind VarMaxIsSame CurveParamsPtr gt Ind VarMax OrigCurveParams Ind VarMax 154 Making the Dialog Operational Finally we will add a function to initialize the dialog fields which will be called from the DialoglInit CB function as described below This function also calls InitializeGUICurve Params which was previously defined The following function is in guicb c below the UpdateMainDialogSensitivities and below the InitializeGUICurveParams function static void UpdateMainDialog void CurveParams s CurveParams InitializeGUICurveParams amp CurveParams TecGUIToggleSet UseInd VarRan_TOG_D1 CurveParams UseIndVarRange TecGUITextFieldSetDouble Ind VarMin_TF_D1 CurveParams IndVarMin G TecGUITextFieldSetDouble Ind VarMax_TF_D1 CurveParams Ind VarMax G UpdateMainDialogSensitivities At this point it is recommended that you compile and run your add on to make sure that the fields and sensitivities are initialized correctly The dialog should appear with the Us
85. later may alter the error message that is reported Attempts to open the file If the file cannot be opened it sets IsOk to FALSE and resets the MessageString to reflect the fact that the file could not be opened f the file was opened it converts it The task of conversion is handed off to the DoConversion function Some clean up is performed such as closing the file de allocating Messag eString if there were no errors and returning IsOk If IsOk is FALSE at the end of the function there was an error Tecplot will use the string in Mes sageString to display an error message 7 4 Writing the DoConversion Function Now that the file is open we want to perform the conversion In ConverterCallback the job of performing the conversion is passed to the DoConversion function DoConver sion is responsible for parsing the file to be converted and sending specific information to the TecUtil functions which take care of the conversion A discussion of the TecUtil functions is available in the ADK Reference Manual In writing the DoConversion function we are going to make some assumptions about the format of the incoming file that the variables are at the top of the file contained in quotes and separated by commas or spaces that the data follows the variables and is separated by commas or spaces An example of such a file would be Var 1 Var 2 Var 3 1 23 4 4 3 24 2 45 3 56 5 2 3 2 2 15 7 56 The
86. llback function Tecplot will also create a unique temporary file name and pass that to ConverterCallback as well 36 Modifying the ConverterCallback Function In ConverterCallback we are required to Open the file DataFName Convert the data and create a Tecplot binary data file Close the file DataFName Inform Tecplot if there were any errors Note how the ConverterCallback function satisfies these requirements Boolean t STDCALL ConverterCallback char DataFName char TempBinFName char MessageString Boolean t ISOk TRUE FILE f TecUtilLockStart AddOnID Tf there is no error remember to free MessageString MessageString TecUtilStringAlloc 1000 MessageString for CNVSS to open the file f fopen DataFName rb G 37 Make sure the file was opened if 10 strcpy MessageString Cannot open input IsOk FALSE Do the conversion if IsOk DoConversion f TempBinFName MessageString Close the file fclose f Tf there was no errors deallocate MessageString if IsOk TecUtilStringDealloc MessageString TecUtilLockFinish AddOnID return IsOk 38 Writing the DoConversion Function This function does the following Creates an error message MessageString is allocated here because the DoConversion function which will be explained
87. mation other than file names you must use a data loader Data loaders are discussed in the following chapter Given the file name the proce dure used by a converter to import that data is similar to creating a Tecplot binary file using the TecIO functions See the Tecplot User s Manual for more information on using library 7 2 Introduction to the Converter Add on Converter the add on created in this tutorial is an example of how to load a comma or space delimited list of values into Tecplot Converter will appear under the Import option of Tecplot s File menu of the examples of the source code shown in this manual are included in the Tecplot distribution and are found in the adk samples sub directory below the Tecplot home directory Converter uses source code files created by the CreateNewAddoOn script UNIX or Tecplot Add on Wizard Windows Our project name will be Converter and the add on name will be Simple Spreadsheet Converter When running CreateNewAddoOn or the Tecplot Add on Wizard answer the questions as follows Project name base name Con verter G 35 Add on name Simple Spreadsheet Con verter Company Name Your company name Type of add on Data Converter Language C Use to create a platform independent GUI Add a menu callback to the Tecplot No After running CreateNewAddoOn Tecplot Add on Wizard you should have the follow
88. mp ErrMsg Notice at the bottom of this function we repair the CurveSettings string if it was invalid It could be that the syntax was wrong or that the string had not yet been initialized Either way we call the function InitializeCurveParams in which we setup the CurveParams s structure with default values Then we create a new CurveSettings string which is con structed with the default values Finally we set the CurveSettings string for the current XY map by calling TecUtilCurveSetExtendedSettings 13 5 The InitializeCurveParams Function Examine the following code in engine c void InitializeCurveParams CurveParams s CurveParams CurveParams UseIndVarRange FALSE CurveParams IndVarMin LARGEDOUBLE CurveParams IndVarMax LARGEDOUBLE Now that we have the laid groundwork for handling the CurveSettings string we can move on to creating the rest of the add on 146 Registering the Add on with Tecplot 13 6 Registering the Add on with Tecplot The first thing that must happen when the add on is loaded into Tecplot is that it must be registered In main c there is a function TecUtilCurveRegisterExtCrvFit ADDON NAME XYDataPointsCallback NULL ProbeValueCallback CurveInfoStringCallback CurveSettingsCallback AbbreviatedSettingsStringCallback This function will register the curve fit add on with Tecplot Notice that parameter three is NULL This is be
89. n The TecUtilDialogGetVariables function has a built in dialog which allows you to select the variable to be summed Then the newly created dialog appears As points are probed the summed total is displayed on the dialog Before adding the code below create a label on the dialog which will be set to the total as the plots are probed See the TGB Reference Manual for more information on adding a label to a TGB dia log Set the variable name of this label to VarName TotalisO0 Set the text string of the label to read The total is 0 0 The new or modified source code is displayed in bulleted lines If you are working along add or edit bulleted lines only Note the MenuCallback function in main c static void STDCALL MenuCallback void TecUtilLockStart AddOnID 80 The MyProbeCallback Function if TecUtilDataSetIsAvailable if TecUtilFrameGetPlotType PlotType Cartesian2D TecUtilDialogGetVariables Pick Variable to Sum NULL NULL NULL amp Variable NULL NULL BuildDialogl MAINDIALOGID TecGUIDialogLaunch DialoglManager TecUtilProbeInstallCallback MyProbeCallback Summing Probed Values else TecUtilDialogErrMsg Plot type must be 2D cartesian else TecUtilDialogErrMsg Frame does not contain a dataset with which to probe TecUtilLockFinish AddOnID This example is limited to 2 D plots 10 3 The MyProbeCallb
90. n Wizard you should have the following files engine c main c ADDGLBL h ENGINE h You will also have other files specific to your platform but the files above are the only ones we will be modifying The purpose of each file will be explained in detail as we proceed through the tuto rial At this point you should verify that you can compile your add on and load it into Tecplot If you are unable to compile or load your add on we recommend that you refer to Chapter 2 ating Add ons under Windows on page 9 or Chapter 3 Creating Add ons under UNIX on page 11 in the ADK User s Manual before proceeding 12 3 Source Files Since this add on has no dialog we will only be dealing with four files main c engine c ADDGLBL h and ENGINE h 12 3 1 File main c This file contains the add on registration routine If you open the file you will see a call to TecUtilCurveRegisterExtCrvFit It is this function that registers the extended curve fit add on with Tecplot In main c the call to TecUtilCurveRegisterExtCrvFit should appear as follows 108 Source Files TecUtilCurveRegisterExtCrvFit ADDON_NAME XYDataPointsCallback Probe ValueCallback CurvelInfoStringCallback NULL CurveSettingsCallback NULL AbbreviatedSettingsStringCallback Notice that parameters five and six are NULL This is because this add on has no settings which may be configured Since the extended curve fit feat
91. nly requires that the value is sent to the Compute function To write out the macro command we will use the TecUtilMacroRecordAddOnCommand function All TecUtil functions are defined in the ADK Reference Manual Note the Compute D1 CB function in guicb c static void Compute BTN D1 CB void char strMulNum NULL TecUtilLockStart AddOnID strMulNum TecGUITextFieldGetString MulNum TF D1 if TecUtilDataSetIsAvailable Compute atof strMulNum if TecUtilMacroIsRecordingActive TecUtilMacroRecordAddOnCommand equate strMulNum else TecUtilDialogErrMsg No data set available TecUtilStringDealloc amp strMulNum TecUtilLockFinish AddOnID We check to see if a macro is being recorded before we write out the macro command When TecUtilMacroRecordAddOnCommand is called it will add a line to the macro file that will appear as follows ADDONCOMMAND ADDONID equate COMMAND 2 ADDONID tells Tecplot which add on to send the command to and COMMAND is the value in the text field of Equate s dialog Now that a macro command is being written out write a function to decode it When a macro is running Tecplot will send the information following COMMAND to the add on In this case the only item that COMMAND contains is a number Tecplot sends all the infor mation following COMMAND as a string Examine the following function in main c Boolean t STDC
92. o collect data from the dialog and check to see that there is a data set available The AnimatePlanes function will take two parameters ZoneSet and Skip ZoneSet will contain the zones that were selected in the dia log and Skip will be the skip value that was entered in the text field static void AnimPlanes 01 CB void TecUtilLockStart AddOnID Make sure there is a dataset if TecUtilDataSetIsAvailable LgIndex_t Count 0 LgIndex_t Selection NULL Set pa ZoneSet TecUtilSetAlloc TRUE 92 The Animate I Planes button Get the Skip value from the text field char strSkip TecGUITextFieldGetString Skip_TF_D1 Get the selected zones from the ZoneList TecGUIListGetSelectedItems ZoneList_MLST_D1 amp Selection amp Count if Count gt 0 LgIndex_t i Put the selected items into ZoneSet for i 0 1 lt Count i TecUtilSetAddMember ZoneSet Selection i TRUE TecUtilArrayDealloc void amp Selection Make sure a zone has been picked if ZoneSet NULL do the animation AnimatePlanes ZoneSet atoi strSkip else G 93 TecUtilDialogErrMsg No zones have been picked Deallocate the ZoneSet and strSkip string when we are done with them if ZoneSet NULL TecUtilSetDealloc amp ZoneSet if strSkip NULL TecUtilStringDealloc amp strSkip else TecUtilDialogErrMsg No data set available
93. oad that variable Add the code below to LoaderCallback after the command to deallo cate the argument list ArgList Place necessary information for Custom Load on Demand into the structure ClientData This includes file name the number of points the data type the offset in the file for the first value of the current variable for VarIndex 1 VarIndex lt NumVars VarIndex ClientDataValues_s ClientData ClientDataValues_s malloc sizeof ClientDataValues_s ClientData gt FileName char malloc sizeof char strlen FileName 1 strcpy ClientData FileName FileName ClientData CurOffset sizeof double VarIndex 1 NumPoints ZoneOffset DataOffset ClientData DataType FieldDataType Double ClientData NumPoints NumPoints IsOk TecUtilDataValueCustomLOD ZoneIndex VarIndex LoadOnDemandVarLoad LoadOnDemandVarUnload LoadOnDemandVarCleanup NULL GetFunction NULL SetFunction ArbParam t ClientData End of Index for loop End of Zone for loop G 71 TecUtilDataSetDefVarLoadFinish IsOk if KMax gt 1 TecUtilFrameSetPlotType PlotType Cartesian3D else TecUtilFrameSetPlotType PlotType Cartesian2D TecUtilRedraw TRUE TecUtilImportSetLoaderInstr ADDON_NAME Instructions End of if IsOk TecUtilLockFinish AddOnID return IsOk End of LoaderCallback Se
94. ogramming interface you can create add ons to generate plots load data from files manipulate or analyze data or perform a broad variety of specialized tasks Because add ons are shared objects you do not need to link them into Tecplot You are not limited to using the com pilers Tecplot uses nor do you have to compile or recompile large libraries of Tecplot function calls Different operating systems have different ways of creating and using shared libraries Add on Developer s Kit ADK provides utilities that mask most of these differences for related programs All Windows or UNIX systems will behave in a similar fashion ADK tools will resolve the differ ences for you All of the examples of the source code shown in this manual are included in the Tec plot distribution and are found in the adk samples _ sub directory below the Tecplot Home Directory read more about advanced topics see the Add on Developer s Kit User s Manual and the Add on Developer s Kit On line Reference All are included as Adobe PDF files with your Tec plot distribution or are available at www tecplot com support tecplot documentation htm Setting Up to Build Add ons under Windows Chapter 2 Creating Add ons under Windows 2 1 Setting Up to Build Add ons under Windows To set up to build add ons install Tecplot Version 360 Make sure the Tecplot Add on Developers Kit option was selected during installation To verify that the Add on Developer
95. out or the debug window in Devel oper Studio reading Menu function called When finished this will read Hello World in a dia log 4 2 Modifying the MenuCallback Function Most add ons contain a callback function named MenuCallback This is called by Tecplot when the user selects the add ons registered menu option from the Tools menu This callback func tion is registered by the TecUtilMenuAddOption function which is in InitTecAd don These will be discussed in detail later Because the add on dialog displays a different message than Hello World it must be edited New or modified source code is displayed in the bulleted lines If you are working along with this tutorial add the bulleted lines only All TecUtil functions are explained in the ADK Reference Manual In main c edit the MenuCallBack function as follows static void STDCALL MenuCallback void TecUtilLockStart AddOnID TecUtilDialogMessageBox Hello World MessageBox Information TecUtilLockFinish AddOnID Hello World is now complete Recompile and run Tecplot Information 16 G Introduction to the Equate Add on Chapter 5 The Equate Add on 5 1 Introduction to the Equate Add on Equate the Tecplot add on you will create in this chapter is an example of how to query and set field data in an add on It will appear on the Tools menu as Equate This add on multiplies each data point of th
96. ows Multiply By You can edit a control by double clicking on it and editing as you would text 3 So that TGB will create meaningful variable names for the text field controls change their properties in Tecplot Double click on the text field TF then select Options Note Do not alter the text string Tecplot uses this string to identify this control as a Text Field In the Macro Function text field set VarName MulNum This will be the base name of the Multi ply By callback function which will be named MuINum TF 1 CB TGB takes the base name and decorates it with the dialog number control type and CB for callback 4 Double click on the Compute button then select Options Set Var Name Compute the Macro Function field The Compute buttoncallback function will be named Compute BTN 1 CB Double click on the Multi ply By label then select Options Set VarName MultiplyBy in the Macro Function field Callback functions are not generated for labels but a variable name will be generated and will be named MultiplyBy LBL 5 In TGB the title of the dialog is specified in the Edit Current Frame dialog Double click on the dialog frame and verify that the Frame Name has been set to Equate lt 19 ID 1 MODE MODELESS TITLE Equate OKCLOSEBUTTON T HELPBUTTON T CM x Bow Test Anchor Location C Pian c C Ure Thickress o1
97. rMsg buffer else InitTGBQ TecUtilMenuAddOption Tools Equate MenuCB TecUtilMacroAddCommandCallback equate ProcessEquateCommand TecUtilLockOffQ Equate is now complete Compile and run your add on Try recording and playing back various macros to verify that the new functions you have added work properly G 33 34 Converters Versus Loaders Chapter 7 Creating a Data Converter 7 1 Converters Versus Loaders Data can be imported into Tecplot using converter or loader add ons A converter is used when simple proprietary data files need to be read into Tecplot and it is not necessary to use complex options to decide which portions of the data should be loaded Converters are simple to create but not as versatile as loaders A loader displays its own custom dialog for the user to enter the param eters needed to load the data file name skip values and so forth With converters Tecplot controls the user interface used to prompt the user for the names of the files to load 7 1 1 How do Converters work in Tecplot A data converter is a special type of add on which can read data in a custom file format and import it into Tecplot It does this by reading the data and writing out a temporary binary data file Tecplot loads this temporary file and then discards it Tecplot queries the user for a file name then passes it to the converter If you need to query users for infor
98. romCurveSettings X YMapNum CurveSettings amp CurveParams if CurveParams UseIndVarRange Adjust the independent variable range to fall either within the range of data or the range specified by the CurveParams structure IndVarMin MAX IndVarMin CurveParams IndVarMin 162 The XYDataPointsCallback IndVarMax MIN IndVarMax CurveParams IndVarMax Delta Ind VarMax Ind VarMin NumCurvePts 1 Find the average value of the raw dependent variable for the default curve fir straight line at average Average SimpleAverage RawDepV RawIndV NumRawPts IndVarMin IndVarMax Step through all the points along the curve and set the DepCurveValues to the Average at each IntCurveValue for ii 0 lt NumCurvePts 11 G 163 IndCurve Values 1 11 Delta Ind VarMin DepCurve Values ii Average TecUtilLockFinish AddOnID return IsOk Notice that the SimpleAverage function has also been changed We are now passing more information to the SimpleAverage function so it can make the decision about what points to include in the average value calculation Alter the SimpleAverage function as follows Function to compute the average of the raw dependent variable for the default fit straight line at average REMOVE THIS FUNCTION FOR OTHER FITS double SimpleAverage FieldData_pa RawDepV FieldData_pa Raw
99. rsing of the incoming file is not in the scope of this tutorial However the parsing code has been included for completeness in the sections below 7 6 The Get Token Function The get_token parses the file fetching basic tokens Here is the function from engine c 46 The Get Token Function define MAX TOKEN LEN 5000 static char _token MAX_TOKEN_LEN Global buffer for tokens Get the next token param f Open file handle The file must be open for binary reading retum TRUE if more a token was fetched FALSE otherwise static Boolean_t get_token FILE f int index 0 char c Boolean_t StopRightQuote Skip white space while fread amp c sizeof char 1 f 1 amp amp lt 47 e Ile S Ile 8e Keep going if feof f Now we re sitting a non white space character StopRightQuote c if StopRightQuote _token index c fread amp c sizeof char 1 f do if index MAX_TOKEN_LEN 1 break Lines shouldn t be longer than 5 000 characters if feof f 48 The Get Token Function break if StopRightQuote if c _token index break else Note that a space or comma may terminate the token if Ile Ie W An bre
100. rstValidPoint amp LastValidPoint StepSize Last ValidPoint First ValidPoint NumCurvePts 1 Fill the third block of the Data array with the calculated independent values 126 The ExtractCurveValuesFromWorkingArray Function for ii 1 ii lt NumCurvePts ii double IndV FirstValidPoint ii 1 StepSize if IndV gt LastValidPoint IndV Last ValidPoint Data Ixn Hii IndV 12 6 The ExtractCurveValuesFromWorkingA rray Function This function will extract the calculated data from the working array Data and place it in the arrays that were passed to the XYDataPointsCallback function by Tecplot Tecplot will then use these values to plot the curve Note the following function above the XYDataPointsCallback function static void ExtractCurveValuesFromWorkingArray Lglndex t NumCurvePts int Ixn int lyn double double IndCurveValues double DepCurve Values G 127 int ii for ii 1 ii lt NumCurvePts ii IndCurve Values ii 1 Data lxn ii DepCurveValues ii 1 Data lyn ii At this point you should compile the add on and load it into Tecplot The curve fit add on is com plete at this point However there is other functionality that may be added In the following sec tions we will add the probe value callback and the curve information callback 12 7 The ProbeValueCallback Function The ProbeValueCallback
101. ructions Revise Load erCallback engine cas shown below to parse the Instructions string list sent to it Boolean t STDCALL LoaderCallback StringList pa Instructions IN Boolean t IsOk TRUE LglIndex t Count LgIndex t InstrIndex 1 char Name NULI char ValueString NULL char FileName 250 FILE MyFile TecUtilLockStart AddOnID Count TecUtilStringListGetCount Instructions Because the Instructions string list has pairs of strings 64 Registering Callbacks get the functional name of the pair and the set value at the same time while IsOk amp amp InstrIndex lt Count Name TecUtilStringListGetString Instructions InstrIndex ValueString TecUtilStringListGetString Instructions InstrlIndex 1 InstrIndex 2 if strcmp Name STANDARDSYNTAX 0 if strcmp ValueString 1 0 0 IsOk TRUE else IsOk FALSE TecUtilDialogErrMsg Error in loader else if strcmp Name FILENAME TOLOAD 0 strcpy FileName ValueString if FileName NULL amp amp strlen FileName gt 0 Ensure that this is a readable binary file Although this was checked when the Instructions were sent from the dialog it must be rechecked here in case LoaderCallback was called from a macro with invalid parameters MyFile fopen FileName rb if MyFile NULL TecUtilDialogErrMsg Invalid file name
102. s ordered and the variable is node located G 27 TecUtilLockFinish AddOnID Equate is now complete Recompile and load it into Tecplot Note that this example add on is only valid for ordered data as we computed MaxIndex by simply multiplying the dimensions together 5 6 Exercises 1 Currently there is no error checking done on the value entered in the text field You could enter ABCDEFG and atof would convert it into 0 0 This could be fixed by adding error checking to the button callback Use TecGUI TextFieldValidateDouble and TecGUITextFieldGetDouble for better error checking 2 Add a multi selection list box which allows you to select one or more zones from a set 3 Add a multi selection list box to select one or more variables from a set 4 This add on assumes variable 1 and Zone 1 are Enabled which may not be the case Add error checking to make sure Zone 1 is enabled TecUtil ZoneIsEnabled and variable 1 is enabled TecUtilVarIsEnabled Getting Started Chapter 6 Extending the Equate Add on 6 1 Getting Started Now we will examine code that allows Equate s compute function to be run from a macro com mand of the examples of the source code shown in this manual are included in the Tecplot dis tribution They may be found in TEC360HOME ADK Samples 6 2 Editing Equate The first step will be to decide what information is required by the add on Equate o
103. s follows Zone s MLST Anim ate Planes You can edit a control by clicking on it then choosing Object Details and editing as you would text Note Although the text fields and buttons are referred to as controls since they exist in a layout file they are actually Tecplot text objects Double click on the MLST multi selection list and select Options In the Macro Function field set VarName ZoneList This will be the base name of the callback associated with the multi selec tion list Also change the Macro Function for the TF text field to VarName Skip and change the Macro Function for the Animate I Planes button to VarName AnimPlanes G 87 The base names are truncated after 12 characters so we specify a macro command for the button here I Enter Test Steg rent options x Teed Bex Text Ancha Location C Now Fd Cun c 01 c cC C Box Coke MN GG 2 Margo 45 8 AmschteZeneMao Lire Spacing 1 Show n Al Like Frames Maio Functor aore Animate Planes Le Next The dialog title is specified in the Edit Current Frame dialog Double click on the dialog frame and verify that the frame is 88 G Setting up State Variables Initializing Dialog Fields 1 MODE MODELESS TITLE Animate I Planes Zone s Frame Dimensions Paper Ruler Units S
104. s is called a State Change Callback function During the setup of this add on we requested to have state change monitoring code included in the initial build This code was added to main c Now locate the function AnimIPlanesState ChangeCallback in main c Notice that it already contains a switch statement with all the state changes you can monitor The cases that the add on is concerned about are grouped together in the state change callback case StateChange NewTopFrame case StateChange ZonesAdded case StateChange ZonesDeleted case StateChange FrameDeleted case StateChange ZoneName case StateChange DataSetReset A call to FillZoneList must be performed when these state changes are detected The resulting code should look as follows void STDCALL AnimIPlanesStateChangeMonitor StateChange e StateChange ArbParam t CallData TecUtilLockStart AddOnID switch StateChange case StateChange_NewTopFrame G 103 case StateChange ZonesAdded case StateChange ZonesDeleted case StateChange FrameDeleted case StateChange ZoneName case StateChange DataSetReset State changes may come in here while the dialog is down We only want to fill the zone list while the dialog is up if TecGUIDialogIsUp Dialog 1 Manager FillZoneList break default break TecUtilLockFinish AddOnID AnimIPlanes is now complete Recompile and load into Tecplot 104
105. string This function will make use of the CurveParams s structure If you have not done so already add the CurveParams s struc ture as defined above to ADDGLBL h G 139 Now that the CurveParams_s structure is in place we will create a function in engine c called CreateCurveSettingsString This function will take one parameter the CurveParams_s structure and return a string based on the values of the structure The function is written as follows Add this prototype to ENGINE h char CreateCurveSettingsString CurveParams 5 CurveParams The following code is in engine c Creates a CurveSettings string based on the values the CurveParams structure that is passed in char CreateCurveSettingsString CurveParams_s CurveParams char S 1000 char CurveSettings if CurveParams UseIndVarRange strcpy S UseIndVarRange TRUE n else strcpy S UseIndVarRange FALSEW sprintf amp S strlen S IndVarMin 0GW CurveParams IndVarMin sprintf amp S strlen S IndVarMax G n CurveParams IndVarMax 140 Handling the CurveSettings String S strlen S 0 CurveSettings TecUtilStringAlloc strlen S CurveSettings strcpy CurveSettings S return CurveSettings Notice that this function calls TecUtilStringAlloc The calling function is responsible for de allocating the string returned by CreateCurveSettingsString Also notice that t
106. t layout file gui lay To do this perform the steps below 1 Load gui lay into Tecplot select Tecplot GUI Builder from the Tools menu then modify the layout to look as follows 2 a We have added a label a text field and a button There will be one variable associated with the text field FileName We will change the properties of controls so that TGB will create meaningful names for these text fields Note Although the text fields and buttons are referred to as controls they are represented by Tecplot text objects since they exist in a Tecplot layout file G 59 Oo Double click on the FileName text field and select Options In the Macro Function field after VarName replace the default name by typing FileName This will be the base name of the FileName variable Text Options xi Text Box Text Anchor Location C NoBox Filed Plain v o eti Line Thickness 2 01 m C C Midline Box Color Black d Fill Color C Cust 2 Left Cnt Right Margin 45 a Attach to Zone Map fi Line Spacing f Show All Like Frames Macro Function ame FileN ame Type T extField Any control on the dialog should have a meaningful name to make it easier to set the associated actions that will occur when the user interacts with that con trol Since the Browse button has a callback change th
107. t this point it is recommended that you compile the add on and verify that you can change the settings via your dialog and that settings are displayed on the Mapping Style dialog 13 11 The Curve Fit The curve fit is almost complete given the code created by the CreateNewAddOn script or the Tecplot Add on Wizard The curve fit computes the average of the data We alter the curve fit to exclude points that fall outside the range specified in the dialog 160 The XYDataPointsCallback 13 12 The XYDataPointsCallback We will need to alter the XYDataPointsCallback to determine the proper independent variable range This range is the range limited by the extents of the data and the values specified in the Curve Fit dialog Alter the XYDataPointsCallback as follows Boolean t STDCALL XYDataPointsCallback FieldData pa RawIndV FieldData pa RawDepV CoordScale e IndVCoordScale CoordScale e DepVCoordScale LgIndex_t NumRawPts Lglndex t NumCurvePts EntIndex t XYMapNum char CurveSettings double IndCurve Values double DepCurveValues Boolean t ISOk TRUE int i double Average double Delta 0 0 double IndVarMin IndVarMax CurveParams s CurveParams 161 TecUtilLockStart AddOnID Get the min and max values of the independent variable TecUtilData ValueGetMinMaxByRef RawIndV amp IndVarMin amp IndVarMax Get the curve parameters GetValuesF
108. t values This code is not needed for this add on and should be deleted Delete the 1 function and all of the code in the callback functions do not delete the function declarations themselves In engine c we will define the three callbacks that are prototyped above First we will deal with the function that actually performs the curve fit The function is called PolyInt It is based on a method given in the Stineman article from Creative Computing July 1980 Much of this tutorial will focus on manipulating the data into a form that the PolyInt function can use The algo rithm used here will not be explained since it is beyond the scope of this tutorial The PolyInt function takes an array that we call Data and some information about the con tents of the array The Data array is separated into four separate blocks Block 1 Raw independent data values Block 2 Raw dependent data values Block 3 Calculated independent values based on the number of points on the calculated curve Block 4 Calculated dependent values to be filled in by PolyInt func tion We will also pass the indices of the start of each block the number of raw data points and the num ber of points on the calculated curve to the PolyInt function Note the following code in engine c just below the last include statement nterpolate using the method given in Stineman article from G 111
109. tain all zero for ii 0 ii lt TotalNumDataPts 1 ii Data ii 0 else IsOk FALSE G 131 if IsOk int Ix ly Ixn lyn int Probe ValueIndex 1 Prepare WorkingArray RawIndV RawDepV NumRawPts NumcCurvePts amp lx amp ly amp lxn amp lyn Data IsOk InsertProbeValueInWorking Array ProbeInd Value NumCurvePts Ixn amp Probe ValueIndex Data 132 The ProbeValueCallback Function if IsOk amp amp ProbeValueIndex 1 Perform the curve fit PolyInt NumRawPts Ix ly NumCurvePts Ixn lyn Data The dependent value is in the same relative location as the probed independent value ProbeDepValue Data lyn Probe ValueIndex if Data NULL free Data TecUtilLockFinish AddOnID return IsOk 133 12 8 The InsertProbeValueInWorkingArray Function This function inserts the probed independent value into the working array so that the curve fit will be performed exactly at the probed value This is done by marching through the calculated independent values and when two values that surround the probed value are found the probed value replaces the lesser of the two surrounding values in the working array Also the relative location of the probed value is saved so that the calculated dependent value can be extracted from the working array Note the following code above the ProbeValueCallback in engine
110. tname is the base name of your DLL 7 Click on the C C tab select Precompiled Headers and select Automatic use of precompiled headers Select this option because with the settings are set to use stdafx h as the precompiled header which causes an error upon compilation Compiling and debugging your add on is now a matter of using the Developer s Studio environ ment as you would for any other DLL project See Chapter 6 Running Tecplot with Add ons in the ADK User s Manual for detailed instruc tions on loading add ons 2 3 Dialog Creation with Tecplot GUI Builder Tecplot Add on Developer s Kit includes a graphical user interface GUI builder called Tecplot GUI Builder TGB TGB is provided in the Tecplot distribution The Tecplot ADK User s Manual outlines its use When you run Tecplot Add on Wizard from Developer Studio a default set of TGB files are created This default code will display a blank dialog which may be modal or modeless These project settings are made automatically by Tecplot Add on Wizard You will edit a TGB dia log layout in Tecplot using TGB add on since TGB dialog layouts are stored as Tecplot layout files Developer Studio is not involved in editing or maintaining TGB dialog layouts 10 Setting Up to Build Add ons Chapter 3 Creating Add ons under UNIX 1 Setting Up to Build Add ons To create Tecplot add ons under Unix you must set up a working directory where sour
111. to test the add ons you are developing use the develop flag when running Tecplot Later when you want to make your add on accessible to all who run Tecplot just copy the shared object library to the 1ib subdirectory below the Tecplot Home Directory and include the command LoadAddOn ITECHOMBH lib 1ibMyAddOnName the tec plot add file in the Tecplot Home Directory 3 2 Creating a New Add on 1 Go to the Add on Development Root Directory i e the directory created in step 2 of Section 3 1 Setting Up to Build Add ons 2 CreateNewAddOn This will ask you a few questions about the add on to be built including whether or not you intend to use the Tecplot GUI Builder When this is finished you will have a new sub directory named MyAddOnName where MyAddOnName is the name that you supplied in step 2 while running CreateNewAddOn This subdirectory contains a set of file These files can be compiled to create a minimal add on gt Edit the tecdev add file located in the Add on Development Root direc tory and add the following line LoadAddOn TECADDONDEVDIR 1ibMyAddOnName where MyAddOnName is the name you supplied in step 2 while running CreateNewAddOn For your add on to communicate with Tecplot it must do the following Make public an initialization function named InitTecAddOn When you run CreateNewAddoOn this function is created automatically for you and is located in the file main
112. tring is changed 158 Updating the Mapping Zone Style Dialog 13 10 Updating the Mapping Zone Style Dialog To update the Mapping Zone Style dialog we move back to the engine c module The CurveSettings field of the Mapping Zone Style dialog will be filled with the string returned by the AbbreviatedSettingsStringCallback function If this function is undefined or returns a value of NULL the CurveSettings string that Tecplot stores will be used in the Mapping Zone Style dialog To create this string we will evaluate the CurveSettings string and create a legible output string The string we will produce will look like If using the Independent Variable Range IndVarMin 2 and Ind VarMax 7 IndVarRange Min 2 Max 7 If not using the Independent Variable Range No IndVarRange void STDCALLAbbreviatedSettingsStringCallback EntIndex t XYMapNum char CurveSettings char AbbreviatedSettings CurveParams s CurveParams char TecUtilLockStart AddOnID GetValuesFromCurveSettings X Y MapNum CurveSettings amp CurveParams TecUtilStringAlloc 80 Abbreviated Settings lt 159 if CurveParams UseIndVarRange sprintf S IndVar Range Min G Max G CurveParams Ind VarMin CurveParams Ind VarMax AbbreviatedSettings S else strcpy S No IndVarRange AbbreviatedSettings 5 TecUtilLockFinish AddOnID A
113. um variable 124 XY Plot Curve Info dialog 107 135 G 177 INDEX Z ZoneList text field 89 initialization 90 ZoneSet in AnimIPlanes 94 ZoneSet parameter in AnimIPlanes 92 178 C
114. ure is unique to Tecplot Version 9 0 and later notice that the InitTecAddOn function contains version checking This ensures that previous versions of Tecplot cannot load extended curve fit add ons We will define the three registered callbacks engine c and prototype them in ENGINE h 12 3 2 File ENGINE h Open ENGINE h and verify that the following lines exist extern Boolean t STDCALL XYDataPointsCallback FieldData pa RawIndV FieldData pa RawDepV CoordScale e IndVCoordScale CoordScale e DepVCoordScale Lglndex t NumRawPts Lglndex t NumCurvePts EntIndex t XYMapNum G 109 char CurveSettings double IndCurve Values double DepCurve Values extern Boolean t STDCALL CurvelnfoStringCallback FieldData pa RawIndV FieldData pa RawDepV CoordScale e IndVCoordScale CoordScale e DepVCoordScale Lglndex t NumRawPts EntIndex_t XYMapNum char CurveSettings char CurvelnfoString extern Boolean_t STDCALL ProbeValueCallback FieldData_pa RawIndV FieldData_pa RawDepV CoordScale_e IndVCoordScale CoordScale_e DepVCoordScale LgIndex_t NumRawPts LgIndex_t NumCurvePts EntIndex_t XYMapNum char CurveSettings 110 Source Files double ProbelInd Value double ProbeDepValue Each of these functions will be defined in engine c 12 3 3 engine c When the source files are created they are filled with code that will compute a simple average of the dependen
115. working array with the raw data and the calculated independent values 3 Pass the working array to the PolyInt function This will fill in the calcu lated dependent values 4 Extract the data from the working array and place into the arrays that Tecplot passed in 5 Free the working array The code for the X YDataPointsCallback is below Boolean t STDCALL XYDataPointsCallback FieldData pa RawIndV FieldData pa RawDepV CoordScale e IndVCoordScale CoordScale e DepVCoordScale Lglndex t NumRawPts Lglndex t NumCurvePts EntIndex_t XYMapNum char CurveSettings double IndCurve Values double DepCurve Values Boolean t ISOk TRUE int il double Data NULL 120 The XYDataPointsCallback Function int TotalNumDataPts TecUtilLockStart AddOnID Data will contain all the data points and is 1 base RawlIndpts RawDepPts ndCurveValues DepCurveValues Therefore the array must be large enough to contain all these points 2 NumRawPts NumCurvePts TotalNumDataPts 2 NumRawPts NumCurvePts Data malloc TotalNumDataPts 1 sizeof double if Data NULL Initialize Data to contain all zero for 11 0 ii lt TotalNumDataPts 1 ii Data ii 0 G 121 else IsOk FALSE if 18 int Ix int ly int Ixn int lyn Setup the working array Data Prepare WorkingArray RawIndV RawDepV NumRawPts NumcCurv
116. xamples code 7 15 17 35 58 79 85 107 creating Equate dialog 18 Equate add on 17 files 7 15 17 35 58 79 85 107 source code 7 15 17 35 58 79 85 107 Excercises 28 Exercises AnimlIPlanes add on 105 Equate add on 28 extending SimpAvg add on 168 extending SumProbe add on 83 ExtractCurveValuesFromWorkingArray function 127 F Field data adding 67 FieldData pa in Equate 24 File about 40 FileName function 61 FileName text field in LoadTxt 62 Files examples 7 15 17 35 58 79 85 107 FillZoneList function 92 103 Functions AbbreviatedSettingsStringCallback 159 about Get Vars 50 AnimatePlanes 92 94 100 101 AnimatePlanes BTN D1 CB 92 Compute 22 23 ConverterCallback 36 CreateCurveSettingsString 140 CurveInfoStringCallback 135 166 CurveSettingsCallback 148 DialoglOkButton CB 156 Dialog1HelpButton 55 172 DialoglInit CB 22 89 90 155 Dialog OkButtonCallback 62 DoConversion 39 DoConversion writing 39 DoLoadDelimitedText 62 ExtraCurveValuesFromWorkingArray 127 FileName 61 FillZoneList 92 103 get_token 40 46 GetVars 40 GUI TextFieldGetString 63 GUI TextFieldSetString 23 InitializeCurveParams 146 InitTecAddOn 16 36 57 80 90 109 InsertProbeValueInWorkingArray 134 LoaderCallback 64 69 LoaderSelectedCallback 63 MenuCallback 16 80 modifying ConverterCallback 37 MyProbeCallback 81 PolyInt 111 119 129 PrepareWorkingArray 124 ProbeValueCallback 128 SimpleAverage

Download Pdf Manuals

image

Related Search

Related Contents

Installationsanweisung Dampfbad MODELL: W500 Verehrter Kunde  Hunter QuietFlo  ~ シート構成 ~  取 扱 説 明 書 - ミドリ安全電気計測事業部ホームページ  TravelPilot DX-V  VoiceMail Pro - Avaya Support  pri bipap avaps  Owner`s Manual  Instalação, Operação e Manutenção  

Copyright © All rights reserved.
Failed to retrieve file