CGM Viewer Library
ISO CGM Viewer is easy to implement for Linux, UNIX, and Windows applications developers. Supports CGM versions (1-4) with profiles for ATA, CALS, CGM PIP, and Web CGM.
Quickly implement our CGM Viewer Library, simply setup parameters, then call a single function to draw the a CGM file to a Device Context (Windows) or Graphics Context (Unix).
The CGM Viewer Library SDK includes sample code and the converter library (DLL), which you can utilize with your C++ or Visual Basic applications.
Example Code (C++):
#include "renderview.h"
appDataStruct appData;
long error = 0;
ISIZE Extent, Dpis;
// TODO: add draw code for native data here
CString WorkDir = "c:\\temp";
CString FontDir = ".\\fonts";
// Render CGM to Window
DdlInfo DispInfo;
memset(&DispInfo, 0, sizeof(DispInfo));
DispInfo.hDC = pDC->m_hDC;
DispInfo.hAttribDC = pDC->m_hAttribDC;
CRect rect;
this->GetClientRect(&rect);
// Draw CGM to a lower right quadrant of the client window
// rectagular area in client coordinates to contain the CGM picture
Extent.cx = rect.Width() / 2;
Extent.cy = rect.Height() / 2;
// move origin for the CGM picture
pDC->OffsetWindowOrg(-Extent.cx, -Extent.cy);
Dpis.cx = pDC->GetDeviceCaps(LOGPIXELSX);
Dpis.cy = pDC->GetDeviceCaps(LOGPIXELSY);
memset((void*)&appData, 0, sizeof(appData));
// Scale CGM picture to fit the specified rectangular area
appData.iMapping = MAPPING_FIT;
// Center the CGM picture
appData.iHalign = HALIGN_MIDDLE;
appData.iValign = VALIGN_MIDDLE;
appData.iPicture = 1;
// Portion of the CGM extents to display in percent
appData.VdcWindow.botx = 0;
appData.VdcWindow.boty = 0;
appData.VdcWindow.topx = 1; // full extents in percent
appData.VdcWindow.topy = 1;
appData.iVdcWinUnits = UNITS_PERCENT;
appData.DdlInfo = (long*)&DispInfo;
appData.ScaleFactor = 1;
error = renderview((char*)(LPCTSTR)CgmPath, TRUE,(char*)(LPCTSTR)WorkDir,
(char*)(LPCTSTR)FontDir, (ISIZE*)&Extent, &Dpis,
NULL, &appData);
// if error is zero then picture was displayed successfully.








