** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: graph3dview.cpp,v 1.24 2001/09/24 11:34:06 kevin Exp $
+** $Id: graph3dview.cpp,v 1.26 2002/06/02 23:39:22 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
END_EVENT_TABLE()
Graph3dFileView::Graph3dFileView ()
- : m_pFileMenu(NULL), m_pViewMenu(NULL), m_pCanvas(NULL), m_pFrame(NULL)
-{
- m_bDoubleBuffer = true;
- m_bSmooth = true;
- m_bLighting = true;
- m_bWireframe = false;
- m_bLighting = true;
- m_bColor = true;
- m_dXRotate = -180;
- m_dYRotate = -210;
- m_dZRotate = -195;
- m_bColorScaleMinSet = false;
- m_bColorScaleMaxSet = false;
-}
+ : m_pFileMenu(NULL), m_pViewMenu(NULL), m_pCanvas(NULL), m_pFrame(NULL),
+ m_bDoubleBuffer(true), m_bSmooth(true), m_bWireframe(false),
+ m_bLighting(true), m_bColor(true), m_dXRotate(-180),
+ m_dYRotate(-210), m_dZRotate(195), m_bColorScaleMinSet(false),
+ m_bColorScaleMaxSet(false)
+{}
+
Graph3dFileView::~Graph3dFileView()
{
Graph3dFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
{
m_pFrame = CreateChildFrame(doc, this);
-
- int width, height;
- m_pFrame->GetClientSize (&width, &height);
- m_pFrame->SetTitle("Graph3dFileView");
m_pCanvas = CreateCanvas (m_pFrame);
-
- m_pFrame->Show (true);
+
+ SetFrame (m_pFrame);
+ m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+ m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+ m_pFrame->SetTitle("Graph3dFileView");
+
m_pCanvas->SetCurrent();
InitGL();
- int x, y; // X requires a forced resize
- m_pFrame->GetSize(&x, &y);
- m_pFrame->SetSize(-1, -1, x, y);
m_pFrame->SetFocus();
m_pFrame->Show(true);
Activate(true);
Graph3dFileView::CreateCanvas (wxFrame* parent)
{
Graph3dFileCanvas* pCanvas;
- int width, height;
- parent->GetClientSize (&width, &height);
- pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(0, 0), wxSize(200, 200), 0);
+ pCanvas = new Graph3dFileCanvas (this, parent, wxPoint(-1,-1), wxSize(-1,-1),
+ 0);
pCanvas->SetBackgroundColour(*wxWHITE);
pCanvas->Clear();
void
Graph3dFileView::OnDraw (wxDC* dc)
{
- if (! m_pCanvas)
- return;
- m_pCanvas->SetCurrent();
-
-#ifndef __WXMOTIF__
- // if (! m_pCanvas->GetContext()) return;
-#endif
-
- Draw();
- std::ostringstream os;
- os << "Xangle=" << m_dXRotate << ", Yangle=" << m_dYRotate << ", Zangle=" << m_dZRotate;
- m_pStatusBar->SetStatusText (os.str().c_str());
- m_pCanvas->SwapBuffers();
+ if (m_pCanvas) {
+ m_pCanvas->SetCurrent();
+
+ Draw();
+ std::ostringstream os;
+ os << "Xangle=" << m_dXRotate << ", Yangle=" << m_dYRotate << ", Zangle="
+ << m_dZRotate;
+ m_pStatusBar->SetStatusText (os.str().c_str());
+ m_pCanvas->SwapBuffers();
+ }
}
Graph3dFileView::CreateChildFrame (wxDocument *doc, wxView *view)
{
#if CTSIM_MDI
- wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Graph3dFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocMDIChildFrame* subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Graph3dFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#else
- wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Graph3dFile Frame", wxPoint(-1, -1), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
+ wxDocChildFrame* subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Graph3dFile Frame", wxPoint(-1,-1), wxSize(-1,-1), wxDEFAULT_FRAME_STYLE);
#endif
theApp->setIconForFrame (subframe);
m_pView->OnDraw(& dc);
}
+
+wxSize
+Graph3dFileCanvas::GetBestSize() const
+{
+ return wxSize (400,400);
+}
+
void
Graph3dFileCanvas::OnSize (wxSizeEvent& event)
{