void progress_dialog::on_show( wxPaintEvent& event )
{
    wxLogDebug( "Entering progress_dialog::on_show()" );
    // If the dialog returns true from event's GetShow() function, that means it is 
    // currently hidden now, and this about thus is about to switch it to a shown state
   if ( m_is_initial_focus_event ) { 
        m_is_initial_focus_event = FALSE;                   
        
        // Update the channels
        update_channels( m_channel_sections, m_install );  
        
        // Run the code snippets to run after finished updating channels
        on_update_channels_completion(); 
    }    
    // Skip up to the next available handler
    event.Skip();
}
예제 #2
0
/**
 * Method used to make the repaints behave correctly on all 3 platforms
 */
void DecoratedTree::OnPaint(wxPaintEvent& ev)
{
    // wxGetApp().Yield();
    ev.Skip();
    
    wxTreeItemId id = GetRootItem();
    
    if (drawOutline) {
        lineNumber = 0;
        DrawOutline(id);
    }
        
    if (drawBoxes) {
        lineNumber = 0;
        DrawBoxes(id);
    }
}
예제 #3
0
//---------------------------------------------------------
void CVIEW_Map::On_Paint(wxPaintEvent &event)
{
	if( m_Ruler_Size > 1 )
	{
		wxPaintDC	dc(this);
		wxRect		rClient(wxPoint(0, 0), GetClientSize()), rMap(rClient);

		rMap.Deflate(m_Ruler_Size - 1);

		dc.DrawLine(rMap   .GetLeft (), rClient.GetTop   (), rMap   .GetLeft (), rClient.GetBottom());
		dc.DrawLine(rMap   .GetRight(), rClient.GetTop   (), rMap   .GetRight(), rClient.GetBottom());
		dc.DrawLine(rClient.GetLeft (), rMap   .GetTop   (), rClient.GetRight(), rMap   .GetTop   ());
		dc.DrawLine(rClient.GetLeft (), rMap   .GetBottom(), rClient.GetRight(), rMap   .GetBottom());
	}

	event.Skip();
}
예제 #4
0
void wxWindow::OnPaint(wxPaintEvent& event)
{
    if ( !m_renderer )
    {
        // it is a native control which paints itself
        event.Skip();
    }
    else
    {
        // get the DC to use and create renderer on it
        wxPaintDC dc(this);
        wxControlRenderer renderer(this, dc, m_renderer);

        // draw the control
        DoDraw(&renderer);
    }
}
예제 #5
0
void wxOwnerDrawFrame::OnPaint(wxPaintEvent& event)
{
	wxPaintDC dc(this);
	wxASSERT(TRUE == dc.Ok());

	//avoid flicker
	wxMemoryDC memDC;
	memDC.SelectObject(mMemBitmap);

	memDC.SetBackground(*wxBLACK);
	memDC.Clear();

	Paint(memDC);

	dc.Blit(0, 0, mMemBitmap.GetWidth(), mMemBitmap.GetHeight(), &memDC, 0, 0);

	event.Skip();
}
예제 #6
0
void wxFoldPanelBar::OnPaint(wxPaintEvent &event)
{
    if(!m_controlCreated)
        return;
#if 0
    // paint the bottom panel only, where the
    // arrow is shown when there is more to show the user
    // just as informative icon

    wxPaintDC dc(m_bottomPanel);

    wxSize size = m_bottomPanel->GetSize();
    int offset = (size.GetHeight() - m_moreBmp->GetHeight()) / 2;

    dc.DrawBitmap(*m_moreBmp, size.GetWidth() - m_moreBmp->GetWidth() - 2, offset, true);
#endif

    event.Skip();
}
예제 #7
0
void MyEvtLogEvtHandler::OnPaint(wxPaintEvent & event)
{
    if (m_listCtrl) {
        // Work around a wxWidgets 3.0 bug in wxGenericListCtrl (Linux
        // only) which causes headers to be misaligned after horizontal
        // scrolling due to wxListHeaderWindow::OnPaint() calling
        // parent->GetViewStart() before the parent window has been
        // scrolled to the new position.
        int view_startX;
        ((CDlgEventLogListCtrl*)m_listCtrl)->savedHandler->ProcessEvent(event);
        m_listCtrl->GetViewStart( &view_startX, NULL );
        if (view_startX != m_view_startX) {
            m_view_startX = view_startX;
            ((wxWindow *)m_listCtrl->m_headerWin)->Refresh();
            ((wxWindow *)m_listCtrl->m_headerWin)->Update();
        }
    } else {
        event.Skip();
   }
}
예제 #8
0
//------------------------------------------------------------------------------
void wxOgreRenderWindow::onPaint (wxPaintEvent &evt)
{
  evt.Skip();

  if ( pre_render_callback_ )
  {
    pre_render_callback_();
  }

  if( !ogre_root_->_fireFrameStarted() )
  {
    return;
  }

  render_window_->update();

  ogre_root_->_fireFrameEnded();

  if ( post_render_callback_ )
  {
    post_render_callback_();
  }
}
예제 #9
0
void frmMain::OnPaint( wxPaintEvent& event )
{
    /*
    wxPaintDC dc( m_pStaticBitmapLogo );

	dc.DrawText(wxT("Version: "), 40, 60); 

	// draw a circle
	dc.SetBrush(*wxGREEN_BRUSH);                    // green filling
	dc.SetPen( wxPen( wxColor(255,0,0), 5 ) );      // 5-pixels-thick red outline
	dc.DrawCircle( wxPoint(200,100), 25 );

	// draw a rectangle
	dc.SetBrush(*wxBLUE_BRUSH); // blue filling
	dc.SetPen( wxPen( wxColor(255,175,175), 10 ) ); // 10-pixels-thick pink outline
	dc.DrawRectangle( 300, 100, 400, 200 );

	// draw a line
	dc.SetPen( wxPen( wxColor(0,0,0), 3 ) );	    // black line, 3 pixels thick
	dc.DrawLine( 300, 100, 700, 300 );			    // draw line across the rectangle
    */

	event.Skip( false );
}
/*
 * Draw (on m_panelShowPin) the pin currently edited
 * accroding to current settings in dialog
 */
void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
{
    wxPaintDC    dc( m_panelShowPin );
    wxSize dc_size = dc.GetSize();
    dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );

    // Give a parent to m_dummyPin only from draw purpose.
    // In fact m_dummyPin should not have a parent, but draw functions need a parent
    // to know some options, about pin texts
    LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent();
    m_dummyPin->SetParent( libframe->GetCurPart() );

    // Calculate a suitable scale to fit the available draw area
    EDA_RECT bBox = m_dummyPin->GetBoundingBox();
    double xscale    = (double) dc_size.x / bBox.GetWidth();
    double yscale = (double) dc_size.y / bBox.GetHeight();
    double scale = std::min( xscale, yscale );

    // Give a 10% margin
    scale *= 0.9;
    dc.SetUserScale( scale, scale );

    wxPoint offset = -bBox.Centre();

    GRResetPenAndBrush( &dc );

    // This is a flag for m_dummyPin->Draw
    uintptr_t flags = uintptr_t( PIN_DRAW_TEXTS | PIN_DRAW_DANGLING );

    m_dummyPin->Draw( NULL, &dc, offset, COLOR4D::UNSPECIFIED, GR_COPY,
                      (void*)flags, DefaultTransform );

    m_dummyPin->SetParent(NULL);

    event.Skip();
}
예제 #11
0
 void OnPaint(wxPaintEvent& event)
 {
     g_str += 'P';   // paint
     event.Skip();
 }
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
    wxPaintDC    dc( m_panelShowPad );
    PAD_DRAWINFO drawInfo;

    EDA_COLOR_T color = BLACK;

    if( m_dummyPad->GetLayerSet()[F_Cu] )
    {
        color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
    }

    if( m_dummyPad->GetLayerSet()[B_Cu] )
    {
        color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
    }

    // What could happen: the pad color is *actually* black, or no
    // copper was selected
    if( color == BLACK )
        color = LIGHTGRAY;

    drawInfo.m_Color     = color;
    drawInfo.m_HoleColor = DARKGRAY;
    drawInfo.m_Offset    = m_dummyPad->GetPosition();
    drawInfo.m_Display_padnum  = true;
    drawInfo.m_Display_netname = true;

    if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
        drawInfo.m_ShowNotPlatedHole = true;

    // Shows the local pad clearance
    drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();

    wxSize dc_size = dc.GetSize();
    dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );

    // Calculate a suitable scale to fit the available draw area
    int dim = m_dummyPad->GetBoundingRadius() *2;

    // Invalid x size. User could enter zero, or have deleted all text prior to
    // entering a new value; this is also treated as zero. If dim is left at
    // zero, the drawing scale is zero and we get a crash.
    if( dim == 0 )
    {
        // If drill size has been set, use that. Otherwise default to 1mm.
        dim = m_dummyPad->GetDrillSize().x;
        if( dim == 0 )
            dim = Millimeter2iu( 1.0 );
    }

    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double scale = (double) dc_size.x / dim;

    // If the pad is a circle, use the x size here instead.
    int ysize;
    if( m_dummyPad->GetShape() == PAD_SHAPE_CIRCLE )
        ysize = m_dummyPad->GetSize().x;
    else
        ysize = m_dummyPad->GetSize().y;

    dim = ysize + std::abs( m_dummyPad->GetDelta().x );

    // Invalid y size. See note about x size above.
    if( dim == 0 )
    {
        dim = m_dummyPad->GetDrillSize().y;
        if( dim == 0 )
            dim = Millimeter2iu( 0.1 );
    }

    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double altscale = (double) dc_size.y / dim;
    scale = std::min( scale, altscale );

    // Give a margin
    scale *= 0.7;
    dc.SetUserScale( scale, scale );

    GRResetPenAndBrush( &dc );
    m_dummyPad->DrawShape( NULL, &dc, drawInfo );

    // Draw X and Y axis. Hhis is particularly useful to show the
    // reference position of pads with offset and no hole, or custom pad shapes
    const int linethickness = 0;
    GRLine( NULL, &dc, -int( dc_size.x/scale ), 0, int( dc_size.x/scale ), 0,
            linethickness, LIGHTBLUE );   // X axis
    GRLine( NULL, &dc, 0, -int( dc_size.y/scale ), 0, int( dc_size.y/scale ),
            linethickness, LIGHTBLUE );   // Y axis

    event.Skip();
}
예제 #13
0
void wxSpeedButton::OnPaint(wxPaintEvent& event)
{
    wxPaintDC dc(this);
    Paint(dc);
    event.Skip();
}
예제 #14
0
void OutputPane::OnPaint(wxPaintEvent &event){
	wxPaintDC dc(this);
	event.Skip();
}
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
    wxPaintDC    dc( m_panelShowPad );
    PAD_DRAWINFO drawInfo;

    EDA_COLOR_T color = BLACK;

    if( m_dummyPad->GetLayerSet()[F_Cu] )
    {
        color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
    }

    if( m_dummyPad->GetLayerSet()[B_Cu] )
    {
        color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
    }

    // What could happen: the pad color is *actually* black, or no
    // copper was selected
    if( color == BLACK )
        color = LIGHTGRAY;

    drawInfo.m_Color     = color;
    drawInfo.m_HoleColor = DARKGRAY;
    drawInfo.m_Offset    = m_dummyPad->GetPosition();
    drawInfo.m_Display_padnum  = true;
    drawInfo.m_Display_netname = true;

    if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
        drawInfo.m_ShowNotPlatedHole = true;

    // Shows the local pad clearance
    drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();

    wxSize dc_size = dc.GetSize();
    dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );

    // Calculate a suitable scale to fit the available draw area
    int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y);

    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double scale = (double) dc_size.x / dim;

    dim = m_dummyPad->GetSize().y + std::abs( m_dummyPad->GetDelta().x);
    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double altscale = (double) dc_size.y / dim;
    scale = std::min( scale, altscale );

    // Give a margin
    scale *= 0.7;
    dc.SetUserScale( scale, scale );

    GRResetPenAndBrush( &dc );
    m_dummyPad->DrawShape( NULL, &dc, drawInfo );

    // Draw X and Y axis.
    // this is particularly useful to show the reference position of pads
    // with offset and no hole
    GRLine( NULL, &dc, -dim, 0, dim, 0, 0, BLUE );   // X axis
    GRLine( NULL, &dc, 0, -dim, 0, dim, 0, BLUE );   // Y axis

    event.Skip();
}
예제 #16
0
void WinEDA_MainFrame::OnPaint(wxPaintEvent & event)
/**********************************************************/
{
	event.Skip();
}
void MyFrame::OnPaint(wxPaintEvent& event)
{

    wxPaintDC dc(this);
	int spacingW = 0;
	int spacingH = 0;

    if( pImage == NULL ){
        event.Skip();
    }
    else{
        wxBitmap tempBitmap(*pImage);
        SetClientSize( tempBitmap.GetWidth()*1.25, tempBitmap.GetHeight()*1.25+10 );
		spacingW = ceilf((tempBitmap.GetWidth()*1.25 - tempBitmap.GetWidth())/2);
		spacingH = ceilf((tempBitmap.GetHeight()*1.25 - tempBitmap.GetHeight())/2);
        dc.DrawBitmap(tempBitmap,(int)spacingW,(int)spacingH+25, TRUE);
    }
	// Lab 5 Area
	if(bleftDown)
		pointNumber = areaindex;
	else if(dist>=0 && dist<5){
		pointNumber = areaindex;
		int idist = (int)(floor(dist));
		SetStatusText( wxString::Format("The Distance is %d", idist),0);
	}
	// Lab 5 Area
	if((areaindex >0) && (areaindex <=pointNumber))//If in area calculation mode
	{
		//wxPoint pt(even, GetLogicalPosition(dc));
		wxPoint* acborder_pt=new wxPoint[pointNumber]; //the pointd coord to be drawn
		for(int i= 0; i<areaindex;i++)
		{
			acborder_pt[i].x=dc.LogicalToDeviceX(areaborder[i].x);
			acborder_pt[i].y=dc.LogicalToDeviceY(areaborder[i].y);
		}
		dc.SetPen(*wxRED_PEN);
		//dc.DrawLine(pt.x, pt.y, acborder_pt[areaindex].x, acborder_pt[areaindex].y);
		dc.DrawLines(areaindex, acborder_pt);
		if(areaindex == pointNumber)
		{
			dc.DrawLine( acborder_pt[pointNumber-1].x, acborder_pt[pointNumber-1].y, acborder_pt[0].x, acborder_pt[0].y);
			float farea = 0;
			int area;
			int minborder = 9999;
			for(int i=0; i<pointNumber;i++){
				if(areaborder[i].x< minborder)
					minborder = areaborder[i].x;
			}
			for (int j=0; j<pointNumber - 1; j++){
				farea = ((float)((areaborder[j].x-minborder)+(areaborder[j+1].x - minborder))/2.0)*(areaborder[j+1].y-areaborder[j].y)+farea;
			}
			farea=((float)((areaborder[pointNumber-1].x-minborder)+(areaborder[0].x - minborder))/2.0)*(areaborder[0].y-areaborder[pointNumber-1].y)+farea;
			if(farea<0) farea = -farea;
			area = (int)farea;
			SetStatusText( wxString::Format("The Area is %d", area), 1);

			areaindex = 0;
			bleftDown = !bleftDown;
			bRed = FALSE;
			pointNumber = 99;
			dist = 9999;
		}
		delete acborder_pt;
	}
    return;
}
예제 #18
0
void CViewHeader::OnComboPaint(wxPaintEvent& event)
{
	// We do a small trick to let the control handle the event before we can paint
	if (m_alreadyInPaint)
	{
		event.Skip();
		return;
	}

	wxComboBox* box = m_pComboBox;

	m_alreadyInPaint = true;
	box->Refresh();
	box->Update();
	m_alreadyInPaint = false;

	wxClientDC dc(box);
	dc.SetBrush(*wxTRANSPARENT_BRUSH);

	int thumbWidth = ::GetSystemMetrics(SM_CXHTHUMB);

	if (m_bLeftMousePressed)
	{
		if (!SendMessage((HWND)box->GetHandle(), CB_GETDROPPEDSTATE, 0, 0))
			m_bLeftMousePressed = false;
	}

#if wxUSE_UXTHEME
	wxUxThemeEngine *p = wxUxThemeEngine::Get();
	if (p && p->IsThemeActive())
	{
	}
	else
#endif //wxUSE_UXTHEME
	{
		dc.SetPen(wxPen(wxSystemSettings::GetColour(box->IsEnabled() ? wxSYS_COLOUR_WINDOW : wxSYS_COLOUR_BTNFACE)));
		wxRect rect = box->GetClientRect();
		rect.Deflate(1);
		wxRect rect2 = rect;
		rect2.SetWidth(rect.GetWidth() - thumbWidth);
		dc.DrawRectangle(rect2);

		if (!m_bLeftMousePressed || !box->IsEnabled())
		{
			wxPoint topLeft = rect.GetTopLeft();
			wxPoint bottomRight = rect.GetBottomRight();
			bottomRight.x--;
			topLeft.x = bottomRight.x - thumbWidth + 1;

			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
			dc.DrawLine(topLeft.x, topLeft.y, bottomRight.x + 1, topLeft.y);
			dc.DrawLine(topLeft.x, topLeft.y + 1, topLeft.x, bottomRight.y);
			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW)));
			dc.DrawLine(bottomRight.x, topLeft.y + 1, bottomRight.x, bottomRight.y + 1);
			dc.DrawLine(topLeft.x, bottomRight.y, bottomRight.x, bottomRight.y);

			topLeft.x++;
			topLeft.y++;
			bottomRight.x--;
			bottomRight.y--;
			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)));
			dc.DrawLine(topLeft.x, topLeft.y, bottomRight.x + 1, topLeft.y);
			dc.DrawLine(topLeft.x, topLeft.y + 1, topLeft.x, bottomRight.y);
			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
			dc.DrawLine(bottomRight.x, topLeft.y + 1, bottomRight.x, bottomRight.y + 1);
			dc.DrawLine(topLeft.x, bottomRight.y, bottomRight.x, bottomRight.y);

			topLeft.x++;
			topLeft.y++;
			bottomRight.x--;
			bottomRight.y--;
			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
			dc.DrawRectangle(wxRect(topLeft, bottomRight));
		}
		else
		{
			wxPoint topLeft = rect.GetTopLeft();
			wxPoint bottomRight = rect.GetBottomRight();
			bottomRight.x--;
			topLeft.x = bottomRight.x - thumbWidth + 1;

			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)));
			dc.DrawRectangle(wxRect(topLeft, bottomRight));

			topLeft.x++;
			topLeft.y++;
			bottomRight.x--;
			bottomRight.y--;
			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
			dc.DrawRectangle(wxRect(topLeft, bottomRight));
		}
	}

	// Cover up dark 3D shadow.
	wxRect rect = box->GetClientRect();
	dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW)));
	dc.DrawRectangle(rect);

}
void fGraleH_guiFrame::P_Main_OnPaint(wxPaintEvent& event)
{
    wxClientDC dc(this->P_Main);
    dc.DrawBitmap(this->mainBkg, 0, 0, false);
    event.Skip();
}
예제 #20
0
void wxImagePanel::paintNow(wxPaintEvent& evt) {

    wxClientDC dc(this);
    render(dc);
    evt.Skip();
}
예제 #21
0
void wxOgrePanel::OnPaint(wxPaintEvent& event)
{
	LogManager::getSingleton().logMessage(String("Pain for ")+m_unique_name+"\n");
	update();
	event.Skip();
}
예제 #22
0
void unFilterList::OnPaint( wxPaintEvent& event )
{
	//ClearBackground();
	Finder->UpdateBoxes();
	event.Skip();
}
예제 #23
0
void CtrlRegisterList::paintEvent(wxPaintEvent & evt)
{
    updateHandler();
    evt.Skip();
}
void C3D_MODEL_VIEWER::OnPaint( wxPaintEvent &event )
{
    wxPaintDC( this );

    // SwapBuffer requires the window to be shown before calling
    if( !IsShownOnScreen() )
    {
        wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::OnPaint !IsShown" ) );
        return;
    }

    // "Makes the OpenGL state that is represented by the OpenGL rendering
    //  context context current, i.e. it will be used by all subsequent OpenGL calls.
    //  This function may only be called when the window is shown on screen"
    GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );

    // Set the OpenGL viewport according to the client size of this canvas.
    // This is done here rather than in a wxSizeEvent handler because our
    // OpenGL rendering context (and thus viewport setting) is used with
    // multiple canvases: If we updated the viewport in the wxSizeEvent
    // handler, changing the size of one canvas causes a viewport setting that
    // is wrong when next another canvas is repainted.
    wxSize clientSize = GetClientSize();

    if( !m_ogl_initialized )
    {
        m_ogl_initialized = true;
        ogl_initialize();
    }

    if( m_reload_is_needed )
    {
        wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::OnPaint m_reload_is_needed" ) );

        m_reload_is_needed = false;
        m_ogl_3dmodel = new C_OGL_3DMODEL( *m_3d_model );

        // It convert a model as it was a board, so get the max size dimension of the board
        // and compute the conversion scale
        m_BiuTo3Dunits = (double)RANGE_SCALE_3D / ((double)m_ogl_3dmodel->GetBBox().GetMaxDimension() * UNITS3D_TO_UNITSPCB);
    }

    glViewport( 0, 0, clientSize.x, clientSize.y );

    m_trackBallCamera.SetCurWindowSize( clientSize );

    // clear color and depth buffers
    // /////////////////////////////////////////////////////////////////////////
    glEnable( GL_DEPTH_TEST );

    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
    glClearDepth( 1.0f );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    // Set projection and modelview matrixes
    // /////////////////////////////////////////////////////////////////////////
    glMatrixMode( GL_PROJECTION );
    glLoadMatrixf( glm::value_ptr( m_trackBallCamera.GetProjectionMatrix() ) );

    glMatrixMode( GL_MODELVIEW );
    glLoadMatrixf( glm::value_ptr( m_trackBallCamera.GetViewMatrix() ) );

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    // Render Model
    if( m_ogl_3dmodel )
    {
        glPushMatrix();

        double modelunit_to_3d_units_factor = m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;

        glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor, modelunit_to_3d_units_factor);

        // Center model in the render viewport
        const SFVEC3F model_center = m_ogl_3dmodel->GetBBox().GetCenter();
        glTranslatef( -model_center.x, -model_center.y, -model_center.z );

        // !TODO: draw transparent models
        m_ogl_3dmodel->Draw_opaque();
        m_ogl_3dmodel->Draw_transparent();
        //m_ogl_3dmodel->Draw_bboxes();

        glPopMatrix();
    }


    glViewport( 0, 0, clientSize.y / 8 , clientSize.y / 8 );                    // YxY squared view port
    glClear( GL_DEPTH_BUFFER_BIT );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective( 45.0f, 1.0f, 0.01f, RANGE_SCALE_3D * 2.0f );

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    const glm::mat4 TranslationMatrix = glm::translate( glm::mat4(1.0f), SFVEC3F( 0.0f, 0.0f, -RANGE_SCALE_3D ) );
    const glm::mat4 ViewMatrix = TranslationMatrix * m_trackBallCamera.GetRotationMatrix();

    glLoadMatrixf( glm::value_ptr( ViewMatrix ) );

    ogl_set_arrow_material();

    glColor3f( 0.9f, 0.0f, 0.0f );
    OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
                    SFVEC3F( RANGE_SCALE_3D / 2.65f, 0.0f, 0.0f ),
                    0.275f );

    glColor3f( 0.0f, 0.9f, 0.0f );
    OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
                    SFVEC3F( 0.0f, RANGE_SCALE_3D / 2.65f, 0.0f ),
                    0.275f );

    glColor3f( 0.0f, 0.0f, 0.9f );
    OGL_draw_arrow( SFVEC3F( 0.0f, 0.0f, 0.0f ),
                    SFVEC3F( 0.0f, 0.0f, RANGE_SCALE_3D / 2.65f ),
                    0.275f );

    // "Swaps the double-buffer of this window, making the back-buffer the
    //  front-buffer and vice versa, so that the output of the previous OpenGL
    //  commands is displayed on the window."
    SwapBuffers();
    GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );

    event.Skip();
}
void GraphicsImageCanvas::OnPaint (wxPaintEvent& event)
{
	wxAlphaPixelData data (*image);
	if (!data) {
		wxLogError (wxT ("Failed to gain access to raw bitmap data"));
		event.Skip();
		return;
	}

	wxAlphaPixelData::Iterator p (data);

	p.Offset (data, 0, 0); // no offset

	// Finding the maximum
	int max = 0;
	for (int ii = 0; ii < length; ii++) {
		if (max < imageData[ii]) {
			max = imageData[ii];
		}
	}

	for (int y = 0; y < height; ++y) {
		wxAlphaPixelData::Iterator rowStart = p;

		//for (int x = 0; x < width; ++x, ++p) {
		for (int x = (width - 1); x >= 0; --x, ++p) {
			p.Red() = ( (this->imageData[ (y * width) + x]) /max) * 255;
			p.Green() = ( (this->imageData[ (y * width) + x]) /max) * 255;
			p.Blue() = ( (this->imageData[ (y * width) + x]) /max) * 255;
		}
		p = rowStart;
		p.OffsetY (data, 1);
	}

	wxBufferedPaintDC dci (this);

	// Find the image scale factor and center the image.
	double scaleW = ( (double) image->GetWidth() / (double) (GetClientSize()).GetWidth());
	double scaleH = ( (double) image->GetHeight() / (double) (GetClientSize()).GetHeight());
	double scaleImage = 1;

	if (scaleW > scaleH) {
		scaleImage = scaleW;
	} else {
		scaleImage = scaleH;
	}

	// The commented out code worked in xp but not osx
	//SetSize(width/scaleImage, height/scaleImage);
	//dci.DrawBitmap (*this->image, 0, 0, true);
	//dci.SetUserScale (scaleImage, scaleImage);
	//if (NULL != fullscreen){
	//	CentreOnParent();
	//}

	wxImage displayImage = image->ConvertToImage();

	displayImage = displayImage.Scale (displayImage.GetWidth() /scaleImage, displayImage.GetHeight() /scaleImage);

	int cw = (GetClientSize()).GetWidth();
	int ch = (GetClientSize()).GetHeight();
	int pw = ( (cw - displayImage.GetWidth()) /2);
	int ph = ( (ch - displayImage.GetHeight()) /2);
	displayImage = displayImage.Size (wxSize (cw, ch), wxPoint (pw, ph), 0, 0, 0);

	wxBitmap tmpBitmap = wxBitmap (displayImage);
	dci.DrawBitmap (tmpBitmap, 0, 0, true);
}