C++ related issues

Disabling Pathological Imagine Macros

Before including any Toolkit headers, it's important to define this macro:

#define EFIO_STDIO_PROTOTYPES_PASSTHROUGH

Otherwise the header file efio_ANSI_WIN32.h will define macros for POSIX system I/O calls, such as:

Efio macro system call redefinitions
original string
what it is redefined to
fopen(f,m) efio_Open(f, m, NULL)
fclose(s) efio_Close(s, NULL)
fread(b, s, n, f) efio_ReadSeq( f, b, (s * n), NULL)
fwrite(b, s, n, f) efio_FileWriteSequential(f, (void*)b, (s * n), 0, NULL)
unlink(f) efio_FileUnlink(f, NULL)
remove(f) efio_CompatibleRemove(f)
puts efio_Puts
fputc efio_Fputc
fputs efio_Fputs
fgetc(s) efio_Fgetc(s, NULL)
fgets(b, c, s) efio_Fgets(b, c, s, NULL)
fseek(f, p, o) efio_CompatibleFseek(f, p, o)
ftell(f) efio_Tell(f, NULL)
rename efio_Frename
fprintf efio_Fprintf
feof efio_Feof
fflush(f) efio_Flush(f, NULL)
printf efio_Printf
rewind(f) efio_Seek(f, 0, SEEK_SET, NULL)
fscanf efio_Fscanf
sscanf
efio_Sscanf
sprintf efio_Sprintf
ungetc(c, f) efio_Ungetc(c, f, NULL)
tmpfile efio_TmpFile
tmpnam efio_TmpName

As you might imagine, some of these macro string redefinitions can clobber your C++ code. The most egregious offenders are remove and rename.  Again, if you're writing C++, be sure to define the aforementioned macro before including any Toolkit header files.

A Note on Including Imagine Headers

 Also, be sure to include all Developer's Toolkit headers before you include any C++ headers.  Otherwise you risk having the C++ word ctype clobbering their use of that word in eeml_Icon.h.  Moreover, insure that you are generating multithreaded DLLs, using 4-byte word boundaries, and have exception handling enabled.  The rule of thumb is, whatever compiler and linker options they use, you should use, too.

Getting Vector Layer Data from a Generic Layer

Getting access to vector data in a layer opened via Edis_OpenGenericLayer() is surprisingly challenging.  That function returns a pointer to a newly created Edis_Layer object which doesn't inherently contain any vector specific members.  However, clearly there must be a way to talk to a vector layer created via that function.  Here's an example on how to do that:


Edis_ViewLayer * view_layer = Edis_OpenGenericLayer(...);
Edis_VectorInfo * vector_info = static_cast<Edis_VectorInfo*>(viewLayer->layerSpecificData);

Unfortunately the struct Edis_VectorInfo isn't defined in any of the Imagine 8.6 Developer's Toolkit headers.  This is what the missing struct looks like, however:


struct Edis_VectorInfo
{
   char * filename;
   Evec_MasterVectorStruct * mvs;
   Exfr_XForm * maptoFileXfm;
   long width;
   long height;
   Edis_Pick * pick;
   Edis_ViewWindow * vwindow;
   Eeml_Canvas * screen_canvas ;
   Eprj_MapInfo * mapinfo ;
   Eprj_ProParameters * projinfo;
   Emsc_Boolean AllowSaving;
   Emsc_Boolean ClearIdLists;
   Emsc_Boolean IncrementTransaction;
   Emsc_Boolean transactionChanged;
   double lastx;
   double lasty;
};

The mvs member contains the vector layer specific information.  You should use the evec_*() functions found in evec.h to access and manipulate mvs.