Commit d15f0e91 authored by Maciej Suminski's avatar Maciej Suminski

Upstream merge.

parents e4315f06 c99243ff
......@@ -338,7 +338,7 @@ if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
mark_as_advanced(PYTHON_DEST)
message( STATUS "Python module install path: ${PYTHON_DEST}")
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH}
include_directories(${PYTHON_INCLUDE_DIRS}
./scripting)
endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
......
# - helper module to find OSX frameworks
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
macro(CMAKE_FIND_FRAMEWORKS fwk)
set(${fwk}_FRAMEWORKS)
if(APPLE)
foreach(dir
~/Library/Frameworks/${fwk}.framework
/Library/Frameworks/${fwk}.framework
/System/Library/Frameworks/${fwk}.framework
/Network/Library/Frameworks/${fwk}.framework)
if(EXISTS ${dir})
set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})
endif()
endforeach()
endif()
endmacro()
endif()
This diff is collapsed.
# - Find python interpreter
# This module finds if Python interpreter is installed and determines where the
# executables are. This code sets the following variables:
#
# PYTHONINTERP_FOUND - Was the Python executable found
# PYTHON_EXECUTABLE - path to the Python interpreter
#
# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2
# PYTHON_VERSION_MAJOR - Python major version found e.g. 2
# PYTHON_VERSION_MINOR - Python minor version found e.g. 5
# PYTHON_VERSION_PATCH - Python patch version found e.g. 2
#
# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of
# version numbers that should be taken into account when searching for Python.
# You need to set this variable before calling find_package(PythonInterp).
#
# You can point to a preferred python install to use by setting the following
# to the point at the root directory of the python install:
#
# PYTHON_ROOT_DIR - The root directory of the python install
#=============================================================================
# Copyright 2005-2010 Kitware, Inc.
# Copyright 2011 Bjoern Ricks <bjoern.ricks@gmail.com>
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
unset(_Python_NAMES)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)
if(PythonInterp_FIND_VERSION)
if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$")
string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}")
string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}")
list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ})
unset(_PYTHON_FIND_OTHER_VERSIONS)
if(NOT PythonInterp_FIND_VERSION_EXACT)
foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS})
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
endif()
endforeach()
endif()
unset(_PYTHON_FIND_MAJ_MIN)
unset(_PYTHON_FIND_MAJ)
else()
list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION})
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS})
endif()
else()
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
endif()
list(APPEND _Python_NAMES python)
# Search for the preferred executable first
if( ${PYTHON_ROOT_DIR} )
# Search for any of the executable names solely in the directory we've
# been pointed to. Failure to find the python executable here is a fatal
# fail.
find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}
PATHS ${PYTHON_ROOT_DIR}
NO_DEFAULT_PATH )
else()
# If there is no specific path given, look for python in the path
find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES})
endif()
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
set(_Python_VERSIONS
${Python_ADDITIONAL_VERSIONS}
${_PYTHON_FIND_OTHER_VERSIONS}
)
unset(_PYTHON_FIND_OTHER_VERSIONS)
unset(_PYTHON1_VERSIONS)
unset(_PYTHON2_VERSIONS)
unset(_PYTHON3_VERSIONS)
# Search for newest python version if python executable isn't found
if(NOT PYTHON_EXECUTABLE)
# If using the MINGW compiler, we mustn't find the standard python
# distribution because of multiple C-Runtime errors. We must instead
# use the Python-a-mingw-us distribution
if(MINGW)
list( APPEND _Python_PPATHS ${PYTHON_ROOT_DIR} )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.9" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.8" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.7" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.6" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.5" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.4" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.3" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.2" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.1" )
list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.0" )
else()
list( APPEND _Python_PPATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] )
endif()
foreach(_CURRENT_VERSION ${_Python_VERSIONS})
set(_Python_NAMES python${_CURRENT_VERSION})
if(WIN32)
list(APPEND _Python_NAMES python)
endif()
find_program(PYTHON_EXECUTABLE
NAMES ${_Python_NAMES}
PATHS ${_Python_PPATHS}
)
endforeach()
endif()
# determine python version string
if(PYTHON_EXECUTABLE)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c
"import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))"
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
ERROR_QUIET)
if(NOT _PYTHON_VERSION_RESULT)
string(REPLACE ";" "." PYTHON_VERSION_STRING "${_VERSION}")
list(GET _VERSION 0 PYTHON_VERSION_MAJOR)
list(GET _VERSION 1 PYTHON_VERSION_MINOR)
list(GET _VERSION 2 PYTHON_VERSION_PATCH)
if(PYTHON_VERSION_PATCH EQUAL 0)
# it's called "Python 2.7", not "2.7.0"
string(REGEX REPLACE "\\.0$" "" PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}")
endif()
else()
# sys.version predates sys.version_info, so use that
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)"
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
ERROR_QUIET)
if(NOT _PYTHON_VERSION_RESULT)
string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}")
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}")
if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}")
else()
set(PYTHON_VERSION_PATCH "0")
endif()
else()
# sys.version was first documented for Python 1.5, so assume
# this is older.
set(PYTHON_VERSION_STRING "1.4")
set(PYTHON_VERSION_MAJOR "1")
set(PYTHON_VERSION_MAJOR "4")
set(PYTHON_VERSION_MAJOR "0")
endif()
endif()
unset(_PYTHON_VERSION_RESULT)
unset(_VERSION)
endif()
# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING)
mark_as_advanced(PYTHON_EXECUTABLE)
This diff is collapsed.
......@@ -56,6 +56,18 @@ macro(perform_feature_checks)
# mean won't fail somewhere down the line.
check_include_file("iso646.h" HAVE_ISO646_H)
# The STDINT header file test is required because MinGW under Windows
# doesn't define HAVE_STDINT_H even though it does have it.
#
# We need to add it to the global compiler definitions as config.h is not
# included in pyport.h which is where the problem ocurrs without this
# fix.
check_include_file("stdint.h" HAVE_STDINT_H)
if( HAVE_STDINT_H )
add_definitions( -DHAVE_STDINT_H )
endif()
# no place is this used, and "HAVE_STRINGS_H", if present in config.h then
# conflicts with /usr/include/python2.6/Python.h. Please rename the macro if
# re-introduce this.
......
# select_library_configurations( basename )
#
# This macro takes a library base name as an argument, and will choose good
# values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and
# basename_LIBRARY_RELEASE depending on what has been found and set. If only
# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG,
# and basename_LIBRARY_RELEASE will be set to the release value. If only
# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY,
# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value.
#
# If the generator supports configuration types, then basename_LIBRARY and
# basename_LIBRARIES will be set with debug and optimized flags specifying the
# library to be used for the given configuration. If no build type has been set
# or the generator in use does not support configuration types, then
# basename_LIBRARY and basename_LIBRARIES will take only the release values.
#=============================================================================
# Copyright 2009 Will Dicharry <wdicharry@stellarscience.com>
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# This macro was adapted from the FindQt4 CMake module and is maintained by Will
# Dicharry <wdicharry@stellarscience.com>.
# Utility macro to check if one variable exists while another doesn't, and set
# one that doesn't exist to the one that exists.
macro( _set_library_name basename GOOD BAD )
if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} )
set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} )
set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} )
set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} )
endif()
endmacro()
macro( select_library_configurations basename )
# if only the release version was found, set the debug to be the release
# version.
_set_library_name( ${basename} RELEASE DEBUG )
# if only the debug version was found, set the release value to be the
# debug value.
_set_library_name( ${basename} DEBUG RELEASE )
# Set a default case, which will come into effect if
# -no build type is set and the generator only supports one build type
# at a time (i.e. CMAKE_CONFIGURATION_TYPES is false)
# -${basename}_LIBRARY_DEBUG and ${basename}_LIBRARY_RELEASE are the same
# -${basename}_LIBRARY_DEBUG and ${basename}_LIBRARY_RELEASE are both empty
set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} )
set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} )
if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND
NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE )
# if the generator supports configuration types or CMAKE_BUILD_TYPE
# is set, then set optimized and debug options.
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
set( ${basename}_LIBRARY "" )
foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE )
list( APPEND ${basename}_LIBRARY optimized "${_libname}" )
endforeach()
foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG )
list( APPEND ${basename}_LIBRARY debug "${_libname}" )
endforeach()
set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" )
endif()
endif()
set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH
"The ${basename} library" )
if( ${basename}_LIBRARY )
set( ${basename}_FOUND TRUE )
endif()
mark_as_advanced( ${basename}_LIBRARY
${basename}_LIBRARY_RELEASE
${basename}_LIBRARY_DEBUG
)
endmacro()
......@@ -288,10 +288,10 @@ GRID_TYPE& BASE_SCREEN::GetGrid( size_t aIndex )
}
wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition,
wxRealPoint* aGridSize ) const
wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition,
const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const
{
wxPoint pt;
wxPoint pt;
wxRealPoint gridSize;
if( aGridSize )
......@@ -299,13 +299,13 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition,
else
gridSize = GetGridSize();
wxPoint gridOrigin = m_GridOrigin;
double offset = fmod( gridOrigin.x, gridSize.x );
double offset = fmod( aGridOrigin.x, gridSize.x );
int x = KiROUND( (aPosition.x - offset) / gridSize.x );
pt.x = KiROUND( x * gridSize.x + offset );
offset = fmod( gridOrigin.y, gridSize.y );
offset = fmod( aGridOrigin.y, gridSize.y );
int y = KiROUND( (aPosition.y - offset) / gridSize.y );
pt.y = KiROUND ( y * gridSize.y + offset );
......@@ -313,19 +313,19 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition,
}
wxPoint BASE_SCREEN::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
wxPoint BASE_SCREEN::getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const
{
if( aOnGrid )
return GetNearestGridPosition( m_crossHairPosition, aGridSize );
return getNearestGridPosition( m_crossHairPosition, aGridOrigin, aGridSize );
return m_crossHairPosition;
}
wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
wxPoint BASE_SCREEN::getCrossHairScreenPosition() const
{
wxPoint pos = m_crossHairPosition - m_DrawOrg;
double scalar = GetScalingFactor();
double scalar = GetScalingFactor();
pos.x = KiROUND( (double) pos.x * scalar );
pos.y = KiROUND( (double) pos.y * scalar );
......@@ -334,10 +334,10 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
}
void BASE_SCREEN::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid )
{
if( aSnapToGrid )
m_crossHairPosition = GetNearestGridPosition( aPosition );
m_crossHairPosition = getNearestGridPosition( aPosition, aGridOrigin, NULL );
else
m_crossHairPosition = aPosition;
}
......
......@@ -34,6 +34,7 @@
* depending on the application.
*/
#include <macros.h>
#include <base_struct.h>
#include <class_title_block.h>
#include <common.h>
......@@ -187,7 +188,7 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed )
/* Convert a value to a string using double notation.
* For readability, the mantissa has 3 or more digits (max 8 digits),
* For readability, the mantissa has 3 or more digits,
* the trailing 0 are removed if the mantissa has more than 3 digits
* and some trailing 0
* This function should be used to display values in dialogs because a value
......@@ -198,23 +199,39 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed )
*/
wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol )
{
wxString stringValue;
double value_to_print;
value_to_print = To_User_Unit( aUnit, aValue );
double value_to_print = To_User_Unit( aUnit, aValue );
#if defined( EESCHEMA )
stringValue.Printf( wxT( "%.3f" ), value_to_print );
#else
#if defined( USE_PCBNEW_NANOMETRES )
stringValue.Printf( wxT( "%.8f" ), value_to_print );
#else
stringValue.Printf( wxT( "%.4f" ), value_to_print );
#endif
wxString stringValue = wxString::Format( wxT( "%.3f" ), value_to_print );
// Strip trailing zeros. However, keep at least 3 digits in mantissa
// For readability
StripTrailingZeros( stringValue, 3 );
#else
char buf[50];
int len;
if( value_to_print != 0.0 && fabs( value_to_print ) <= 0.0001 )
{
len = sprintf( buf, "%.10f", value_to_print );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
if( buf[len]=='.' || buf[len]==',' )
buf[len] = '\0';
else
++len;
}
else
{
len = sprintf( buf, "%.10g", value_to_print );
}
wxString stringValue( buf, wxConvUTF8 );
#endif
if( aAddUnitSymbol )
......@@ -269,8 +286,6 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue )
}
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
double value;
......
......@@ -42,8 +42,8 @@
BLOCK_SELECTOR::BLOCK_SELECTOR() :
EDA_RECT()
{
m_state = STATE_NO_BLOCK; /* State (enum BLOCK_STATE_T) of block. */
m_command = BLOCK_IDLE; /* Type (enum BLOCK_COMMAND_T) of operation. */
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
m_color = BROWN;
}
......@@ -62,24 +62,24 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
case BLOCK_IDLE:
break;
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
case BLOCK_MOVE: // Move
case BLOCK_PRESELECT_MOVE: // Move with preselection list
msg = _( "Block Move" );
break;
case BLOCK_DRAG: /* Drag */
case BLOCK_DRAG: // Drag
msg = _( "Block Drag" );
break;
case BLOCK_COPY: /* Copy */
case BLOCK_COPY: // Copy
msg = _( "Block Copy" );
break;
case BLOCK_DELETE: /* Delete */
case BLOCK_DELETE: // Delete
msg = _( "Block Delete" );
break;
case BLOCK_SAVE: /* Save */
case BLOCK_SAVE: // Save
msg = _( "Block Save" );
break;
......@@ -87,20 +87,20 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
msg = _( "Block Paste" );
break;
case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_ZOOM: // Window Zoom
msg = _( "Win Zoom" );
break;
case BLOCK_ROTATE: /* Rotate 90 deg */
case BLOCK_ROTATE: // Rotate 90 deg
msg = _( "Block Rotate" );
break;
case BLOCK_FLIP: /* Flip */
case BLOCK_FLIP: // Flip
msg = _( "Block Flip" );
break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */
case BLOCK_MIRROR_Y: // mirror
msg = _( "Block Mirror" );
break;
......@@ -185,15 +185,15 @@ void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoin
if( aErase )
block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
block->SetLastCursorPosition( aPanel->GetScreen()->GetCrossHairPosition() );
block->SetEnd( aPanel->GetScreen()->GetCrossHairPosition() );
block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition() );
block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
if( block->GetState() == STATE_BLOCK_INIT )
{
if( block->GetWidth() || block->GetHeight() )
/* 2nd point exists: the rectangle is not surface anywhere */
// 2nd point exists: the rectangle is not surface anywhere
block->SetState( STATE_BLOCK_END );
}
}
......@@ -203,14 +203,14 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
BASE_SCREEN* screen = aPanel->GetScreen();
if( aPanel->IsMouseCaptured() ) /* Erase current drawing on screen */
if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen
{
/* Clear block outline. */
// Clear block outline.
aPanel->CallMouseCapture( aDC, wxDefaultPosition, false );
aPanel->SetMouseCapture( NULL, NULL );
screen->SetCurItem( NULL );
/* Delete the picked wrapper if this is a picked list. */
// Delete the picked wrapper if this is a picked list.
if( screen->m_BlockLocate.GetCommand() != BLOCK_PASTE )
screen->m_BlockLocate.ClearItemsList();
}
......
......@@ -118,26 +118,18 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
m_snapToGrid = true;
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
//#define ZOOM_DISPLAY_SIZE 60
//#define COORD_DISPLAY_SIZE 165
//#define DELTA_DISPLAY_SIZE 245
//#define UNITS_DISPLAY_SIZE 65
#define FUNCTION_DISPLAY_SIZE 110
CreateStatusBar( 6 );
// set the size of the status bar subwindows:
wxWindow* stsbar = GetStatusBar();
int dims[] = {
// balance of status bar on far left is set to a default or whatever is left over.
// remainder of status bar on far left is set to a default or whatever is left over.
-1,
// When using GetTextSize() remember the width of '1' is not the same
// When using GetTextSize() remember the width of character '1' is not the same
// as the width of '0' unless the font is fixed width, and it usually won't be.
// zoom:
......@@ -152,7 +144,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
// units display, Inches is bigger than mm
GetTextSize( _( "Inches" ), stsbar ).x + 10,
FUNCTION_DISPLAY_SIZE,
// Size for the panel used as "Current tool in play": will take longest string from
// void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp
GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
};
SetStatusWidths( DIM( dims ), dims );
......@@ -391,7 +385,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
*/
m_LastGridSizeId = id - ID_POPUP_GRID_LEVEL_1000;
screen->SetGrid( id );
screen->SetCrossHairPosition( screen->RefPos( true ) );
SetCrossHairPosition( RefPos( true ) );
if( m_galCanvasActive )
{
......@@ -440,7 +434,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
m_galCanvas->Refresh();
}
else
RedrawScreen( GetScreen()->GetScrollCenterPosition(), false );
RedrawScreen( GetScrollCenterPosition(), false );
}
}
......@@ -526,7 +520,7 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
wxPoint pos = aPosition;
if( m_currentScreen != NULL && m_snapToGrid )
pos = m_currentScreen->GetNearestGridPosition( aPosition );
pos = GetNearestGridPosition( aPosition );
return pos;
}
......@@ -757,12 +751,9 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
{
BASE_SCREEN* screen = GetScreen();
if( screen == NULL || m_canvas == NULL )
if( !screen || !m_canvas )
return;
// There are no safety limits on these calculations, so in NANOMETRES build it
// still blows up. This is incomplete work.
double scale = screen->GetScalingFactor();
wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
......@@ -909,7 +900,7 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
// Calculate the scroll bar position in internal units to place the
// center position at the center of client rectangle.
screen->SetScrollCenterPosition( centerPositionIU );
SetScrollCenterPosition( centerPositionIU );
double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
......@@ -991,7 +982,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
//gal->SetGridColor( KiGfx::COLOR4D( GetGridColor() ) );
gal->SetGridColor( KiGfx::COLOR4D( 0.1, 0.1, 0.1, 1.0 ) );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 );
}
......@@ -1019,3 +1010,71 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_galCanvasActive = aEnable;
}
//-----< BASE_SCREEN API moved here >--------------------------------------------
wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const
{
// subject to change, borrow from old BASE_SCREEN for now.
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCrossHairPosition( aInvertY );
}
void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
}
wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
}
wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
}
wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCrossHairScreenPosition();
}
void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setMousePosition( aPosition );
}
wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->refPos( useMouse );
}
const wxPoint& EDA_DRAW_FRAME::GetScrollCenterPosition() const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getScrollCenterPosition();
}
void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setScrollCenterPosition( aPoint );
}
//-----</BASE_SCREEN API moved here >--------------------------------------------
......@@ -182,7 +182,7 @@ void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
return;
wxPoint cursor = GetScreen()->GetCrossHairPosition();
wxPoint cursor = GetParent()->GetCrossHairPosition();
GRSetDrawMode( aDC, GR_XOR );
......@@ -298,7 +298,7 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition()
void EDA_DRAW_PANEL::MoveCursorToCrossHair()
{
MoveCursor( GetScreen()->GetCrossHairPosition() );
MoveCursor( GetParent()->GetCrossHairPosition() );
}
......@@ -434,10 +434,10 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
double scale = GetParent()->GetScreen()->GetScalingFactor();
wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
wxPoint center = GetParent()->GetScrollCenterPosition();
center.x += KiROUND( (double) ( x - tmpX ) / scale );
center.y += KiROUND( (double) ( y - tmpY ) / scale );
GetParent()->GetScreen()->SetScrollCenterPosition( center );
GetParent()->SetScrollCenterPosition( center );
Scroll( x, y );
event.Skip();
......@@ -610,7 +610,7 @@ void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC )
DrawAuxiliaryAxis( DC, GR_COPY );
if( GetParent()->m_showGridAxis )
DrawGridAxis( DC, GR_COPY );
DrawGridAxis( DC, GR_COPY, GetParent()->GetGridOrigin() );
}
......@@ -646,7 +646,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
return;
org = screen->GetNearestGridPosition( org, &gridSize );
org = GetParent()->GetNearestGridPosition( org, &gridSize );
// Setting the nearest grid position can select grid points outside the clip box.
// Incrementing the start point by one grid step should prevent drawing grid points
......@@ -741,7 +741,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
{
wxPoint origin = GetParent()->GetOriginAxisPosition();
wxPoint origin = GetParent()->GetAuxOrigin();
if( origin == wxPoint( 0, 0 ) )
return;
......@@ -769,33 +769,30 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
}
void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin )
{
BASE_SCREEN* screen = GetScreen();
if( !GetParent()->m_showGridAxis
|| ( screen->m_GridOrigin.x == 0 && screen->m_GridOrigin.y == 0 ) )
if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) )
return;
EDA_COLOR_T color = GetParent()->GetGridColor();
wxSize pageSize = GetParent()->GetPageSizeIU();
EDA_COLOR_T color = GetParent()->GetGridColor();
wxSize pageSize = GetParent()->GetPageSizeIU();
GRSetDrawMode( aDC, aDrawMode );
// Draw the Y axis
GRDashedLine( &m_ClipBox, aDC,
screen->m_GridOrigin.x,
aGridOrigin.x,
-pageSize.y,
screen->m_GridOrigin.x,
aGridOrigin.x,
pageSize.y,
0, color );
// Draw the X axis
GRDashedLine( &m_ClipBox, aDC,
-pageSize.x,
screen->m_GridOrigin.y,
aGridOrigin.y,
pageSize.x,
screen->m_GridOrigin.y,
aGridOrigin.y,
0, color );
}
......@@ -847,7 +844,7 @@ void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event )
cross_hair_pos.x = dc.DeviceToLogicalX( cross_hair_pos.x );
cross_hair_pos.y = dc.DeviceToLogicalY( cross_hair_pos.y );
GetScreen()->SetCrossHairPosition( cross_hair_pos );
GetParent()->SetCrossHairPosition( cross_hair_pos );
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
cmd.SetEventObject( this );
......@@ -877,7 +874,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
}
INSTALL_UNBUFFERED_DC( dc, this );
GetScreen()->SetCrossHairPosition( event.GetLogicalPosition( dc ) );
GetParent()->SetCrossHairPosition( event.GetLogicalPosition( dc ) );
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
......@@ -971,7 +968,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
DC.SetBackground( *wxBLACK_BRUSH );
// Compute the cursor position in drawing (logical) units.
screen->SetMousePosition( event.GetLogicalPosition( DC ) );
GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );
int kbstat = 0;
......@@ -987,7 +984,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// Calling Double Click and Click functions :
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{
GetParent()->OnLeftDClick( &DC, screen->RefPos( true ) );
GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) );
// inhibit a response to the mouse left button release,
// because we have a double click, and we do not want a new
......@@ -1004,7 +1001,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_ignoreNextLeftButtonRelease = false;
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
GetParent()->OnLeftClick( &DC, screen->RefPos( true ) );
GetParent()->OnLeftClick( &DC, GetParent()->RefPos( true ) );
}
else if( !event.LeftIsDown() )
......@@ -1028,7 +1025,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_PanStartCenter.y *= ppuy;
}
else
m_PanStartCenter = GetParent()->GetScreen()->GetScrollCenterPosition();
m_PanStartCenter = GetParent()->GetScrollCenterPosition();
m_PanStartEventPosition = event.GetPosition();
......@@ -1102,10 +1099,10 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
double scale = GetParent()->GetScreen()->GetScalingFactor();
wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
wxPoint center = GetParent()->GetScrollCenterPosition();
center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux;
center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy;
GetParent()->GetScreen()->SetScrollCenterPosition( center );
GetParent()->SetScrollCenterPosition( center );
Refresh();
Update();
......@@ -1165,7 +1162,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
* (a filter creates a delay for the real block command start, and
* we must remember this point)
*/
m_CursorStartPos = screen->GetCrossHairPosition();
m_CursorStartPos = GetParent()->GetCrossHairPosition();
}
if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
......@@ -1324,17 +1321,14 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
INSTALL_UNBUFFERED_DC( DC, this );
BASE_SCREEN* Screen = GetScreen();
// Some key commands use the current mouse position: refresh it.
pos = wxGetMousePosition() - GetScreenPosition();
// Compute the cursor position in drawing units. Also known as logical units to wxDC.
pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );
Screen->SetMousePosition( pos );
GetParent()->SetMousePosition( pos );
GetParent()->GeneralControl( &DC, pos, localkey );
}
......
......@@ -76,6 +76,7 @@ fp_poly
fp_text
full
general
grid_origin
gr_arc
gr_circle
gr_curve
......
......@@ -59,7 +59,7 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
{
wxPoint dPos = posBefore - m_canvas->GetClientSize() / 2; // relative screen position to center before zoom
wxPoint newScreenPos = m_canvas->ToDeviceXY( GetScreen()->GetCrossHairPosition() ); // screen position of crosshair after zoom
wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() ); // screen position of crosshair after zoom
wxPoint newCenter = m_canvas->ToLogicalXY( newScreenPos - dPos );
AdjustScrollBars( newCenter );
......@@ -82,10 +82,10 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
screen->SetScalingFactor( bestzoom );
if( screen->m_FirstRedraw )
screen->SetCrossHairPosition( screen->GetScrollCenterPosition() );
SetCrossHairPosition( GetScrollCenterPosition() );
if( !m_galCanvasActive )
RedrawScreen( screen->GetScrollCenterPosition(), aWarpPointer );
RedrawScreen( GetScrollCenterPosition(), aWarpPointer );
}
......@@ -123,19 +123,19 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
int id = event.GetId();
bool zoom_at_cursor = false;
BASE_SCREEN* screen = GetScreen();
wxPoint center = screen->GetScrollCenterPosition();
wxPoint center = GetScrollCenterPosition();
switch( id )
{
case ID_OFFCENTER_ZOOM_IN:
center = m_canvas->ToDeviceXY( screen->GetCrossHairPosition() );
center = m_canvas->ToDeviceXY( GetCrossHairPosition() );
if( screen->SetPreviousZoom() )
RedrawScreen2( center );
break;
case ID_POPUP_ZOOM_IN:
zoom_at_cursor = true;
center = screen->GetCrossHairPosition();
center = GetCrossHairPosition();
// fall thru
case ID_ZOOM_IN:
......@@ -144,14 +144,14 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break;
case ID_OFFCENTER_ZOOM_OUT:
center = m_canvas->ToDeviceXY( screen->GetCrossHairPosition() );
center = m_canvas->ToDeviceXY( GetCrossHairPosition() );
if( screen->SetNextZoom() )
RedrawScreen2( center );
break;
case ID_POPUP_ZOOM_OUT:
zoom_at_cursor = true;
center = screen->GetCrossHairPosition();
center = GetCrossHairPosition();
// fall thru
case ID_ZOOM_OUT:
......@@ -164,7 +164,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break;
case ID_POPUP_ZOOM_CENTER:
center = screen->GetCrossHairPosition();
center = GetCrossHairPosition();
RedrawScreen( center, true );
break;
......
......@@ -339,8 +339,8 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
pos = screen->GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition();
pos = GetNearestGridPosition( pos );
oldpos = GetCrossHairPosition();
gridSize = screen->GetGridSize();
switch( aHotKey )
......@@ -371,7 +371,7 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
break;
case ' ':
screen->m_O_Curseur = screen->GetCrossHairPosition();
screen->m_O_Curseur = GetCrossHairPosition();
break;
case WXK_NUMPAD8: /* cursor moved up */
......@@ -399,14 +399,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
break;
}
screen->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
if( oldpos != screen->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos );
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos );
m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......
......@@ -215,7 +215,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
block->SetState( state );
block->SetCommand( command );
m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
GetScreen()->SetCrossHairPosition( block->GetEnd() );
SetCrossHairPosition( block->GetEnd() );
if( block->GetCommand() != BLOCK_ABORT )
m_canvas->MoveCursorToCrossHair();
......@@ -237,8 +237,8 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
{
// Compute the rotation center and put it on grid:
wxPoint rotationPoint = block->Centre();
rotationPoint = GetScreen()->GetNearestGridPosition( rotationPoint );
GetScreen()->SetCrossHairPosition( rotationPoint );
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint );
RotateListOfItems( block->GetItems(), rotationPoint );
OnModify();
......@@ -433,8 +433,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
/* Compute the rotation center and put it on grid */
wxPoint rotationPoint = block->Centre();
rotationPoint = GetScreen()->GetNearestGridPosition( rotationPoint );
GetScreen()->SetCrossHairPosition( rotationPoint );
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint );
RotateListOfItems( block->GetItems(), rotationPoint );
OnModify();
......@@ -452,8 +452,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetScreen()->GetNearestGridPosition( mirrorPoint );
GetScreen()->SetCrossHairPosition( mirrorPoint );
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint );
MirrorX( block->GetItems(), mirrorPoint );
OnModify();
......@@ -471,8 +471,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetScreen()->GetNearestGridPosition( mirrorPoint );
GetScreen()->SetCrossHairPosition( mirrorPoint );
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint );
MirrorY( block->GetItems(), mirrorPoint );
OnModify();
......@@ -519,7 +519,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
}
/* Repaint new view. */
block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() );
block->SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
......
......@@ -99,8 +99,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
GetScreen()->m_BlockLocate.SetState( state );
GetScreen()->m_BlockLocate.SetCommand( command );
m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(),
GetScreen()->m_BlockLocate.GetBottom() ) );
SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(),
GetScreen()->m_BlockLocate.GetBottom() ) );
m_canvas->MoveCursorToCrossHair();
}
......@@ -171,7 +171,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre();
pt = GetScreen()->GetNearestGridPosition( pt );
pt = GetNearestGridPosition( pt );
NEGATE( pt.y );
if ( m_component )
......@@ -183,7 +183,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
m_component->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X)
m_component->MirrorSelectedItemsV( pt );
else if( block_cmd == BLOCK_ROTATE)
else if( block_cmd == BLOCK_ROTATE )
m_component->RotateSelectedItems( pt );
}
......@@ -275,7 +275,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre();
pt = GetScreen()->GetNearestGridPosition( pt );
pt = GetNearestGridPosition( pt );
NEGATE( pt.y );
if ( m_component )
......@@ -342,7 +342,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
}
// Repaint new view
block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() );
block->SetMoveVector( parent->GetCrossHairPosition() - block->GetLastCursorPosition() );
GRSetDrawMode( aDC, g_XorMode );
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
......
......@@ -81,8 +81,9 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
}
}
wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition();
SCH_EDIT_FRAME * frame = ( SCH_EDIT_FRAME * ) aPanel->GetParent();
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent();
wxPoint endpos = frame->GetCrossHairPosition();
if( frame->GetForceHVLines() ) /* Coerce the line to vertical or horizontal one: */
ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos );
......@@ -105,7 +106,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
{
SCH_LINE* segment;
SCH_LINE* nextSegment;
wxPoint cursorpos = GetScreen()->GetCrossHairPosition();
wxPoint cursorpos = GetCrossHairPosition();
// We should know if a segment is currently in progress
segment = (SCH_LINE*) GetScreen()->GetCurItem();
......@@ -426,8 +427,9 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
if( m_itemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode
{
wxPoint pos = GetScreen()->GetCrossHairPosition() -
wxPoint pos = GetCrossHairPosition() -
( (SCH_COMPONENT*) m_itemToRepeat )->GetPosition();
m_itemToRepeat->SetFlags( IS_NEW );
( (SCH_COMPONENT*) m_itemToRepeat )->SetTimeStamp( GetNewTimeStamp() );
m_itemToRepeat->Move( pos );
......
......@@ -45,10 +45,9 @@ static int s_LastShape = '\\';
SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC )
{
SCH_SCREEN* screen = GetScreen();
// Create and place a new bus entry at cursor position
SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToList( aDC );
......@@ -57,10 +56,9 @@ SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC )
SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry( wxDC* aDC )
{
SCH_SCREEN* screen = GetScreen();
// Create and place a new bus entry at cursor position
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToList( aDC );
......
......@@ -56,7 +56,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
wxString msg;
LIB_PIN* Pin = NULL;
SCH_COMPONENT* LibItem = NULL;
wxPoint gridPosition = GetScreen()->GetNearestGridPosition( aPosition );
wxPoint gridPosition = GetNearestGridPosition( aPosition );
// Check the on grid position first. There is more likely to be multiple items on
// grid than off grid.
......@@ -222,9 +222,9 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
snapToGrid = true;
if( snapToGrid )
pos = screen->GetNearestGridPosition( pos );
pos = GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition();
oldpos = GetCrossHairPosition();
gridSize = screen->GetGridSize();
switch( aHotKey )
......@@ -261,14 +261,14 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// Update cursor position.
screen->SetCrossHairPosition( pos, snapToGrid );
SetCrossHairPosition( pos, snapToGrid );
if( oldpos != screen->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos, false);
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos, false);
m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos, snapToGrid );
SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......@@ -304,7 +304,6 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen();
wxPoint oldpos;
wxPoint pos = aPosition;
......@@ -320,10 +319,10 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
snapToGrid = true;
if( snapToGrid )
pos = screen->GetNearestGridPosition( pos );
pos = GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition();
gridSize = screen->GetGridSize();
oldpos = GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
switch( aHotKey )
{
......@@ -359,14 +358,14 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// Update the cursor position.
screen->SetCrossHairPosition( pos, snapToGrid );
SetCrossHairPosition( pos, snapToGrid );
if( oldpos != screen->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos, false );
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos, false );
m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos, snapToGrid );
SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......@@ -403,8 +402,8 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos;
wxPoint pos = aPosition;
pos = screen->GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition();
pos = GetNearestGridPosition( pos );
oldpos = GetCrossHairPosition();
gridSize = screen->GetGridSize();
switch( aHotKey )
......@@ -441,14 +440,14 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// Update cursor position.
screen->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
if( oldpos != screen->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos );
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos );
m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......
......@@ -205,7 +205,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event )
}
m_lastMarkerFound = marker;
m_parent->GetScreen()->SetCrossHairPosition( marker->m_Pos );
m_parent->SetCrossHairPosition( marker->m_Pos );
m_parent->RedrawScreen( marker->m_Pos, false);
}
......@@ -218,7 +218,7 @@ void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event )
// (NULL if not found)
if( m_lastMarkerFound )
{
m_parent->GetScreen()->SetCrossHairPosition( m_lastMarkerFound->m_Pos );
m_parent->SetCrossHairPosition( m_lastMarkerFound->m_Pos );
m_parent->RedrawScreen( m_lastMarkerFound->m_Pos, true);
// prevent a mouse left button release event in
// coming from the ERC dialog double click
......
......@@ -93,7 +93,7 @@ static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosit
}
// Draw the bitmap at it's new position.
image->SetPosition( screen->GetCrossHairPosition() );
image->SetPosition( aPanel->GetParent()->GetCrossHairPosition() );
image->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
}
......@@ -116,7 +116,7 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC )
return NULL;
}
wxPoint pos = GetScreen()->GetCrossHairPosition();
wxPoint pos = GetCrossHairPosition();
SCH_BITMAP* image = new SCH_BITMAP( pos );
......@@ -149,7 +149,7 @@ void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC )
SetUndoItem( aImageItem );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( aImageItem->GetPosition() );
SetCrossHairPosition( aImageItem->GetPosition() );
m_canvas->MoveCursorToCrossHair();
m_canvas->CrossHairOn( aDC );
......
......@@ -77,20 +77,20 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
switch( aType )
{
case LAYER_NOTES:
textItem = new SCH_TEXT( GetScreen()->GetCrossHairPosition() );
textItem = new SCH_TEXT( GetCrossHairPosition() );
break;
case LAYER_LOCLABEL:
textItem = new SCH_LABEL( GetScreen()->GetCrossHairPosition() );
textItem = new SCH_LABEL( GetCrossHairPosition() );
break;
case LAYER_HIERLABEL:
textItem = new SCH_HIERLABEL( GetScreen()->GetCrossHairPosition() );
textItem = new SCH_HIERLABEL( GetCrossHairPosition() );
textItem->SetShape( lastGlobalLabelShape );
break;
case LAYER_GLOBLABEL:
textItem = new SCH_GLOBALLABEL( GetScreen()->GetCrossHairPosition() );
textItem = new SCH_GLOBALLABEL( GetCrossHairPosition() );
textItem->SetShape( lastGlobalLabelShape );
break;
......
......@@ -90,7 +90,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
m_CurrentSheet->UpdateAllScreenReferences();
}
sheetFoundIn->LastScreen()->SetCrossHairPosition( lastMarker->GetPosition() );
SetCrossHairPosition( lastMarker->GetPosition() );
RedrawScreen( lastMarker->GetPosition(), warpCursor );
......@@ -213,7 +213,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
if( centerAndRedraw )
{
GetScreen()->SetCrossHairPosition(pos);
SetCrossHairPosition( pos );
RedrawScreen( pos, aWarpMouse );
}
......@@ -226,7 +226,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
if( aWarpMouse )
m_canvas->MoveCursor( pos );
GetScreen()->SetCrossHairPosition(pos);
SetCrossHairPosition( pos );
m_canvas->CrossHairOn( &dc );
}
......@@ -351,7 +351,8 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent )
SetScreen( sheet->LastScreen() );
}
sheet->LastScreen()->SetCrossHairPosition( data.GetPosition() );
// careful here
SetCrossHairPosition( data.GetPosition() );
RedrawScreen( data.GetPosition(), warpCursor );
......
......@@ -231,7 +231,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
SCH_COMPONENT* component;
component = new SCH_COMPONENT( *Entry, m_CurrentSheet, unit, convert,
GetScreen()->GetCrossHairPosition(), true );
GetCrossHairPosition(), true );
// Set the m_ChipName value, from component name in lib, for aliases
// Note if Entry is found, and if Name is an alias of a component,
......
......@@ -284,12 +284,12 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
{
Zoom_Automatique( false );
screen->m_FirstRedraw = false;
screen->SetCrossHairPosition( screen->GetScrollCenterPosition() );
SetCrossHairPosition( GetScrollCenterPosition() );
m_canvas->MoveCursorToCrossHair();
}
else
{
RedrawScreen( screen->GetScrollCenterPosition(), true );
RedrawScreen( GetScrollCenterPosition(), true );
}
// Now refresh m_canvas. Should be not necessary, but because screen has changed
......
......@@ -74,14 +74,14 @@
*/
/* local variables */
/* Hotkey list: */
// local variables
// Hotkey list:
/**
* Common commands
*/
/* Fit on Screen */
// Fit on Screen
#if !defined( __WXMAC__ )
static EDA_HOTKEY HkZoomAuto( wxT( "Fit on Screen" ), HK_ZOOM_AUTO, WXK_HOME, ID_ZOOM_PAGE );
#else
......@@ -92,7 +92,7 @@ static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0'
static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4,
ID_POPUP_ZOOM_CENTER );
/* Refresh Screen */
// Refresh Screen
#if !defined( __WXMAC__ )
static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3, ID_ZOOM_REDRAW );
#else
......@@ -100,14 +100,14 @@ static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL
ID_ZOOM_REDRAW );
#endif
/* Zoom In */
// Zoom In
#if !defined( __WXMAC__ )
static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_POPUP_ZOOM_IN );
#else
static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+', ID_POPUP_ZOOM_IN );
#endif
/* Zoom Out */
// Zoom Out
#if !defined( __WXMAC__ )
static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_POPUP_ZOOM_OUT );
#else
......@@ -115,13 +115,13 @@ static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-', I
#endif
static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' );
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
/* Undo */
// Undo
static EDA_HOTKEY HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_UNDO );
/* Redo */
// Redo
#if !defined( __WXMAC__ )
static EDA_HOTKEY HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO );
#else
......@@ -358,8 +358,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
break;
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
case HK_RESET_LOCAL_COORD: // Reset the relative coord
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
case HK_ZOOM_IN:
......@@ -561,8 +561,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
DisplayHotkeyList( this, s_Libedit_Hokeys_Descr );
break;
case HK_RESET_LOCAL_COORD: /* Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
case HK_RESET_LOCAL_COORD: // Reset the relative coord
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
case HK_ZOOM_IN:
......
......@@ -218,7 +218,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
GetScreen()->m_Center = true;
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
SetCrossHairPosition( wxPoint( 0, 0 ) );
LoadSettings();
......@@ -402,7 +402,7 @@ double LIB_EDIT_FRAME::BestZoom()
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight();
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
else
{
......@@ -411,7 +411,7 @@ double LIB_EDIT_FRAME::BestZoom()
dx = pageInfo.GetSizeIU().x;
dy = pageInfo.GetSizeIU().y;
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
size = m_canvas->GetClientSize();
......@@ -753,7 +753,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
STATUS_FLAGS oldFlags = m_drawItem->GetFlags();
m_drawItem->ClearFlags();
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) );
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) );
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
m_drawItem->SetFlags( oldFlags );
m_lastDrawItem = NULL;
......@@ -1139,7 +1139,7 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
if( item == NULL )
return NULL;
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
wxPoint pos = GetNearestGridPosition( aPosition );
if( item == NULL && aPosition != pos )
item = locateItem( pos, aFilterList );
......
......@@ -663,8 +663,8 @@ void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunct
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
{
SCH_SCREEN* screen = frame->GetScreen();
wxPoint pos = screen->GetCrossHairPosition();
wxString msg;
wxPoint pos = frame->GetCrossHairPosition();
wxString msg;
if( Wire == NULL )
{
......@@ -691,9 +691,9 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
KiBitmap( delete_connection_xpm ) );
SCH_LINE* line = screen->GetWireOrBus( screen->GetCrossHairPosition() );
SCH_LINE* line = screen->GetWireOrBus( frame->GetCrossHairPosition() );
if( line && !line->IsEndPoint( screen->GetCrossHairPosition() ) )
if( line && !line->IsEndPoint( frame->GetCrossHairPosition() ) )
AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
KiBitmap( break_line_xpm ) );
......@@ -713,8 +713,8 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
{
wxPoint pos = frame->GetScreen()->GetCrossHairPosition();
wxString msg;
wxPoint pos = frame->GetCrossHairPosition();
wxString msg;
if( Bus == NULL )
{
......
......@@ -210,7 +210,7 @@ void LIB_EDIT_FRAME::PlacePin()
return;
}
newpos = GetScreen()->GetCrossHairPosition( true );
newpos = GetCrossHairPosition( true );
// Test for an other pin in same new position:
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
......@@ -308,7 +308,7 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC )
startPos.x = OldPos.x;
startPos.y = -OldPos.y;
// m_canvas->CrossHairOff( DC );
GetScreen()->SetCrossHairPosition( startPos );
SetCrossHairPosition( startPos );
m_canvas->MoveCursorToCrossHair();
MSG_PANEL_ITEMS items;
......@@ -350,7 +350,7 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
}
// Redraw pin in new position
CurrentPin->Move( aPanel->GetScreen()->GetCrossHairPosition( true ) );
CurrentPin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
&showPinText, DefaultTransform );
......@@ -388,7 +388,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
if( SynchronizePins() )
pin->SetFlags( IS_LINKED );
pin->Move( GetScreen()->GetCrossHairPosition( true ) );
pin->Move( GetCrossHairPosition( true ) );
pin->SetLength( LastPinLength );
pin->SetOrientation( LastPinOrient );
pin->SetType( LastPinType );
......@@ -555,10 +555,10 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
if( SynchronizePins() )
Pin->SetFlags( IS_LINKED );
wxPoint savepos = GetScreen()->GetCrossHairPosition();
wxPoint savepos = GetCrossHairPosition();
m_canvas->CrossHairOff( DC );
GetScreen()->SetCrossHairPosition( wxPoint( Pin->GetPosition().x,
-Pin->GetPosition().y ) );
SetCrossHairPosition( wxPoint( Pin->GetPosition().x, -Pin->GetPosition().y ) );
// Add this new pin in list, and creates pins for others parts if needed
m_drawItem = Pin;
......@@ -566,7 +566,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
PlacePin();
m_lastDrawItem = Pin;
GetScreen()->SetCrossHairPosition( savepos );
SetCrossHairPosition( savepos );
m_canvas->CrossHairOn( DC );
MSG_PANEL_ITEMS items;
......
......@@ -73,17 +73,17 @@ const wxSize SCH_BASE_FRAME::GetPageSizeIU() const
}
const wxPoint& SCH_BASE_FRAME::GetOriginAxisPosition() const
const wxPoint& SCH_BASE_FRAME::GetAuxOrigin() const
{
wxASSERT( GetScreen() );
return GetScreen()->GetOriginAxisPosition();
return GetScreen()->GetAuxOrigin();
}
void SCH_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
void SCH_BASE_FRAME::SetAuxOrigin( const wxPoint& aPosition )
{
wxASSERT( GetScreen() );
GetScreen()->SetOriginAxisPosition( aPosition );
GetScreen()->SetAuxOrigin( aPosition );
}
......@@ -113,8 +113,8 @@ void SCH_BASE_FRAME::UpdateStatusBar()
EDA_DRAW_FRAME::UpdateStatusBar();
// Display absolute coordinates:
double dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x );
double dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y );
double dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
double dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );
if ( g_UserUnit == MILLIMETRES )
{
......@@ -147,8 +147,9 @@ void SCH_BASE_FRAME::UpdateStatusBar()
SetStatusText( line, 2 );
// Display relative coordinates:
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx );
dYpos = To_User_Unit( g_UserUnit, dy );
......
......@@ -132,7 +132,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case wxID_PASTE:
HandleBlockBegin( &dc, BLOCK_PASTE, screen->GetCrossHairPosition() );
HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() );
break;
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
......@@ -165,12 +165,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_BEGIN_WIRE:
m_canvas->MoveCursorToCrossHair();
OnLeftClick( &dc, screen->GetCrossHairPosition() );
OnLeftClick( &dc, GetCrossHairPosition() );
break;
case ID_POPUP_SCH_BEGIN_BUS:
m_canvas->MoveCursorToCrossHair();
OnLeftClick( &dc, screen->GetCrossHairPosition() );
OnLeftClick( &dc, GetCrossHairPosition() );
break;
case ID_POPUP_SCH_SET_SHAPE_TEXT:
......@@ -194,7 +194,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
m_canvas->MoveCursorToCrossHair();
screen->ExtractWires( oldWires, true );
screen->BreakSegment( screen->GetCrossHairPosition() );
screen->BreakSegment( GetCrossHairPosition() );
if( oldWires.GetCount() != 0 )
{
......@@ -344,7 +344,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ADD_JUNCTION:
m_canvas->MoveCursorToCrossHair();
screen->SetCurItem( AddJunction( &dc, screen->GetCrossHairPosition(), true ) );
screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) );
screen->TestDanglingEnds( m_canvas, &dc );
screen->SetCurItem( NULL );
break;
......@@ -588,7 +588,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
{
PICKED_ITEMS_LIST pickList;
SCH_SCREEN* screen = GetScreen();
wxPoint pos = screen->GetCrossHairPosition();
wxPoint pos = GetCrossHairPosition();
if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
{
......@@ -603,7 +603,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC )
SCH_ITEM* item;
SCH_SCREEN* screen = GetScreen();
item = LocateItem( screen->GetCrossHairPosition(), SCH_COLLECTOR::ParentItems );
item = LocateItem( GetCrossHairPosition(), SCH_COLLECTOR::ParentItems );
if( item )
{
......@@ -637,7 +637,7 @@ static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositio
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
#endif
item->SetPosition( screen->GetCrossHairPosition() );
item->SetPosition( aPanel->GetParent()->GetCrossHairPosition() );
// Draw the item item at it's new position.
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
......@@ -713,7 +713,7 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC )
m_canvas->CrossHairOff( aDC );
if( aItem->Type() != SCH_SHEET_PIN_T )
GetScreen()->SetCrossHairPosition( aItem->GetPosition() );
SetCrossHairPosition( aItem->GetPosition() );
m_canvas->MoveCursorToCrossHair();
......@@ -959,7 +959,7 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
// is to simulate a block drag command
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
{
if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->GetCrossHairPosition() ) )
if( !HandleBlockBegin( &dc, BLOCK_DRAG, GetCrossHairPosition() ) )
break;
// Give a non null size to the search block:
......
......@@ -501,7 +501,7 @@ double SCH_EDIT_FRAME::BestZoom()
double bestzoom = std::max( zx, zy );
GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
return bestzoom;
}
......
......@@ -244,8 +244,8 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( sheet->IsResized() )
{
int width = screen->GetCrossHairPosition().x - sheet->GetPosition().x;
int height = screen->GetCrossHairPosition().y - sheet->GetPosition().y;
int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x;
int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y;
// If the sheet doesn't have any pins, clamp the minimum size to the default values.
width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
......@@ -263,12 +263,13 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
sheet->GetMinWidth() + gridSizeX : width;
}
wxPoint grid = screen->GetNearestGridPosition( wxPoint( pos.x + width, pos.y + height ) );
wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
wxPoint( pos.x + width, pos.y + height ) );
sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
}
else if( sheet->IsMoving() )
{
moveVector = screen->GetCrossHairPosition() - pos;
moveVector = aPanel->GetParent()->GetCrossHairPosition() - pos;
sheet->Move( moveVector );
}
......@@ -324,7 +325,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
{
m_itemToRepeat = NULL;
SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->GetCrossHairPosition() );
SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
sheet->SetFlags( IS_NEW | IS_RESIZED );
sheet->SetTimeStamp( GetNewTimeStamp() );
......@@ -338,7 +339,9 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( sheet->GetResizePosition() );
SetCrossHairPosition( sheet->GetResizePosition() );
m_canvas->MoveCursorToCrossHair();
m_canvas->CrossHairOn( aDC );
......@@ -356,7 +359,7 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
GetChars( aSheet->GetClass() ) ) );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( aSheet->GetResizePosition() );
SetCrossHairPosition( aSheet->GetResizePosition() );
m_canvas->MoveCursorToCrossHair();
m_canvas->CrossHairOn( aDC );
......@@ -377,7 +380,7 @@ void SCH_EDIT_FRAME::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
return;
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( aSheet->GetPosition() );
SetCrossHairPosition( aSheet->GetPosition() );
m_canvas->MoveCursorToCrossHair();
if( !aSheet->IsNew() )
......
......@@ -136,7 +136,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
return;
bool newItem = item->IsNew();
item->EndEdit( parent->GetScreen()->GetCrossHairPosition( true ), true );
item->EndEdit( parent->GetCrossHairPosition( true ), true );
if( newItem )
{
......@@ -153,7 +153,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC )
{
m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
wxPoint drawPos = GetScreen()->GetCrossHairPosition( true );
wxPoint drawPos = GetCrossHairPosition( true );
// no temp copy -> the current version of component will be used for Undo
// This is normal when adding new items to the current component
......@@ -239,7 +239,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
if( m_drawItem == NULL )
return;
wxPoint pos = GetScreen()->GetCrossHairPosition( true );
wxPoint pos = GetCrossHairPosition( true );
if( m_drawItem->ContinueEdit( pos ) )
{
......@@ -264,21 +264,20 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
if( item == NULL )
return;
BASE_SCREEN* Screen = aPanel->GetScreen();
item->SetEraseLastDrawItem( aErase );
// if item is the reference field, we must add the current unit id
if( item->Type() == LIB_FIELD_T )
{
int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ),
int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
UNSPECIFIED_COLOR, g_XorMode, &text,
DefaultTransform );
}
else
item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ),
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
UNSPECIFIED_COLOR, g_XorMode, NULL,
DefaultTransform );
}
......@@ -298,7 +297,7 @@ void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC )
if( m_drawItem->Type() == LIB_FIELD_T )
m_drawItem->BeginEdit( IS_MOVED, m_drawItem->GetPosition() );
else
m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCrossHairPosition( true ) );
m_drawItem->BeginEdit( IS_MOVED, GetCrossHairPosition( true ) );
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
......@@ -312,7 +311,7 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC )
return;
TempCopyComponent();
m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCrossHairPosition( true ) );
m_drawItem->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) );
m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
}
......@@ -322,14 +321,13 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC )
static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
BASE_SCREEN* Screen = aPanel->GetScreen();
LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
if( item == NULL )
return;
item->SetEraseLastDrawItem( aErase );
item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL,
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL,
DefaultTransform );
}
......@@ -357,7 +355,7 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
if( m_drawItem->IsNew() )
m_component->AddDrawItem( m_drawItem );
m_drawItem->EndEdit( GetScreen()->GetCrossHairPosition( true ) );
m_drawItem->EndEdit( GetCrossHairPosition( true ) );
m_drawItem = NULL;
......
......@@ -65,7 +65,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol()
if( dlg.ShowModal() == wxID_CANCEL )
return;
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
SetCrossHairPosition( wxPoint( 0, 0 ) );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
......@@ -238,7 +238,9 @@ void LIB_EDIT_FRAME::PlaceAnchor()
if( m_component == NULL )
return;
wxPoint offset( -GetScreen()->GetCrossHairPosition().x, GetScreen()->GetCrossHairPosition().y );
const wxPoint& cross_hair = GetCrossHairPosition();
wxPoint offset( -cross_hair.x, cross_hair.y );
OnModify( );
......
......@@ -335,7 +335,7 @@ void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv )
void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
{
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
GetScreen()->m_O_Curseur = GetCrossHairPosition();
UpdateStatusBar();
}
......@@ -348,18 +348,16 @@ double LIB_VIEW_FRAME::BestZoom()
* search for line static const int VIEWPORT_EXTENT = 1000;
* and replace by static const int VIEWPORT_EXTENT = 10000;
*/
LIB_COMPONENT* component = NULL;
CMP_LIBRARY* lib;
double bestzoom = 16.0; // default value for bestzoom
lib = CMP_LIBRARY::FindLibrary( m_libraryName );
LIB_COMPONENT* component = NULL;
double bestzoom = 16.0; // default value for bestzoom
CMP_LIBRARY* lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib )
component = lib->FindComponent( m_entryName );
if( component == NULL )
{
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return bestzoom;
}
......@@ -382,7 +380,7 @@ double LIB_VIEW_FRAME::BestZoom()
if( bestzoom < GetScreen()->m_ZoomList[0] )
bestzoom = GetScreen()->m_ZoomList[0];
GetScreen()->SetScrollCenterPosition( BoundaryBox.Centre() );
SetScrollCenterPosition( BoundaryBox.Centre() );
return bestzoom;
}
......
......@@ -171,10 +171,11 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP )
{
screen->m_BlockLocate.SetMoveVector( wxPoint( screen->GetCrossHairPosition().x -
screen->m_BlockLocate.GetRight(),
screen->GetCrossHairPosition().y -
screen->m_BlockLocate.GetBottom() ) );
const wxPoint& cross_hair = aPanel->GetParent()->GetCrossHairPosition();
screen->m_BlockLocate.SetMoveVector(
wxPoint( cross_hair.x - screen->m_BlockLocate.GetRight(),
cross_hair.y - screen->m_BlockLocate.GetBottom() ) );
}
screen->m_BlockLocate.Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, Color );
......@@ -195,10 +196,10 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC )
wxPoint delta;
wxPoint oldpos;
oldpos = GetScreen()->GetCrossHairPosition();
oldpos = GetCrossHairPosition();
m_canvas->SetMouseCaptureCallback( NULL );
GetScreen()->SetCrossHairPosition( oldpos );
SetCrossHairPosition( oldpos );
m_canvas->MoveCursorToCrossHair();
GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize();
......
......@@ -38,12 +38,12 @@ public:
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
const wxPoint& GetOriginAxisPosition() const
const wxPoint& GetAuxOrigin() const
{
return m_originAxisPosition;
}
void SetOriginAxisPosition( const wxPoint& aPosition )
void SetAuxOrigin( const wxPoint& aPosition )
{
m_originAxisPosition = aPosition;
}
......
......@@ -38,9 +38,9 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos;
wxPoint pos = aPosition;
pos = GetScreen()->GetNearestGridPosition( pos );
pos = GetNearestGridPosition( pos );
oldpos = GetScreen()->GetCrossHairPosition();
oldpos = GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
switch( aHotKey )
......@@ -73,14 +73,14 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
break;
}
GetScreen()->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
if( oldpos != GetScreen()->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( oldpos );
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......
......@@ -196,7 +196,7 @@ double GERBVIEW_FRAME::BestZoom()
double x = (double) bbox.GetWidth() / (double) size.x;
double y = (double) bbox.GetHeight() / (double) size.y;
GetScreen()->SetScrollCenterPosition( bbox.Centre() );
SetScrollCenterPosition( bbox.Centre() );
double best_zoom = std::max( x, y );
return best_zoom;
......@@ -733,17 +733,17 @@ void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
}
const wxPoint& GERBVIEW_FRAME::GetOriginAxisPosition() const
const wxPoint& GERBVIEW_FRAME::GetAuxOrigin() const
{
wxASSERT( m_gerberLayout );
return m_gerberLayout->GetOriginAxisPosition();
return m_gerberLayout->GetAuxOrigin();
}
void GERBVIEW_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
{
wxASSERT( m_gerberLayout );
m_gerberLayout->SetOriginAxisPosition( aPosition );
m_gerberLayout->SetAuxOrigin( aPosition );
}
......@@ -800,8 +800,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
{
double theta, ro;
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
// atan2 in the 0,0 case returns 0
theta = RAD2DEG( atan2( -dy, dx ) );
......@@ -829,9 +829,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
}
// Display absolute coordinates:
dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y );
dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );
wxString absformatter;
......@@ -859,8 +858,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
{
// Display relative coordinates:
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx );
dYpos = To_User_Unit( g_UserUnit, dy );
......
......@@ -82,7 +82,9 @@ public:
class GERBVIEW_FRAME : public EDA_DRAW_FRAME // PCB_BASE_FRAME
{
GBR_LAYOUT* m_gerberLayout;
GBR_LAYOUT* m_gerberLayout;
wxPoint m_grid_origin;
public:
GBR_DISPLAY_OPTIONS m_DisplayOptions;
......@@ -126,8 +128,14 @@ public:
const PAGE_INFO& GetPageSettings() const; // overload
const wxSize GetPageSizeIU() const; // overload
const wxPoint& GetOriginAxisPosition() const; // overload
void SetOriginAxisPosition( const wxPoint& aPosition ); // overload
const wxPoint& GetAuxOrigin() const; // overload
void SetAuxOrigin( const wxPoint& aPoint ); // overload
const wxPoint& GetGridOrigin() const { return m_grid_origin; } // overload
void SetGridOrigin( const wxPoint& aPoint ) // overload
{
m_grid_origin = aPoint;
}
const TITLE_BLOCK& GetTitleBlock() const; // overload
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload
......
......@@ -31,30 +31,28 @@
* and see this list for some ascii keys (space ...)
*/
/* local variables */
/* Hotkey list: */
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' );
static EDA_HOTKEY HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static EDA_HOTKEY HkTrackDisplayMode( wxT( "Track Display Mode" ),
HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' );
static EDA_HOTKEY HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ),
HK_SWITCH_LAYER_TO_NEXT, '+' );
static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" ),
HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
// local variables
// Hotkey list:
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' );
static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' );
static EDA_HOTKEY HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static EDA_HOTKEY HkTrackDisplayMode( wxT( "Track Display Mode" ), HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' );
static EDA_HOTKEY HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ), HK_SWITCH_LAYER_TO_NEXT, '+' );
static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" ), HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
// List of common hotkey descriptors
EDA_HOTKEY* s_Gerbview_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkZoomAuto, &HkSwitchUnits, &HkResetLocalCoord,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkZoomAuto, &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin,
&HkTrackDisplayMode,
&HkSwitch2NextCopperLayer,
&HkSwitch2PreviousCopperLayer,
......@@ -130,8 +128,12 @@ void GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
case HK_RESET_LOCAL_COORD: // Reset the relative coord
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
case HK_SET_GRID_ORIGIN:
SetGridOrigin( GetCrossHairPosition() );
break;
case HK_SWITCH_UNITS:
......
......@@ -44,7 +44,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
bool found = false;
if( aTypeloc == CURSEUR_ON_GRILLE )
ref = GetScreen()->GetNearestGridPosition( ref );
ref = GetNearestGridPosition( ref );
LAYER_NUM layer = getActiveLayer();
......
This diff is collapsed.
......@@ -45,6 +45,8 @@ public:
wxSize m_ModuleTextSize; ///< Default footprint texts size
int m_ModuleTextWidth;
int m_ModuleSegmentWidth;
wxPoint m_AuxOrigin; ///< origin for plot exports
wxPoint m_GridOrigin; ///< origin for grid offsets
D_PAD m_Pad_Master;
......
......@@ -55,52 +55,55 @@ typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC
class EDA_DRAW_PANEL : public wxScrolledWindow
{
private:
int m_currentCursor; ///< Current mouse cursor shape id.
int m_defaultCursor; ///< The default mouse cursor shape id.
bool m_showCrossHair; ///< Indicate if cross hair is to be shown.
int m_cursorLevel; ///< Index for cursor redraw in XOR mode.
int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit.
int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit.
wxPoint m_CursorStartPos; ///< Used for testing the cursor movement.
wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started
wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started
int m_currentCursor; ///< Current mouse cursor shape id.
int m_defaultCursor; ///< The default mouse cursor shape id.
bool m_showCrossHair; ///< Indicate if cross hair is to be shown.
int m_cursorLevel; ///< Index for cursor redraw in XOR mode.
int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit.
int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit.
wxPoint m_CursorStartPos; ///< Used for testing the cursor movement.
wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started
wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started
/// The drawing area used to redraw the screen which is usually the visible area
/// of the drawing in internal units.
EDA_RECT m_ClipBox;
EDA_RECT m_ClipBox;
bool m_abortRequest; ///< Flag used to abort long commands.
bool m_abortRequest; ///< Flag used to abort long commands.
bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center
bool m_enableMiddleButtonPan; ///< True to enable middle mouse button panning.
bool m_panScrollbarLimits; ///< has meaning only if m_enableMiddleButtonPan = true
///< true to limit panning to scrollbar current limits
///< false to used unlimited pan
bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center
bool m_enableMiddleButtonPan; ///< True to enable middle mouse button panning.
bool m_panScrollbarLimits; ///< has meaning only if m_enableMiddleButtonPan = true
///< true to limit panning to scrollbar current limits
///< false to used unlimited pan
bool m_enableAutoPan; ///< True to enable automatic panning.
bool m_enableAutoPan; ///< True to enable automatic panning.
/// true to request an auto pan. Valid only when m_enableAutoPan = true.
bool m_requestAutoPan;
bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true.
bool m_ignoreMouseEvents; ///< Ignore mouse events when true.
bool m_ignoreMouseEvents; ///< Ignore mouse events when true.
/* Used to inhibit a response to a mouse left button release, after a double click
* (when releasing the left button at the end of the second click. Used in Eeschema
* to inhibit a mouse left release command when switching between hierarchical sheets
* on a double click.
*/
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true.
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true.
bool m_enableBlockCommands; ///< True enables block commands.
bool m_enableBlockCommands; ///< True enables block commands.
int m_minDragEventCount; /* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if
* MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
* in order to avoid spurious block commands. */
/**
* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if
* MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid
* spurious block commands.
*/
int m_minDragEventCount;
/// True when drawing in mirror mode. Used by the draw arc function, because arcs
/// are oriented, and in mirror mode, orientations are reversed.
bool m_PrintIsMirrored;
bool m_PrintIsMirrored;
/// Mouse capture move callback function.
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback;
......@@ -108,9 +111,10 @@ private:
/// Abort mouse capture callback function.
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback;
// useful to avoid false start block in certain cases
// (like switch from a sheet to an other sheet
int m_canStartBlock; // >= 0 (or >= n) if a block can start
/// useful to avoid false start block in certain cases
/// (like switch from a sheet to an other sheet
/// >= 0 (or >= n) if a block can start
int m_canStartBlock;
public:
......@@ -155,9 +159,8 @@ public:
void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; }
bool GetPrintMirrored() const { return m_PrintIsMirrored; }
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
bool GetPrintMirrored() const { return m_PrintIsMirrored; }
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; }
......@@ -196,8 +199,9 @@ public:
* the grid origin is set by user, and is not (0,0)
* @param aDC = current Device Context
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
* @param aGridOrigin = the absolute coordinate of grid origin for snap.
*/
void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode );
void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin );
void OnEraseBackground( wxEraseEvent& event ) { }
......@@ -324,7 +328,7 @@ public:
* warps the cursor to the current cross hair position.
*/
void MoveCursorToCrossHair();
/**
* Function ToDeviceXY
* transforms logical to device coordinates
......
......@@ -73,8 +73,8 @@ private:
TITLE_BLOCK m_titles;
/// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA
wxPoint m_originAxisPosition;
/// Origin of the auxilliary axis, which is used in exports mostly, but not yet in EESCHEMA
wxPoint m_aux_origin;
DLIST< SCH_ITEM > m_drawList; ///< Object list for the screen.
/// @todo use DLIST<SCH_ITEM> or superior container
......@@ -108,12 +108,12 @@ public:
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
const wxString& GetFileName() const { return m_fileName; }
const wxString& GetFileName() const { return m_fileName; }
const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
const wxPoint& GetAuxOrigin() const { return m_aux_origin; }
void SetAuxOrigin( const wxPoint& aPosition ) { m_aux_origin = aPosition; }
const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
//TITLE_BLOCK& GetTitleBlock() const { return (TITLE_BLOCK&) m_titles; }
......
......@@ -217,6 +217,8 @@ void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescLis
enum common_hotkey_id_commnand {
HK_NOT_FOUND = 0,
HK_RESET_LOCAL_COORD,
HK_SET_GRID_ORIGIN,
HK_RESET_GRID_ORIGIN,
HK_HELP,
HK_ZOOM_IN,
HK_ZOOM_OUT,
......
......@@ -58,8 +58,15 @@ public:
const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME
const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME
const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME
void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME
const wxPoint& GetAuxOrigin() const; // overload EDA_DRAW_FRAME
void SetAuxOrigin( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME
const wxPoint& GetGridOrigin() const // overload EDA_DRAW_FRAME
{
static wxPoint zero;
return zero;
}
void SetGridOrigin( const wxPoint& aPoint ) {} // overload EDA_DRAW_FRAME
const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME
......
......@@ -131,8 +131,11 @@ public:
const PAGE_INFO& GetPageSettings() const; // overload
const wxSize GetPageSizeIU() const; // overload
const wxPoint& GetOriginAxisPosition() const; // overload
void SetOriginAxisPosition( const wxPoint& aPosition ); // overload
const wxPoint& GetAuxOrigin() const; // overload
void SetAuxOrigin( const wxPoint& aPoint ); // overload
const wxPoint& GetGridOrigin() const; // overload
void SetGridOrigin( const wxPoint& aPoint ); // overload
const TITLE_BLOCK& GetTitleBlock() const; // overload
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload
......
......@@ -114,15 +114,15 @@ extern const wxChar* traceAutoSave;
class EDA_BASE_FRAME : public wxFrame
{
protected:
ID_DRAWFRAME_TYPE m_Ident; // Id Type (pcb, schematic, library..)
ID_DRAWFRAME_TYPE m_Ident; ///< Id Type (pcb, schematic, library..)
wxPoint m_FramePos;
wxSize m_FrameSize;
wxAuiToolBar* m_mainToolBar; // Standard horizontal Toolbar
wxAuiToolBar* m_mainToolBar; ///< Standard horizontal Toolbar
bool m_FrameIsActive;
wxString m_FrameName; // name used for writing and reading setup
// It is "SchematicFrame", "PcbFrame" ....
wxString m_AboutTitle; // Name of program displayed in About.
wxString m_FrameName; ///< name used for writing and reading setup
///< It is "SchematicFrame", "PcbFrame" ....
wxString m_AboutTitle; ///< Name of program displayed in About.
wxAuiManager m_auimgr;
......@@ -409,47 +409,47 @@ protected:
EDA_DRAW_PANEL_GAL* m_galCanvas;
/// Tool ID of previously active draw tool bar button.
int m_lastDrawToolId;
int m_lastDrawToolId;
/// The shape of the KiCad cursor. The default value (0) is the normal cross
/// hair cursor. Set to non-zero value to draw the full screen cursor.
/// @note This is not the system mouse cursor.
int m_cursorShape;
int m_cursorShape;
/// True shows the X and Y axis indicators.
bool m_showAxis;
bool m_showAxis;
/// True shows the grid axis indicators.
bool m_showGridAxis;
bool m_showGridAxis;
/// True shows the origin axis used to indicate the coordinate offset for
/// drill, gerber, and component position files.
bool m_showOriginAxis;
bool m_showOriginAxis;
/// True shows the drawing border and title block.
bool m_showBorderAndTitleBlock;
bool m_showBorderAndTitleBlock;
/// Choice box to choose the grid size.
wxComboBox* m_gridSelectBox;
wxComboBox* m_gridSelectBox;
/// Choice box to choose the zoom value.
wxComboBox* m_zoomSelectBox;
wxComboBox* m_zoomSelectBox;
/// The tool bar that contains the buttons for quick access to the application draw
/// tools. It typically is located on the right side of the main window.
wxAuiToolBar* m_drawToolBar;
wxAuiToolBar* m_drawToolBar;
/// The options tool bar typcially located on the left edge of the main window.
wxAuiToolBar* m_optionsToolBar;
wxAuiToolBar* m_optionsToolBar;
/// Panel used to display information at the bottom of the main window.
EDA_MSG_PANEL* m_messagePanel;
EDA_MSG_PANEL* m_messagePanel;
int m_MsgFrameHeight;
int m_MsgFrameHeight;
#ifdef USE_WX_OVERLAY
// MAC Uses overlay to workaround the wxINVERT and wxXOR miss
wxOverlay m_overlay;
wxOverlay m_overlay;
#endif
protected:
......@@ -485,8 +485,89 @@ public:
*/
virtual const wxSize GetPageSizeIU() const = 0;
virtual const wxPoint& GetOriginAxisPosition() const = 0;
virtual void SetOriginAxisPosition( const wxPoint& aPosition ) = 0;
/**
* Function GetAuxOrigin
* returns the origin of the axis used for plotting and various exports.
*/
virtual const wxPoint& GetAuxOrigin() const = 0;
virtual void SetAuxOrigin( const wxPoint& aPosition ) = 0;
/**
* Function GetGridOrigin
* returns the absolute coordinates of the origin of the snap grid. This is
* treated as a relative offset, and snapping will occur at multiples of the grid
* size relative to this point.
*/
virtual const wxPoint& GetGridOrigin() const = 0;
virtual void SetGridOrigin( const wxPoint& aPosition ) = 0;
//-----<BASE_SCREEN API moved here>------------------------------------------
/**
* Function GetCrossHairPosition
* return the current cross hair position in logical (drawing) coordinates.
* @param aInvertY Inverts the Y axis position.
* @return The cross hair position in drawing coordinates.
*/
wxPoint GetCrossHairPosition( bool aInvertY = false ) const;
/**
* Function SetCrossHairPosition
* sets the screen cross hair position to \a aPosition in logical (drawing) units.
* @param aPosition The new cross hair position.
* @param aGridOrigin Origin point of the snap grid.
* @param aSnapToGrid Sets the cross hair position to the nearest grid position to
* \a aPosition.
*
*/
void SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid = true );
/**
* Function GetCursorPosition
* returns the current cursor position in logical (drawing) units.
* @param aOnGrid Returns the nearest grid position at the current cursor position.
* @param aGridOrigin Origin point of the snap grid.
* @param aGridSize Custom grid size instead of the current grid size. Only valid
* if \a aOnGrid is true.
* @return The current cursor position.
*/
wxPoint GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize = NULL ) const;
/**
* Function GetNearestGridPosition
* returns the nearest \a aGridSize location to \a aPosition.
* @param aPosition The position to check.
* @param aGridSize The grid size to locate to if provided. If NULL then the current
* grid size is used.
* @return The nearst grid position.
*/
wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL ) const;
/**
* Function GetCursorScreenPosition
* returns the cross hair position in device (display) units.b
* @return The current cross hair position.
*/
wxPoint GetCrossHairScreenPosition() const;
void SetMousePosition( const wxPoint& aPosition );
/**
* Function RefPos
* Return the reference position, coming from either the mouse position
* or the cursor position.
*
* @param useMouse If true, return mouse position, else cursor's.
*
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
*/
wxPoint RefPos( bool useMouse ) const;
const wxPoint& GetScrollCenterPosition() const;
void SetScrollCenterPosition( const wxPoint& aPoint );
//-----</BASE_SCREEN API moved here>-----------------------------------------
virtual const TITLE_BLOCK& GetTitleBlock() const = 0;
virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0;
......@@ -723,13 +804,13 @@ public:
void DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScale, const wxString &aFilename );
void DisplayToolMsg( const wxString& msg );
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0;
virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0;
virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0;
virtual void ToolOnRightClick( wxCommandEvent& event );
void AdjustScrollBars( const wxPoint& aCenterPosition );
void DisplayToolMsg( const wxString& msg );
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0;
virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0;
virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0;
virtual void ToolOnRightClick( wxCommandEvent& event );
void AdjustScrollBars( const wxPoint& aCenterPosition );
/**
* Function OnActivate (virtual)
......
......@@ -33,7 +33,7 @@ public:
m_paper = aPageSettings;
}
const wxPoint& GetOriginAxisPosition() const
const wxPoint& GetAuxOrigin() const
{
static wxPoint zero( 0, 0 );
return zero;
......
......@@ -35,14 +35,9 @@
void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
int aHotKey )
{
wxRealPoint gridSize;
wxPoint oldpos;
wxPoint pos = aPosition;
pos = GetScreen()->GetNearestGridPosition( pos );
oldpos = GetScreen()->GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
wxPoint pos = GetNearestGridPosition( aPosition );
wxPoint oldpos = GetCrossHairPosition();
wxRealPoint gridSize = GetScreen()->GetGridSize();
switch( aHotKey )
{
......@@ -74,14 +69,14 @@ void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
break;
}
GetScreen()->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
if( oldpos != GetScreen()->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( oldpos );
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......
......@@ -250,7 +250,7 @@ static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositio
WORKSHEET_DATAITEM *item = screen->GetCurItem();
wxCHECK_RET( (item != NULL), wxT( "Cannot move NULL item." ) );
wxPoint position = screen->GetCrossHairPosition()
wxPoint position = aPanel->GetParent()->GetCrossHairPosition()
- ( initialCursorPosition - initialPositionUi );
if( (item->GetFlags() & LOCATE_STARTPOINT) )
......@@ -285,12 +285,13 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
aPanel->Refresh();
}
void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem )
{
wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) );
initialPosition = aItem->GetStartPos();
initialPositionUi = aItem->GetStartPosUi();
initialCursorPosition = GetScreen()->GetCrossHairPosition();
initialCursorPosition = GetCrossHairPosition();
if( (aItem->GetFlags() & LOCATE_ENDPOINT) )
{
......@@ -300,8 +301,8 @@ void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem )
if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
{
GetScreen()->SetCrossHairPosition( initialPositionUi, false );
initialCursorPosition = GetScreen()->GetCrossHairPosition();
SetCrossHairPosition( initialPositionUi, false );
initialCursorPosition = GetCrossHairPosition();
if( m_canvas->IsPointOnDisplay( initialCursorPosition ) )
{
m_canvas->MoveCursorToCrossHair();
......@@ -317,6 +318,7 @@ void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem )
GetScreen()->SetCurItem( aItem );
}
/**
* Save in Undo list the layout, and place an item being moved.
* @param aItem is the item moved
......
......@@ -180,7 +180,11 @@ void PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
break;
case HK_RESET_LOCAL_COORD: // Reset the relative coord
GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
case HK_SET_GRID_ORIGIN:
SetGridOrigin( GetCrossHairPosition() );
break;
case HK_MOVE_ITEM:
......
......@@ -254,7 +254,7 @@ double PL_EDITOR_FRAME::BestZoom()
double bestzoom = std::max( zx, zy );
GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
return bestzoom;
}
......@@ -369,42 +369,44 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
wxPoint originCoord;
int Xsign = 1;
int Ysign = 1;
WORKSHEET_DATAITEM dummy( WORKSHEET_DATAITEM::WS_SEGMENT );
switch( m_originSelectChoice )
{
default:
case 0: // Origin = paper Left Top corner
break;
default:
case 0: // Origin = paper Left Top corner
break;
case 1: // Origin = page Right Bottom corner
Xsign = -1;
Ysign = -1;
dummy.SetStart( 0, 0, RB_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 1: // Origin = page Right Bottom corner
Xsign = -1;
Ysign = -1;
dummy.SetStart( 0, 0, RB_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 2: // Origin = page Left Bottom corner
Ysign = -1;
dummy.SetStart( 0, 0, LB_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 2: // Origin = page Left Bottom corner
Ysign = -1;
dummy.SetStart( 0, 0, LB_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 3: // Origin = page Right Top corner
Xsign = -1;
dummy.SetStart( 0, 0, RT_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 3: // Origin = page Right Top corner
Xsign = -1;
dummy.SetStart( 0, 0, RT_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 4: // Origin = page Left Top corner
dummy.SetStart( 0, 0, LT_CORNER );
originCoord = dummy.GetStartPosUi();
break;
case 4: // Origin = page Left Top corner
dummy.SetStart( 0, 0, LT_CORNER );
originCoord = dummy.GetStartPosUi();
break;
}
screen->m_GridOrigin = originCoord;
SetGridOrigin( originCoord );
// Display absolute coordinates:
wxPoint coord = screen->GetCrossHairPosition() - originCoord;
wxPoint coord = GetCrossHairPosition() - originCoord;
double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign );
double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign );
......@@ -441,8 +443,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
SetStatusText( line, 2 );
// Display relative coordinates:
int dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
int dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx * Xsign );
dYpos = To_User_Unit( g_UserUnit, dy * Ysign );
line.Printf( locformatter, dXpos, dYpos );
......@@ -594,10 +596,11 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::GetSelectedItem()
*/
WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
{
const PAGE_INFO& pageInfo = GetPageSettings();
TITLE_BLOCK t_block = GetTitleBlock();
EDA_COLOR_T color = RED; // Needed, not used
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
const PAGE_INFO& pageInfo = GetPageSettings();
TITLE_BLOCK t_block = GetTitleBlock();
EDA_COLOR_T color = RED; // Needed, not used
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
WS_DRAW_ITEM_LIST drawList;
......@@ -623,9 +626,9 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
// Choose item in list if more than 1 item
if( list.size() > 1 )
{
wxArrayString choices;
wxArrayString choices;
wxString text;
wxPoint cursPos = screen->GetCrossHairPosition();
wxPoint cursPos = GetCrossHairPosition();
for( unsigned ii = 0; ii < list.size(); ++ii )
{
......@@ -656,7 +659,7 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
if( selection < 0 )
return NULL;
screen->SetCrossHairPosition( cursPos );
SetCrossHairPosition( cursPos );
m_canvas->MoveCursorToCrossHair();
drawitem = list[selection];
}
......
......@@ -58,6 +58,8 @@ class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
// usefull when there are some items which are
// only on page 1, not on page 1
wxPoint m_grid_origin;
protected:
/// The last filename chosen to be proposed to the user
wxString m_lastFileName;
......@@ -90,12 +92,21 @@ public:
return (PL_EDITOR_SCREEN*) m_canvas->GetScreen();
}
const wxPoint& GetOriginAxisPosition() const // overload EDA_DRAW_FRAME
const wxPoint& GetAuxOrigin() const // overload EDA_DRAW_FRAME
{
static wxPoint dummy( 0,0 );
static wxPoint dummy; // ( 0,0 );
return dummy;
}
void SetOriginAxisPosition( const wxPoint& aPosition ) {} // overload EDA_DRAW_FRAME
void SetAuxOrigin( const wxPoint& aPosition ) {} // overload EDA_DRAW_FRAME
const wxPoint& GetGridOrigin() const // overload EDA_DRAW_FRAME
{
return m_grid_origin;
}
void SetGridOrigin( const wxPoint& aPoint ) // overload EDA_DRAW_FRAME
{
m_grid_origin = aPoint;
}
const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME
......
......@@ -106,7 +106,7 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event )
break;
}
/* Erase ratsnest if needed */
// Erase ratsnest if needed
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
DrawGeneralRatsnest( &dc );
......@@ -191,7 +191,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
return;
}
/* Confirmation */
// Confirmation
if( !IsOK( this, _( "Move modules?" ) ) )
return;
......@@ -223,15 +223,15 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
*/
if( PlaceModulesHorsPcb && edgesExist )
{
if( GetScreen()->GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) )
if( GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) )
{
wxPoint pos = GetScreen()->GetCrossHairPosition();
wxPoint pos = GetCrossHairPosition();
pos.y = bbbox.GetBottom() + 2000;
GetScreen()->SetCrossHairPosition( pos );
SetCrossHairPosition( pos );
}
}
/* calculate the area needed by footprints */
// calculate the area needed by footprints
surface = 0.0;
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
......@@ -249,7 +249,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 );
start = current = GetScreen()->GetCrossHairPosition();
start = current = GetCrossHairPosition();
Ymax_size = 0;
for( unsigned ii = 0; ii < moduleList.size(); ii++ )
......@@ -276,8 +276,8 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
Ymax_size = 0;
}
GetScreen()->SetCrossHairPosition( current + Module->GetPosition() -
Module->GetBoundingBox().GetPosition() );
SetCrossHairPosition( current + Module->GetPosition() -
Module->GetBoundingBox().GetPosition() );
Ymax_size = std::max( Ymax_size, Module->GetBoundingBox().GetHeight() );
......
This diff is collapsed.
......@@ -217,17 +217,31 @@ const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
}
const wxPoint& PCB_BASE_FRAME::GetOriginAxisPosition() const
const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
{
wxASSERT( m_Pcb );
return m_Pcb->GetOriginAxisPosition();
return m_Pcb->GetAuxOrigin();
}
void PCB_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition )
void PCB_BASE_FRAME::SetAuxOrigin( const wxPoint& aPoint )
{
wxASSERT( m_Pcb );
m_Pcb->SetOriginAxisPosition( aPosition );
m_Pcb->SetAuxOrigin( aPoint );
}
const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
{
wxASSERT( m_Pcb );
return m_Pcb->GetGridOrigin();
}
void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
{
wxASSERT( m_Pcb );
m_Pcb->SetGridOrigin( aPoint );
}
......@@ -327,7 +341,7 @@ double PCB_BASE_FRAME::BestZoom()
double bestzoom = std::max( iu_per_du_X, iu_per_du_Y );
GetScreen()->SetScrollCenterPosition( ibbbox.Centre() );
SetScrollCenterPosition( ibbbox.Centre() );
return bestzoom;
}
......@@ -337,21 +351,19 @@ void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp )
{
// factored out of pcbnew/find.cpp
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
INSTALL_UNBUFFERED_DC( dc, m_canvas );
// There may be need to reframe the drawing.
if( !m_canvas->IsPointOnDisplay( aPos ) )
{
screen->SetCrossHairPosition( aPos );
SetCrossHairPosition( aPos );
RedrawScreen( aPos, aWarp );
}
else
{
// Put cursor on item position
m_canvas->CrossHairOff( &dc );
screen->SetCrossHairPosition( aPos );
SetCrossHairPosition( aPos );
if( aWarp )
m_canvas->MoveCursorToCrossHair();
......@@ -641,8 +653,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
{
double theta, ro;
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
theta = ArcTangente( -dy, dx ) / 10;
......@@ -679,8 +691,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
}
// Display absolute coordinates:
dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y );
dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );
// The following sadly is an if Eeschema/if Pcbnew
wxString absformatter;
......@@ -723,8 +735,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
if( !DisplayOpt.DisplayPolarCood ) // display relative cartesian coordinates
{
// Display relative coordinates:
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx );
dYpos = To_User_Unit( g_UserUnit, dy );
......
......@@ -120,7 +120,7 @@ private:
static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title )
{
wxPoint oldpos = parent->GetScreen()->GetCrossHairPosition();
wxPoint oldpos = parent->GetCrossHairPosition();
parent->GetCanvas()->SetIgnoreMouseEvents( true );
DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, title );
......@@ -128,7 +128,7 @@ static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title
int cmd = dlg->ShowModal();
dlg->Destroy();
parent->GetScreen()->SetCrossHairPosition( oldpos );
parent->SetCrossHairPosition( oldpos );
parent->GetCanvas()->MoveCursorToCrossHair();
parent->GetCanvas()->SetIgnoreMouseEvents( false );
......@@ -232,9 +232,9 @@ void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_IDLE:
break;
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
case BLOCK_DRAG: // Drag
case BLOCK_MOVE: // Move
case BLOCK_PRESELECT_MOVE: // Move with preselection list
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......@@ -242,7 +242,7 @@ void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
GetScreen()->m_BlockLocate.ClearItemsList();
break;
case BLOCK_COPY: /* Copy */
case BLOCK_COPY: // Copy
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......@@ -315,35 +315,35 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break;
case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
case BLOCK_DRAG: // Drag (not used, for future enhancements)
case BLOCK_MOVE: // Move
case BLOCK_COPY: // Copy
case BLOCK_PRESELECT_MOVE: // Move with preselection list
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
nextcmd = true;
m_canvas->SetMouseCaptureCallback( drawMovingBlock );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
break;
case BLOCK_DELETE: /* Delete */
case BLOCK_DELETE: // Delete
m_canvas->SetMouseCaptureCallback( NULL );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
Block_Delete();
break;
case BLOCK_ROTATE: /* Rotation */
case BLOCK_ROTATE: // Rotation
m_canvas->SetMouseCaptureCallback( NULL );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
Block_Rotate();
break;
case BLOCK_FLIP: /* Flip */
case BLOCK_FLIP: // Flip
m_canvas->SetMouseCaptureCallback( NULL );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
Block_Flip();
break;
case BLOCK_SAVE: /* Save (not used, for future enhancements)*/
case BLOCK_SAVE: // Save (not used, for future enhancements)
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
if( GetScreen()->m_BlockLocate.GetCount() )
......@@ -355,7 +355,7 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_PASTE:
break;
case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_ZOOM: // Window Zoom
// Turn off the redraw block routine now so it is not displayed
// with one corner at the new center of the screen
......@@ -577,7 +577,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP )
{
screen->m_BlockLocate.SetMoveVector( screen->GetCrossHairPosition() -
screen->m_BlockLocate.SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() -
screen->m_BlockLocate.GetLastCursorPosition() );
}
......@@ -600,7 +600,7 @@ void PCB_EDIT_FRAME::Block_Delete()
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
itemsList->m_Status = UR_DELETED;
/* unlink items and clear flags */
// unlink items and clear flags
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
......@@ -658,7 +658,7 @@ void PCB_EDIT_FRAME::Block_Rotate()
wxPoint centre; // rotation cent-re for the rotation transform
int rotAngle = 900; // rotation angle in 0.1 deg.
oldpos = GetScreen()->GetCrossHairPosition();
oldpos = GetCrossHairPosition();
centre = GetScreen()->m_BlockLocate.Centre();
OnModify();
......@@ -680,7 +680,7 @@ void PCB_EDIT_FRAME::Block_Rotate()
m_Pcb->m_Status_Pcb = 0;
break;
/* Move and rotate the track segments */
// Move and rotate the track segments
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like track segment on a copper layer)
m_Pcb->m_Status_Pcb = 0;
......@@ -716,14 +716,14 @@ void PCB_EDIT_FRAME::Block_Flip()
{
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
wxPoint memo;
wxPoint center; /* Position of the axis for inversion of all elements */
wxPoint center; // Position of the axis for inversion of all elements
OnModify();
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
itemsList->m_Status = UR_FLIPPED;
memo = GetScreen()->GetCrossHairPosition();
memo = GetCrossHairPosition();
center = GetScreen()->m_BlockLocate.Centre();
......@@ -741,7 +741,7 @@ void PCB_EDIT_FRAME::Block_Flip()
m_Pcb->m_Status_Pcb = 0;
break;
/* Move and rotate the track segments */
// Move and rotate the track segments
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like track segment on a copper layer)
m_Pcb->m_Status_Pcb = 0;
......@@ -795,7 +795,7 @@ void PCB_EDIT_FRAME::Block_Move()
item->ClearFlags();
break;
/* Move track segments */
// Move track segments
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like a track segment on a copper layer)
m_Pcb->m_Status_Pcb = 0;
......
......@@ -127,12 +127,14 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
{
BLOCK_STATE_T state = GetScreen()->m_BlockLocate.GetState();
BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
m_canvas->CallEndMouseCapture( DC );
GetScreen()->m_BlockLocate.SetState( state );
GetScreen()->m_BlockLocate.SetCommand( command );
m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(),
GetScreen()->m_BlockLocate.GetBottom() ) );
SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(),
GetScreen()->m_BlockLocate.GetBottom() ) );
m_canvas->MoveCursorToCrossHair();
}
......@@ -142,9 +144,9 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break;
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
case BLOCK_DRAG: // Drag
case BLOCK_MOVE: // Move
case BLOCK_COPY: // Copy
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
......@@ -164,13 +166,13 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
case BLOCK_PRESELECT_MOVE: // Move with preselection list
nextcmd = true;
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
break;
case BLOCK_DELETE: /* Delete */
case BLOCK_DELETE: // Delete
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
......@@ -179,7 +181,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DeleteMarkedItems( currentModule );
break;
case BLOCK_SAVE: /* Save */
case BLOCK_SAVE: // Save
case BLOCK_PASTE:
break;
......@@ -195,7 +197,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_FLIP: /* mirror */
case BLOCK_FLIP: // mirror
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
......@@ -204,7 +206,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break;
case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_ZOOM: // Window Zoom
Window_Zoom( GetScreen()->m_BlockLocate );
break;
......@@ -249,28 +251,28 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_IDLE:
break;
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
case BLOCK_DRAG: // Drag
case BLOCK_MOVE: // Move
case BLOCK_PRESELECT_MOVE: // Move with preselection list
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( currentModule, UR_MODEDIT );
MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
m_canvas->Refresh( true );
break;
case BLOCK_COPY: /* Copy */
case BLOCK_COPY: // Copy
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( currentModule, UR_MODEDIT );
CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
break;
case BLOCK_PASTE: /* Paste */
case BLOCK_PASTE: // Paste
GetScreen()->m_BlockLocate.ClearItemsList();
break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_FLIP: /* Mirror by popup menu, from block move */
case BLOCK_FLIP: // Mirror by popup menu, from block move
SaveCopyInUndoList( currentModule, UR_MODEDIT );
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break;
......@@ -304,8 +306,8 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
BASE_SCREEN* screen = aPanel->GetScreen();
FOOTPRINT_EDIT_FRAME * moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
BASE_SCREEN* screen = aPanel->GetScreen();
FOOTPRINT_EDIT_FRAME* moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
wxASSERT( moduleEditFrame );
MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
......@@ -319,7 +321,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
if( currentModule )
{
wxPoint move_offset = -block->GetMoveVector();
wxPoint move_offset = -block->GetMoveVector();
BOARD_ITEM* item = currentModule->GraphicalItems();
for( ; item != NULL; item = item->Next() )
......@@ -351,15 +353,15 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
}
}
/* Repaint new view. */
block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() );
// Repaint new view.
block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
if( currentModule )
{
BOARD_ITEM* item = currentModule->GraphicalItems();
wxPoint move_offset = - block->GetMoveVector();
wxPoint move_offset = - block->GetMoveVector();
for( ; item != NULL; item = item->Next() )
{
......
......@@ -215,6 +215,8 @@ private:
ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_LAYERS];
wxPoint m_grid_origin;
// if true m_highLight_NetCode is used
HIGH_LIGHT_INFO m_highLight; // current high light data
HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
......@@ -231,9 +233,6 @@ private:
TITLE_BLOCK m_titles; ///< text in lower right of screen and plots
PCB_PLOT_PARAMS m_plotOptions;
/// Position of the origin axis, which is used in exports mostly
wxPoint m_originAxisPosition;
/// Number of pads connected to the current net.
int m_nodeCount;
......@@ -387,6 +386,20 @@ public:
return (int) m_markers.size();
}
/**
* Function SetAuxOrigin
* sets the origin point used for plotting.
*/
void SetAuxOrigin( const wxPoint& aPoint ) { m_designSettings.m_AuxOrigin = aPoint; }
const wxPoint& GetAuxOrigin() const { return m_designSettings.m_AuxOrigin; }
/**
* Function SetGridOrigin
* sets the origin point of the grid.
*/
void SetGridOrigin( const wxPoint& aPoint ) { m_designSettings.m_GridOrigin = aPoint; }
const wxPoint& GetGridOrigin() const { return m_designSettings.m_GridOrigin; }
/**
* Function ResetHighLight
* Reset all high light data to the init state
......@@ -594,9 +607,6 @@ public:
const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; }
void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
TITLE_BLOCK& GetTitleBlock() { return m_titles; }
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
......
......@@ -141,7 +141,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
}
}
m_Collector->Collect( m_Pcb, scanList, GetScreen()->RefPos( true ), guide );
m_Collector->Collect( m_Pcb, scanList, RefPos( true ), guide );
#if 0
// debugging: print out the collected items, showing their priority order too.
......@@ -161,7 +161,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
if( item->Type() != PCB_ZONE_T )
continue;
/* Found a TYPE ZONE */
// Found a TYPE ZONE
if( item->GetTimeStamp() == timestampzone ) // Remove it, redundant, zone already found
{
m_Collector->Remove( ii );
......@@ -200,7 +200,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
{
wxMenu itemMenu;
/* Give a title to the selection menu. This is also a cancel menu item */
// Give a title to the selection menu. This is also a cancel menu item
wxMenuItem * item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__
......@@ -269,9 +269,9 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
snapToGrid = false;
if( snapToGrid )
pos = GetScreen()->GetNearestGridPosition( pos );
pos = GetNearestGridPosition( pos );
oldpos = GetScreen()->GetCrossHairPosition();
oldpos = GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
......@@ -306,7 +306,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// Put cursor in new position, according to the zoom keys (if any).
GetScreen()->SetCrossHairPosition( pos, snapToGrid );
SetCrossHairPosition( pos, snapToGrid );
/* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the
* cursor is left off grid this is better to reach items to delete off grid,
......@@ -326,7 +326,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( Magnetize( this, GetToolId(), igridsize, curs_pos, &pos ) )
{
GetScreen()->SetCrossHairPosition( pos, false );
SetCrossHairPosition( pos, false );
}
else
{
......@@ -335,19 +335,19 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( !g_Drc_On || !g_CurrentTrackSegment ||
(BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() ||
!LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment,
GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) )
GetScreen()->m_Active_Layer, RefPos( true ) ) )
{
GetScreen()->SetCrossHairPosition( curs_pos, snapToGrid );
SetCrossHairPosition( curs_pos, snapToGrid );
}
}
if( oldpos != GetScreen()->GetCrossHairPosition() )
if( oldpos != GetCrossHairPosition() )
{
pos = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( oldpos, false );
pos = GetCrossHairPosition();
SetCrossHairPosition( oldpos, false );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( pos, false );
SetCrossHairPosition( pos, false );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......@@ -373,5 +373,5 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
OnHotKey( aDC, aHotKey, aPosition );
}
UpdateStatusBar(); /* Display new cursor coordinates */
UpdateStatusBar(); // Display new cursor coordinates
}
......@@ -96,7 +96,7 @@ void RemoteCommand( const char* cmdline )
pos = pad->GetPosition();
}
if( netcode > 0 ) /* highlight the pad net*/
if( netcode > 0 ) // highlight the pad net
{
pcb->HighLightON();
pcb->SetHighLightNet( netcode );
......@@ -127,7 +127,7 @@ void RemoteCommand( const char* cmdline )
if( module ) // if found, center the module on screen, and redraw the screen.
{
frame->GetScreen()->SetCrossHairPosition(pos);
frame->SetCrossHairPosition( pos );
frame->RedrawScreen( pos, false );
}
}
......
......@@ -317,7 +317,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
m_plotOpts.SetValueColor( color );
PAGE_INFO pageInfo = m_board->GetPageSettings();
wxPoint axisorigin = m_board->GetOriginAxisPosition();
wxPoint axisorigin = m_board->GetAuxOrigin();
if( PageIsBoardBoundarySize() )
{
......@@ -328,7 +328,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
m_board->SetPageSettings( currpageInfo );
m_plotOpts.SetUseAuxOrigin( true );
wxPoint origin = bbox.GetOrigin();
m_board->SetOriginAxisPosition( origin );
m_board->SetAuxOrigin( origin );
}
LOCALE_IO toggle;
......@@ -344,7 +344,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
}
delete plotter;
m_board->SetOriginAxisPosition( axisorigin );
m_board->SetAuxOrigin( axisorigin );
m_board->SetPageSettings( pageInfo );
return true;
......
......@@ -85,7 +85,7 @@ DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR()
}
/* Creation of the panel properties of the module editor. */
// Creation of the panel properties of the module editor.
void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
{
PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x );
......@@ -244,7 +244,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
m_LastSelected3DShapeIndex = -1;
/* Init 3D shape list */
// Init 3D shape list
S3D_MASTER* draw3D = m_CurrentModule->Models();
while( draw3D )
......@@ -276,7 +276,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
_( "Use this attribute for \"virtual\" components drawn on board\n"
"(like a old ISA PC bus connector)" ) );
/* Controls on right side of the dialog */
// Controls on right side of the dialog
switch( m_CurrentModule->GetAttributes() & 255 )
{
case 0:
......@@ -601,7 +601,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
if( change_layer )
m_CurrentModule->Flip( m_CurrentModule->GetPosition() );
/* Update 3D shape list */
// Update 3D shape list
int ii = m_3D_ShapeNameListBox->GetSelection();
if( ii >= 0 )
......@@ -660,23 +660,23 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event )
{
wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition();
wxPoint tmp = m_Parent->GetCrossHairPosition();
m_Parent->GetScreen()->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() );
m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() );
m_ReferenceCopy->SetParent( m_CurrentModule );
m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL );
m_Parent->GetScreen()->SetCrossHairPosition( tmp );
m_Parent->SetCrossHairPosition( tmp );
m_ReferenceCtrl->SetValue( m_ReferenceCopy->GetText() );
}
void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event )
{
wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition();
wxPoint tmp = m_Parent->GetCrossHairPosition();
m_Parent->GetScreen()->SetCrossHairPosition( m_ValueCopy->GetTextPosition() );
m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPosition() );
m_ValueCopy->SetParent( m_CurrentModule );
m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL );
m_Parent->GetScreen()->SetCrossHairPosition( tmp );
m_Parent->SetCrossHairPosition( tmp );
m_ValueCtrl->SetValue( m_ValueCopy->GetText() );
}
......@@ -84,9 +84,7 @@ DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR()
}
/********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
/********************************************************/
{
SetFocus();
......@@ -213,8 +211,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
}
/* Initialize 3D info displayed in dialog box from values in aStruct3DSource
*/
// Initialize 3D info displayed in dialog box from values in aStruct3DSource
void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource )
{
if( aStruct3DSource )
......@@ -247,9 +244,8 @@ void DIALOG_MODULE_MODULE_EDITOR::TransfertDisplayTo3DValues( int aIndexSelectio
struct3DDest->m_MatPosition = m_3D_Offset->GetValue();
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
/***********************************************************/
{
if( m_lastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex );
......@@ -268,9 +264,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event)
/***********************************************************/
{
if( m_lastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex );
......@@ -293,9 +287,7 @@ void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event)
}
/*********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event )
/*********************************************************************/
{
wxString fullfilename, shortfilename;
wxString fullpath;
......@@ -364,16 +356,13 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event )
}
/**********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& event )
/**********************************************************************/
{
EndModal( -1 );
}
/******************************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
/******************************************************************************/
{
// First, test for invalid chars in module name
wxString footprintName = m_FootprintNameCtrl->GetValue();
......@@ -486,25 +475,22 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
}
/***********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
/***********************************************************************/
{
wxPoint tmp = m_parent->GetScreen()->GetCrossHairPosition();
m_parent->GetScreen()->SetCrossHairPosition( m_referenceCopy->GetTextPosition() );
wxPoint tmp = m_parent->GetCrossHairPosition();
m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPosition() );
m_parent->InstallTextModOptionsFrame( m_referenceCopy, NULL );
m_parent->GetScreen()->SetCrossHairPosition( tmp );
m_parent->SetCrossHairPosition( tmp );
m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() );
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event)
/***********************************************************/
{
wxPoint tmp = m_parent->GetScreen()->GetCrossHairPosition();
m_parent->GetScreen()->SetCrossHairPosition( m_valueCopy->GetTextPosition() );
wxPoint tmp = m_parent->GetCrossHairPosition();
m_parent->SetCrossHairPosition( m_valueCopy->GetTextPosition() );
m_parent->InstallTextModOptionsFrame( m_valueCopy, NULL );
m_parent->GetScreen()->SetCrossHairPosition( tmp );
m_parent->SetCrossHairPosition( tmp );
m_ValueCtrl->SetValue( m_valueCopy->GetText() );
}
......@@ -321,7 +321,7 @@ void DIALOG_GENDRILL::SetParams()
if( m_Choice_Drill_Offset->GetSelection() == 0 )
m_FileDrillOffset = wxPoint( 0, 0 );
else
m_FileDrillOffset = m_parent->GetOriginAxisPosition();
m_FileDrillOffset = m_parent->GetAuxOrigin();
if( m_UnitDrillIsInch )
m_Precision = precisionListForInches;
......
......@@ -201,14 +201,21 @@ void DIALOG_SET_GRID::OnOkClick( wxCommandEvent& event )
bool PCB_BASE_FRAME::InvokeDialogGrid()
{
wxPoint grid_origin = GetGridOrigin();
DIALOG_SET_GRID dlg( this, &m_UserGridUnit, g_UserUnit, &m_UserGridSize,
&GetScreen()->m_GridOrigin, &m_FastGrid1, &m_FastGrid2,
&grid_origin, &m_FastGrid1, &m_FastGrid2,
m_gridSelectBox->GetStrings() );
int ret = dlg.ShowModal();
if( ret == wxID_OK )
{
if( GetGridOrigin() != grid_origin && IsType( PCB_FRAME_TYPE ) )
OnModify(); // because grid origin is saved in board, show as modified
SetGridOrigin( grid_origin );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
// If the user grid is the current option, recall SetGrid()
......
......@@ -240,7 +240,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
if( aDimension == NULL )
{
status_dimension = 1;
pos = GetScreen()->GetCrossHairPosition();
pos = GetCrossHairPosition();
aDimension = new DIMENSION( GetBoard() );
aDimension->SetFlags( IS_NEW );
......@@ -302,7 +302,7 @@ static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
{
PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem();
wxPoint pos = screen->GetCrossHairPosition();
wxPoint pos = aPanel->GetParent()->GetCrossHairPosition();
if( Dimension == NULL )
return;
......@@ -386,7 +386,7 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC )
aItem->SetFlags( IS_MOVED );
SetMsgPanel( aItem );
GetScreen()->SetCrossHairPosition( aItem->Text().GetTextPosition() );
SetCrossHairPosition( aItem->Text().GetTextPosition() );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText );
......@@ -407,7 +407,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aErase )
dimension->Draw( aPanel, aDC, GR_XOR );
dimension->Text().SetTextPosition( aPanel->GetScreen()->GetCrossHairPosition() );
dimension->Text().SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() );
dimension->Draw( aPanel, aDC, GR_XOR );
}
......
......@@ -66,7 +66,7 @@ void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* aEdge, wxDC* DC )
aEdge->Draw( m_canvas, DC, GR_XOR );
aEdge->SetFlags( IS_MOVED );
MoveVector.x = MoveVector.y = 0;
CursorInitialPosition = GetScreen()->GetCrossHairPosition();
CursorInitialPosition = GetCrossHairPosition();
m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline );
SetCurItem( aEdge );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......@@ -115,7 +115,7 @@ static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
}
MoveVector = -(screen->GetCrossHairPosition() - CursorInitialPosition);
MoveVector = -(aPanel->GetParent()->GetCrossHairPosition() - CursorInitialPosition);
edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
......@@ -142,7 +142,7 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
edge->Draw( aPanel, aDC, GR_XOR );
}
edge->SetEnd( screen->GetCrossHairPosition() );
edge->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
// Update relative coordinate.
edge->SetEnd0( edge->GetEnd() - module->GetPosition() );
......@@ -346,7 +346,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge,
aEdge->SetLayer( SILKSCREEN_N_FRONT );
// Initialize the starting point of the new segment or arc
aEdge->SetStart( GetScreen()->GetCrossHairPosition() );
aEdge->SetStart( GetCrossHairPosition() );
// Initialize the ending point of the new segment or arc
aEdge->SetEnd( aEdge->GetStart() );
......@@ -383,7 +383,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge,
aEdge->SetFlags( IS_NEW );
aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
aEdge->SetStart( GetScreen()->GetCrossHairPosition() );
aEdge->SetStart( GetCrossHairPosition() );
aEdge->SetEnd( aEdge->GetStart() );
// Update relative coordinate.
......
......@@ -56,7 +56,7 @@
#include <dialog_global_edit_tracks_and_vias.h>
/* Handles the selection of command events. */
// Handles the selection of command events.
void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
......@@ -153,7 +153,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->EndMouseCapture();
}
/* Should not be executed, just in case */
// Should not be executed, just in case
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
{
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
......@@ -544,7 +544,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
m_canvas->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
wxPoint pos = GetScreen()->GetCrossHairPosition();
wxPoint pos = GetCrossHairPosition();
/* add corner between zone_cont->m_CornerSelection
* and zone_cont->m_CornerSelection+1
......@@ -644,12 +644,12 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
SendMessageToEESCHEMA( module );
GetScreen()->SetCrossHairPosition( module->GetPosition() );
SetCrossHairPosition( module->GetPosition() );
m_canvas->MoveCursorToCrossHair();
StartMoveModule( module, &dc, id == ID_POPUP_PCB_DRAG_MODULE_REQUEST );
break;
case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: /* get module by name and move it */
case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
SetCurItem( GetModuleByName() );
module = (MODULE*) GetCurItem();
......@@ -658,9 +658,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( module->IsLocked() )
{
wxString msg;
msg.Printf( _( "Footprint %s found, but it is locked" ),
module->GetReference().GetData() );
wxString msg = wxString::Format(
_( "Footprint %s found, but it is locked" ),
module->GetReference().GetData() );
DisplayInfoMessage( this, msg );
break;
}
......@@ -719,7 +719,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
/* This is a simple rotation, no other editing in progress */
// This is a simple rotation, no other editing in progress
if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() );
......@@ -747,7 +747,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
/* This is a simple rotation, no other editing in progress */
// This is a simple rotation, no other editing in progress
if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE,
((MODULE*)GetCurItem())->GetPosition() );
......@@ -776,7 +776,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
/* This is a simple flip, no other editing in progress */
// This is a simple flip, no other editing in progress
if( !GetCurItem()->IsMoving() )
SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
......@@ -1108,14 +1108,18 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair();
{
TRACK* track = (TRACK*) GetScreen()->GetCurItem();
wxPoint pos = GetScreen()->GetCrossHairPosition();
wxPoint pos = GetCrossHairPosition();
track->Draw( m_canvas, &dc, GR_XOR );
PICKED_ITEMS_LIST itemsListPicker;
TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
track->Draw( m_canvas, &dc, GR_XOR );
newtrack->Draw( m_canvas, &dc, GR_XOR );
/* compute the new ratsnest, because connectivity could change */
// compute the new ratsnest, because connectivity could change
TestNetConnection( &dc, track->GetNet() );
}
break;
......
......@@ -147,7 +147,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE
m_canvas->Refresh();
#endif
GetScreen()->SetCrossHairPosition( aTextePcb->GetTextPosition() );
SetCrossHairPosition( aTextePcb->GetTextPosition() );
m_canvas->MoveCursorToCrossHair();
m_canvas->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text );
......@@ -156,7 +156,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE
}
/* Move PCB text following the cursor. */
// Move PCB text following the cursor.
static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
......@@ -168,7 +168,7 @@ static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aP
if( aErase )
TextePcb->Draw( aPanel, aDC, GR_XOR );
TextePcb->SetTextPosition( aPanel->GetScreen()->GetCrossHairPosition() );
TextePcb->SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() );
TextePcb->Draw( aPanel, aDC, GR_XOR );
}
......@@ -214,7 +214,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
textePcb->SetMirrored( true );
textePcb->SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize );
textePcb->SetTextPosition( GetScreen()->GetCrossHairPosition() );
textePcb->SetTextPosition( GetCrossHairPosition() );
textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth );
InstallTextPCBOptionsFrame( textePcb, aDC );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -146,8 +146,8 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
GetBoard()->ComputeBoundingBox();
// Save the auxiliary origin for the rest of the module
GencadOffsetX = GetOriginAxisPosition().x;
GencadOffsetY = GetOriginAxisPosition().y;
GencadOffsetX = GetAuxOrigin().x;
GencadOffsetY = GetAuxOrigin().y;
// No idea on *why* this should be needed... maybe to fix net names?
Compile_Ratsnest( NULL, true );
......@@ -708,8 +708,8 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
fputs( "UNITS INCH\n", aFile );
msg.Printf( wxT( "ORIGIN %g %g\n" ),
MapXTo( aFrame->GetOriginAxisPosition().x ),
MapYTo( aFrame->GetOriginAxisPosition().y ) );
MapXTo( aFrame->GetAuxOrigin().x ),
MapYTo( aFrame->GetAuxOrigin().y ) );
fputs( TO_UTF8( msg ), aFile );
fputs( "INTERTRACK 0\n", aFile );
......
This diff is collapsed.
......@@ -359,7 +359,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
MODULE* module;
char line[1024];
File_Place_Offset = GetOriginAxisPosition();
File_Place_Offset = GetAuxOrigin();
// Calculating the number of useful modules (CMS attribute, not VIRTUAL)
int moduleCount = 0;
......
......@@ -133,7 +133,7 @@ int PCB_EDIT_FRAME::SelectHighLight( wxDC* DC )
// optionally, modify the "guide" here as needed using its member functions
m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsTracksOrZones,
GetScreen()->RefPos( true ), guide );
RefPos( true ), guide );
BOARD_ITEM* item = (*m_Collector)[0];
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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