CAD System Web Site - Computer Aided Design Software
i NET1000.COM
by Makoto Honda
Last Update: 2010-September-10                   Update Info     Site Index     Licensing     Copyright Notice     Privacy Policy     Contact Us  

 


 
System Architecture

 DLL Hierarchy
 Element Classes
 FM Programming
 Temp Elements
 Current Plane
 Rendering
 Undo/Redo
 OpenGL Display List


 
HOME  

                                   
Current Plane
Computer-Aided Design Software
(CAD System)


 

Current Plane / Construction Plane


Current Plane Class Structure / GUtil.h

class AFX_EXT_CLASS CCurPlane : public CObject
{
protected: // create from serialization only
CCurPlane() {};
// DECLARE_DYNCREATE(CCurPlane)
public:
///////////// virtual ~CCurPlane();
virtual void Serialize(CArchive& ar);

protected:
CViewMatrix m_matrix;

public:
CCurPlane ( const CPoint3D& orig, const CPoint3D& normal, const CPoint3D& xAx, const CPoint3D& yAx );

void SetMxAxisX (const CPoint3D& p); // { m_matrix.Xx = p.x; m_matrix.Xy = p.y; m_matrix.Xz = p.z; };
void SetMxAxisY (const CPoint3D& p); // { m_matrix.Yx = p.x; m_matrix.Yy = p.y; m_matrix.Yz = p.z; };
void SetMxAxisZ (const CPoint3D& p); // { m_matrix.Zx = p.x; m_matrix.Zy = p.y; m_matrix.Zz = p.z; };
void SetMxOrigin(const CPoint3D& p); // { m_matrix.Ox = p.x; m_matrix.Oy = p.y; m_matrix.Oz = p.z; };

void SetMatrix (const CPoint3D& x, const CPoint3D& y, const CPoint3D& z, const CPoint3D& o);
void SetPresetPlaneXY ();
void SetPresetPlaneXZ ();
void SetPresetPlaneYZ ();

CPoint3D GetMxAxisX () const; // { return CPoint3D (m_matrix.Xx, m_matrix.Xy, m_matrix.Xz); }
CPoint3D GetMxAxisY () const; // { return CPoint3D (m_matrix.Yx, m_matrix.Yy, m_matrix.Yz); }
CPoint3D GetMxAxisZ () const; // { return CPoint3D (m_matrix.Zx, m_matrix.Zy, m_matrix.Zz); }
CPoint3D GetMxOrigin() const; // { return CPoint3D (m_matrix.Ox, m_matrix.Oy, m_matrix.Oz); }

CViewMatrix GetMatrix() const; // { return m_matrix; }
CPoint3D GetMxAxisNegZ () const;
void MakeHomogeneousMatrix16 ( float* mmm );
void MakeHomogeneousMatrix16ColumnFirst ( float* mmm );
CPlane3D GetPlane() const;
};


Current Plane Control Variables / GData.h

// ------------------- CURRENT PLANE CONTROL VARIABLES ---------------- //
public:

CCurPlane* m_pCurPlane; // current plane currency

float m_gridSpacingX;
float m_gridSpacingY;
float m_gridExtent; // total length of grid
int m_gridAxisType; // 0, 1, 2
int m_gridType; // 0 = lines, 1 = points
int m_curPlaneColor; // 0 = grey ....
int m_curPlanePresetXYZ; //

// Current Plane Rotation
CPoint3D m_curPlaneRotAxisPt;
int m_curPlaneRotAxisXYZ;

void SetCurPlaneRotAxisPt (CPoint3D pt) { m_curPlaneRotAxisPt = pt; };
void SetCurPlaneRotAxisVec (int i) { m_curPlaneRotAxisXYZ = i; };
CPoint3D GetCurPlaneRotAxisPt (){ return m_curPlaneRotAxisPt; };
CPoint3D GetCurPlaneRotAxisVec ()
{
if (m_curPlaneRotAxisXYZ == 1) return m_pCurPlane->GetMxAxisX();
else if (m_curPlaneRotAxisXYZ == 2) return m_pCurPlane->GetMxAxisY();
else return m_pCurPlane->GetMxAxisZ();
};


Draw Current Plane / GView.cpp

void CGView::DrawCurPlane ()
{
// Draw the current plane for this viewport

// (1) MAKE DISPLAY LIST at the origin AND STORE IT
// (2) Apply modeling transformation
// (3) Apply viewing transformation

CGDoc* pDoc = GetDocument();
CCurPlane* pCP = m_pData->m_pCurPlane;

// Set current plane matrix
GLfloat mmm[16];
pCP->MakeHomogeneousMatrix16 ( mmm );

// Apply the matrix before displaying current plane
glLoadIdentity();
glMultMatrixf(mmm);

// Call display list
glCallList ( DL_CUR_PLANE );

// Needed for proper polygon display
glLoadIdentity();
}

Create Display List (OpenGL) for Current Plane / GData.cpp

void CData::CreateDisplayList (DISPLAY_LIST no)
{
glNewList (no, GL_COMPILE);

switch (no)
{
case DL_ROTATOR: // Rotator axes
break;

case DL_AXIS: // Axis
break;

case DL_GRAB_POINT: // Pick Point element
break;

case DL_POINT: // Point element
{
glPointSize (4.0);
//glColor3f (1.0, 1.0, 0.0);
glBegin (GL_POINTS);
glVertex3f (0.0f , 0.0f , 0.0f );
glEnd();
break;
}
case DL_LIGHT_SOURCE: // Light Source element
break;

case DL_DRAG_MOVE_BOX: // Used during drag move
break;

case DL_CUR_PLANE: /// Current plane
{
glLineWidth (0.5);
// Color of the current plane --- User-customizable 97-4-25
if (m_modeGlobalCP == COORD_CUR_PLANE)
glColor3f (0.6f, 0.4f, 0.0f);
else
{
switch (m_curPlaneColor)
{
case 0: glColor3f (0.4f, 0.4f, 0.4f); break;
case 1: glColor3f (0.2f, 0.5f, 0.5f); break;
case 2: glColor3f (0.2f, 0.3f, 0.6f); break;
case 3: glColor3f (0.4f, 0.6f, 0.2f); break;
default: glColor3f (0.4f, 0.4f, 0.4f); break;
}
}
int gridTotalX = (float)m_gridExtent / (float)m_gridSpacingX;
int gridTotalY = (float)m_gridExtent / (float)m_gridSpacingY;

const float xMax = m_gridExtent;
const float yMax = m_gridExtent;
const float zMax = 0.0f;
float xx, yy;

switch (m_gridType)
{
case 0:
{
// Line grid ------------------------------- use lines
xx = m_gridSpacingX;
yy = m_gridSpacingY;
glBegin (GL_LINES);
for (int k = 0; k < gridTotalX; k++)
{
glVertex3f (xx, yMax, zMax);
glVertex3f (xx, -yMax, zMax);
glVertex3f (-xx, yMax, zMax);
glVertex3f (-xx, -yMax, zMax);
xx += m_gridSpacingX;
}
for (int kk = 0; kk < gridTotalY; kk++)
{
glVertex3f (xMax, yy, zMax);
glVertex3f (-xMax, yy, zMax);
glVertex3f (xMax, -yy, zMax);
glVertex3f (-xMax, -yy, zMax);
yy += m_gridSpacingY;
}
glEnd ();
break;
}
case 1:
{
xx = m_gridSpacingX;
yy = m_gridSpacingY;
glPointSize (2.0);

// Point grid ----------------------------- use points
glBegin (GL_POINTS);
for (int k = 0; k < gridTotalX; k++)
{
for (int j = 0; j < gridTotalY; j++)
{
glVertex3f ( xx, yy, zMax);
glVertex3f ( xx, -yy, zMax);
glVertex3f (-xx, yy, zMax);
glVertex3f (-xx, -yy, zMax);
yy += m_gridSpacingY;
}
xx += m_gridSpacingX;
yy = m_gridSpacingY;
}
xx = m_gridSpacingX;
yy = m_gridSpacingY;
for (int kk = 0; kk < gridTotalY; kk++)
{
for (int j = 0; j < gridTotalX; j++)
{
glVertex3f ( xx, yy, zMax);
glVertex3f (-xx, yy, zMax);
glVertex3f ( xx, -yy, zMax);
glVertex3f (-xx, -yy, zMax);
xx += m_gridSpacingX;
}
yy += m_gridSpacingY;
xx = m_gridSpacingX;
}
glEnd ();
break;
}
case 2:
{
// Line grid ------------------------------- frame only
xx = m_gridSpacingX;
yy = m_gridSpacingY;
glBegin (GL_LINE_STRIP);
glVertex3f (xMax, yMax, zMax);
glVertex3f (-xMax, yMax, zMax);
glVertex3f (-xMax, -yMax, zMax);
glVertex3f (xMax, -yMax, zMax);
glVertex3f (xMax, yMax, zMax);
glEnd ();
break;
}
}
// Draw negative X and Y axes (same color)
glBegin (GL_LINE_STRIP);
glVertex3f (-xMax, 0.0f, zMax);
glVertex3f (0.0f, 0.0f, zMax);
glVertex3f (0.0f,-yMax, zMax);
glEnd ();
// Draw X axis with RED
glColor3f (1.0f, 0.0f, 0.0f);
glBegin (GL_LINES);
glVertex3f (xMax, 0.0f, zMax);
glVertex3f (0.0f, 0.0f, zMax);
glEnd ();
// Draw Y axis with GREEN
glColor3f (0.0f, 1.0f, 0.0f);
glBegin (GL_LINES);
glVertex3f (0.0f, yMax, zMax);
glVertex3f (0.0f, 0.0f, zMax);
glEnd ();

glLineWidth (1.0);
break;
}

case DL_CIRCLE:
break;

default: // Default
break;
}
glEndList();
}

///////////////////////////////////////////////////////////////////////////
 

CAD System Web Site - Computer Aided Design Software:  Copyright 2010-2013 Makoto Honda. All Rights Reserved.  

Copyright 2010-2013 Makoto Honda. All Rights Reserved.                                       www.iNET1000.com