49 changed files with 657 additions and 696 deletions
-
8common/CMakeLists.txt
-
20common/dialogs/dialog_page_settings.cpp
-
4common/dialogs/dialog_page_settings.h
-
2common/page_layout/page_layout_default_description.cpp
-
80common/page_layout/page_layout_reader.cpp
-
108common/page_layout/ws_data_item.cpp
-
65common/page_layout/ws_data_model.cpp
-
44common/page_layout/ws_draw_item.cpp
-
20common/page_layout/ws_painter.cpp
-
20common/page_layout/ws_view_item.cpp
-
6common/plotters/common_plot_functions.cpp
-
2eeschema/dialogs/dialog_plot_schematic.cpp
-
15eeschema/eeschema_config.cpp
-
10eeschema/files-io.cpp
-
2eeschema/sch_draw_panel.cpp
-
2eeschema/sch_preview_panel.cpp
-
4eeschema/sch_view.cpp
-
6eeschema/sch_view.h
-
4gerbview/gerbview_draw_panel_gal.cpp
-
8gerbview/gerbview_draw_panel_gal.h
-
2gerbview/gerbview_frame.cpp
-
26include/ws_data_item.h
-
193include/ws_data_model.h
-
252include/ws_draw_item.h
-
16include/ws_painter.h
-
18include/ws_view_item.h
-
30pagelayout_editor/dialogs/dialog_new_dataitem.cpp
-
2pagelayout_editor/dialogs/dialogs_for_printing.cpp
-
22pagelayout_editor/files.cpp
-
1pagelayout_editor/hotkeys.cpp
-
4pagelayout_editor/invoke_pl_editor_dialog.h
-
121pagelayout_editor/page_layout_writer.cpp
-
10pagelayout_editor/pl_draw_panel_gal.cpp
-
6pagelayout_editor/pl_draw_panel_gal.h
-
42pagelayout_editor/pl_editor_frame.cpp
-
4pagelayout_editor/pl_editor_frame.h
-
8pagelayout_editor/pl_editor_screen.h
-
10pagelayout_editor/pl_editor_undo_redo.cpp
-
82pagelayout_editor/properties_frame.cpp
-
6pagelayout_editor/properties_frame.h
-
16pagelayout_editor/tools/pl_drawing_tools.cpp
-
8pagelayout_editor/tools/pl_edit_tool.cpp
-
4pagelayout_editor/tools/pl_editor_control.cpp
-
10pagelayout_editor/tools/pl_selection_tool.cpp
-
2pcbnew/class_board.cpp
-
4pcbnew/pcb_draw_panel_gal.cpp
-
6pcbnew/pcb_draw_panel_gal.h
-
6pcbnew/pcb_edit_frame.cpp
-
12pcbnew/pcbnew_config.cpp
@ -0,0 +1,193 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef WS_DATA_MODEL_H |
|||
#define WS_DATA_MODEL_H |
|||
|
|||
#include <math/vector2d.h> |
|||
#include <eda_text.h> |
|||
#include <eda_text.h> |
|||
#include <bitmap_base.h> |
|||
#include <ws_data_item.h> |
|||
|
|||
|
|||
|
|||
/** |
|||
* WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block |
|||
*/ |
|||
class WS_DATA_MODEL |
|||
{ |
|||
std::vector <WS_DATA_ITEM*> m_list; |
|||
bool m_allowVoidList; // If false, the default page layout |
|||
// will be loaded the first time |
|||
// WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList |
|||
// is run (useful mainly for page layout editor) |
|||
double m_leftMargin; // the left page margin in mm |
|||
double m_rightMargin; // the right page margin in mm |
|||
double m_topMargin; // the top page margin in mm |
|||
double m_bottomMargin; // the bottom page margin in mm |
|||
|
|||
public: |
|||
WS_DATA_MODEL(); |
|||
~WS_DATA_MODEL() {ClearList(); } |
|||
|
|||
/** |
|||
* static function: returns the instance of WS_DATA_MODEL used in the application |
|||
*/ |
|||
static WS_DATA_MODEL& GetTheInstance(); |
|||
|
|||
/** |
|||
* static function: Set an alternate instance of WS_DATA_MODEL |
|||
* mainly used in page setting dialog |
|||
* @param aLayout = the alternate page layout; if null restore the basic page layout |
|||
*/ |
|||
static void SetAltInstance( WS_DATA_MODEL* aLayout = NULL ); |
|||
|
|||
// Accessors: |
|||
double GetLeftMargin() { return m_leftMargin; } |
|||
double GetRightMargin() { return m_rightMargin; } |
|||
double GetTopMargin() { return m_topMargin; } |
|||
double GetBottomMargin() { return m_bottomMargin; } |
|||
|
|||
void SetLeftMargin( double aMargin ); |
|||
void SetRightMargin( double aMargin ); |
|||
void SetTopMargin( double aMargin ); |
|||
void SetBottomMargin( double aMargin ); |
|||
|
|||
/** |
|||
* In Kicad applications, a page layout description is needed |
|||
* So if the list is empty, a default description is loaded, |
|||
* the first time a page layout is drawn. |
|||
* However, in page layout editor, an empty list is acceptable. |
|||
* AllowVoidList allows or not the empty list |
|||
*/ |
|||
void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; } |
|||
|
|||
/** |
|||
* @return true if an empty list is allowed |
|||
* (mainly allowed for page layout editor). |
|||
*/ |
|||
bool VoidListAllowed() { return m_allowVoidList; } |
|||
|
|||
/** |
|||
* erase the list of items |
|||
*/ |
|||
void ClearList(); |
|||
|
|||
/** |
|||
* Save the description in a file |
|||
* @param aFullFileName the filename of the file to created |
|||
*/ |
|||
void Save( const wxString& aFullFileName ); |
|||
|
|||
/** |
|||
* Save the description in a buffer |
|||
* @param aOutputString = a wxString to store the S expr string |
|||
*/ |
|||
void SaveInString( wxString& aOutputString ); |
|||
|
|||
void Append( WS_DATA_ITEM* aItem ); |
|||
void Remove( WS_DATA_ITEM* aItem ); |
|||
|
|||
/** |
|||
* @return the index of aItem, or -1 if does not exist |
|||
*/ |
|||
int GetItemIndex( WS_DATA_ITEM* aItem ) const; |
|||
|
|||
/** |
|||
* @return the item from its index aIdx, or NULL if does not exist |
|||
*/ |
|||
WS_DATA_ITEM* GetItem( unsigned aIdx ) const; |
|||
|
|||
/** |
|||
* @return a reference to the items. |
|||
*/ |
|||
std::vector<WS_DATA_ITEM*>& GetItems() { return m_list; } |
|||
|
|||
/** |
|||
* @return the item count |
|||
*/ |
|||
unsigned GetCount() const { return m_list.size(); } |
|||
|
|||
void SetDefaultLayout(); |
|||
void SetEmptyLayout(); |
|||
|
|||
/** |
|||
* Returns a string containing the empty layout shape |
|||
*/ |
|||
static wxString EmptyLayout(); |
|||
|
|||
/** |
|||
* Returns a string containing the empty layout shape |
|||
*/ |
|||
static wxString DefaultLayout(); |
|||
|
|||
/** |
|||
* Populates the list with a custom layout, or |
|||
* the default layout, if no custom layout available |
|||
* @param aFullFileName = the custom page layout description file. |
|||
* if empty, loads the file defined by KICAD_WKSFILE |
|||
* and if its is not defined, uses the default internal description |
|||
* @param Append = if true: do not delete old layout, and load only |
|||
aFullFileName. |
|||
*/ |
|||
void SetPageLayout( const wxString& aFullFileName = wxEmptyString, bool Append = false ); |
|||
|
|||
/** |
|||
* Populates the list from a S expr description stored in a string |
|||
* @param aPageLayout = the S expr string |
|||
* @param aAppend Do not delete old layout if true and append \a aPageLayout |
|||
* the existing one. |
|||
@param aSource is the layout source description. |
|||
*/ |
|||
void SetPageLayout( const char* aPageLayout, bool aAppend = false, |
|||
const wxString& aSource = wxT( "Sexpr_string" ) ); |
|||
|
|||
/** |
|||
* @return a short filename from a full filename: |
|||
* if the path is the current project path, or if the path |
|||
* is the same as kicad.pro (in template), returns the shortname |
|||
* else do nothing and returns a full filename |
|||
* @param aFullFileName = the full filename, which can be a relative |
|||
* @param aProjectPath = the curr project absolute path (can be empty) |
|||
*/ |
|||
static const wxString MakeShortFileName( const wxString& aFullFileName, |
|||
const wxString& aProjectPath ); |
|||
|
|||
/** |
|||
* Static function |
|||
* @return a full filename from a short filename. |
|||
* @param aShortFileName = the short filename, which can be a relative |
|||
* @param aProjectPath = the curr project absolute path (can be empty) |
|||
* or absolute path, and can include env variable reference ( ${envvar} expression ) |
|||
* if the short filename path is relative, it is expected relative to the project path |
|||
* or (if aProjectPath is empty or if the file does not exist) |
|||
* relative to kicad.pro (in template) |
|||
* If aShortFileName is absolute return aShortFileName |
|||
*/ |
|||
static const wxString MakeFullFileName( const wxString& aShortFileName, |
|||
const wxString& aProjectPath ); |
|||
}; |
|||
|
|||
#endif // WS_DATA_MODEL_H |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue