From 0ee7234cf9704b2a8477da07ee20befdfa4b0a0b Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 30 Oct 2011 00:02:23 -0500 Subject: [PATCH] sweet editor work --- new/CMakeLists.txt | 13 ++---- new/sch_canvas.cpp | 87 ++++++++++++++++++++++++++++++++++++++ new/sch_canvas.h | 67 +++++++++++++++++++++++++++++ new/sch_part.cpp | 2 +- new/sch_part.h | 4 +- new/sch_sweet_parser.cpp | 2 +- new/sweet_editor_panel.cpp | 2 +- new/sweet_editor_panel.fbp | 8 ++-- new/sweet_editor_panel.h | 4 +- 9 files changed, 169 insertions(+), 20 deletions(-) create mode 100644 new/sch_canvas.cpp create mode 100644 new/sch_canvas.h diff --git a/new/CMakeLists.txt b/new/CMakeLists.txt index 7d5c1d912c..9843b90215 100644 --- a/new/CMakeLists.txt +++ b/new/CMakeLists.txt @@ -42,9 +42,9 @@ if( 1 ) # On Apple only wxwidgets 2.9 or higher doesn't need to find aui part of base if(APPLE) - find_package(wxWidgets COMPONENTS gl adv html core net base xml QUIET) + find_package(wxWidgets COMPONENTS gl adv html core net base xml QUIET ) else() - find_package(wxWidgets COMPONENTS gl aui adv html core net base xml QUIET) + find_package(wxWidgets COMPONENTS gl adv html core net base xml aui QUIET ) endif() check_find_package_result( wxWidgets_FOUND "wxWidgets" ) @@ -168,12 +168,7 @@ if( MINGW ) endif() target_link_libraries( test_sch_lib_table sweet ) - -include_directories ("${gal_ROOT}/gal/cairo") -include_directories( "${gal_ROOT}/gal/common" ) -include_directories ("${gal_ROOT}/gal/font") -include_directories ("${gal_ROOT}/gal/opengl") -include_directories ("${gal_ROOT}/math") +include_directories ( "${gal_ROOT}" ) # Find pkg-config in order find cairo. find_package( PkgConfig REQUIRED ) @@ -192,7 +187,7 @@ include_directories( ${GLEW_INCLUDE_DIRS} ) include_directories( ${gal_ROOT} ) -add_executable( sweet_edit sweet_edit.cpp sweet_editor_panel.cpp ) +add_executable( sweet_edit sweet_edit.cpp sweet_editor_panel.cpp sch_canvas.cpp ) target_link_libraries( sweet_edit ${OPENGL_LIBRARIES} diff --git a/new/sch_canvas.cpp b/new/sch_canvas.cpp new file mode 100644 index 0000000000..2c6ae6c64e --- /dev/null +++ b/new/sch_canvas.cpp @@ -0,0 +1,87 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2011 Kicad Developers, see change_log.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 + */ + + +#include "sch_canvas.h" + +#include "sch_part.h" + +namespace SCH { + + +CANVAS::CANVAS( wxWindow* aParent ) : + OPENGL_GAL( aParent, wxDefaultSize ) +{ + // Set the world unit length + SetWorldUnitLength( 0.01 ); + + SetScreenDPI( 100 ); + + // SetLookAtPoint( VECTOR2D( size.x / 2, size.y / 2 ) ); + + ComputeWorldScreenMatrix(); + +/* + // Compute the world size + m_worldSize = VECTOR2D( m_screenSize.x, m_screenSize.y ); + + m_isReady = true; + m_isPanning = false; + m_isGroupStarted = true; + + m_offset = 0.333; + + // Load Font + if( !m_font.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ) ) + { + cout << "Loading of the font failed." << endl; + } + + m_font.SetGraphicsAbstractionLayer( this ); +*/ +} + + +void CANVAS::Paint() +{ +/* + BeginDrawing(); + + SetBackgroundColor( COLOR4D( 0, 0, 0, 1.0 ) ); + + ClearScreen(); + + SetLayerDepth( -10 ); + SetGridSize( VECTOR2D( 50, 50 ) ); + DrawGrid(); + + SetLayerDepth( 0 ); + + Flush(); + EndDrawing(); +*/ +} + + +} // namespace SCH diff --git a/new/sch_canvas.h b/new/sch_canvas.h new file mode 100644 index 0000000000..38484259d9 --- /dev/null +++ b/new/sch_canvas.h @@ -0,0 +1,67 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2011 Kicad Developers, see change_log.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 SCH_CANVAS_H_ +#define SCH_CANVAS_H_ + +#include + + +namespace SCH { + +class PART; + +class CANVAS : public OPENGL_GAL +{ + +protected: + PART* part; ///< which PART to draw + + +public: + CANVAS( wxWindow* aParent ); + + /** + * Function Paint (overloaded) + * redraws the entire window, overloads OPENGL_GAL::Paint() + */ + void Paint(); + + /** + * Function SetPart + * sets the PART to draw, returns the previous PART. + */ + PART* SetPart( PART* aPart ) + { + PART* ret = part; + part = aPart; + return ret; + } +}; + + +} // namespace SCH + +#endif // SCH_PART_H_ + diff --git a/new/sch_part.cpp b/new/sch_part.cpp index 7f1854f74f..d63f0d8606 100644 --- a/new/sch_part.cpp +++ b/new/sch_part.cpp @@ -293,7 +293,7 @@ void PART::Parse( SWEET_PARSER* aParser , LIB_TABLE* aTable ) throw( IO_ERROR, P } -bool PART::PropertyDelete( const wxString& aPropertyName ) +bool PART::PropDelete( const wxString& aPropertyName ) { PROPERTIES::iterator it = propertyFind( aPropertyName ); if( it != properties.end() ) diff --git a/new/sch_part.h b/new/sch_part.h index 41483d12d8..216d214cbd 100644 --- a/new/sch_part.h +++ b/new/sch_part.h @@ -729,11 +729,11 @@ public: throw( IO_ERROR ); /** - * Function PropertyDelete + * Function PropDelete * deletes the property with aPropertyName if found and returns true, else false * if not found. */ - bool PropertyDelete( const wxString& aPropertyName ); + bool PropDelete( const wxString& aPropertyName ); /** * Function Field diff --git a/new/sch_sweet_parser.cpp b/new/sch_sweet_parser.cpp index 588db881c2..8fcf0efc52 100644 --- a/new/sch_sweet_parser.cpp +++ b/new/sch_sweet_parser.cpp @@ -992,7 +992,7 @@ void SWEET_PARSER::parsePropertyDel( PART* me ) wxString propertyName = FromUTF8(); - if( !me->PropertyDelete( propertyName ) ) + if( !me->PropDelete( propertyName ) ) { wxString msg; msg.Printf( _( "Unable to find property: %s" ), propertyName.GetData() ); diff --git a/new/sweet_editor_panel.cpp b/new/sweet_editor_panel.cpp index 86cfced17e..14f90152ff 100644 --- a/new/sweet_editor_panel.cpp +++ b/new/sweet_editor_panel.cpp @@ -41,7 +41,7 @@ SWEET_EDITOR_PANEL::SWEET_EDITOR_PANEL( wxWindow* parent, wxWindowID id, const w wxStaticBoxSizer* m_gal_sizer; m_gal_sizer = new wxStaticBoxSizer( new wxStaticBox( m_gal_scrolled_window, wxID_ANY, _("Visual Part") ), wxVERTICAL ); - m_gal = new OPENGL_GAL( m_gal_scrolled_window, size ); + m_gal = new SCH::CANVAS( m_gal_scrolled_window ); m_gal_sizer->Add( m_gal, 0, wxALL, 5 ); m_gal_scrolled_window->SetSizer( m_gal_sizer ); diff --git a/new/sweet_editor_panel.fbp b/new/sweet_editor_panel.fbp index 899e0e26ee..1e378a11f8 100644 --- a/new/sweet_editor_panel.fbp +++ b/new/sweet_editor_panel.fbp @@ -668,12 +668,12 @@ 1 0 - OPENGL_GAL + SCH::CANVAS 1 - m_gal = new OPENGL_GAL( m_gal_scrolled_window, size ); + m_gal = new SCH::CANVAS( m_gal_scrolled_window ); 1 - OPENGL_GAL* m_gal; + SCH::CANVAS* m_gal; 0 Dock 0 @@ -685,7 +685,7 @@ 0 0 wxID_ANY - #include <opengl_gal.h> + #include <sch_canvas.h> 0 diff --git a/new/sweet_editor_panel.h b/new/sweet_editor_panel.h index 4c98756b77..37033f8ec8 100644 --- a/new/sweet_editor_panel.h +++ b/new/sweet_editor_panel.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ class SWEET_EDITOR_PANEL : public wxPanel wxScrolledWindow* m_scrolledTextWindow; wxTextCtrl* m_sweet_scroll_window; wxScrolledWindow* m_gal_scrolled_window; - OPENGL_GAL* m_gal; + SCH::CANVAS* m_gal; wxScrolledWindow* m_scrolledWindow3; wxHtmlWindow* m_htmlWin2;