彩票走势图

工控图表控件ProEssentials使用教程:创建3D曲面图

原创|使用教程|编辑:郝浩|2013-04-08 16:35:15.000|阅读 1383 次

概述:3D Scientific Graph Control是工控图表控件ProEssentials的图表组件之一,本文用ProEssentials创建了一个简单的3D曲面图。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

3D Scientific Graph Control是工控图表控件ProEssentials的图表组件之一,它可以生成各种类型的图表,比如3D曲面图、3D柱状图、3D散点图等,所有的图表均支持旋转和查看高度调整。下面是用ProEssentials创建的一个简单的3D曲面图

3D Scientific Graph Control是工控图表控件ProEssentials的图表组件,3D曲面图

功能:

  • 双击生成的图表,它会开始自动旋转,再次双击即停止旋转
  • 按住鼠标左键可拖动查看曲面图的各个部分

PS:要体验这个3D曲面图的旋转功能,可以下载ProEssential's v7 Demo

ProEssentials创建3D曲面图的源代码:

void CPEView::Create3DSimpleWireFrame()
{

   RECT rect;
   GetClientRect( &rect );

   // Construct Object //
   m_hPE = PEcreate(PECONTROL_3D, WS_VISIBLE, &rect, m_hWnd, 1001);

   // Enable mouse dragging //
   PEnset(m_hPE, PEP_bMOUSEDRAGGINGX, TRUE);
   PEnset(m_hPE, PEP_bMOUSEDRAGGINGY, TRUE);

   long Row, Col, o, s, e, nQ;
   long nStartRow, nEndRow, nStartCol, nEndCol, nTargetRows, nTargetCols;

   nStartRow = 160;
   nEndRow = 185;
   nTargetRows = nEndRow - nStartRow + 1;

   nStartCol = 85;
   nEndCol = 110;
   nTargetCols = nEndCol - nStartCol + 1;

   nQ = nTargetRows * nTargetCols;

   long* pElevData = NULL;
   float* pMyXData = NULL;    
   float* pMyYData = NULL;
   float* pMyZData = NULL;

   TCHAR szFile[] = TEXT("terrain.bin");
   FILE * pFile = NULL;
   pFile = _tfopen(szFile, TEXT("rb"));

   if (pFile)
   {
       pElevData = new long[202500];
       // Transfer entire data file into memory //
       size_t cnt;
       e = 0;
       for (s = 0; s < 45; s++)
       {
           cnt = fread(&pElevData[e], sizeof(long), 4500, pFile);
           e += 4500;
       }
       fclose(pFile);
   }
   else
   {
       MessageBox(TEXT("Data File [terrain.bin] not found in program directory."));
       return;
   }

   pMyXData = new float[nQ];
   pMyYData = new float[nQ];
   pMyZData = new float[nQ];

   long rowcounter, colcounter;
   BOOL foundtargetindex = FALSE;
   rowcounter = 0;
   colcounter = 0;

   for (Row=0; Row<450; Row++)
   {
       for (Col=0; Col<450; Col++)
       {
           foundtargetindex = FALSE;

           if (Row >= nStartRow && Row <= nEndRow) 
           {
               if (Col >= nStartCol && Col <= nEndCol)
               {
                   foundtargetindex = TRUE;
                   o = (rowcounter * nTargetRows) + colcounter;
                   pMyXData[o] = (float) Col + 1;
                   pMyZData[o] = (float) Row + 1;
                   pMyYData[o] = pElevData[(Row * 450) + Col] * 0.1F;
               }
           }
           if (foundtargetindex) 
               colcounter++;
       }
       if (foundtargetindex)
	        rowcounter++;
   }

   PEnset(m_hPE, PEP_nSUBSETS, nTargetRows);
   PEnset(m_hPE, PEP_nPOINTS, nTargetCols);

   // Perform the actual transfer of data //
   PEvset(m_hPE, PEP_faXDATA, pMyXData, nQ);
   PEvset(m_hPE, PEP_faYDATA, pMyYData, nQ);
   PEvset(m_hPE, PEP_faZDATA, pMyZData, nQ);

   if (pElevData)
       delete pElevData;
   if (pMyXData)
       delete pMyXData;
   if (pMyYData)
       delete pMyYData;
   if (pMyZData)
       delete pMyZData;

   PEnset(m_hPE, PEP_dwXZBACKCOLOR, 1);
   PEnset(m_hPE, PEP_dwYBACKCOLOR, 1);

   // Mechanism to control polygon border color //
   PEnset(m_hPE, PEP_dwBARBORDERCOLOR, PERGB( 255,0,0,0));

   DWORD dw = PERGB( 96,198,0,0);
   PEvsetcell(m_hPE, PEP_dwaSUBSETCOLORS, WIRE_FRAME_COLOR, &dw); 

   dw = PERGB( 96,0,148,0);
   PEvsetcell(m_hPE, PEP_dwaSUBSETCOLORS, SOLID_SURFACE_COLOR, &dw);  

   // Set the plotting method //
   //! There are different plotting method values for each //
   //! case of PolyMode  //
   PEnset( m_hPE, PEP_nPLOTTINGMETHOD, 1 );

   // Set various other properties //
   PEnset(m_hPE, PEP_bBITMAPGRADIENTMODE, TRUE);
   PEnset(m_hPE, PEP_nQUICKSTYLE, PEQS_DARK_LINE);

   PEnset(m_hPE, PEP_bSIMPLEPOINTLEGEND, TRUE);
   PEnset(m_hPE, PEP_bSIMPLELINELEGEND, TRUE);
   PEnset(m_hPE, PEP_nLEGENDSTYLE, PELS_1_LINE);

   PEszset(m_hPE, PEP_szMAINTITLE, TEXT("Wire Frame"));
   PEszset(m_hPE, PEP_szSUBTITLE, TEXT("")); // no subtitle
   PEnset(m_hPE, PEP_nVIEWINGHEIGHT, 20);				   
   PEnset(m_hPE, PEP_nDEGREEOFROTATION, 275);
   PEnset(m_hPE, PEP_bFIXEDFONTS, TRUE);
   PEnset(m_hPE, PEP_nFONTSIZE, PEFS_MEDIUM);
   PEnset(m_hPE, PEP_bPREPAREIMAGES, TRUE); 
   PEnset(m_hPE, PEP_bCACHEBMP, TRUE);
   PEnset(m_hPE, PEP_bFOCALRECT, FALSE);
   PEnset(m_hPE, PEP_nSHADINGSTYLE, PESS_WHITESHADING);

   PEnset(m_hPE, PEP_nTEXTSHADOWS, PETS_BOLD_TEXT);
   PEnset(m_hPE, PEP_bMAINTITLEBOLD, TRUE);
   PEnset(m_hPE, PEP_bSUBTITLEBOLD, TRUE);
   PEnset(m_hPE, PEP_bLABELBOLD, TRUE);

   // Improves metafile export //
   PEnset(m_hPE, PEP_nDPIX, 600);
   PEnset(m_hPE, PEP_nDPIY, 600);

   PEnset(m_hPE, PEP_nSHOWBOUNDINGBOX, PESBB_NEVER);
   PEnset(m_hPE, PEP_bANTIALIASTEXT, TRUE);
   PEnset(m_hPE, PEP_bANTIALIASGRAPHICS, FALSE);
   PEnset(m_hPE, PEP_nRENDERENGINE, PERE_GDIPLUS);

   // Set Demo's RenderEngine to Gdi Plus // 
   CMDIFrameWnd* pWnd = (CMDIFrameWnd*) AfxGetApp()->GetMainWnd();
   pWnd->SendMessage(WM_CHANGE_METAFILE, PEPLAYMETAFILEGDIPLUS );


}

//***************************************************************************

 


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@capbkgr.cn

文章转载自:慧都控件

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP