Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
getdunne committed Sep 8, 2014
1 parent 9c74b42 commit e171d2d
Show file tree
Hide file tree
Showing 84 changed files with 7,278 additions and 0 deletions.
53 changes: 53 additions & 0 deletions 15BitRGBDoc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "stdafx.h"
#include "Voxvu.h"
#include "15BitRGBDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(C15BitRGBDoc, VoxelFilePair)

C15BitRGBDoc::C15BitRGBDoc()
{
m_kind = k15BitRGB;
}

BOOL C15BitRGBDoc::OnNewDocument()
{
m_array.m_voxBytes = 2;

if (!VoxelFilePair::OnNewDocument())
return FALSE;

m_colors = 0;

return TRUE;
}

C15BitRGBDoc::~C15BitRGBDoc()
{
}


BEGIN_MESSAGE_MAP(C15BitRGBDoc, VoxelFilePair)
END_MESSAGE_MAP()

#ifdef _DEBUG
void C15BitRGBDoc::AssertValid() const
{
CDocument::AssertValid();
}

void C15BitRGBDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG

void C15BitRGBDoc::Serialize(CArchive& ar)
{
VoxelFilePair::Serialize(ar);
}
28 changes: 28 additions & 0 deletions 15BitRGBDoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "VoxelFilePair.h"

class C15BitRGBDoc : public VoxelFilePair
{
protected:
C15BitRGBDoc(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(C15BitRGBDoc)

// Overrides
public:
virtual void Serialize(CArchive& ar); // overridden for document i/o
protected:
virtual BOOL OnNewDocument();

// Implementation
public:
virtual ~C15BitRGBDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};
61 changes: 61 additions & 0 deletions 16BitGrayDoc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "stdafx.h"
#include "Voxvu.h"

#include "16BitGrayDoc.h"

#include "CineParamsDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(C16BitGrayDoc, VoxelFilePair)

C16BitGrayDoc::C16BitGrayDoc()
{
m_kind = k16BitGray;
}

BOOL C16BitGrayDoc::OnNewDocument()
{
m_array.m_voxBytes = 2;

if (!VoxelFilePair::OnNewDocument())
return FALSE;

// set up color table with 256 entries
m_colors = 256;
for (int i=0; i<256; i++) {
m_color[i].rgbRed = m_color[i].rgbGreen = m_color[i].rgbBlue = i;
m_color[i].rgbReserved = 0;
}

return TRUE;
}

C16BitGrayDoc::~C16BitGrayDoc()
{
}


BEGIN_MESSAGE_MAP(C16BitGrayDoc, VoxelFilePair)
END_MESSAGE_MAP()

#ifdef _DEBUG
void C16BitGrayDoc::AssertValid() const
{
CDocument::AssertValid();
}

void C16BitGrayDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG

void C16BitGrayDoc::Serialize(CArchive& ar)
{
VoxelFilePair::Serialize(ar);
}
28 changes: 28 additions & 0 deletions 16BitGrayDoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "VoxelFilePair.h"

class C16BitGrayDoc : public VoxelFilePair
{
protected:
C16BitGrayDoc(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(C16BitGrayDoc)

// Overrides
public:
virtual void Serialize(CArchive& ar); // overridden for document i/o
protected:
virtual BOOL OnNewDocument();

// Implementation
public:
virtual ~C16BitGrayDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};
59 changes: 59 additions & 0 deletions 8BitGrayDoc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "stdafx.h"
#include "Voxvu.h"

#include "8BitGrayDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(C8BitGrayDoc, VoxelFilePair)

C8BitGrayDoc::C8BitGrayDoc()
{
m_kind = k8BitGray;
}

BOOL C8BitGrayDoc::OnNewDocument()
{
m_array.m_voxBytes = 1;

if (!VoxelFilePair::OnNewDocument())
return FALSE;

// set up color table with 256 entries
m_colors = 256;
for (int i=0; i<256; i++) {
m_color[i].rgbRed = m_color[i].rgbGreen = m_color[i].rgbBlue = i;
m_color[i].rgbReserved = 0;
}

return TRUE;
}

C8BitGrayDoc::~C8BitGrayDoc()
{
}


BEGIN_MESSAGE_MAP(C8BitGrayDoc, VoxelFilePair)
END_MESSAGE_MAP()

#ifdef _DEBUG
void C8BitGrayDoc::AssertValid() const
{
CDocument::AssertValid();
}

void C8BitGrayDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG

void C8BitGrayDoc::Serialize(CArchive& ar)
{
VoxelFilePair::Serialize(ar);
}
28 changes: 28 additions & 0 deletions 8BitGrayDoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "VoxelFilePair.h"

class C8BitGrayDoc : public VoxelFilePair
{
protected:
C8BitGrayDoc(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(C8BitGrayDoc)

// Overrides
public:
virtual void Serialize(CArchive& ar); // overridden for document i/o
protected:
virtual BOOL OnNewDocument();

// Implementation
public:
virtual ~C8BitGrayDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};
110 changes: 110 additions & 0 deletions ArcballControl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include "stdafx.h"
#include "Vector3.h"
#include <math.h>
#include "ArcballControl.h"


//--------------------------------------------------------------
// Constructor
//--------------------------------------------------------------
ArcballControl::ArcballControl ()
{
m_color = RGB(0,192,255); // default color is light blue
m_pDragProc = NULL;
m_pDblClickProc = NULL;
m_pReleaseProc = NULL;
}

//--------------------------------------------------------------
// Draw
//--------------------------------------------------------------
void ArcballControl::Draw (CDC* pDC)
{
CRgn rgn;
rgn.CreateRectRgnIndirect(m_bbox);
pDC->SelectClipRgn(&rgn);

CPen pen(PS_SOLID,0,m_color);
CPen* pOldPen = pDC->SelectObject(&pen);

CRect abr(m_center,m_center);
abr.InflateRect(int(m_radius),int(m_radius));
pDC->Arc(abr,m_bbox.TopLeft(),m_bbox.TopLeft());

pDC->SelectObject(pOldPen);
pDC->SelectClipRgn(NULL);
rgn.DeleteObject();
}

//--------------------------------------------------------------
// SetBBox
//--------------------------------------------------------------
void ArcballControl::SetBBox (const CRect& rect)
{
m_bbox = rect;
m_center = rect.CenterPoint();
int maxDim = rect.Height();
if (rect.Width() > maxDim) maxDim = rect.Width();
m_radius = 0.45 * maxDim;
}

//--------------------------------------------------------------
// Helper: transform 2D screen coordinate pairs to 3D points on
// arcball surface.
//--------------------------------------------------------------
void ArcballControl::ArcballTrans(CPoint point, Vector3* result)
{
Vector3 pt;
double r,s;

pt.x = (point.x - m_center.x) / m_radius;
pt.y = (point.y - m_center.y) / m_radius;
r = pt.x * pt.x + pt.y * pt.y;
if (r > 1.0) {
s = 1.0 / sqrt(r);
pt.x *= s;
pt.y *= s;
pt.z = 0.0;
}
else pt.z = -sqrt(1.0 - r);
*result = pt;
}

//--------------------------------------------------------------
// Click
//--------------------------------------------------------------
void ArcballControl::Click (UINT nFlags, CPoint point)
{
m_lastMouse = point;
}

//--------------------------------------------------------------
// Drag
//--------------------------------------------------------------
void ArcballControl::Drag (UINT nFlags, CPoint point)
{
CSize diff = point - m_lastMouse;
if (m_pDragProc) {
Vector3 p0,p1;
ArcballTrans(m_lastMouse,&p0);
ArcballTrans(point,&p1);
(*m_pDragProc)(m_pOwner,nFlags,Quaternion(p0.Cross(p1),p0.Dot(p1)));
}
m_lastMouse = point;
}

//--------------------------------------------------------------
// Release: pass on to owner
//--------------------------------------------------------------
void ArcballControl::Release (UINT nFlags, CPoint point)
{
if (m_pReleaseProc) (*m_pReleaseProc)(m_pOwner,nFlags,point);
}

//--------------------------------------------------------------
// Double Click: pass on to owner
//--------------------------------------------------------------
void ArcballControl::DoubleClick (UINT nFlags, CPoint point)
{
if (m_pDblClickProc) (*m_pDblClickProc)(m_pOwner,nFlags,point);
}
Loading

0 comments on commit e171d2d

Please sign in to comment.