2015-12-08 18:31:57 +11:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 13:35:25 -04:00
|
|
|
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2015-12-08 18:31:57 +11:00
|
|
|
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2017-02-06 15:20:46 +01:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2015-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 18:31:57 +11:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
/**
|
|
|
|
* @file panel_prev_model.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <3d_canvas/eda_3d_canvas.h>
|
2015-12-08 18:31:57 +11:00
|
|
|
#include <common_ogl/cogl_att_list.h>
|
|
|
|
#include <cstdlib>
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2015-12-09 16:43:30 +11:00
|
|
|
#include <wx/valnum.h>
|
2016-07-19 13:35:25 -04:00
|
|
|
#include <wx/tglbtn.h>
|
2016-01-25 15:55:36 +11:00
|
|
|
|
|
|
|
#include "project.h"
|
2015-12-08 18:31:57 +11:00
|
|
|
#include "panel_prev_model.h"
|
2016-07-19 13:35:25 -04:00
|
|
|
#include <class_board.h>
|
2015-12-08 18:31:57 +11:00
|
|
|
|
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
PANEL_PREV_3D_B::PANEL_PREV_3D_B( wxWindow* aParent, S3D_CACHE* aCacheManager,
|
|
|
|
MODULE* aModuleCopy,
|
|
|
|
std::vector<S3D_INFO> *aParentInfoList ):
|
|
|
|
PANEL_PREV_3D_BASE( aParent, wxID_ANY )
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2017-02-06 15:20:46 +01:00
|
|
|
initPanel();
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
if( NULL != aCacheManager )
|
|
|
|
m_resolver = aCacheManager->GetResolver();
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
m_parentInfoList = aParentInfoList;
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
m_dummyBoard->Add( (MODULE*)aModuleCopy );
|
|
|
|
m_copyModule = aModuleCopy;
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
// Set 3d viewer configuration for preview
|
|
|
|
m_settings3Dviewer = new CINFO3D_VISU();
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
// Create the 3D canvas
|
|
|
|
m_previewPane = new EDA_3D_CANVAS( this,
|
|
|
|
COGL_ATT_LIST::GetAttributesList( true ),
|
|
|
|
m_dummyBoard,
|
|
|
|
*m_settings3Dviewer,
|
|
|
|
aCacheManager );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
m_previewPane->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler(
|
|
|
|
PANEL_PREV_3D_B::onEnterPreviewCanvas ), NULL, this );
|
|
|
|
}
|
2015-12-08 18:31:57 +11:00
|
|
|
|
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
PANEL_PREV_3D_B::~PANEL_PREV_3D_B()
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2017-02-06 15:20:46 +01:00
|
|
|
m_previewPane->Disconnect( wxEVT_ENTER_WINDOW,
|
|
|
|
wxMouseEventHandler( PANEL_PREV_3D_B::onEnterPreviewCanvas ), NULL, this );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
delete m_settings3Dviewer;
|
2016-07-19 13:35:25 -04:00
|
|
|
delete m_dummyBoard;
|
|
|
|
delete m_previewPane;
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
void PANEL_PREV_3D_B::initPanel()
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2017-02-06 15:20:46 +01:00
|
|
|
m_resolver = NULL;
|
|
|
|
currentModelFile.clear();
|
|
|
|
m_dummyBoard = new BOARD();
|
|
|
|
m_currentSelectedIdx = -1;
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
m_bpvTop->SetBitmap( KiBitmap( axis3d_top_xpm ) );
|
|
|
|
m_bpvFront->SetBitmap( KiBitmap( axis3d_front_xpm ) );
|
|
|
|
m_bpvBack->SetBitmap( KiBitmap( axis3d_back_xpm ) );
|
|
|
|
m_bpvLeft->SetBitmap( KiBitmap( axis3d_left_xpm ) );
|
|
|
|
m_bpvRight->SetBitmap( KiBitmap( axis3d_right_xpm ) );
|
|
|
|
m_bpvBottom->SetBitmap( KiBitmap( axis3d_bottom_xpm ) );
|
|
|
|
m_bpvISO->SetBitmap( KiBitmap( ortho_xpm ) );
|
|
|
|
m_bpUpdate->SetBitmap( KiBitmap( reload_xpm ) );
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
/**
|
|
|
|
* @brief checkRotation - ensure -360 < rotation < 360
|
|
|
|
* @param rot: in out parameter
|
|
|
|
*/
|
|
|
|
static void checkRotation( double& rot )
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2017-02-06 15:20:46 +01:00
|
|
|
if( rot >= 360.0 )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2017-02-06 15:20:46 +01:00
|
|
|
int n = rot / 360.0;
|
|
|
|
rot -= 360.0 * (double)n;
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
2017-02-06 15:20:46 +01:00
|
|
|
else if( rot <= -360.0 )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2017-02-06 15:20:46 +01:00
|
|
|
int n = -rot / 360.0;
|
|
|
|
rot += 360.0 * (double)n;
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
return;
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
void PANEL_PREV_3D::OnCloseWindow( wxCloseEvent &event )
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_previewPane )
|
2017-02-06 15:20:46 +01:00
|
|
|
m_previewPane->Close();
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2017-02-06 15:20:46 +01:00
|
|
|
event.Skip();
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
void PANEL_PREV_3D::SetModelDataIdx( int idx, bool aReloadPreviewModule )
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
wxASSERT( m_parentInfoList != NULL );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_parentInfoList && (idx >= 0) )
|
2016-01-24 08:37:28 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
wxASSERT( (unsigned int)idx < (*m_parentInfoList).size() );
|
2016-01-24 08:37:28 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( (unsigned int)idx < (*m_parentInfoList).size() )
|
|
|
|
{
|
|
|
|
m_currentSelectedIdx = -1; // In case that we receive events on the
|
|
|
|
// next updates, it will set first an
|
|
|
|
// invalid selection
|
|
|
|
|
|
|
|
const S3D_INFO *aModel = (const S3D_INFO *)&((*m_parentInfoList)[idx]);
|
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
xscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.x ) );
|
|
|
|
yscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.y ) );
|
|
|
|
zscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.z ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
xrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.x ) );
|
|
|
|
yrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.y ) );
|
|
|
|
zrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.z ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
switch( g_UserUnit )
|
|
|
|
{
|
|
|
|
case MILLIMETRES:
|
2016-08-05 21:30:23 +02:00
|
|
|
xoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.x * 25.4 ) );
|
|
|
|
yoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.y * 25.4 ) );
|
|
|
|
zoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.z * 25.4 ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INCHES:
|
2016-08-05 21:30:23 +02:00
|
|
|
xoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.x ) );
|
|
|
|
yoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.y ) );
|
|
|
|
zoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.z ) );
|
2016-07-19 13:35:25 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DEGREES:
|
|
|
|
case UNSCALED_UNITS:
|
|
|
|
default:
|
|
|
|
wxASSERT(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateModelName( aModel->m_Filename );
|
|
|
|
|
|
|
|
if( aReloadPreviewModule && m_previewPane )
|
|
|
|
{
|
|
|
|
updateListOnModelCopy();
|
|
|
|
|
|
|
|
m_previewPane->ReloadRequest();
|
|
|
|
m_previewPane->Request_refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_currentSelectedIdx = idx;
|
|
|
|
}
|
2016-01-24 08:37:28 +11:00
|
|
|
}
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_previewPane )
|
|
|
|
m_previewPane->SetFocus();
|
2015-12-08 18:31:57 +11:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
void PANEL_PREV_3D::ResetModelData( bool aReloadPreviewModule )
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
m_currentSelectedIdx = -1;
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
xscale->SetValue( wxString::FromDouble( 1.0 ) );
|
|
|
|
yscale->SetValue( wxString::FromDouble( 1.0 ) );
|
|
|
|
zscale->SetValue( wxString::FromDouble( 1.0 ) );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
xrot->SetValue( wxString::FromDouble( 0.0 ) );
|
|
|
|
yrot->SetValue( wxString::FromDouble( 0.0 ) );
|
|
|
|
zrot->SetValue( wxString::FromDouble( 0.0 ) );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
xoff->SetValue( wxString::FromDouble( 0.0 ) );
|
|
|
|
yoff->SetValue( wxString::FromDouble( 0.0 ) );
|
|
|
|
zoff->SetValue( wxString::FromDouble( 0.0 ) );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
// This will update the model on the preview board with the current list of 3d shapes
|
|
|
|
if( aReloadPreviewModule )
|
|
|
|
{
|
|
|
|
updateListOnModelCopy();
|
|
|
|
|
|
|
|
if( m_previewPane )
|
|
|
|
{
|
|
|
|
m_previewPane->ReloadRequest();
|
|
|
|
m_previewPane->Request_refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_previewPane )
|
|
|
|
m_previewPane->SetFocus();
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_PREV_3D::UpdateModelName( wxString const& aModelName )
|
|
|
|
{
|
|
|
|
bool newModel = false;
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
m_modelInfo.m_Filename = aModelName;
|
2016-01-25 15:55:36 +11:00
|
|
|
|
2015-12-08 18:31:57 +11:00
|
|
|
// if the model name is a directory simply clear the current model
|
|
|
|
if( aModelName.empty() || wxFileName::DirExists( aModelName ) )
|
|
|
|
{
|
|
|
|
currentModelFile.clear();
|
2016-07-19 13:35:25 -04:00
|
|
|
m_modelInfo.m_Filename.clear();
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxString newModelFile;
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
if( m_resolver )
|
|
|
|
newModelFile = m_resolver->ResolvePath( aModelName );
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-02-23 17:46:22 +11:00
|
|
|
if( !newModelFile.empty() && newModelFile.Cmp( currentModelFile ) )
|
2015-12-08 18:31:57 +11:00
|
|
|
newModel = true;
|
|
|
|
|
|
|
|
currentModelFile = newModelFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( currentModelFile.empty() || newModel )
|
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
updateListOnModelCopy();
|
|
|
|
|
|
|
|
if( m_previewPane )
|
2015-12-09 16:43:30 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
m_previewPane->ReloadRequest();
|
|
|
|
m_previewPane->Refresh();
|
2015-12-09 16:43:30 +11:00
|
|
|
}
|
2015-12-08 18:31:57 +11:00
|
|
|
|
|
|
|
if( currentModelFile.empty() )
|
|
|
|
return;
|
|
|
|
}
|
2016-01-25 15:55:36 +11:00
|
|
|
else
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_previewPane )
|
|
|
|
m_previewPane->Refresh();
|
2015-12-08 18:31:57 +11:00
|
|
|
}
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_previewPane )
|
|
|
|
m_previewPane->SetFocus();
|
2015-12-08 18:31:57 +11:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
void PANEL_PREV_3D::updateOrientation( wxCommandEvent &event )
|
2015-12-08 18:31:57 +11:00
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
wxTextCtrl *textCtrl = (wxTextCtrl *)event.GetEventObject();
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( textCtrl == NULL )
|
|
|
|
return;
|
2015-12-08 18:31:57 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( textCtrl->GetLineLength(0) == 0 ) // This will skip the got and event with empty field
|
|
|
|
return;
|
2015-12-09 10:38:25 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( textCtrl->GetLineLength(0) == 1 )
|
|
|
|
if( (textCtrl->GetLineText(0).compare( "." ) == 0) ||
|
|
|
|
(textCtrl->GetLineText(0).compare( "," ) == 0) )
|
|
|
|
return;
|
2015-12-09 10:38:25 +11:00
|
|
|
|
2015-12-09 16:43:30 +11:00
|
|
|
SGPOINT scale;
|
|
|
|
SGPOINT rotation;
|
|
|
|
SGPOINT offset;
|
|
|
|
|
|
|
|
getOrientationVars( scale, rotation, offset );
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
m_modelInfo.m_Scale = scale;
|
|
|
|
m_modelInfo.m_Offset = offset;
|
|
|
|
m_modelInfo.m_Rotation = rotation;
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
if( m_currentSelectedIdx >= 0 )
|
|
|
|
{
|
|
|
|
// This will update the parent list with the new data
|
|
|
|
(*m_parentInfoList)[m_currentSelectedIdx] = m_modelInfo;
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
// It will update the copy model in the preview board
|
|
|
|
updateListOnModelCopy();
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
// Since the OpenGL render does not need to be reloaded to update the
|
|
|
|
// shapes position, we just request to redraw again the canvas
|
|
|
|
if( m_previewPane )
|
|
|
|
m_previewPane->Refresh();
|
2015-12-09 16:43:30 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
void PANEL_PREV_3D::getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGPOINT& aOffset )
|
2015-12-09 16:43:30 +11:00
|
|
|
{
|
|
|
|
if( NULL == xscale || NULL == yscale || NULL == zscale
|
|
|
|
|| NULL == xrot || NULL == yrot || NULL == zrot
|
|
|
|
|| NULL == xoff || NULL == yoff || NULL == zoff )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
xscale->GetValue().ToDouble( &aScale.x );
|
|
|
|
yscale->GetValue().ToDouble( &aScale.y );
|
|
|
|
zscale->GetValue().ToDouble( &aScale.z );
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
xrot->GetValue().ToDouble( &aRotation.x );
|
|
|
|
yrot->GetValue().ToDouble( &aRotation.y );
|
|
|
|
zrot->GetValue().ToDouble( &aRotation.z );
|
2016-01-12 17:09:04 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
checkRotation( aRotation.x );
|
|
|
|
checkRotation( aRotation.y );
|
|
|
|
checkRotation( aRotation.z );
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
xoff->GetValue().ToDouble( &aOffset.x );
|
|
|
|
yoff->GetValue().ToDouble( &aOffset.y );
|
|
|
|
zoff->GetValue().ToDouble( &aOffset.z );
|
2015-12-09 16:43:30 +11:00
|
|
|
|
2016-07-19 13:35:25 -04:00
|
|
|
switch( g_UserUnit )
|
|
|
|
{
|
|
|
|
case MILLIMETRES:
|
|
|
|
// Convert to Inches. Offset is stored in inches.
|
|
|
|
aOffset.x = aOffset.x / 25.4;
|
|
|
|
aOffset.y = aOffset.y / 25.4;
|
|
|
|
aOffset.z = aOffset.z / 25.4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INCHES:
|
|
|
|
// It is already in Inches
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEGREES:
|
|
|
|
case UNSCALED_UNITS:
|
|
|
|
default:
|
|
|
|
wxASSERT(0);
|
|
|
|
}
|
2015-12-09 16:43:30 +11:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
|
2016-09-30 01:51:18 -04:00
|
|
|
bool PANEL_PREV_3D::ValidateWithMessage( wxString& aErrorMessage )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2016-08-05 21:30:23 +02:00
|
|
|
bool invalidScale = false;
|
|
|
|
#define MIN_SCALE 0.001
|
|
|
|
#define MAX_SCALE 1000.0
|
2016-07-19 13:35:25 -04:00
|
|
|
|
|
|
|
for( unsigned int idx = 0; idx < m_parentInfoList->size(); ++idx )
|
|
|
|
{
|
2016-08-05 21:30:23 +02:00
|
|
|
wxString msg;
|
|
|
|
bool addError = false;
|
|
|
|
S3D_INFO& s3dshape = (*m_parentInfoList)[idx];
|
|
|
|
|
|
|
|
SGPOINT scale = s3dshape.m_Scale;
|
|
|
|
|
|
|
|
if( MIN_SCALE > scale.x || MAX_SCALE < scale.x )
|
|
|
|
{
|
|
|
|
invalidScale = true;
|
|
|
|
addError = true;
|
|
|
|
msg += _( "Invalid X scale" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( MIN_SCALE > scale.y || MAX_SCALE < scale.y )
|
|
|
|
{
|
|
|
|
invalidScale = true;
|
|
|
|
addError = true;
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
msg += "\n";
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
msg += _( "Invalid Y scale" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( MIN_SCALE > scale.z || MAX_SCALE < scale.z )
|
|
|
|
{
|
|
|
|
invalidScale = true;
|
|
|
|
addError = true;
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
msg += "\n";
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
msg += _( "Invalid Z scale" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( addError )
|
|
|
|
{
|
|
|
|
msg.Prepend( s3dshape.m_Filename + "\n" );
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
if( !aErrorMessage.IsEmpty() )
|
|
|
|
aErrorMessage += "\n\n";
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
aErrorMessage += msg;
|
|
|
|
}
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
if( !aErrorMessage.IsEmpty() )
|
2016-07-19 13:35:25 -04:00
|
|
|
{
|
2016-08-05 21:30:23 +02:00
|
|
|
aErrorMessage += "\n\n";
|
|
|
|
aErrorMessage += wxString::Format( "Min value = %.4f and max value = %.4f",
|
|
|
|
MIN_SCALE, MAX_SCALE );
|
2016-07-19 13:35:25 -04:00
|
|
|
}
|
|
|
|
|
2016-08-05 21:30:23 +02:00
|
|
|
return invalidScale == false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PANEL_PREV_3D::updateListOnModelCopy()
|
|
|
|
{
|
2016-07-19 13:35:25 -04:00
|
|
|
std::list<S3D_INFO>* draw3D = &m_copyModule->Models();
|
|
|
|
draw3D->clear();
|
|
|
|
draw3D->insert( draw3D->end(), m_parentInfoList->begin(), m_parentInfoList->end() );
|
|
|
|
}
|