|
 |
Prize winner in Competition "MFC/C++ May 2003"
|
|
|

Introduction
This is an ActiveX control based on the OpenGL library, which allows you to plot three-dimensional data. The control is entirely written on ATL/STL, and does not link to MFC libraries.
The control can perform the following functions:
- Axis customization, including customizable font, colors, and titles.
- Plot a large number of points and updating one or more plots on the graph with new data, replacing the old plot with the new plot.
- Plot the multiple elements with individual properties such as line and point color, line width, and point size.
- Lighting
- Plot styles: {0 (Lines); 1 (Points); 2 (LinePoint); 3 (Surface)}
- By setting the
Projection property you should be able to change the viewing to: (0) Perspective (in which objects that are closer appear larger), and (1) Orthographic (in which the sizes and angles between objects are maintained no matter what their distance from the viewer).
- By setting the
TrackMode property you should be able to do: (1) Zooming, (2) Rotation, and (3) Panning at runtime.
About the Code
To use this control, embed it in an application that supports the use of ActiveX controls. Microsoft Visual Basic applications, all MS Office applications, VBScript and JavaScript in the HTA or Internet Explorer applications, and applications created with the Microsoft Developer Studio’s AppWizard can support the use of ActiveX controls.
Before you start, the control must be register as a COM component using Regsvr32.exe. Regsvr32 takes one argument the DLL or control to register and any of several command-line switches, the most notable of which is /u to uninstall a control. By default that is, when run with only a dll or ocx Regsvr32.exe registers the control.
Note: you must do this on every computer that you are going to use the control!
For more information on how to register and how to include the control in a VC Project, refer to my article 2D Graph ActiveX Control.
Bellow are two listings that demonstrates how to use the control to draw a Torus:
C++
void CDemoDlg::OnButton1()
{
m_Graph3D.SetCaption ("Torus");
m_Graph3D.ClearGraph();
m_Graph3D.AddElement();
m_Graph3D.SetElementLineColor(0, RGB(255,0,0));
m_Graph3D.SetElementType(0, 3);
double x,y,z,ti,tj;
for (int i = 0; i < 41; i++)
{
ti = (i - 20.0)/20.0 * 3.15;
for (int j = 0; j < 41 ; j++)
{
tj = (j - 20.0)/20.0 * 3.15;
x = (cos(tj) + 3.0) * cos(ti);
y = sin(tj);
z = (cos(tj) + 3.0) * sin(ti);
m_Graph3D.PlotXYZ(x,y,z,0);
}
}
m_Graph3D.AutoRange();
}
Visual Basic
Sub Torus
With Graph3D
.ClearGraph
.AddElement
.Caption = "Torus"
.ElementType(0) = 3
For i = 0 To 41
ti = (i - 20.0)/20.0 * 3.15
For j = 0 To 41
tj = (j - 20.0)/20.0 * 3.15
x = (cos(tj) + 3.0) * cos(ti)
y = sin(tj)
z = (cos(tj) + 3.0) * sin(ti)
.PlotXYZ x,y,z,0
Next
Next
.Autorange
End With
End Sub
List of Control Properties:
Graph
-
short Appearance
-
long BorderStyle
-
VARIANT_BOOL BorderVisible
-
BSTR Caption
-
IFontDisp* Font
-
OLE_COLOR BackColor
-
OLE_COLOR CaptionColor
-
short TrackMode
-
short Projection
-
BSTR XLabel
-
BSTR YLabel
-
BSTR ZLabel
-
short XGridNumber
-
short YGridNumber
-
short ZGridNumber
-
OLE_COLOR XGridColor
-
OLE_COLOR YGridColor
-
OLE_COLOR ZGridColor
Elements
-
OLE_COLOR ElementLineColor(long ElementID, OLE_COLOR newVal)
-
OLE_COLOR ElementPointColor(long ElementID, OLE_COLOR newVal)
-
float ElementLineWidth(long ElementID, float newVal)
-
float ElementPointSize(long ElementID, float newVal)
-
short ElementType(long ElementID)
-
BOOL ElementShow(long ElementID)
-
BOOL ElementSurfaceFill(long ElementID)
-
BOOL ElementSurfaceFlat(long ElementID)
-
BOOL ElementLight(long ElementID
-
short ElementLightingAmbient(long ElementID)
-
short ElementLightingDiffuse(long ElementID)
-
short ElementLightingSpecular(long ElementID)
-
short ElementMaterialAmbient(long ElementID)
-
short ElementMaterialDiffuse(long ElementID)
-
short ElementMaterialSpecular(long ElementID)
-
short ElementMaterialShinines(long ElementID)
-
short ElementMaterialShinines(long ElementID)
-
short ElementMaterialEmission(long ElementID)
List of Control Methods:
Graph
-
void SetRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
-
void AutoRange()
-
void ShowPropertyPages()
Elements
-
void AddElement()
-
void DeleteElement(long ElementID)
-
void ClearGraph()
-
void PlotXYZ(double x, double y, double z, long ElementID)
-
void SetLightCoordinates(long ElementID, float x, float y, float z)
Cost: One bottle wine. :-)
Enjoy!
Note: I am not expert on OpenGL, therefore all good suggestions, code and help for imporving the control are welcome!
Send mail to nteofilov@yahoo.de with questions or comments about this article.
History
16 Jun 2003 - v1.0 Initial release
22 Jun 2003 - v2.0
- Thanks to Alexander Chernosvitov for the Excellent article Function graphics in 3D.
- Lot’s of new properties (see property list and demo files)
ElementType = {0 (Lines); 1 (Points); 2 (LinePoint); 3 (Surface)}
- Added new demo file that demonstrate the new features
- New Property
BOOL ElementShow(long ElementID) 29 Jul 2003 - v2.1
- Some drawing fixes
- Added CopyToClipboard (Works only with release versions of the control! )
- Added Klein Bottle
- Changes to the Demo Projects
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 78 (Total in Forum: 78) (Refresh) | FirstPrevNext |
|
 |
|
|
Have you checked the exact name of the control in Access? If yes, have you then tried writing NTGraph3D0.Object instead of just NTGraph3D0 (or whatever your control`s name was) in the With line of the Torus example? Torus example with this .Object modification works fine in Access for me.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
please tell me how to change the grid distances of x & y axis in ntgraph activex control.
abhinav bhorkar
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, I've been using VBA for some time but have never worked with ActiveX controls. I am trying to use this ActiveX Control in Excel. I have registered the dll using REGSVR32. I created an ActiveX control using NTGraph3D class. I can see the empty x,y,z axis in the control. I double-clicked on the control to add code. I have ensured that I've ticked "NTGraph3D 1.0 Type Library" in my project References. I can see the NTGraph3D objects when I open the object browser.
I have created the following test code:
Sub TstTorus()
Dim Gr As OLEObject Dim WS As Worksheet
Set WS = Worksheets("Sheet1") WS.OLEObject("NTGraph3D").ClearGraph End Sub
I keep getting the same compile error: Object library invalid or contains references to object definitions that could not be found.
Is there some step that I've missed? I would greatly appreciate help! bd
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I want to use 2d capabilities of Direct3D. I have different bitmaps and need to blit these directly on 'Backbuffer of device'. I created a surface using IDirect3Device::CreateOffScreenPlainSurface() then I blit bitmap on this surfsace using GetDC() function of surface. Then I used IDirect3Device::GetBackBuffer() method to get backbuffer surface and using IDirect3Device::StretchRect(), did blit on backbuffer surfaceBut It did not work. Kindly guide me in this regard. Raheel
modified on Saturday, September 6, 2008 7:46 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I want to move a point(x,y,z) on straight or curved path in NTGraph3D control. Should I use line drawing function to draw curved path? Can Grid in background be made invisible? I only need 3-Axis in background. Is there anyother free 3D-Graph Drawing Actvx control like NTGraph3D? Thanks Raheel
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Anyone got the surface plot and associated properties to work or is it disabled? Any idea on how to get the release version? No valid contact details are available for the author here.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I want to have print option for 3D Graphs plotted using this ActiveX control . Can anyone help me in this. There is one in 2D ActiveX, but he has not provided in this control - 3D ActiveX.
Thanks in advance.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I found this 3D Graph ActiveX Control in this website, but I don't konw how to use it? what is m_Graph3D then? it seems to be a instance of the class. Any one who has used it, please give me one hint.
thanks.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Hi
I tryed your code in an MFC DLL and it worked, but very slow. I have to show every 12Hz new 3D images. Now i can display 1 Image per second and this will bring the CPU to 100%.
Ok what i have done is calling an function from the Dialog with this code:
m_Graph3D.AddElement(); // fügt ein Element hinzu m_Graph3D.put_ElementType( 0 , 1); // definiert dasd ELement als Punkt m_Graph3D.put_ElementPointSize( 0, 10.0); // setzt die Punktgröße //m_Graph3D.put_ElementPointColor( 0 , ( ((unsigned long)((unsigned char)(piPixel/20 + 100))<<16) + ((unsigned short)((unsigned char)(piPixel/10))<<8))) ;
for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { piPixel = *piData++; m_Graph3D.PlotXYZ(j,i,piPixel, slElementID ); } }
m_Graph3D.put_TrackMode( 2 ); m_Graph3D.AutoRange();
But this takes so much times and only every second Image will be shown
Can u help be to make it faster?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hi I registerd this dll and ntgraoh.ocx in win 3000 server but when I want to put it on my prog not only a new form it takes a long time and my prog can not be started my prog is in vc++.net windows form application . please help me to say what can I do?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi All, Can anyone tell me what changes required other than registering dll, i have to made while using NTGraph3D dll in Vista system
-- modified at 4:22 Friday 17th August, 2007
NSRS
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I have found in some sites that i have to install some drivers to support OpenGL, Can any one suggest the relevant driver
NSRS
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hey all, sorry i'm pretty average at this VB business, currently using VB6 though. Downloaded the NTGraph3D binary and registered it using regsvr32 and all went well. However after adding as a component in VB only NTGraph3D's properties show up, the elements (ie ClearGraph, AddElement, ElementType) don't appear in the objects properties box. As such the given code example refuses to work.
Have downloaded, registered and successfully used the 2D version of NTGraph and i'm not entirely sure where i've gone wrong.
Any help much appreciated,
Mike
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, first off, thanks for making this, its been really helpful. i have been having problems plotting an iterative sequence of a lattice like structure using a scatter diagram. while the program is running only the corners of the cube appear then the rest is plotted at the end. yet if the code is run a second time all the points are plotted. is there a way this could be fixed? manythanks again. Ollie
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Is anything other than registering NTGraph3D.dll required to get the control to work in Access?
I have it registered adn working with Excel. Right now Access is a no go though.
Any help will be greatly appreciated
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Good code, I hope to embedded our project,as a preview 3D motion track component, could you tell me how can draw a arc by pssing center plot ,start plot and direct?
anyway, studying your code let me master lots of experiences.
coolman
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
Dear Friends can any body help in usin this 3D control in VB I want to Plot the Graph from my Data Table my Table Consist of X = Columns Y = Rows Z = Values in that Row.
Can any body help in to plot the Drawing.
Z contains the Values which needs to be Ploted.
 help needed urgently


NileshG
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
Aside from scores of warnings about "possible loss of data", C2664 is keeping me from compiling this code in anything but VC++ 6.0. Would someone please post a method to "convert"? The code to convert, not just "oh great, it works now! Because I casted!" or "dude, you gotta cast". Thanx.
GraphCtl.cpp(1078) : error C2664: 'CGraphCtl::SetLight' : cannot convert parameter 1 from 'std::vector<_Ty>::iterator' to 'CElement *' with [ _Ty=CElement ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called GraphCtl.cpp(1099) : error C2664: 'CGraphCtl::PtInRange' : cannot convert parameter 1 from 'std::vector<_Ty>::iterator' to 'CPoint3D *' with [ _Ty=CPoint3D ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called GraphCtl.cpp(1101) : error C2664: 'CGraphCtl::Coordinate' : cannot convert parameter 1 from 'std::vector<_Ty>::iterator' to 'CPoint3D *' with [ _Ty=CPoint3D ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called GraphCtl.cpp(1118) : error C2664: 'CGraphCtl::PtInRange' : cannot convert parameter 1 from 'std::vector<_Ty>::iterator' to 'CPoint3D *' with [ _Ty=CPoint3D ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called GraphCtl.cpp(1120) : error C2664: 'CGraphCtl::Coordinate' : cannot convert parameter 1 from 'std::vector<_Ty>::iterator' to 'CPoint3D *' with [ _Ty=CPoint3D ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called GraphCtl.cpp(1145) : error C2668: 'sqrt' : ambiguous call to overloaded function C:\Program Files\VS71\Vc7\include\math.h(626): could be 'long double sqrt(long double)' C:\Program Files\VS71\Vc7\include\math.h(578): or 'float sqrt(float)' C:\Program Files\VS71\Vc7\include\math.h(200): or 'double sqrt(double)' while trying to match the argument list '(std::vector<_Ty>::size_type)' with [ _Ty=CPoint3D ]
Quite a mess, huh?
RedDK
|
| Sign In·View Thread·PermaLink | 2.50/5 (3 votes) |
|
|
|
 |
|
|
I had the same problem trying to compile the dll in VS C++ 2005.
CElement (and other iterators alike in the erring code) is a pointer which is different to an iterator. Hence you have to dereference it first then get its address before you can pass it through. This converts the iterator value into a pointer to an object behind the iterator.
Modifying each of the erring the code similar to below will make it compile:
SetLight(&*CElement);
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
|
Hy guys, I need to implement in my C# app same things that control does, just like 3d surfaces and points visualization. How can I perform this?By wrap the *.dll?And if true why? Thankyou a lot. Mirko
|
| Sign In·View Thread·PermaLink | 2.40/5 (5 votes) |
|
|
|
 |
|
|
I cannot add property pages because the compiler said "windows.h already include" or similar. Anybody can help me? Thank you.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I want to develope a 3D game with vc++ can anyone help me for using opengl , is there any simple example present on the net free to download. If anyone in the same field can help me ok take care
Vikas Amin Embin Technology Bombay vikas.amin@embin.com
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
there is one game on codeproject [ good website ] in the OpneGL section (just scroll down the list) but i need one like the Arked or Shooting game.
Vikas Amin Embin Technology Bombay vikas.amin@embin.com
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
Hi, Actually I think there is another bug in the PlotElement function. Indeed, I believe the loop in order to display a surface is wrong.
What about the following code?
... // Turn on the primitive connection mode (not connected) glBegin (GL_QUADS) ;
/* Original code int i, npt = sqrt(theElement->m_PointList.size()); aPoint = theElement->m_PointList.begin(); for (aPoint, i=0; aPoint != theElement->m_PointList.end(); aPoint++,i++) { int j,k,n; if (PtInRange(&(theElement->m_PointList[i]))) { // i, j, k, n ・4 indices of a quad // Counter Clockwise direction j = i + npt; // Other vertices indices k = j+1; n = i+1; */
int i = 0 ; int npt = theElement->m_PointList.size() ; int nxpt = sqrt(npt); int nypt = sqrt(npt); int x, y ; for (i = 0, x = 0 ; x < nxpt-1 ; x++, i++) for (y = 0; y < nypt-1 ; y++, i++) { int j,k,n ; if (PtInRange(&(theElement->m_PointList[i]))) { // i, j, k, n ・4 indices of a quad // Counter Clockwise direction j = i + nxpt ; // Other vertices indices k = j+1 ; n = i+1 ; ...
|
| Sign In·View Thread·PermaLink | 4.40/5 (2 votes) |
|
|
|
 |
|
|
Hi, Thank you for this article. It is great! However I think there is a small bug in the PtInAxisBox function.
Because we convert the coordinates inside the function Corrdinate, and then we convert back inside the function PtInAxisBox. If so, this second convertion is wrong.
What about the following code?
BOOL CGraphCtl::PtInAxisBox(CPoint3D* pt) { float xF=dRangeX[MAX]-dRangeX[MIN]; float yF=dRangeY[MAX]-dRangeY[MIN]; float zF=dRangeZ[MAX]-dRangeZ[MIN];
CPoint3D point;
/*point.x = (pt->x+dRangeX[MIN])/xF + 0.5f; point.y = (pt->y+dRangeY[MIN])/yF + 0.5f; point.z = (pt->z+dRangeZ[MIN])/zF + 0.5f;*/
point.x = (pt->x + 0.5f) * xF + dRangeX[MIN] ; point.y = (pt->y + 0.5f) * yF + dRangeY[MIN] ; point.z = (pt->z + 0.5f) * zF + dRangeZ[MIN] ; return (PtInRange(&point)); }
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
General News Question Answer Joke Rant Admin
|