Commit 17bf2435 authored by stambaughw's avatar stambaughw

Build fixes for VC8, compiler warnings fixed, and some minor wxDC zoom changes.

* Added modified version of FindwxWidgets.cmake to prevent manifest build and link errors
  with VC8.
* Fixed ambiguous math function ( sqrt, atan, cos, etc. ) call errors when building
  with MSVC.
* Moved bitmap copy bitmap source file destination to the build path to prevent source
  tree pollution and library rebuilds when building on different platforms.
parent ddd8bf48
This diff is collapsed.
# - Convenience include for using wxWidgets library
# Finds if wxWidgets is installed
# and set the appropriate libs, incdirs, flags etc.
# INCLUDE_DIRECTORIES, LINK_DIRECTORIES and ADD_DEFINITIONS
# are called.
#
# USAGE
# SET( wxWidgets_USE_LIBS gl xml xrc ) # optionally: more than wx std libs
# FIND_PACKAGE(wxWidgets REQUIRED)
# INCLUDE( ${xWidgets_USE_FILE} )
# ... add your targets here, e.g. ADD_EXECUTABLE/ ADD_LIBRARY ...
# TARGET_LINK_LIBRARIERS( <yourWxDependantTarget> ${wxWidgets_LIBRARIES})
#
# DEPRECATED
# LINK_LIBRARIES is not called in favor of adding dependencies per target.
#
# AUTHOR
# Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
# debug message and logging.
# comment these out for distribution
IF (NOT LOGFILE )
# SET(LOGFILE "${PROJECT_BINARY_DIR}/CMakeOutput.log")
ENDIF (NOT LOGFILE )
MACRO(MSG _MSG)
# FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}\n")
# MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
ENDMACRO(MSG)
MSG("wxWidgets_FOUND=${wxWidgets_FOUND}")
IF (wxWidgets_FOUND)
IF (wxWidgets_INCLUDE_DIRS)
IF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
ELSE(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
INCLUDE_DIRECTORIES(SYSTEM ${wxWidgets_INCLUDE_DIRS})
ENDIF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
ENDIF(wxWidgets_INCLUDE_DIRS)
IF (wxWidgets_LIBRARY_DIRS)
LINK_DIRECTORIES(${wxWidgets_LIBRARY_DIRS})
MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
ENDIF(wxWidgets_LIBRARY_DIRS)
IF (wxWidgets_DEFINITIONS)
ADD_DEFINITIONS( ${wxWidgets_DEFINITIONS} )
MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
ENDIF(wxWidgets_DEFINITIONS)
IF (wxWidgets_CXX_FLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}")
MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
ENDIF(wxWidgets_CXX_FLAGS)
# DEPRECATED JW
# just for backward compatibility: add deps to all targets
# library projects better use advanced FIND_PACKAGE(wxWidgets) directly.
#IF(wxWidgets_LIBRARIES)
# LINK_LIBRARIES(${wxWidgets_LIBRARIES})
# # BUG: str too long: MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
# IF(LOGFILE)
# FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${wxWidgets_LIBRARIES}\n")
# ENDIF(LOGFILE)
#ENDIF(wxWidgets_LIBRARIES)
ELSE (wxWidgets_FOUND)
MESSAGE("wxWidgets requested but not found.")
ENDIF(wxWidgets_FOUND)
...@@ -394,7 +394,7 @@ set(PATH ${CMAKE_CURRENT_SOURCE_DIR}) ...@@ -394,7 +394,7 @@ set(PATH ${CMAKE_CURRENT_SOURCE_DIR})
# The name of the directory to put the copied and renamed *.xpm files into. # The name of the directory to put the copied and renamed *.xpm files into.
# As files are copied they are renamed to *.cpp. # As files are copied they are renamed to *.cpp.
set(XPM_CPP_PATH "${PATH}/auto_renamed_to_cpp" set(XPM_CPP_PATH "${CMAKE_BINARY_DIR}/bitmaps/auto_renamed_to_cpp"
CACHE PATH "path to store renamed .xpm files for compilation") CACHE PATH "path to store renamed .xpm files for compilation")
foreach(LOOP_VAR ${BITMAP_SRCS}) foreach(LOOP_VAR ${BITMAP_SRCS})
......
...@@ -104,7 +104,7 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int level ...@@ -104,7 +104,7 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int level
int dx = x3 - x1; int dx = x3 - x1;
int dy = y3 - y1; int dy = y3 - y1;
double d = fabs( ( (x2 - x3) * dy - (y2 - y3) * dx ) ); double d = fabs( (double) ( (x2 - x3) * dy - (y2 - y3) * dx ) );
double da; double da;
if( d > bezier_curve_collinearity_epsilon ) if( d > bezier_curve_collinearity_epsilon )
...@@ -124,7 +124,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int level ...@@ -124,7 +124,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int level
// Angle & Cusp Condition // Angle & Cusp Condition
//---------------------- //----------------------
da = fabs( atan2( y3 - y2, x3 - x2 ) - atan2( y2 - y1, x2 - x1 ) ); da = fabs( atan2( (double) ( y3 - y2 ), (double) ( x3 - x2 ) ) -
atan2( (double) ( y2 - y1 ), (double) ( x2 - x1 ) ) );
if( da >=M_PI ) if( da >=M_PI )
da = 2 * M_PI - da; da = 2 * M_PI - da;
...@@ -160,7 +161,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int level ...@@ -160,7 +161,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int level
else if( d >= 1 ) else if( d >= 1 )
d = calc_sq_distance( x2, y2, x3, y3 ); d = calc_sq_distance( x2, y2, x3, y3 );
else else
d = calc_sq_distance( x2, y2, x1 + d * dx, y1 + d * dy ); d = calc_sq_distance( x2, y2, x1 + (int) d * dx,
y1 + (int) d * dy );
} }
if( d < bezier_distance_tolerance_square ) if( d < bezier_distance_tolerance_square )
{ {
...@@ -204,8 +206,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i ...@@ -204,8 +206,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i
int dx = x4 - x1; int dx = x4 - x1;
int dy = y4 - y1; int dy = y4 - y1;
double d2 = fabs( ( (x2 - x4) * dy - (y2 - y4) * dx ) ); double d2 = fabs( (double) ( (x2 - x4) * dy - (y2 - y4) * dx ) );
double d3 = fabs( ( (x3 - x4) * dy - (y3 - y4) * dx ) ); double d3 = fabs( (double) ( (x3 - x4) * dy - (y3 - y4) * dx ) );
double da1, da2, k; double da1, da2, k;
switch( (int(d2 > bezier_curve_collinearity_epsilon) << 1) + switch( (int(d2 > bezier_curve_collinearity_epsilon) << 1) +
...@@ -241,14 +243,16 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i ...@@ -241,14 +243,16 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i
else if( d2 >= 1 ) else if( d2 >= 1 )
d2 = calc_sq_distance( x2, y2, x4, y4 ); d2 = calc_sq_distance( x2, y2, x4, y4 );
else else
d2 = calc_sq_distance( x2, y2, x1 + d2 * dx, y1 + d2 * dy ); d2 = calc_sq_distance( x2, y2, x1 + (int) d2 * dx,
y1 + (int) d2 * dy );
if( d3 <= 0 ) if( d3 <= 0 )
d3 = calc_sq_distance( x3, y3, x1, y1 ); d3 = calc_sq_distance( x3, y3, x1, y1 );
else if( d3 >= 1 ) else if( d3 >= 1 )
d3 = calc_sq_distance( x3, y3, x4, y4 ); d3 = calc_sq_distance( x3, y3, x4, y4 );
else else
d3 = calc_sq_distance( x3, y3, x1 + d3 * dx, y1 + d3 * dy ); d3 = calc_sq_distance( x3, y3, x1 + (int) d3 * dx,
y1 + (int) d3 * dy );
} }
if( d2 > d3 ) if( d2 > d3 )
{ {
...@@ -282,7 +286,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i ...@@ -282,7 +286,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i
// Angle Condition // Angle Condition
//---------------------- //----------------------
da1 = fabs( atan2( y4 - y3, x4 - x3 ) - atan2( y3 - y2, x3 - x2 ) ); da1 = fabs( atan2( (double) ( y4 - y3 ), (double) ( x4 - x3 ) ) -
atan2( (double) ( y3 - y2 ), (double) ( x3 - x2 ) ) );
if( da1 >= M_PI ) if( da1 >= M_PI )
da1 = 2 * M_PI - da1; da1 = 2 * M_PI - da1;
...@@ -318,7 +323,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i ...@@ -318,7 +323,8 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i
// Angle Condition // Angle Condition
//---------------------- //----------------------
da1 = fabs( atan2( y3 - y2, x3 - x2 ) - atan2( y2 - y1, x2 - x1 ) ); da1 = fabs( atan2( (double) ( y3 - y2 ), (double) ( x3 - x2 ) ) -
atan2( (double) ( y2 - y1 ), (double) ( x2 - x1 ) ) );
if( da1 >= M_PI ) if( da1 >= M_PI )
da1 = 2 * M_PI - da1; da1 = 2 * M_PI - da1;
...@@ -357,9 +363,11 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i ...@@ -357,9 +363,11 @@ void recursive_bezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, i
// Angle & Cusp Condition // Angle & Cusp Condition
//---------------------- //----------------------
k = atan2( y3 - y2, x3 - x2 ); k = atan2( (double) ( y3 - y2 ), (double) ( x3 - x2 ) );
da1 = fabs( k - atan2( y2 - y1, x2 - x1 ) ); da1 = fabs( k - atan2( (double) ( y2 - y1 ),
da2 = fabs( atan2( y4 - y3, x4 - x3 ) - k ); (double) ( x2 - x1 ) ) );
da2 = fabs( atan2( (double) ( y4 - y3 ),
(double) ( x4 - x3 ) ) - k );
if( da1 >= M_PI ) if( da1 >= M_PI )
da1 = 2 * M_PI - da1; da1 = 2 * M_PI - da1;
if( da2 >= M_PI ) if( da2 >= M_PI )
......
...@@ -508,7 +508,6 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) ...@@ -508,7 +508,6 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars() void WinEDA_DrawFrame::AdjustScrollBars()
/*********************************************/ /*********************************************/
{ {
#ifndef WX_ZOOM
int xUnit, yUnit; int xUnit, yUnit;
wxSize draw_size, panel_size; wxSize draw_size, panel_size;
wxSize scrollbar_number; wxSize scrollbar_number;
...@@ -544,6 +543,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -544,6 +543,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_DrawOrg.y = -panel_size.y / 2; screen->m_DrawOrg.y = -panel_size.y / 2;
} }
#ifndef WX_ZOOM
// Calculate the number of scroll bar units for the given zoom level. */ // Calculate the number of scroll bar units for the given zoom level. */
scrollbar_number.x = scrollbar_number.x =
wxRound( (double) draw_size.x / wxRound( (double) draw_size.x /
...@@ -583,18 +583,26 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -583,18 +583,26 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_ScrollbarNumber.y, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.x,
screen->m_ScrollbarPos.y, TRUE ); screen->m_ScrollbarPos.y, TRUE );
// #else #else
// BASE_SCREEN* screen = GetBaseScreen(); int x, y, scroll_x, scroll_y;
// wxSize drawingSize = screen->ReturnPageSize() * 2; double scale_x, scale_y;
// wxCoord x, y;
// wxClientDC DC( this ); wxClientDC DC( this );
// DrawPanel->PrepareGraphicContext( &DC );
// x = DC.LogicalToDeviceXRel( drawingSize.GetWidth() ); DrawPanel->PrepareGraphicContext( &DC );
// y = DC.LogicalToDeviceYRel( drawingSize.GetHeight() ); x = DC.LogicalToDeviceXRel( draw_size.GetWidth() );
// DrawPanel->SetScrollbars( 1, 1, x, y, y = DC.LogicalToDeviceYRel( draw_size.GetHeight() );
// DC.LogicalToDeviceX( screen->m_Curseur.x ),
// DC.LogicalToDeviceY( screen->m_Curseur.y ), scrollbar_pos = screen->m_Curseur - screen->m_DrawOrg;
// true ); scrollbar_pos.x -= panel_size.x / 2;
scrollbar_pos.y -= panel_size.y / 2;
scroll_x = DC.LogicalToDeviceXRel( scrollbar_pos.x );
scroll_y = DC.LogicalToDeviceYRel( scrollbar_pos.y );
wxLogDebug( wxT( "SetScrollbars(1, 1, %d, %d, %d, %d)" ),
x, y, scroll_x, scroll_y );
DrawPanel->SetScrollbars( 1, 1, x, y, scroll_x, scroll_y );
#endif #endif
} }
......
...@@ -197,27 +197,10 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) ...@@ -197,27 +197,10 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
GRResetPenAndBrush( DC ); GRResetPenAndBrush( DC );
DC->SetBackgroundMode( wxTRANSPARENT ); DC->SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM #ifdef WX_ZOOM
int clientWidth, clientHeight;
GetClientSize( &clientWidth, &clientHeight );
wxSize drawingSize = GetScreen()->ReturnPageSize() * 2;
double scale = GetScreen()->GetScalingFactor(); double scale = GetScreen()->GetScalingFactor();
int dx = 0, dy = 0;
int drawingWidth = wxRound( (double)drawingSize.GetWidth() * scale );
int drawingHeight = wxRound( (double)drawingSize.GetHeight() * scale );
if( drawingWidth < clientWidth )
dx = ( clientWidth - drawingWidth ) / 2;
if( drawingHeight < clientHeight )
dy = ( clientHeight - drawingHeight ) / 2;
wxCoord x, y;
DC->GetDeviceOrigin( &x, &y );
DC->SetUserScale( scale, scale ); DC->SetUserScale( scale, scale );
DC->SetDeviceOrigin( x + dx, y + dy ); wxPoint origin = GetScreen()->m_DrawOrg;
// wxSize size = GetScreen()->ReturnPageSize() * 2 * scale; DC->SetLogicalOrigin( origin.x, origin.y );
// DC->SetLogicalOrigin( origin.x, origin.y );
#endif #endif
SetBoundaryBox(); SetBoundaryBox();
} }
...@@ -613,6 +596,12 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) ...@@ -613,6 +596,12 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
/***************************************************/ /***************************************************/
{ {
if( GetScreen() == NULL )
{
event.Skip();
return;
}
#ifdef USE_GCDC_IN_KICAD #ifdef USE_GCDC_IN_KICAD
wxPaintDC pDC( this ); wxPaintDC pDC( this );
wxGCDC paintDC(pDC); // Following line should be disabled on MSW and OS X wxGCDC paintDC(pDC); // Following line should be disabled on MSW and OS X
...@@ -647,10 +636,23 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -647,10 +636,23 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#endif #endif
#ifdef WX_ZOOM #ifdef WX_ZOOM
m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( m_ClipBox.m_Pos.x ); wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) " \
m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( m_ClipBox.m_Pos.y ); "m_ClipBox=(%d, %d, %d, %d)\n" ), PaintClipBox.x,
m_ClipBox.m_Size.SetWidth( paintDC.DeviceToLogicalXRel( m_ClipBox.m_Size.GetWidth() ) ); PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
m_ClipBox.m_Size.SetHeight( paintDC.DeviceToLogicalYRel( m_ClipBox.m_Size.GetHeight() ) ); org.x, org.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
wxSize drawing_size = GetScreen()->ReturnPageSize() * 2;
m_ClipBox.m_Pos.x = 0;
m_ClipBox.m_Pos.y = 0;
m_ClipBox.SetWidth( drawing_size.x );
m_ClipBox.SetHeight( drawing_size.y );
wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) " \
"m_ClipBox=(%d, %d, %d, %d)\n" ), PaintClipBox.x,
PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
org.x, org.y, m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#else #else
PaintClipBox.Offset( org ); PaintClipBox.Offset( org );
m_ClipBox.SetX( PaintClipBox.GetX() ); m_ClipBox.SetX( PaintClipBox.GetX() );
...@@ -677,8 +679,9 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -677,8 +679,9 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
// call ~wxDCClipper() before ~wxPaintDC() // call ~wxDCClipper() before ~wxPaintDC()
{ {
#ifndef WX_ZOOM
wxDCClipper dcclip( paintDC, PaintClipBox ); wxDCClipper dcclip( paintDC, PaintClipBox );
#endif
ReDraw( &paintDC, true ); ReDraw( &paintDC, true );
#ifdef WX_ZOOM #ifdef WX_ZOOM
......
...@@ -194,7 +194,8 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat ...@@ -194,7 +194,8 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat
NEGATE( relpos.y ); // reverse Y axis NEGATE( relpos.y ); // reverse Y axis
relpos -= m_Pos; relpos -= m_Pos;
int dist = wxRound( sqrt( ( (double) relpos.x * relpos.x ) + ( (double) relpos.y * relpos.y ) ) ); int dist = wxRound( sqrt( ( (double) relpos.x * (double) relpos.x ) +
( (double) relpos.y * (double) relpos.y ) ) );
if( abs( dist - m_Rayon ) > aThreshold ) if( abs( dist - m_Rayon ) > aThreshold )
return false; return false;
...@@ -202,7 +203,7 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat ...@@ -202,7 +203,7 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold, const int aTransMat
// We are on the circle, ensure we are only on the arc, i.e. between m_ArcStart and m_ArcEnd // We are on the circle, ensure we are only on the arc, i.e. between m_ArcStart and m_ArcEnd
int astart = t1; // arc starting point ( in 0.1 degree) int astart = t1; // arc starting point ( in 0.1 degree)
int aend = t2; // arc ending point ( in 0.1 degree) int aend = t2; // arc ending point ( in 0.1 degree)
int atest = wxRound( atan2( relpos.y, relpos.x ) * 1800.0 / M_PI ); int atest = wxRound( atan2( (double) relpos.y, (double) relpos.x ) * 1800.0 / M_PI );
NORMALIZE_ANGLE_180( atest ); NORMALIZE_ANGLE_180( atest );
NORMALIZE_ANGLE_180( astart ); NORMALIZE_ANGLE_180( astart );
NORMALIZE_ANGLE_180( aend ); NORMALIZE_ANGLE_180( aend );
......
...@@ -422,8 +422,8 @@ void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event ) ...@@ -422,8 +422,8 @@ void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event )
void WinEDA_SchematicFrame::OnUpdatePaste( wxUpdateUIEvent& event ) void WinEDA_SchematicFrame::OnUpdatePaste( wxUpdateUIEvent& event )
{ {
event.Enable( g_BlockSaveDataList ); event.Enable( g_BlockSaveDataList != NULL );
m_HToolBar->EnableTool( wxID_PASTE, g_BlockSaveDataList ); m_HToolBar->EnableTool( wxID_PASTE, g_BlockSaveDataList != NULL );
} }
void WinEDA_SchematicFrame::OnUpdateSchematicUndo( wxUpdateUIEvent& event ) void WinEDA_SchematicFrame::OnUpdateSchematicUndo( wxUpdateUIEvent& event )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment