From 7848b2a52e27a3105cc010330444d2be5abb94df Mon Sep 17 00:00:00 2001 From: Cirilo Bernardo Date: Mon, 18 Jan 2016 16:59:06 +1100 Subject: [PATCH] Implemented new 3D searchpath configurator --- .../3d_cache/dialogs/3d_cache_dialogs.cpp | 6 +- .../3d_cache/dialogs/dialog_config_3dpath.cpp | 253 ------ .../3d_cache/dialogs/dlg_3d_pathconfig.cpp | 259 ++++++ ...og_config_3dpath.h => dlg_3d_pathconfig.h} | 43 +- .../dialogs/dlg_3d_pathconfig_base.cpp | 94 +++ .../dialogs/dlg_3d_pathconfig_base.fbp | 781 ++++++++++++++++++ .../3d_cache/dialogs/dlg_3d_pathconfig_base.h | 61 ++ 3d-viewer/CMakeLists.txt | 3 +- 8 files changed, 1216 insertions(+), 284 deletions(-) delete mode 100644 3d-viewer/3d_cache/dialogs/dialog_config_3dpath.cpp create mode 100644 3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp rename 3d-viewer/3d_cache/dialogs/{dialog_config_3dpath.h => dlg_3d_pathconfig.h} (54%) create mode 100644 3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp create mode 100644 3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp create mode 100644 3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h diff --git a/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp b/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp index b60863d344..37398660b0 100644 --- a/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp +++ b/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015 Cirilo Bernardo + * Copyright (C) 2015-2016 Cirilo Bernardo * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,7 +27,7 @@ #include "3d_cache.h" #include "plugins/3dapi/ifsg_api.h" #include "3d_cache_dialogs.h" -#include "dialog_config_3dpath.h" +#include "dlg_3d_pathconfig.h" #include "dialog_select_3dmodel.h" @@ -59,7 +59,7 @@ bool S3D::Select3DModel( wxWindow* aParent, S3D_CACHE* aCache, bool S3D::Configure3DPaths( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) { - DLG_CFG_3DPATH* dp = new DLG_CFG_3DPATH( aParent, aResolver ); + DLG_3D_PATH_CONFIG* dp = new DLG_3D_PATH_CONFIG( aParent, aResolver ); if( wxID_OK == dp->ShowModal() ) { diff --git a/3d-viewer/3d_cache/dialogs/dialog_config_3dpath.cpp b/3d-viewer/3d_cache/dialogs/dialog_config_3dpath.cpp deleted file mode 100644 index db57b297e7..0000000000 --- a/3d-viewer/3d_cache/dialogs/dialog_config_3dpath.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Cirilo Bernardo - * - * 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 -#include -#include - -#include "3d_cache.h" -#include "dialog_config_3dpath.h" - -enum -{ - btnEditPath = wxID_HIGHEST + 1, - btnAddPath, - btnDeletePath, - lbPathList -}; - - -wxBEGIN_EVENT_TABLE( DLG_CFG_3DPATH, wxDialog ) - EVT_BUTTON( btnEditPath, DLG_CFG_3DPATH::EditPath ) - EVT_BUTTON( btnAddPath, DLG_CFG_3DPATH::AddPath ) - EVT_BUTTON( btnDeletePath, DLG_CFG_3DPATH::DeletePath ) -wxEND_EVENT_TABLE() - - -DLG_CFG_3DPATH::DLG_CFG_3DPATH( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) - : wxDialog( aParent, -1, _( "3D Model Path Configuration" ), - wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxSYSTEM_MENU - | wxRESIZE_BORDER | wxMINIMIZE_BOX ) -{ - resolver = aResolver; - - Bind( wxEVT_LIST_ITEM_ACTIVATED, &DLG_CFG_3DPATH::EditPath, this, lbPathList ); - Bind( wxEVT_LIST_ITEM_SELECTED, &DLG_CFG_3DPATH::PathSelect, this, lbPathList ); - Bind( wxEVT_LIST_ITEM_DESELECTED, &DLG_CFG_3DPATH::PathSelect, this, lbPathList ); - - wxBoxSizer *vboxMain = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer *vboxSide = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* hboxTop = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* hboxBot = new wxBoxSizer( wxHORIZONTAL ); - - pathList = new wxListView( this, lbPathList, wxDefaultPosition, wxSize( 400, 200 ), - wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL ); - - pathList->AppendColumn( wxEmptyString ); - - editButton = new wxButton( this, btnEditPath, _( "Edit" ), - wxDefaultPosition, wxSize( 100, 30 ) ); - - editButton->Enable( false ); - - wxButton* addButton = new wxButton( this, btnAddPath, _( "Add" ), - wxDefaultPosition, wxSize( 100, 30 ) ); - - deleteButton = new wxButton( this, btnDeletePath, _( "Delete" ), - wxDefaultPosition, wxSize( 100, 30 ) ); - - deleteButton->Enable( false ); - - wxButton* okButton = new wxButton( this, wxID_OK, _( "Ok" ), - wxDefaultPosition, wxSize( 100, 30 ) ); - - wxButton* cancelButton = new wxButton( this, wxID_CANCEL, _( "Cancel" ), - wxDefaultPosition, wxSize( 100, 30 ) ); - - vboxSide->Add( editButton, 0, wxALL, 10 ); - vboxSide->Add( addButton, 0, wxALL, 10 ); - vboxSide->Add( deleteButton, 0, wxALL, 10 ); - - hboxTop->Add( pathList, 1, wxEXPAND | wxALL, 10 ); - hboxTop->Add( vboxSide, 0, wxEXPAND | wxALL, 10 ); - - hboxBot->Add( okButton, 0, wxALL, 10 ); - hboxBot->Add( cancelButton, 0, wxALL, 10 ); - - vboxMain->Add( hboxTop, 1, wxEXPAND | wxALL, 10 ); - vboxMain->Add( hboxBot, 0, wxEXPAND | wxALL, 10 ); - - if( resolver ) - { - const std::list< S3D_ALIAS >* pl = resolver->GetPaths(); - std::list< S3D_ALIAS >::const_iterator sL = pl->begin(); - std::list< S3D_ALIAS >::const_iterator eL = pl->end(); - - // always skip the first entry which is the current project dir - if( sL != eL ) - ++sL; - - long i = 0; - - while( sL != eL ) - { - m_paths.push_back( *sL ); - pathList->InsertItem( i, sL->m_alias ); - ++i; - ++sL; - } - - pathList->SetColumnWidth(0, wxLIST_AUTOSIZE); - } - - SetSizerAndFit( vboxMain ); - Centre(); - - return; -} - - -bool DLG_CFG_3DPATH::TransferDataFromWindow() -{ - // NOTE: This dialog is to be deprecated - - //if( resolver && resolver->UpdatePathList( m_paths ) ) - // return true; - - return false; -} - - -void DLG_CFG_3DPATH::EditPath( wxCommandEvent& event ) -{ - // NOTE: This dialog is to be deprecated - - /* - long nItem = pathList->GetFirstSelected(); - wxString tmpname = m_paths[ nItem ]; - - wxDirDialog* dd = new wxDirDialog( this, _( "Change 3D model directory" ), - m_paths[ nItem ] ); - - if( wxID_OK == dd->ShowModal() ) - { - wxFileName path( wxFileName::DirName( dd->GetPath() ) ); - path.Normalize(); - wxString newname = path.GetPath(); - - if( tmpname.Cmp( newname ) ) - { - pathList->DeleteItem( nItem ); - pathList->InsertItem( nItem, newname ); - m_paths[ nItem ] = newname; - pathList->Focus( nItem ); - editButton->Enable( false ); - deleteButton->Enable( false ); - pathList->SetColumnWidth(0, wxLIST_AUTOSIZE); - } - } - - delete dd; - */ - - return; -} - - -void DLG_CFG_3DPATH::AddPath( wxCommandEvent& event ) -{ - // NOTE: This dialog is to be deprecated - - /* - wxDirDialog* dd = new wxDirDialog( this, _( "Add a 3D model directory" ) ); - - if( wxID_OK == dd->ShowModal() ) - { - wxFileName path( wxFileName::DirName( dd->GetPath() ) ); - path.Normalize(); - wxString newname = path.GetPath(); - - m_paths.push_back( newname ); - pathList->InsertItem( pathList->GetItemCount(), *m_paths.rbegin() ); - pathList->Focus( pathList->GetItemCount() -1 ); - editButton->Enable( false ); - deleteButton->Enable( false ); - pathList->SetColumnWidth(0, wxLIST_AUTOSIZE); - } - - delete dd; - */ - - return; -} - - -void DLG_CFG_3DPATH::DeletePath( wxCommandEvent& event ) -{ - // NOTE: This dialog is to be deprecated - - /* - long nItem = pathList->GetFirstSelected(); - - if( -1 == nItem ) - return; - - m_paths.erase( m_paths.begin() + nItem ); - pathList->DeleteItem( nItem ); - - if( m_paths.size() > 0 ) - { - if( nItem > 0 ) - --nItem; - - pathList->Select( nItem ); - } - else - { - editButton->Enable( false ); - deleteButton->Enable( false ); - pathList->Select( -1 ); - } - */ - - return; -} - - -void DLG_CFG_3DPATH::PathSelect( wxCommandEvent& event ) -{ - long nItem = pathList->GetFirstSelected(); - - if( -1 == nItem ) - { - editButton->Enable( false ); - deleteButton->Enable( false ); - return; - } - - editButton->Enable( true ); - deleteButton->Enable( true ); - - return; -} diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp new file mode 100644 index 0000000000..6660c3b74e --- /dev/null +++ b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp @@ -0,0 +1,259 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2016 Cirilo Bernardo + * + * 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 "3d_cache/dialogs/dlg_3d_pathconfig.h" +#include "3d_cache/3d_filename_resolver.h" + +DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) : + DLG_3D_PATH_CONFIG_BASE( aParent ), m_resolver( aResolver ) +{ + m_Aliases->EnableEditing( true ); + + if( m_resolver ) + { + // prohibit these characters in teh alias names: []{}()%~<>"='`;:.,&?/\|$ + m_aliasValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST ); + m_aliasValidator.SetCharExcludes( wxT( "{}[]()%~<>\"='`;:.,&?/\\|$" ) ); + + const std::list< S3D_ALIAS >* rpaths = m_resolver->GetPaths(); + size_t listsize = rpaths->size(); + + if( listsize > 0 ) + m_curdir = rpaths->front().m_pathexp; + + if( listsize < 2 ) + return; + + listsize = listsize - 1 - m_Aliases->GetNumberRows(); + + // note: if the list allocation fails we have bigger problems + // and there is no point in trying to notify the user here + if( listsize > 0 && !m_Aliases->InsertRows( 0, listsize ) ) + return; + + std::list< S3D_ALIAS >::const_iterator sL = rpaths->begin(); + std::list< S3D_ALIAS >::const_iterator eL = rpaths->end(); + int nitems = 0; + + // skip the first entry which is always the current project dir + ++sL; + wxGridCellTextEditor* pEdAlias; + + while( sL != eL ) + { + m_Aliases->SetCellValue( nitems, 0, sL->m_alias ); + pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( nitems, 0 ); + pEdAlias->SetValidator( m_aliasValidator ); + pEdAlias->DecRef(); + m_Aliases->SetCellValue( nitems, 1, sL->m_pathvar ); + m_Aliases->SetCellValue( nitems++, 2, sL->m_description ); + + // TODO: implement a wxGridCellEditor which invokes a wxDirDialog + + ++sL; + } + + m_Aliases->AutoSizeColumns(); + } + + Layout(); + Fit(); + SetMinSize( GetSize() ); + + return; +} + + +bool DLG_3D_PATH_CONFIG::TransferDataFromWindow() +{ + if( NULL == m_resolver ) + return false; + + std::vector alist; + S3D_ALIAS alias; + + int ni = m_Aliases->GetNumberRows(); + + if( ni <= 0 ) + { + // note: UI usability: we should ask a user if they're sure they + // want to clear the entire path list + m_resolver->UpdatePathList( alist ); + return true; + } + + for( int i = 0; i < ni; ++i ) + { + alias.m_alias = m_Aliases->GetCellValue( i, 0 ); + alias.m_pathvar = m_Aliases->GetCellValue( i, 1 ); + alias.m_description = m_Aliases->GetCellValue( i, 2 ); + + if( !alias.m_alias.empty() && !alias.m_pathvar.empty() ) + alist.push_back( alias ); + + } + + return m_resolver->UpdatePathList( alist ); +} + + +void DLG_3D_PATH_CONFIG::OnAddAlias( wxCommandEvent& event ) +{ + int ni = m_Aliases->GetNumberRows(); + + if( m_Aliases->InsertRows( ni, 1 ) ) + { + wxGridCellTextEditor* pEdAlias; + pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( ni, 0 ); + pEdAlias->SetValidator( m_aliasValidator ); + pEdAlias->DecRef(); + m_Aliases->SelectRow( ni, false ); + + // TODO: set the editors on any newly created rows + } + + event.Skip(); + return; +} + + +void DLG_3D_PATH_CONFIG::OnDelAlias( wxCommandEvent& event ) +{ + wxArrayInt sel = m_Aliases->GetSelectedRows(); + + if( sel.empty() ) + { + wxMessageBox( _T( "No entry selected" ), _T( "Delete alias entry" ) ); + return; + } + + if( sel.size() > 1 ) + { + wxMessageBox( _T( "Multiple entries selected; please\nselect only one entry" ), + _T( "Delete alias entry" ) ); + return; + } + + if( m_Aliases->GetNumberRows() > 1 ) + { + int ni = sel.front(); + m_Aliases->DeleteRows( ni, 1 ); + + if( ni >= m_Aliases->GetNumberRows() ) + ni = m_Aliases->GetNumberRows() - 1; + + m_Aliases->SelectRow( ni, false ); + } + else + { + m_Aliases->SetCellValue( 0, 0, wxEmptyString ); + m_Aliases->SetCellValue( 0, 1, wxEmptyString ); + m_Aliases->SetCellValue( 0, 2, wxEmptyString ); + } + + event.Skip(); +} + + +void DLG_3D_PATH_CONFIG::OnAliasMoveUp( wxCommandEvent& event ) +{ + wxArrayInt sel = m_Aliases->GetSelectedRows(); + + if( sel.empty() ) + { + wxMessageBox( _T( "No entry selected" ), _T( "Move alias up" ) ); + return; + } + + if( sel.size() > 1 ) + { + wxMessageBox( _T( "Multiple entries selected; please\nselect only one entry" ), + _T( "Move alias up" ) ); + return; + } + + int ci = sel.front(); + + if( ci > 0 ) + { + S3D_ALIAS al0; + al0.m_alias = m_Aliases->GetCellValue( ci, 0 ); + al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 ); + al0.m_description = m_Aliases->GetCellValue( ci, 2 ); + + int ni = ci - 1; + m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) ); + m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) ); + m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) ); + + m_Aliases->SetCellValue( ni, 0, al0.m_alias ); + m_Aliases->SetCellValue( ni, 1, al0.m_pathvar ); + m_Aliases->SetCellValue( ni, 2, al0.m_description ); + m_Aliases->SelectRow( ni, false ); + } + + event.Skip(); +} + + +void DLG_3D_PATH_CONFIG::OnAliasMoveDown( wxCommandEvent& event ) +{ + wxArrayInt sel = m_Aliases->GetSelectedRows(); + + if( sel.empty() ) + { + wxMessageBox( _T( "No entry selected" ), _T( "Move alias down" ) ); + return; + } + + if( sel.size() > 1 ) + { + wxMessageBox( _T( "Multiple entries selected; please\nselect only one entry" ), + _T( "Move alias down" ) ); + return; + } + + int ni = m_Aliases->GetNumberRows() - 1; + int ci = sel.front(); + + if( ci < ni ) + { + S3D_ALIAS al0; + al0.m_alias = m_Aliases->GetCellValue( ci, 0 ); + al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 ); + al0.m_description = m_Aliases->GetCellValue( ci, 2 ); + + ni = ci + 1; + m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) ); + m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) ); + m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) ); + + m_Aliases->SetCellValue( ni, 0, al0.m_alias ); + m_Aliases->SetCellValue( ni, 1, al0.m_pathvar ); + m_Aliases->SetCellValue( ni, 2, al0.m_description ); + m_Aliases->SelectRow( ni, false ); + } + + event.Skip(); +} diff --git a/3d-viewer/3d_cache/dialogs/dialog_config_3dpath.h b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h similarity index 54% rename from 3d-viewer/3d_cache/dialogs/dialog_config_3dpath.h rename to 3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h index e47baa4365..74e5491424 100644 --- a/3d-viewer/3d_cache/dialogs/dialog_config_3dpath.h +++ b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015 Cirilo Bernardo + * Copyright (C) 2016 Cirilo Bernardo * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,41 +21,30 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file dialog_config_3dpath.h - * creates a dialog to edit the default search paths for 3D model files. - */ -#ifndef DIALOG_CONFIG_3DPATH_H -#define DIALOG_CONFIG_3DPATH_H +#ifndef DLG_3D_PATHCONFIG_H +#define DLG_3D_PATHCONFIG_H -#include -#include -#include +#include +#include "dlg_3d_pathconfig_base.h" class S3D_FILENAME_RESOLVER; -class DLG_CFG_3DPATH : public wxDialog +class DLG_3D_PATH_CONFIG : public DLG_3D_PATH_CONFIG_BASE { private: - wxListView* pathList; - wxButton* editButton; - wxButton* deleteButton; + S3D_FILENAME_RESOLVER* m_resolver; + wxString m_curdir; + wxTextValidator m_aliasValidator; - S3D_FILENAME_RESOLVER* resolver; - std::vector< S3D_ALIAS > m_paths; + void OnAddAlias( wxCommandEvent& event ); + void OnDelAlias( wxCommandEvent& event ); + void OnAliasMoveUp( wxCommandEvent& event ); + void OnAliasMoveDown( wxCommandEvent& event ); public: - DLG_CFG_3DPATH( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ); - virtual bool TransferDataFromWindow(); - -private: - void EditPath( wxCommandEvent& event ); - void AddPath( wxCommandEvent& event ); - void DeletePath( wxCommandEvent& event ); - void PathSelect( wxCommandEvent& event ); - - wxDECLARE_EVENT_TABLE(); + DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ); + bool TransferDataFromWindow(); }; -#endif // DIALOG_CONFIG_3DPATH_H +#endif // DLG_3D_PATHCONFIG_H diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp new file mode 100644 index 0000000000..a81e45db31 --- /dev/null +++ b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp @@ -0,0 +1,94 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 5 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dlg_3d_pathconfig_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizer1; + bSizer1 = new wxBoxSizer( wxVERTICAL ); + + m_Aliases = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_Aliases->CreateGrid( 1, 3 ); + m_Aliases->EnableEditing( true ); + m_Aliases->EnableGridLines( true ); + m_Aliases->EnableDragGridSize( false ); + m_Aliases->SetMargins( 0, 0 ); + + // Columns + m_Aliases->AutoSizeColumns(); + m_Aliases->EnableDragColMove( false ); + m_Aliases->EnableDragColSize( true ); + m_Aliases->SetColLabelSize( 30 ); + m_Aliases->SetColLabelValue( 0, _("Alias") ); + m_Aliases->SetColLabelValue( 1, _("Path") ); + m_Aliases->SetColLabelValue( 2, _("Description") ); + m_Aliases->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Rows + m_Aliases->EnableDragRowSize( true ); + m_Aliases->SetRowLabelSize( 80 ); + m_Aliases->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Label Appearance + + // Cell Defaults + m_Aliases->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + bSizer1->Add( m_Aliases, 0, wxALL, 5 ); + + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxHORIZONTAL ); + + m_btnAddAlias = new wxButton( this, wxID_ANY, _("Add Alias"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_btnAddAlias, 0, wxALL, 5 ); + + m_btnDelAlias = new wxButton( this, wxID_ANY, _("Remove Alias"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_btnDelAlias, 0, wxALL, 5 ); + + m_btnMoveUp = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_btnMoveUp, 0, wxALL, 5 ); + + m_btnMoveDown = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_btnMoveDown, 0, wxALL, 5 ); + + m_btnOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_btnOK, 0, wxALL, 5 ); + + m_btnCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_btnCancel, 0, wxALL, 5 ); + + + bSizer1->Add( bSizer2, 1, wxEXPAND, 5 ); + + + this->SetSizer( bSizer1 ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + m_btnAddAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this ); + m_btnDelAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this ); + m_btnMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this ); + m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this ); +} + +DLG_3D_PATH_CONFIG_BASE::~DLG_3D_PATH_CONFIG_BASE() +{ + // Disconnect Events + m_btnAddAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this ); + m_btnDelAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this ); + m_btnMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this ); + m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this ); + +} diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp new file mode 100644 index 0000000000..f3eeec9b47 --- /dev/null +++ b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp @@ -0,0 +1,781 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dlg_3d_pathconfig_base + 1000 + none + 1 + MyProject1 + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DLG_3D_PATH_CONFIG_BASE + + 593,300 + wxDEFAULT_FRAME_STYLE + DIALOG_SHIM; dialog_shim.h + 3D Search Path Configuration + + + + wxTAB_TRAVERSAL + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer1 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTRE + 30 + "Alias" "Path" "Description" + wxALIGN_CENTRE + 3 + + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + m_Aliases + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTRE + 80 + + wxALIGN_CENTRE + + 1 + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer2 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Add Alias + + 0 + + + 0 + + 1 + m_btnAddAlias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddAlias + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Remove Alias + + 0 + + + 0 + + 1 + m_btnDelAlias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDelAlias + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move Up + + 0 + + + 0 + + 1 + m_btnMoveUp + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAliasMoveUp + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move Down + + 0 + + + 0 + + 1 + m_btnMoveDown + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAliasMoveDown + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_OK + OK + + 0 + + + 0 + + 1 + m_btnOK + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Cancel + + 0 + + + 0 + + 1 + m_btnCancel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h new file mode 100644 index 0000000000..b5ccf3e880 --- /dev/null +++ b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h @@ -0,0 +1,61 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 5 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DLG_3D_PATHCONFIG_BASE_H__ +#define __DLG_3D_PATHCONFIG_BASE_H__ + +#include +#include +#include +class DIALOG_SHIM; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DLG_3D_PATH_CONFIG_BASE +/////////////////////////////////////////////////////////////////////////////// +class DLG_3D_PATH_CONFIG_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxGrid* m_Aliases; + wxButton* m_btnAddAlias; + wxButton* m_btnDelAlias; + wxButton* m_btnMoveUp; + wxButton* m_btnMoveDown; + wxButton* m_btnOK; + wxButton* m_btnCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnAddAlias( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDelAlias( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAliasMoveUp( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAliasMoveDown( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("3D Search Path Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 593,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + + ~DLG_3D_PATH_CONFIG_BASE(); + +}; + +#endif //__DLG_3D_PATHCONFIG_BASE_H__ diff --git a/3d-viewer/CMakeLists.txt b/3d-viewer/CMakeLists.txt index 4b86bf1a3c..bdd1b32094 100644 --- a/3d-viewer/CMakeLists.txt +++ b/3d-viewer/CMakeLists.txt @@ -54,7 +54,8 @@ set(3D-VIEWER_SRCS 3d_cache/3d_plugin_manager.cpp 3d_cache/3d_filename_resolver.cpp ${DIR_DLG}/3d_cache_dialogs.cpp - ${DIR_DLG}/dialog_config_3dpath.cpp + ${DIR_DLG}/dlg_3d_pathconfig_base.cpp + ${DIR_DLG}/dlg_3d_pathconfig.cpp ${DIR_DLG}/dialog_select_3dmodel.cpp ${DIR_DLG}/panel_prev_model.cpp 3d_model_viewer/c3d_model_viewer.cpp