2013-08-09 06:57:18 +02:00
# include "lc_global.h"
# include <stdio.h>
# include "lc_application.h"
# include "lc_library.h"
# include "lc_profile.h"
# include "project.h"
2013-08-16 03:25:51 +02:00
# include "lc_mainwindow.h"
2017-12-11 03:12:31 +01:00
# include "lc_qpreferencesdialog.h"
2017-11-25 03:19:29 +01:00
# include "lc_partselectionwidget.h"
2013-08-09 06:57:18 +02:00
# include "lc_shortcuts.h"
2020-12-25 19:43:22 +01:00
# include "lc_view.h"
2020-12-16 03:47:58 +01:00
# include "camera.h"
2020-10-03 12:02:27 +02:00
# include "lc_previewwidget.h"
2013-08-09 06:57:18 +02:00
2017-12-03 04:42:42 +01:00
lcApplication * gApplication ;
2013-08-09 06:57:18 +02:00
2014-02-10 01:13:41 +01:00
void lcPreferences : : LoadDefaults ( )
{
2014-10-05 07:21:51 +02:00
mFixedAxes = lcGetProfileInt ( LC_PROFILE_FIXED_AXES ) ;
2014-02-10 01:13:41 +01:00
mMouseSensitivity = lcGetProfileInt ( LC_PROFILE_MOUSE_SENSITIVITY ) ;
2020-03-22 21:44:20 +01:00
mShadingMode = static_cast < lcShadingMode > ( lcGetProfileInt ( LC_PROFILE_SHADING_MODE ) ) ;
2020-11-26 20:51:50 +01:00
mBackgroundGradient = lcGetProfileInt ( LC_PROFILE_BACKGROUND_GRADIENT ) ;
mBackgroundSolidColor = lcGetProfileInt ( LC_PROFILE_BACKGROUND_COLOR ) ;
mBackgroundGradientColorTop = lcGetProfileInt ( LC_PROFILE_GRADIENT_COLOR_TOP ) ;
mBackgroundGradientColorBottom = lcGetProfileInt ( LC_PROFILE_GRADIENT_COLOR_BOTTOM ) ;
2014-02-10 01:13:41 +01:00
mDrawAxes = lcGetProfileInt ( LC_PROFILE_DRAW_AXES ) ;
2020-07-11 19:47:52 +02:00
mAxesColor = lcGetProfileInt ( LC_PROFILE_AXES_COLOR ) ;
2020-12-30 22:44:08 +01:00
mTextColor = lcGetProfileInt ( LC_PROFILE_TEXT_COLOR ) ;
2020-07-11 19:47:52 +02:00
mOverlayColor = lcGetProfileInt ( LC_PROFILE_OVERLAY_COLOR ) ;
2020-07-25 22:21:22 +02:00
mActiveViewColor = lcGetProfileInt ( LC_PROFILE_ACTIVE_VIEW_COLOR ) ;
2020-12-12 03:01:04 +01:00
mInactiveViewColor = lcGetProfileInt ( LC_PROFILE_INACTIVE_VIEW_COLOR ) ;
2014-02-10 01:13:41 +01:00
mDrawEdgeLines = lcGetProfileInt ( LC_PROFILE_DRAW_EDGE_LINES ) ;
mLineWidth = lcGetProfileFloat ( LC_PROFILE_LINE_WIDTH ) ;
2019-11-28 22:52:06 +01:00
mAllowLOD = lcGetProfileInt ( LC_PROFILE_ALLOW_LOD ) ;
2020-08-16 01:16:26 +02:00
mMeshLODDistance = lcGetProfileFloat ( LC_PROFILE_LOD_DISTANCE ) ;
2020-01-02 02:06:17 +01:00
mFadeSteps = lcGetProfileInt ( LC_PROFILE_FADE_STEPS ) ;
2020-04-25 21:16:37 +02:00
mFadeStepsColor = lcGetProfileInt ( LC_PROFILE_FADE_STEPS_COLOR ) ;
2020-04-25 20:36:28 +02:00
mHighlightNewParts = lcGetProfileInt ( LC_PROFILE_HIGHLIGHT_NEW_PARTS ) ;
mHighlightNewPartsColor = lcGetProfileInt ( LC_PROFILE_HIGHLIGHT_NEW_PARTS_COLOR ) ;
2014-02-10 01:13:41 +01:00
mDrawGridStuds = lcGetProfileInt ( LC_PROFILE_GRID_STUDS ) ;
mGridStudColor = lcGetProfileInt ( LC_PROFILE_GRID_STUD_COLOR ) ;
mDrawGridLines = lcGetProfileInt ( LC_PROFILE_GRID_LINES ) ;
mGridLineSpacing = lcGetProfileInt ( LC_PROFILE_GRID_LINE_SPACING ) ;
mGridLineColor = lcGetProfileInt ( LC_PROFILE_GRID_LINE_COLOR ) ;
2020-01-05 20:38:24 +01:00
mViewSphereEnabled = lcGetProfileInt ( LC_PROFILE_VIEW_SPHERE_ENABLED ) ;
2020-03-22 21:44:20 +01:00
mViewSphereLocation = static_cast < lcViewSphereLocation > ( lcGetProfileInt ( LC_PROFILE_VIEW_SPHERE_LOCATION ) ) ;
2018-10-29 01:59:01 +01:00
mViewSphereSize = lcGetProfileInt ( LC_PROFILE_VIEW_SPHERE_SIZE ) ;
2019-01-20 20:59:18 +01:00
mViewSphereColor = lcGetProfileInt ( LC_PROFILE_VIEW_SPHERE_COLOR ) ;
mViewSphereTextColor = lcGetProfileInt ( LC_PROFILE_VIEW_SPHERE_TEXT_COLOR ) ;
mViewSphereHighlightColor = lcGetProfileInt ( LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR ) ;
2019-03-10 01:38:54 +01:00
mAutoLoadMostRecent = lcGetProfileInt ( LC_PROFILE_AUTOLOAD_MOSTRECENT ) ;
2020-01-02 02:06:17 +01:00
mRestoreTabLayout = lcGetProfileInt ( LC_PROFILE_RESTORE_TAB_LAYOUT ) ;
2020-07-25 22:21:22 +02:00
mColorTheme = static_cast < lcColorTheme > ( lcGetProfileInt ( LC_PROFILE_COLOR_THEME ) ) ;
2020-10-03 12:02:27 +02:00
mPreviewViewSphereEnabled = lcGetProfileInt ( LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED ) ;
mPreviewViewSphereSize = lcGetProfileInt ( LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE ) ;
mPreviewViewSphereLocation = static_cast < lcViewSphereLocation > ( lcGetProfileInt ( LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION ) ) ;
mDrawPreviewAxis = lcGetProfileInt ( LC_PROFILE_PREVIEW_DRAW_AXES ) ;
2014-02-10 01:13:41 +01:00
}
void lcPreferences : : SaveDefaults ( )
{
2014-10-05 07:21:51 +02:00
lcSetProfileInt ( LC_PROFILE_FIXED_AXES , mFixedAxes ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileInt ( LC_PROFILE_MOUSE_SENSITIVITY , mMouseSensitivity ) ;
2020-03-22 21:44:20 +01:00
lcSetProfileInt ( LC_PROFILE_SHADING_MODE , static_cast < int > ( mShadingMode ) ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileInt ( LC_PROFILE_DRAW_AXES , mDrawAxes ) ;
2020-07-11 19:47:52 +02:00
lcSetProfileInt ( LC_PROFILE_AXES_COLOR , mAxesColor ) ;
2020-12-30 22:44:08 +01:00
lcSetProfileInt ( LC_PROFILE_TEXT_COLOR , mTextColor ) ;
2020-11-26 20:51:50 +01:00
lcSetProfileInt ( LC_PROFILE_BACKGROUND_GRADIENT , mBackgroundGradient ) ;
lcSetProfileInt ( LC_PROFILE_BACKGROUND_COLOR , mBackgroundSolidColor ) ;
lcSetProfileInt ( LC_PROFILE_GRADIENT_COLOR_TOP , mBackgroundGradientColorTop ) ;
lcSetProfileInt ( LC_PROFILE_GRADIENT_COLOR_BOTTOM , mBackgroundGradientColorBottom ) ;
2020-07-11 19:47:52 +02:00
lcSetProfileInt ( LC_PROFILE_OVERLAY_COLOR , mOverlayColor ) ;
2020-07-25 22:21:22 +02:00
lcSetProfileInt ( LC_PROFILE_ACTIVE_VIEW_COLOR , mActiveViewColor ) ;
2020-12-12 03:01:04 +01:00
lcSetProfileInt ( LC_PROFILE_INACTIVE_VIEW_COLOR , mInactiveViewColor ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileInt ( LC_PROFILE_DRAW_EDGE_LINES , mDrawEdgeLines ) ;
lcSetProfileFloat ( LC_PROFILE_LINE_WIDTH , mLineWidth ) ;
2019-11-28 21:47:19 +01:00
lcSetProfileInt ( LC_PROFILE_ALLOW_LOD , mAllowLOD ) ;
2020-08-16 01:16:26 +02:00
lcSetProfileFloat ( LC_PROFILE_LOD_DISTANCE , mMeshLODDistance ) ;
2020-01-02 02:06:17 +01:00
lcSetProfileInt ( LC_PROFILE_FADE_STEPS , mFadeSteps ) ;
2020-04-25 21:16:37 +02:00
lcSetProfileInt ( LC_PROFILE_FADE_STEPS_COLOR , mFadeStepsColor ) ;
2020-04-25 20:36:28 +02:00
lcSetProfileInt ( LC_PROFILE_HIGHLIGHT_NEW_PARTS , mHighlightNewParts ) ;
lcSetProfileInt ( LC_PROFILE_HIGHLIGHT_NEW_PARTS_COLOR , mHighlightNewPartsColor ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileInt ( LC_PROFILE_GRID_STUDS , mDrawGridStuds ) ;
lcSetProfileInt ( LC_PROFILE_GRID_STUD_COLOR , mGridStudColor ) ;
lcSetProfileInt ( LC_PROFILE_GRID_LINES , mDrawGridLines ) ;
lcSetProfileInt ( LC_PROFILE_GRID_LINE_SPACING , mGridLineSpacing ) ;
lcSetProfileInt ( LC_PROFILE_GRID_LINE_COLOR , mGridLineColor ) ;
2020-01-05 20:38:24 +01:00
lcSetProfileInt ( LC_PROFILE_VIEW_SPHERE_ENABLED , mViewSphereSize ? 1 : 0 ) ;
2020-07-25 22:21:22 +02:00
lcSetProfileInt ( LC_PROFILE_VIEW_SPHERE_LOCATION , static_cast < int > ( mViewSphereLocation ) ) ;
2018-10-29 01:59:01 +01:00
lcSetProfileInt ( LC_PROFILE_VIEW_SPHERE_SIZE , mViewSphereSize ) ;
2019-01-20 20:59:18 +01:00
lcSetProfileInt ( LC_PROFILE_VIEW_SPHERE_COLOR , mViewSphereColor ) ;
lcSetProfileInt ( LC_PROFILE_VIEW_SPHERE_TEXT_COLOR , mViewSphereTextColor ) ;
lcSetProfileInt ( LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR , mViewSphereHighlightColor ) ;
2019-03-10 01:38:54 +01:00
lcSetProfileInt ( LC_PROFILE_AUTOLOAD_MOSTRECENT , mAutoLoadMostRecent ) ;
2020-01-02 02:06:17 +01:00
lcSetProfileInt ( LC_PROFILE_RESTORE_TAB_LAYOUT , mRestoreTabLayout ) ;
2020-07-25 22:21:22 +02:00
lcSetProfileInt ( LC_PROFILE_COLOR_THEME , static_cast < int > ( mColorTheme ) ) ;
2020-10-03 12:02:27 +02:00
lcSetProfileInt ( LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE , mPreviewViewSphereSize ) ;
lcSetProfileInt ( LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION , static_cast < int > ( mPreviewViewSphereLocation ) ) ;
lcSetProfileInt ( LC_PROFILE_PREVIEW_DRAW_AXES , mDrawPreviewAxis ) ;
2020-07-25 22:21:22 +02:00
}
void lcPreferences : : SetInterfaceColors ( lcColorTheme ColorTheme )
{
if ( ColorTheme = = lcColorTheme : : Dark )
{
2020-12-30 22:44:08 +01:00
mAxesColor = LC_RGBA ( 160 , 160 , 160 , 255 ) ;
mTextColor = LC_RGBA ( 160 , 160 , 160 , 255 ) ;
2020-11-26 20:51:50 +01:00
mBackgroundSolidColor = LC_RGB ( 49 , 52 , 55 ) ;
mBackgroundGradientColorTop = LC_RGB ( 0 , 0 , 191 ) ;
mBackgroundGradientColorBottom = LC_RGB ( 255 , 255 , 255 ) ;
2020-07-25 22:21:22 +02:00
mOverlayColor = lcGetProfileInt ( LC_PROFILE_OVERLAY_COLOR ) ;
mActiveViewColor = LC_RGBA ( 41 , 128 , 185 , 255 ) ;
mGridStudColor = LC_RGBA ( 24 , 24 , 24 , 192 ) ;
mGridLineColor = LC_RGBA ( 24 , 24 , 24 , 255 ) ;
mViewSphereColor = LC_RGBA ( 35 , 38 , 41 , 255 ) ;
mViewSphereTextColor = LC_RGBA ( 224 , 224 , 224 , 255 ) ;
mViewSphereHighlightColor = LC_RGBA ( 41 , 128 , 185 , 255 ) ;
}
else
{
mAxesColor = LC_RGBA ( 0 , 0 , 0 , 255 ) ;
2020-12-30 22:44:08 +01:00
mTextColor = LC_RGBA ( 0 , 0 , 0 , 255 ) ;
2020-11-26 20:51:50 +01:00
mBackgroundSolidColor = LC_RGB ( 255 , 255 , 255 ) ;
mBackgroundGradientColorTop = LC_RGB ( 54 , 72 , 95 ) ;
mBackgroundGradientColorBottom = LC_RGB ( 49 , 52 , 55 ) ;
2020-07-25 22:21:22 +02:00
mOverlayColor = LC_RGBA ( 0 , 0 , 0 , 255 ) ;
mActiveViewColor = LC_RGBA ( 255 , 0 , 0 , 255 ) ;
mGridStudColor = LC_RGBA ( 64 , 64 , 64 , 192 ) ;
mGridLineColor = LC_RGBA ( 0 , 0 , 0 , 255 ) ;
mViewSphereColor = LC_RGBA ( 255 , 255 , 255 , 255 ) ;
mViewSphereTextColor = LC_RGBA ( 0 , 0 , 0 , 255 ) ;
mViewSphereHighlightColor = LC_RGBA ( 255 , 0 , 0 , 255 ) ;
}
2014-02-10 01:13:41 +01:00
}
2017-12-10 19:20:31 +01:00
lcApplication : : lcApplication ( int & Argc , char * * Argv )
2017-12-03 04:42:42 +01:00
: QApplication ( Argc , Argv )
2013-08-09 06:57:18 +02:00
{
2017-12-03 04:42:42 +01:00
# if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
setApplicationDisplayName ( " LeoCAD " ) ;
# endif
setOrganizationDomain ( " leocad.org " ) ;
setOrganizationName ( " LeoCAD Software " ) ;
setApplicationName ( " LeoCAD " ) ;
setApplicationVersion ( LC_VERSION_TEXT ) ;
gApplication = this ;
2017-04-14 02:26:40 +02:00
mProject = nullptr ;
mLibrary = nullptr ;
2020-07-25 22:21:22 +02:00
mDefaultStyle = style ( ) - > objectName ( ) ;
2014-02-10 01:13:41 +01:00
mPreferences . LoadDefaults ( ) ;
2020-07-25 22:21:22 +02:00
UpdateStyle ( ) ;
2013-08-09 06:57:18 +02:00
}
lcApplication : : ~ lcApplication ( )
{
2019-09-21 18:47:33 +02:00
delete mProject ;
delete mLibrary ;
2017-12-03 04:42:42 +01:00
gApplication = nullptr ;
2013-08-09 06:57:18 +02:00
}
2020-07-25 22:21:22 +02:00
void lcApplication : : UpdateStyle ( )
{
if ( mPreferences . mColorTheme = = lcColorTheme : : Dark )
{
if ( ! QApplication : : setStyle ( " fusion " ) )
return ;
QPalette Palette = QApplication : : palette ( ) ;
Palette . setColor ( QPalette : : Window , QColor ( 49 , 52 , 55 ) ) ;
Palette . setColor ( QPalette : : WindowText , QColor ( 240 , 240 , 240 ) ) ;
Palette . setColor ( QPalette : : Base , QColor ( 35 , 38 , 41 ) ) ;
Palette . setColor ( QPalette : : AlternateBase , QColor ( 44 , 47 , 50 ) ) ;
Palette . setColor ( QPalette : : ToolTipBase , QColor ( 224 , 224 , 244 ) ) ;
Palette . setColor ( QPalette : : ToolTipText , QColor ( 58 , 58 , 58 ) ) ;
2020-07-25 22:25:45 +02:00
# if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
2020-07-25 22:21:22 +02:00
Palette . setColor ( QPalette : : PlaceholderText , QColor ( 100 , 100 , 100 ) ) ;
2020-07-25 22:25:45 +02:00
# endif
2020-07-25 22:21:22 +02:00
Palette . setColor ( QPalette : : Text , QColor ( 224 , 224 , 224 ) ) ;
Palette . setColor ( QPalette : : Button , QColor ( 45 , 48 , 51 ) ) ;
Palette . setColor ( QPalette : : ButtonText , QColor ( 224 , 224 , 244 ) ) ;
Palette . setColor ( QPalette : : Light , QColor ( 65 , 65 , 65 ) ) ;
Palette . setColor ( QPalette : : Midlight , QColor ( 62 , 62 , 62 ) ) ;
Palette . setColor ( QPalette : : Dark , QColor ( 35 , 35 , 35 ) ) ;
Palette . setColor ( QPalette : : Mid , QColor ( 50 , 50 , 50 ) ) ;
Palette . setColor ( QPalette : : Shadow , QColor ( 20 , 20 , 20 ) ) ;
// Palette.setColor(QPalette::Highlight, QColor(46, 108, 219));
Palette . setColor ( QPalette : : Highlight , QColor ( 41 , 128 , 185 ) ) ;
Palette . setColor ( QPalette : : HighlightedText , QColor ( 232 , 232 , 232 ) ) ;
Palette . setColor ( QPalette : : Link , QColor ( 41 , 128 , 185 ) ) ;
Palette . setColor ( QPalette : : Disabled , QPalette : : Text , QColor ( 128 , 128 , 128 ) ) ;
Palette . setColor ( QPalette : : Disabled , QPalette : : WindowText , QColor ( 128 , 128 , 128 ) ) ;
Palette . setColor ( QPalette : : Disabled , QPalette : : ButtonText , QColor ( 128 , 128 , 128 ) ) ;
QApplication : : setPalette ( Palette ) ;
2020-07-26 02:48:48 +02:00
QFile StylesheetFile ( QLatin1String ( " :/stylesheet/stylesheet.qss " ) ) ;
2020-07-25 22:21:22 +02:00
if ( StylesheetFile . open ( QIODevice : : ReadOnly ) )
{
QString Stylesheet = QString : : fromLatin1 ( StylesheetFile . readAll ( ) ) ;
qApp - > setStyleSheet ( Stylesheet ) ;
}
}
else
{
QApplication : : setStyle ( mDefaultStyle ) ;
QApplication : : setPalette ( qApp - > style ( ) - > standardPalette ( ) ) ;
qApp - > setStyleSheet ( QString ( ) ) ;
}
}
2018-01-07 00:01:04 +01:00
void lcApplication : : SaveTabLayout ( ) const
{
if ( ! mProject | | mProject - > GetFileName ( ) . isEmpty ( ) )
return ;
QSettings Settings ;
QByteArray TabLayout = gMainWindow - > GetTabLayout ( ) ;
Settings . setValue ( GetTabLayoutKey ( ) , TabLayout ) ;
}
QString lcApplication : : GetTabLayoutKey ( ) const
{
if ( mProject )
{
QString FileName = mProject - > GetFileName ( ) ;
if ( ! FileName . isEmpty ( ) )
{
FileName . replace ( ' \\ ' , ' ? ' ) ;
FileName . replace ( ' / ' , ' ? ' ) ;
return QString ( " TabLayouts/%1 " ) . arg ( FileName ) ;
}
}
return QString ( ) ;
}
2014-12-04 02:47:28 +01:00
void lcApplication : : SetProject ( Project * Project )
{
2018-01-07 00:01:04 +01:00
SaveTabLayout ( ) ;
2018-11-05 23:37:01 +01:00
gMainWindow - > RemoveAllModelTabs ( ) ;
2020-10-03 12:02:27 +02:00
if ( gMainWindow - > GetPreviewWidget ( ) )
gMainWindow - > GetPreviewWidget ( ) - > ClearPreview ( ) ;
2014-12-04 02:47:28 +01:00
delete mProject ;
mProject = Project ;
2015-03-14 20:07:07 +01:00
Project - > SetActiveModel ( 0 ) ;
2015-01-07 17:52:42 +01:00
lcGetPiecesLibrary ( ) - > RemoveTemporaryPieces ( ) ;
2018-01-07 00:01:04 +01:00
2020-01-02 02:10:24 +01:00
if ( mProject & & ! mProject - > GetFileName ( ) . isEmpty ( ) & & mPreferences . mRestoreTabLayout )
2018-01-07 00:01:04 +01:00
{
QSettings Settings ;
QByteArray TabLayout = Settings . value ( GetTabLayoutKey ( ) ) . toByteArray ( ) ;
gMainWindow - > RestoreTabLayout ( TabLayout ) ;
}
2014-12-04 02:47:28 +01:00
}
2014-12-16 00:55:17 +01:00
void lcApplication : : SetClipboard ( const QByteArray & Clipboard )
2013-08-09 06:57:18 +02:00
{
mClipboard = Clipboard ;
2014-12-16 00:55:17 +01:00
gMainWindow - > UpdatePaste ( ! mClipboard . isEmpty ( ) ) ;
2013-08-09 06:57:18 +02:00
}
2015-01-31 21:38:53 +01:00
void lcApplication : : ExportClipboard ( const QByteArray & Clipboard )
{
QMimeData * MimeData = new QMimeData ( ) ;
MimeData - > setData ( " application/vnd.leocad-clipboard " , Clipboard ) ;
QApplication : : clipboard ( ) - > setMimeData ( MimeData ) ;
SetClipboard ( Clipboard ) ;
}
2017-11-25 05:00:16 +01:00
bool lcApplication : : LoadPartsLibrary ( const QList < QPair < QString , bool > > & LibraryPaths , bool OnlyUsePaths , bool ShowProgress )
2013-08-09 06:57:18 +02:00
{
2017-04-14 02:26:40 +02:00
if ( mLibrary = = nullptr )
2014-02-10 01:13:41 +01:00
mLibrary = new lcPiecesLibrary ( ) ;
2013-08-09 06:57:18 +02:00
2017-11-25 03:19:29 +01:00
if ( ! OnlyUsePaths )
{
char * EnvPath = getenv ( " LEOCAD_LIB " ) ;
2014-09-13 00:47:08 +02:00
2017-11-25 03:19:29 +01:00
if ( EnvPath & & EnvPath [ 0 ] )
2017-11-25 05:00:16 +01:00
return mLibrary - > Load ( EnvPath , ShowProgress ) ;
2013-08-09 06:57:18 +02:00
2017-11-25 03:19:29 +01:00
QString CustomPath = lcGetProfileString ( LC_PROFILE_PARTS_LIBRARY ) ;
2013-08-09 06:57:18 +02:00
2017-11-25 03:19:29 +01:00
if ( ! CustomPath . isEmpty ( ) )
2017-11-25 05:00:16 +01:00
return mLibrary - > Load ( CustomPath , ShowProgress ) ;
2017-11-25 03:19:29 +01:00
}
2013-08-09 06:57:18 +02:00
2017-08-29 04:13:17 +02:00
for ( const QPair < QString , bool > & LibraryPathEntry : LibraryPaths )
2014-09-13 00:47:08 +02:00
{
2017-11-25 05:00:16 +01:00
if ( mLibrary - > Load ( LibraryPathEntry . first , ShowProgress ) )
2014-09-13 00:47:08 +02:00
{
2017-08-29 04:13:17 +02:00
if ( LibraryPathEntry . second )
mLibrary - > SetOfficialPieces ( ) ;
2014-09-13 00:47:08 +02:00
return true ;
2017-08-29 04:13:17 +02:00
}
2014-09-13 00:47:08 +02:00
}
2013-08-09 06:57:18 +02:00
return false ;
}
2017-12-03 04:42:42 +01:00
bool lcApplication : : Initialize ( QList < QPair < QString , bool > > & LibraryPaths , bool & ShowWindow )
2013-08-09 06:57:18 +02:00
{
2017-11-25 03:19:29 +01:00
bool OnlyUseLibraryPaths = false ;
2013-08-09 06:57:18 +02:00
bool SaveImage = false ;
2015-01-23 02:58:33 +01:00
bool SaveWavefront = false ;
2015-03-27 21:20:12 +01:00
bool Save3DS = false ;
2017-08-26 01:10:06 +02:00
bool SaveCOLLADA = false ;
2017-12-11 20:14:37 +01:00
bool SaveHTML = false ;
2017-12-14 02:36:35 +01:00
bool SetCameraAngles = false ;
2020-12-13 00:03:06 +01:00
bool SetCameraPosition = false ;
2017-06-21 07:46:52 +02:00
bool Orthographic = false ;
2020-12-13 00:03:06 +01:00
bool SetFoV = false ;
bool SetZPlanes = false ;
2020-12-12 20:27:06 +01:00
bool SetFadeStepsColor = false ;
bool SetHighlightColor = false ;
bool FadeSteps = mPreferences . mFadeSteps ;
2020-04-25 20:36:28 +02:00
bool ImageHighlight = mPreferences . mHighlightNewParts ;
2013-08-09 06:57:18 +02:00
int ImageWidth = lcGetProfileInt ( LC_PROFILE_IMAGE_WIDTH ) ;
int ImageHeight = lcGetProfileInt ( LC_PROFILE_IMAGE_HEIGHT ) ;
2020-12-12 20:27:06 +01:00
int AASamples = lcGetProfileInt ( LC_PROFILE_ANTIALIASING_SAMPLES ) ;
2019-09-21 18:47:33 +02:00
int StudLogo = lcGetProfileInt ( LC_PROFILE_STUD_LOGO ) ;
2017-12-03 04:42:42 +01:00
int ImageStart = 0 ;
int ImageEnd = 0 ;
2020-12-14 03:23:52 +01:00
lcVector3 CameraPosition [ 3 ] = { } ;
2020-12-14 21:45:01 +01:00
float CameraLatLon [ 2 ] = { 0.0f , 0.0f } ;
2020-12-13 00:03:06 +01:00
float FoV = 0.0f ;
2020-12-14 21:45:01 +01:00
float ZPlanes [ 2 ] = { 0.0f , 0.0f } ;
2020-12-12 20:27:06 +01:00
quint32 FadeStepsColor = mPreferences . mFadeStepsColor ;
quint32 HighlightColor = mPreferences . mHighlightNewPartsColor ;
2017-12-03 04:42:42 +01:00
QString ImageName ;
QString ModelName ;
QString CameraName ;
QString ViewpointName ;
2019-03-10 21:41:21 +01:00
QString ProjectName ;
2017-12-03 04:42:42 +01:00
QString SaveWavefrontName ;
QString Save3DSName ;
QString SaveCOLLADAName ;
2017-12-11 20:14:37 +01:00
QString SaveHTMLName ;
2017-12-03 04:42:42 +01:00
QStringList Arguments = arguments ( ) ;
const int NumArguments = Arguments . size ( ) ;
2020-12-14 21:45:01 +01:00
bool ParseOK = true ;
2017-12-03 04:42:42 +01:00
for ( int ArgIdx = 1 ; ArgIdx < NumArguments ; ArgIdx + + )
2013-08-09 06:57:18 +02:00
{
2017-12-03 04:42:42 +01:00
const QString & Param = Arguments [ ArgIdx ] ;
2013-08-09 06:57:18 +02:00
2019-02-21 01:55:46 +01:00
if ( Param . isEmpty ( ) )
continue ;
2017-12-03 04:42:42 +01:00
if ( Param [ 0 ] ! = ' - ' )
2013-08-09 06:57:18 +02:00
{
2017-12-03 04:42:42 +01:00
ProjectName = Param ;
2020-12-16 22:51:02 +01:00
// TODO: check file is readable
2017-12-03 04:42:42 +01:00
continue ;
}
2013-08-09 06:57:18 +02:00
2020-12-14 21:45:01 +01:00
auto ParseString = [ & ArgIdx , & Arguments , NumArguments , & ParseOK ] ( QString & Value , bool Required )
2017-12-03 04:42:42 +01:00
{
if ( ArgIdx < NumArguments - 1 & & Arguments [ ArgIdx + 1 ] [ 0 ] ! = ' - ' )
2015-01-23 02:58:33 +01:00
{
2017-12-03 04:42:42 +01:00
ArgIdx + + ;
Value = Arguments [ ArgIdx ] ;
2015-03-27 21:20:12 +01:00
}
2017-12-03 04:42:42 +01:00
else if ( Required )
2017-08-26 01:10:06 +02:00
{
2020-12-16 22:51:02 +01:00
printf ( " Not enough parameters for the '%s' option. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-14 21:45:01 +01:00
ParseOK = false ;
return false ;
}
return true ;
2017-12-03 04:42:42 +01:00
} ;
2013-08-09 06:57:18 +02:00
2020-12-14 21:45:01 +01:00
auto ParseInteger = [ & ArgIdx , & Arguments , NumArguments , & ParseOK ] ( int & Value )
2018-07-22 00:33:15 +02:00
{
if ( ArgIdx < NumArguments - 1 & & Arguments [ ArgIdx + 1 ] [ 0 ] ! = ' - ' )
{
bool Ok = false ;
ArgIdx + + ;
2020-12-14 21:45:01 +01:00
int NewValue = Arguments [ ArgIdx ] . toInt ( & Ok ) ;
2018-07-22 00:33:15 +02:00
if ( Ok )
2020-12-13 00:03:06 +01:00
{
2018-07-22 00:33:15 +02:00
Value = NewValue ;
2020-12-13 00:03:06 +01:00
return true ;
}
2018-07-22 00:33:15 +02:00
else
2020-12-16 22:51:02 +01:00
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Arguments [ ArgIdx - 1 ] . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2018-07-22 00:33:15 +02:00
}
else
2020-12-16 22:51:02 +01:00
printf ( " Not enough parameters for the '%s' option. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-13 00:03:06 +01:00
2020-12-14 21:45:01 +01:00
ParseOK = false ;
2020-12-13 00:03:06 +01:00
return false ;
2018-07-22 00:33:15 +02:00
} ;
2020-12-14 21:45:01 +01:00
auto ParseFloat = [ & ArgIdx , & Arguments , NumArguments , & ParseOK ] ( float & Value )
2017-12-14 02:36:35 +01:00
{
2020-12-14 21:45:01 +01:00
if ( ArgIdx < NumArguments - 1 & & Arguments [ ArgIdx + 1 ] [ 0 ] ! = ' - ' )
2017-12-14 02:36:35 +01:00
{
2020-12-14 21:45:01 +01:00
bool Ok = false ;
2017-12-14 02:36:35 +01:00
ArgIdx + + ;
2020-12-14 21:45:01 +01:00
float NewValue = Arguments [ ArgIdx ] . toFloat ( & Ok ) ;
2017-12-14 02:36:35 +01:00
2020-12-14 21:45:01 +01:00
if ( Ok )
2017-12-14 02:36:35 +01:00
{
2020-12-14 21:45:01 +01:00
Value = NewValue ;
2017-12-14 02:36:35 +01:00
return true ;
}
else
2020-12-16 22:51:02 +01:00
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Arguments [ ArgIdx - 1 ] . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2017-12-14 02:36:35 +01:00
}
else
2020-12-16 22:51:02 +01:00
printf ( " Not enough parameters for the '%s' option. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2017-12-14 02:36:35 +01:00
2020-12-14 21:45:01 +01:00
ParseOK = false ;
2017-12-14 02:36:35 +01:00
return false ;
} ;
2020-12-14 21:45:01 +01:00
auto ParseFloatArray = [ & ArgIdx , & Arguments , NumArguments , & ParseOK ] ( int Count , float * ValueArray , bool NegativesValid )
2020-12-13 00:03:06 +01:00
{
if ( ArgIdx + Count > = NumArguments )
{
2020-12-16 22:51:02 +01:00
printf ( " Not enough parameters for the '%s' option. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-14 21:45:01 +01:00
ArgIdx + = Count ;
ParseOK = false ;
2020-12-13 00:03:06 +01:00
return false ;
}
for ( int ParseIndex = 0 ; ParseIndex < Count ; ParseIndex + + )
{
2020-12-14 21:45:01 +01:00
if ( NegativesValid | | Arguments [ ArgIdx + ParseIndex + 1 ] [ 0 ] ! = ' - ' )
2020-12-13 00:03:06 +01:00
{
2020-12-14 21:45:01 +01:00
bool Ok = false ;
float NewValue = Arguments [ ArgIdx + ParseIndex + 1 ] . toFloat ( & Ok ) ;
if ( Ok )
{
* ( ValueArray + + ) = NewValue ;
continue ;
}
2020-12-16 22:51:02 +01:00
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx + ParseIndex + 1 ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-13 00:03:06 +01:00
}
2020-12-14 21:45:01 +01:00
else
2020-12-16 22:51:02 +01:00
printf ( " Not enough parameters for the '%s' option. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-14 21:45:01 +01:00
ArgIdx + = ParseIndex ;
ParseOK = false ;
return false ;
2020-12-13 00:03:06 +01:00
}
ArgIdx + = Count ;
return true ;
} ;
2020-12-14 21:45:01 +01:00
auto ParseColor = [ & ArgIdx , & Arguments , NumArguments , & ParseOK ] ( quint32 & Color )
2020-12-12 20:27:06 +01:00
{
2020-12-14 21:45:01 +01:00
if ( ArgIdx < NumArguments - 1 & & Arguments [ ArgIdx + 1 ] [ 0 ] ! = ' - ' )
2020-12-12 20:27:06 +01:00
{
2020-12-14 21:45:01 +01:00
ArgIdx + + ;
QColor ParsedColor = QColor ( Arguments [ ArgIdx ] ) ;
if ( ParsedColor . isValid ( ) )
{
Color = LC_RGBA ( ParsedColor . red ( ) , ParsedColor . green ( ) , ParsedColor . blue ( ) , ParsedColor . alpha ( ) ) ;
return true ;
}
else
2020-12-16 22:51:02 +01:00
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Arguments [ ArgIdx - 1 ] . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-12 20:27:06 +01:00
}
2020-12-14 21:45:01 +01:00
else
2020-12-16 22:51:02 +01:00
printf ( " Not enough parameters for the '%s' option. \n " , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
2020-12-12 20:27:06 +01:00
2020-12-14 21:45:01 +01:00
ParseOK = false ;
return false ;
2020-12-12 20:27:06 +01:00
} ;
2017-12-03 04:42:42 +01:00
if ( Param = = QLatin1String ( " -l " ) | | Param = = QLatin1String ( " --libpath " ) )
{
QString LibPath ;
ParseString ( LibPath , true ) ;
if ( ! LibPath . isEmpty ( ) )
2013-08-09 06:57:18 +02:00
{
2017-12-03 04:42:42 +01:00
LibraryPaths . clear ( ) ;
LibraryPaths + = qMakePair < QString , bool > ( LibPath , false ) ;
OnlyUseLibraryPaths = true ;
2013-08-09 06:57:18 +02:00
}
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " -i " ) | | Param = = QLatin1String ( " --image " ) )
2013-08-09 06:57:18 +02:00
{
2017-12-03 04:42:42 +01:00
SaveImage = true ;
ParseString ( ImageName , false ) ;
}
else if ( Param = = QLatin1String ( " -w " ) | | Param = = QLatin1String ( " --width " ) )
2020-12-16 22:51:02 +01:00
{
if ( ParseInteger ( ImageWidth ) & & ImageWidth < = 0 )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " -h " ) | | Param = = QLatin1String ( " --height " ) )
2020-12-16 22:51:02 +01:00
{
if ( ParseInteger ( ImageHeight ) & & ImageWidth < = 0 )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " -f " ) | | Param = = QLatin1String ( " --from " ) )
2020-12-16 22:51:02 +01:00
{
if ( ParseInteger ( ImageStart ) & & ImageStart < = 0 )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " -t " ) | | Param = = QLatin1String ( " --to " ) )
2020-12-16 22:51:02 +01:00
{
if ( ParseInteger ( ImageEnd ) & & ( ImageEnd < = 0 | | ( ImageStart & & ImageStart > ImageEnd ) ) )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2017-12-14 02:36:35 +01:00
else if ( Param = = QLatin1String ( " -s " ) | | Param = = QLatin1String ( " --submodel " ) )
2017-12-03 04:42:42 +01:00
ParseString ( ModelName , true ) ;
else if ( Param = = QLatin1String ( " -c " ) | | Param = = QLatin1String ( " --camera " ) )
ParseString ( CameraName , true ) ;
else if ( Param = = QLatin1String ( " --viewpoint " ) )
2020-12-16 22:51:02 +01:00
{
if ( ParseString ( ViewpointName , true )
// TODO: move the string checks into view or camera
& & ViewpointName ! = QLatin1String ( " front " )
& & ViewpointName ! = QLatin1String ( " back " )
& & ViewpointName ! = QLatin1String ( " top " )
& & ViewpointName ! = QLatin1String ( " bottom " )
& & ViewpointName ! = QLatin1String ( " left " )
& & ViewpointName ! = QLatin1String ( " right " )
& & ViewpointName ! = QLatin1String ( " home " ) )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2017-12-14 02:36:35 +01:00
else if ( Param = = QLatin1String ( " --camera-angles " ) )
2020-12-14 03:23:52 +01:00
{
2020-12-16 22:51:02 +01:00
if ( ( SetCameraAngles = ParseFloatArray ( 2 , CameraLatLon , true ) ) & & ( fabsf ( CameraLatLon [ 0 ] ) > 360.0f | | fabsf ( CameraLatLon [ 1 ] ) > 360.0f ) )
2020-12-14 03:23:52 +01:00
{
2020-12-16 22:51:02 +01:00
printf ( " Invalid parameter value(s) specified for the '%s' option: limits are +/- 360 \n " , Param . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
else if ( Param = = QLatin1String ( " --camera-position " ) | | Param = = QLatin1String ( " --camera-position-ldraw " ) )
{
if ( ( SetCameraPosition = ParseFloatArray ( 9 , CameraPosition [ 0 ] , true ) ) )
{
lcVector3 Front = CameraPosition [ 1 ] - CameraPosition [ 0 ] ;
if ( Front . LengthSquared ( ) < 1.0f | | CameraPosition [ 2 ] . LengthSquared ( ) < 1.0f | | fabsf ( lcDot ( lcNormalize ( Front ) , lcNormalize ( CameraPosition [ 2 ] ) ) ) > 0.99f )
{
printf ( " Invalid parameter value(s) specified for the '%s' option. \n " , Param . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
else if ( Param = = QLatin1String ( " --camera-position-ldraw " ) )
{
CameraPosition [ 0 ] = lcVector3LDrawToLeoCAD ( CameraPosition [ 0 ] ) ;
CameraPosition [ 1 ] = lcVector3LDrawToLeoCAD ( CameraPosition [ 1 ] ) ;
CameraPosition [ 2 ] = lcVector3LDrawToLeoCAD ( CameraPosition [ 2 ] ) ;
}
2020-12-14 03:23:52 +01:00
}
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " --orthographic " ) )
Orthographic = true ;
2020-12-13 00:03:06 +01:00
else if ( Param = = QLatin1String ( " --fov " ) )
2020-12-16 22:51:02 +01:00
{
if ( ( SetFoV = ParseFloat ( FoV ) ) & & fabsf ( FoV ) > = 180 )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2020-12-13 00:03:06 +01:00
else if ( Param = = QLatin1String ( " --zplanes " ) )
2020-12-16 22:51:02 +01:00
{
if ( ( SetZPlanes = ParseFloatArray ( 2 , ZPlanes , false ) ) & & ( ZPlanes [ 0 ] < 1.0 | | ZPlanes [ 0 ] > = ZPlanes [ 1 ] ) )
{
printf ( " Invalid parameter value(s) specified for the '%s' option: requirements are: 1 <= <near> < <far> \n " , Param . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2020-12-12 20:27:06 +01:00
else if ( Param = = QLatin1String ( " --fade-steps " ) )
FadeSteps = true ;
else if ( Param = = QLatin1String ( " --no-fade-steps " ) )
FadeSteps = false ;
else if ( Param = = QLatin1String ( " --fade-steps-color " ) )
{
if ( ParseColor ( FadeStepsColor ) )
{
SetFadeStepsColor = true ;
FadeSteps = true ;
}
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " --highlight " ) )
ImageHighlight = true ;
2020-12-12 20:27:06 +01:00
else if ( Param = = QLatin1String ( " --no-highlight " ) )
ImageHighlight = false ;
else if ( Param = = QLatin1String ( " --highlight-color " ) )
{
if ( ParseColor ( HighlightColor ) )
{
SetHighlightColor = true ;
ImageHighlight = true ;
}
}
2018-07-22 00:33:15 +02:00
else if ( Param = = QLatin1String ( " --shading " ) )
{
QString ShadingString ;
2020-12-16 22:51:02 +01:00
if ( ParseString ( ShadingString , true ) )
{
if ( ShadingString = = QLatin1String ( " wireframe " ) )
mPreferences . mShadingMode = lcShadingMode : : Wireframe ;
else if ( ShadingString = = QLatin1String ( " flat " ) )
mPreferences . mShadingMode = lcShadingMode : : Flat ;
else if ( ShadingString = = QLatin1String ( " default " ) )
mPreferences . mShadingMode = lcShadingMode : : DefaultLights ;
else if ( ShadingString = = QLatin1String ( " full " ) )
mPreferences . mShadingMode = lcShadingMode : : Full ;
else
{
printf ( " Invalid parameter value specified for the '%s' option: '%s' \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2018-07-22 00:33:15 +02:00
}
else if ( Param = = QLatin1String ( " --line-width " ) )
ParseFloat ( mPreferences . mLineWidth ) ;
2020-12-12 20:27:06 +01:00
else if ( Param = = QLatin1String ( " --aa-samples " ) )
2020-12-16 22:51:02 +01:00
{
if ( ParseInteger ( AASamples ) & & AASamples ! = 1 & & AASamples ! = 2 & & AASamples ! = 4 & & AASamples ! = 8 )
{
printf ( " Invalid parameter value specified for the '%s' option: '%s'. \n " , Param . toLatin1 ( ) . constData ( ) , Arguments [ ArgIdx ] . toLatin1 ( ) . constData ( ) ) ;
ParseOK = false ;
}
}
2019-09-21 18:47:33 +02:00
else if ( Param = = QLatin1String ( " -sl " ) | | Param = = QLatin1String ( " --stud-logo " ) )
{
ParseInteger ( StudLogo ) ;
2019-09-24 01:22:11 +02:00
if ( StudLogo ! = lcGetProfileInt ( LC_PROFILE_STUD_LOGO ) )
{
2019-09-24 01:55:24 +02:00
lcGetPiecesLibrary ( ) - > SetStudLogo ( StudLogo , false ) ;
2019-09-24 01:22:11 +02:00
}
2019-09-21 18:47:33 +02:00
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " -obj " ) | | Param = = QLatin1String ( " --export-wavefront " ) )
{
SaveWavefront = true ;
ParseString ( SaveWavefrontName , false ) ;
}
else if ( Param = = QLatin1String ( " -3ds " ) | | Param = = QLatin1String ( " --export-3ds " ) )
{
Save3DS = true ;
ParseString ( Save3DSName , false ) ;
}
else if ( Param = = QLatin1String ( " -dae " ) | | Param = = QLatin1String ( " --export-collada " ) )
{
SaveCOLLADA = true ;
ParseString ( SaveCOLLADAName , false ) ;
2013-08-09 06:57:18 +02:00
}
2017-12-11 20:14:37 +01:00
else if ( Param = = QLatin1String ( " -html " ) | | Param = = QLatin1String ( " --export-html " ) )
{
SaveHTML = true ;
ParseString ( SaveHTMLName , false ) ;
}
2017-12-03 04:42:42 +01:00
else if ( Param = = QLatin1String ( " -v " ) | | Param = = QLatin1String ( " --version " ) )
{
2019-03-17 20:29:02 +01:00
# ifdef LC_CONTINUOUS_BUILD
printf ( " LeoCAD Continuous Build " QT_STRINGIFY ( LC_CONTINUOUS_BUILD ) " \n " ) ;
# else
printf ( " LeoCAD Version " LC_VERSION_TEXT " \n " ) ;
# endif
2017-12-03 04:42:42 +01:00
printf ( " Compiled " __DATE__ " \n " ) ;
ShowWindow = false ;
return true ;
}
else if ( Param = = QLatin1String ( " -? " ) | | Param = = QLatin1String ( " --help " ) )
{
printf ( " Usage: leocad [options] [file] \n " ) ;
printf ( " [options] can be: \n " ) ;
2017-12-14 02:36:35 +01:00
printf ( " -l, --libpath <path>: Set the Parts Library location to path. \n " ) ;
2020-12-12 20:27:06 +01:00
printf ( " -i, --image <outfile.ext>: Save a picture in the format specified by ext and exit. \n " ) ;
2017-12-14 02:36:35 +01:00
printf ( " -w, --width <width>: Set the picture width. \n " ) ;
printf ( " -h, --height <height>: Set the picture height. \n " ) ;
2020-12-12 20:27:06 +01:00
printf ( " -f, --from <step>: Set the first step to save pictures. \n " ) ;
printf ( " -t, --to <step>: Set the last step to save pictures. \n " ) ;
2017-12-14 02:36:35 +01:00
printf ( " -s, --submodel <submodel>: Set the active submodel. \n " ) ;
printf ( " -c, --camera <camera>: Set the active camera. \n " ) ;
2020-12-12 20:27:06 +01:00
printf ( " -sl, --stud-logo <type>: Set the stud logo type 0 - 5, 0 is no logo. \n " ) ;
2017-12-14 02:36:35 +01:00
printf ( " --viewpoint <front|back|left|right|top|bottom|home>: Set the viewpoint. \n " ) ;
printf ( " --camera-angles <latitude> <longitude>: Set the camera angles in degrees around the model. \n " ) ;
2020-12-13 00:03:06 +01:00
printf ( " --camera-position <x> <y> <z> <tx> <ty> <tz> <ux> <uy> <uz>: Set the camera position, target and up vector. \n " ) ;
2020-12-14 03:23:52 +01:00
printf ( " --camera-position-ldraw <x> <y> <z> <tx> <ty> <tz> <ux> <uy> <uz>: Set the camera position, target and up vector using LDraw coordinates. \n " ) ;
2020-12-13 00:03:06 +01:00
printf ( " --orthographic: Render images using an orthographic projection. \n " ) ;
2020-12-16 22:51:02 +01:00
printf ( " --fov <degrees>: Set the vertical field of view used to render images (< 180). \n " ) ;
printf ( " --zplanes <near> <far>: Set the near and far clipping planes used to render images (1 <= <near> < <far>). \n " ) ;
2020-12-12 20:27:06 +01:00
printf ( " --fade-steps: Render parts from prior steps faded. \n " ) ;
printf ( " --no-fade-steps: Do not render parts from prior steps faded. \n " ) ;
printf ( " --fade-steps-color <rgba>: Renderinng color for prior step parts (#AARRGGBB). \n " ) ;
printf ( " --highlight: Highlight parts in the steps they appear. \n " ) ;
printf ( " --no-highlight: Do not highlight parts in the steps they appear. \n " ) ;
printf ( " --highlight-color: Renderinng color for highlighted parts (#AARRGGBB). \n " ) ;
2018-07-22 00:33:15 +02:00
printf ( " --shading <wireframe|flat|default|full>: Select shading mode for rendering. \n " ) ;
printf ( " --line-width <width>: Set the with of the edge lines. \n " ) ;
2020-12-12 20:27:06 +01:00
printf ( " --aa-samples <count>: AntiAliasing sample size (1, 2, 4, or 8). \n " ) ;
2017-12-14 02:36:35 +01:00
printf ( " -obj, --export-wavefront <outfile.obj>: Export the model to Wavefront OBJ format. \n " ) ;
printf ( " -3ds, --export-3ds <outfile.3ds>: Export the model to 3D Studio 3DS format. \n " ) ;
printf ( " -dae, --export-collada <outfile.dae>: Export the model to COLLADA DAE format. \n " ) ;
printf ( " -html, --export-html <folder>: Create an HTML page for the model. \n " ) ;
2017-12-03 04:42:42 +01:00
printf ( " -v, --version: Output version information and exit. \n " ) ;
2017-12-14 02:36:35 +01:00
printf ( " -?, --help: Display this help message and exit. \n " ) ;
2017-12-03 04:42:42 +01:00
printf ( " \n " ) ;
ShowWindow = false ;
return true ;
}
else
2020-12-14 21:45:01 +01:00
{
2020-12-16 22:51:02 +01:00
printf ( " Unknown option: '%s' \n " , Param . toLatin1 ( ) . constData ( ) ) ;
2020-12-14 21:45:01 +01:00
ParseOK = false ;
}
}
if ( ! ParseOK )
{
ShowWindow = false ;
return false ;
2013-08-09 06:57:18 +02:00
}
2020-12-31 01:43:23 +01:00
if ( AASamples > 1 )
{
# ifdef LC_USE_QOPENGLWIDGET
QSurfaceFormat Format = QSurfaceFormat : : defaultFormat ( ) ;
Format . setSamples ( AASamples ) ;
QSurfaceFormat : : setDefaultFormat ( Format ) ;
# else
QGLFormat Format ;
Format . setSampleBuffers ( true ) ;
Format . setSamples ( AASamples ) ;
QGLFormat : : setDefaultFormat ( Format ) ;
# endif
}
2015-01-24 00:18:32 +01:00
gMainWindow = new lcMainWindow ( ) ;
2015-01-24 03:12:24 +01:00
lcLoadDefaultKeyboardShortcuts ( ) ;
2016-04-23 02:17:33 +02:00
lcLoadDefaultMouseShortcuts ( ) ;
2015-01-24 00:18:32 +01:00
2020-12-30 20:06:38 +01:00
if ( SaveImage | | SaveWavefront | | Save3DS | | SaveCOLLADA | | SaveHTML )
{
ShowWindow = false ;
if ( ProjectName . isEmpty ( ) )
{
printf ( " No file name specified. \n " ) ;
return false ;
}
}
else
ShowWindow = true ;
2016-12-07 18:24:47 +01:00
2017-11-25 05:00:16 +01:00
if ( ! LoadPartsLibrary ( LibraryPaths , OnlyUseLibraryPaths , ShowWindow ) )
2013-08-09 06:57:18 +02:00
{
2016-12-07 18:24:47 +01:00
QString Message ;
2013-08-09 06:57:18 +02:00
2014-09-11 21:55:34 +02:00
if ( mLibrary - > LoadBuiltinPieces ( ) )
2018-03-22 00:47:00 +01:00
Message = tr ( " LeoCAD could not find a compatible Parts Library so only a small number of parts will be available. \n \n Please visit https://www.leocad.org for information on how to download and install a library. " ) ;
2014-09-11 21:55:34 +02:00
else
2018-03-22 00:47:00 +01:00
Message = tr ( " LeoCAD could not load Parts Library. \n \n Please visit https://www.leocad.org for information on how to download and install a library. " ) ;
2016-12-07 18:24:47 +01:00
if ( ShowWindow )
QMessageBox : : information ( gMainWindow , tr ( " LeoCAD " ) , Message ) ;
else
2016-12-16 21:52:36 +01:00
fprintf ( stderr , " %s " , Message . toLatin1 ( ) . constData ( ) ) ;
2013-08-09 06:57:18 +02:00
}
2020-12-31 01:43:23 +01:00
gMainWindow - > CreateWidgets ( ) ;
2015-01-24 00:18:32 +01:00
2015-01-23 19:45:58 +01:00
Project * NewProject = new Project ( ) ;
SetProject ( NewProject ) ;
2013-08-09 06:57:18 +02:00
2019-03-10 21:41:21 +01:00
if ( ShowWindow & & ProjectName . isEmpty ( ) & & lcGetProfileInt ( LC_PROFILE_AUTOLOAD_MOSTRECENT ) )
ProjectName = lcGetProfileString ( LC_PROFILE_RECENT_FILE1 ) ;
2017-12-03 04:42:42 +01:00
if ( ! ProjectName . isEmpty ( ) & & gMainWindow - > OpenProject ( ProjectName ) )
2013-08-09 06:57:18 +02:00
{
2017-12-03 04:42:42 +01:00
if ( ! ModelName . isEmpty ( ) )
2017-12-27 22:55:37 +01:00
mProject - > SetActiveModel ( ModelName ) ;
2017-06-20 05:03:49 +02:00
2020-12-25 19:54:33 +01:00
lcView * ActiveView = gMainWindow - > GetActiveView ( ) ;
2017-12-14 02:36:35 +01:00
2017-12-03 04:42:42 +01:00
if ( ! CameraName . isEmpty ( ) )
2017-06-21 07:46:52 +02:00
{
2020-12-14 01:30:01 +01:00
ActiveView - > SetCamera ( CameraName ) ;
2017-12-14 02:36:35 +01:00
if ( ! ViewpointName . isEmpty ( ) )
printf ( " Warning: --viewpoint is ignored when --camera is set. \n " ) ;
if ( Orthographic )
printf ( " Warning: --orthographic is ignored when --camera is set. \n " ) ;
if ( SetCameraAngles )
printf ( " Warning: --camera-angles is ignored when --camera is set. \n " ) ;
2020-12-13 00:03:06 +01:00
if ( SetCameraPosition )
printf ( " Warning: --camera-position is ignored when --camera is set. \n " ) ;
2017-06-21 07:46:52 +02:00
}
else
{
2020-12-14 02:10:25 +01:00
ActiveView - > SetProjection ( Orthographic ) ;
if ( SetFoV )
ActiveView - > GetCamera ( ) - > m_fovy = FoV ;
if ( SetZPlanes )
{
lcCamera * Camera = ActiveView - > GetCamera ( ) ;
2020-12-14 21:45:01 +01:00
Camera - > m_zNear = ZPlanes [ 0 ] ;
Camera - > m_zFar = ZPlanes [ 1 ] ;
2020-12-14 02:10:25 +01:00
}
2017-12-03 04:42:42 +01:00
if ( ! ViewpointName . isEmpty ( ) )
2017-06-21 07:46:52 +02:00
{
2017-12-03 04:42:42 +01:00
if ( ViewpointName = = QLatin1String ( " front " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Front ) ;
2017-12-03 04:42:42 +01:00
else if ( ViewpointName = = QLatin1String ( " back " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Back ) ;
2017-12-03 04:42:42 +01:00
else if ( ViewpointName = = QLatin1String ( " top " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Top ) ;
2017-12-03 04:42:42 +01:00
else if ( ViewpointName = = QLatin1String ( " bottom " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Bottom ) ;
2017-12-03 04:42:42 +01:00
else if ( ViewpointName = = QLatin1String ( " left " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Left ) ;
2017-12-03 04:42:42 +01:00
else if ( ViewpointName = = QLatin1String ( " right " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Right ) ;
2017-12-03 04:42:42 +01:00
else if ( ViewpointName = = QLatin1String ( " home " ) )
2020-12-13 01:58:40 +01:00
ActiveView - > SetViewpoint ( lcViewpoint : : Home ) ;
2017-06-21 07:46:52 +02:00
else
2020-12-16 22:51:02 +01:00
printf ( " Warning: unknown viewpoint: '%s' \n " , ViewpointName . toLatin1 ( ) . constData ( ) ) ;
// TODO: move the above into view or camera
2017-12-14 02:36:35 +01:00
if ( SetCameraAngles )
printf ( " Warning: --camera-angles is ignored when --viewpoint is set. \n " ) ;
2020-12-13 00:03:06 +01:00
if ( SetCameraPosition )
printf ( " Warning: --camera-position is ignored when --viewpoint is set. \n " ) ;
2017-06-21 07:46:52 +02:00
}
2017-12-14 02:36:35 +01:00
else if ( SetCameraAngles )
2020-12-13 00:03:06 +01:00
{
2020-12-14 21:45:01 +01:00
ActiveView - > SetCameraAngles ( CameraLatLon [ 0 ] , CameraLatLon [ 1 ] ) ;
2017-12-14 02:36:35 +01:00
2020-12-13 00:03:06 +01:00
if ( SetCameraPosition )
printf ( " Warning: --camera-position is ignored when --camera-angles is set. \n " ) ;
}
else if ( SetCameraPosition )
{
2020-12-14 03:23:52 +01:00
ActiveView - > SetViewpoint ( CameraPosition [ 0 ] , CameraPosition [ 1 ] , CameraPosition [ 2 ] ) ;
2020-12-13 00:03:06 +01:00
}
2017-06-21 07:46:52 +02:00
}
2017-06-20 05:03:49 +02:00
2015-01-23 02:58:33 +01:00
if ( SaveImage )
{
2018-07-08 00:26:36 +02:00
lcModel * ActiveModel ;
if ( ModelName . isEmpty ( ) )
ActiveModel = mProject - > GetMainModel ( ) ;
else
ActiveModel = mProject - > GetActiveModel ( ) ;
2018-04-18 01:08:29 +02:00
2017-12-27 22:55:37 +01:00
if ( ImageName . isEmpty ( ) )
2018-04-15 03:27:16 +02:00
ImageName = mProject - > GetImageFileName ( true ) ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
if ( ImageEnd < ImageStart )
ImageEnd = ImageStart ;
else if ( ImageStart > ImageEnd )
ImageStart = ImageEnd ;
if ( ( ImageStart = = 0 ) & & ( ImageEnd = = 0 ) )
2018-04-18 01:08:29 +02:00
ImageStart = ImageEnd = ActiveModel - > GetCurrentStep ( ) ;
2015-01-23 02:58:33 +01:00
else if ( ( ImageStart = = 0 ) & & ( ImageEnd ! = 0 ) )
ImageStart = ImageEnd ;
else if ( ( ImageStart ! = 0 ) & & ( ImageEnd = = 0 ) )
ImageEnd = ImageStart ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
if ( ImageStart > 255 )
ImageStart = 255 ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
if ( ImageEnd > 255 )
ImageEnd = 255 ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
QString Frame ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
if ( ImageStart ! = ImageEnd )
{
2017-12-27 22:55:37 +01:00
QString Extension = QFileInfo ( ImageName ) . suffix ( ) ;
Frame = ImageName . left ( ImageName . length ( ) - Extension . length ( ) - 1 ) + QLatin1String ( " %1. " ) + Extension ;
2015-01-23 02:58:33 +01:00
}
else
2017-12-27 22:55:37 +01:00
Frame = ImageName ;
2013-08-09 06:57:18 +02:00
2020-12-12 20:27:06 +01:00
mPreferences . mFadeSteps = FadeSteps ;
2020-12-14 01:53:49 +01:00
if ( SetFadeStepsColor )
mPreferences . mFadeStepsColor = FadeStepsColor ;
2020-04-25 20:36:28 +02:00
mPreferences . mHighlightNewParts = ImageHighlight ;
2020-12-14 01:53:49 +01:00
if ( SetHighlightColor )
mPreferences . mHighlightNewPartsColor = HighlightColor ;
2020-04-25 20:36:28 +02:00
2020-12-13 00:03:06 +01:00
ActiveModel - > SaveStepImages ( Frame , ImageStart ! = ImageEnd , CameraName . isEmpty ( ) & & ! SetCameraPosition , ImageWidth , ImageHeight , ImageStart , ImageEnd ) ;
2015-01-23 02:58:33 +01:00
}
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
if ( SaveWavefront )
2013-08-09 06:57:18 +02:00
{
2015-01-23 02:58:33 +01:00
QString FileName ;
2017-12-03 04:42:42 +01:00
if ( ! SaveWavefrontName . isEmpty ( ) )
2015-03-27 21:20:12 +01:00
FileName = SaveWavefrontName ;
2015-01-23 02:58:33 +01:00
else
FileName = ProjectName ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
QString Extension = QFileInfo ( FileName ) . suffix ( ) . toLower ( ) ;
2013-08-09 06:57:18 +02:00
2015-01-23 02:58:33 +01:00
if ( Extension . isEmpty ( ) )
{
FileName + = " .obj " ;
}
else if ( Extension ! = " obj " )
{
FileName = FileName . left ( FileName . length ( ) - Extension . length ( ) - 1 ) ;
FileName + = " .obj " ;
}
mProject - > ExportWavefront ( FileName ) ;
}
2015-03-27 21:20:12 +01:00
if ( Save3DS )
{
QString FileName ;
2017-12-03 04:42:42 +01:00
if ( ! Save3DSName . isEmpty ( ) )
2015-03-27 21:20:12 +01:00
FileName = Save3DSName ;
else
FileName = ProjectName ;
QString Extension = QFileInfo ( FileName ) . suffix ( ) . toLower ( ) ;
if ( Extension . isEmpty ( ) )
{
FileName + = " .3ds " ;
}
else if ( Extension ! = " 3ds " )
{
FileName = FileName . left ( FileName . length ( ) - Extension . length ( ) - 1 ) ;
FileName + = " .3ds " ;
}
mProject - > Export3DStudio ( FileName ) ;
}
2017-08-26 01:10:06 +02:00
if ( SaveCOLLADA )
{
QString FileName ;
2017-12-03 04:42:42 +01:00
if ( ! SaveCOLLADAName . isEmpty ( ) )
2017-08-26 01:10:06 +02:00
FileName = SaveCOLLADAName ;
else
FileName = ProjectName ;
QString Extension = QFileInfo ( FileName ) . suffix ( ) . toLower ( ) ;
if ( Extension . isEmpty ( ) )
{
FileName + = " .dae " ;
}
else if ( Extension ! = " dae " )
{
FileName = FileName . left ( FileName . length ( ) - Extension . length ( ) - 1 ) ;
FileName + = " .dae " ;
}
mProject - > ExportCOLLADA ( FileName ) ;
}
2017-12-11 20:14:37 +01:00
if ( SaveHTML )
{
lcHTMLExportOptions Options ( mProject ) ;
if ( ! SaveHTMLName . isEmpty ( ) )
Options . PathName = SaveHTMLName ;
mProject - > ExportHTML ( Options ) ;
}
2013-08-09 06:57:18 +02:00
}
2015-01-23 02:58:33 +01:00
2017-11-25 03:19:29 +01:00
if ( ShowWindow )
{
2020-07-25 22:21:22 +02:00
gMainWindow - > SetColorIndex ( lcGetColorIndex ( 7 ) ) ;
2017-11-25 03:19:29 +01:00
gMainWindow - > GetPartSelectionWidget ( ) - > SetDefaultPart ( ) ;
gMainWindow - > UpdateRecentFiles ( ) ;
gMainWindow - > show ( ) ;
}
2013-08-09 06:57:18 +02:00
return true ;
}
void lcApplication : : Shutdown ( )
{
2014-02-10 01:13:41 +01:00
delete mLibrary ;
2017-04-14 02:26:40 +02:00
mLibrary = nullptr ;
2013-08-09 06:57:18 +02:00
}
2014-02-10 01:13:41 +01:00
void lcApplication : : ShowPreferencesDialog ( )
{
lcPreferencesDialogOptions Options ;
int CurrentAASamples = lcGetProfileInt ( LC_PROFILE_ANTIALIASING_SAMPLES ) ;
2019-09-21 18:47:33 +02:00
int CurrentStudLogo = lcGetProfileInt ( LC_PROFILE_STUD_LOGO ) ;
2014-02-10 01:13:41 +01:00
Options . Preferences = mPreferences ;
2015-01-31 22:44:57 +01:00
Options . LibraryPath = lcGetProfileString ( LC_PROFILE_PARTS_LIBRARY ) ;
2019-06-21 03:52:33 +02:00
Options . MinifigSettingsPath = lcGetProfileString ( LC_PROFILE_MINIFIG_SETTINGS ) ;
Options . ColorConfigPath = lcGetProfileString ( LC_PROFILE_COLOR_CONFIG ) ;
2015-01-31 22:44:57 +01:00
Options . POVRayPath = lcGetProfileString ( LC_PROFILE_POVRAY_PATH ) ;
Options . LGEOPath = lcGetProfileString ( LC_PROFILE_POVRAY_LGEO_PATH ) ;
2019-06-21 03:52:33 +02:00
Options . DefaultAuthor = lcGetProfileString ( LC_PROFILE_DEFAULT_AUTHOR_NAME ) ;
2019-11-28 22:52:06 +01:00
Options . Language = lcGetProfileString ( LC_PROFILE_LANGUAGE ) ;
2014-02-10 01:13:41 +01:00
Options . CheckForUpdates = lcGetProfileInt ( LC_PROFILE_CHECK_UPDATES ) ;
Options . AASamples = CurrentAASamples ;
2019-09-21 18:47:33 +02:00
Options . StudLogo = CurrentStudLogo ;
2014-02-10 01:13:41 +01:00
Options . Categories = gCategories ;
Options . CategoriesModified = false ;
Options . CategoriesDefault = false ;
Options . KeyboardShortcuts = gKeyboardShortcuts ;
2016-04-25 07:26:34 +02:00
Options . KeyboardShortcutsModified = false ;
Options . KeyboardShortcutsDefault = false ;
Options . MouseShortcuts = gMouseShortcuts ;
Options . MouseShortcutsModified = false ;
Options . MouseShortcutsDefault = false ;
2014-02-10 01:13:41 +01:00
2017-12-11 03:12:31 +01:00
lcQPreferencesDialog Dialog ( gMainWindow , & Options ) ;
if ( Dialog . exec ( ) ! = QDialog : : Accepted )
2014-02-10 01:13:41 +01:00
return ;
2019-11-28 22:52:06 +01:00
bool LanguageChanged = Options . Language ! = lcGetProfileString ( LC_PROFILE_LANGUAGE ) ;
2015-01-31 22:44:57 +01:00
bool LibraryChanged = Options . LibraryPath ! = lcGetProfileString ( LC_PROFILE_PARTS_LIBRARY ) ;
2019-06-21 03:52:33 +02:00
bool ColorsChanged = Options . ColorConfigPath ! = lcGetProfileString ( LC_PROFILE_COLOR_CONFIG ) ;
2014-02-10 01:13:41 +01:00
bool AAChanged = CurrentAASamples ! = Options . AASamples ;
2019-09-21 18:47:33 +02:00
bool StudLogoChanged = CurrentStudLogo ! = Options . StudLogo ;
2014-02-10 01:13:41 +01:00
mPreferences = Options . Preferences ;
mPreferences . SaveDefaults ( ) ;
2020-07-25 22:21:22 +02:00
UpdateStyle ( ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileString ( LC_PROFILE_DEFAULT_AUTHOR_NAME , Options . DefaultAuthor ) ;
lcSetProfileString ( LC_PROFILE_PARTS_LIBRARY , Options . LibraryPath ) ;
2019-06-21 03:52:33 +02:00
lcSetProfileString ( LC_PROFILE_COLOR_CONFIG , Options . ColorConfigPath ) ;
lcSetProfileString ( LC_PROFILE_MINIFIG_SETTINGS , Options . MinifigSettingsPath ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileString ( LC_PROFILE_POVRAY_PATH , Options . POVRayPath ) ;
lcSetProfileString ( LC_PROFILE_POVRAY_LGEO_PATH , Options . LGEOPath ) ;
2019-11-28 22:52:06 +01:00
lcSetProfileString ( LC_PROFILE_LANGUAGE , Options . Language ) ;
2014-02-10 01:13:41 +01:00
lcSetProfileInt ( LC_PROFILE_CHECK_UPDATES , Options . CheckForUpdates ) ;
lcSetProfileInt ( LC_PROFILE_ANTIALIASING_SAMPLES , Options . AASamples ) ;
2019-09-21 18:47:33 +02:00
lcSetProfileInt ( LC_PROFILE_STUD_LOGO , Options . StudLogo ) ;
2014-02-10 01:13:41 +01:00
2019-11-28 22:52:06 +01:00
if ( LanguageChanged | | LibraryChanged | | ColorsChanged | | AAChanged )
2019-06-21 03:52:33 +02:00
QMessageBox : : information ( gMainWindow , tr ( " LeoCAD " ) , tr ( " Some changes will only take effect the next time you start LeoCAD. " ) ) ;
2014-02-10 01:13:41 +01:00
if ( Options . CategoriesModified )
{
if ( Options . CategoriesDefault )
lcResetDefaultCategories ( ) ;
else
{
gCategories = Options . Categories ;
lcSaveDefaultCategories ( ) ;
}
gMainWindow - > UpdateCategories ( ) ;
}
2016-04-25 07:26:34 +02:00
if ( Options . KeyboardShortcutsModified )
2014-02-10 01:13:41 +01:00
{
2016-04-25 07:26:34 +02:00
if ( Options . KeyboardShortcutsDefault )
2014-02-10 01:13:41 +01:00
lcResetDefaultKeyboardShortcuts ( ) ;
else
{
gKeyboardShortcuts = Options . KeyboardShortcuts ;
lcSaveDefaultKeyboardShortcuts ( ) ;
}
gMainWindow - > UpdateShortcuts ( ) ;
}
2016-04-25 07:26:34 +02:00
if ( Options . MouseShortcutsModified )
{
if ( Options . MouseShortcutsDefault )
lcResetDefaultMouseShortcuts ( ) ;
else
{
gMouseShortcuts = Options . MouseShortcuts ;
lcSaveDefaultMouseShortcuts ( ) ;
}
}
2019-09-24 01:55:24 +02:00
if ( StudLogoChanged )
2019-09-24 01:22:11 +02:00
{
2019-09-24 01:55:24 +02:00
lcSetProfileInt ( LC_PROFILE_STUD_LOGO , Options . StudLogo ) ;
lcGetPiecesLibrary ( ) - > SetStudLogo ( Options . StudLogo , true ) ;
2019-09-24 01:22:11 +02:00
}
2014-02-10 01:13:41 +01:00
// TODO: printing preferences
/*
strcpy ( opts . strFooter , m_strFooter ) ;
strcpy ( opts . strHeader , m_strHeader ) ;
*/
2017-09-13 23:21:53 +02:00
gMainWindow - > SetShadingMode ( Options . Preferences . mShadingMode ) ;
2020-12-25 19:54:33 +01:00
lcView : : UpdateAllViews ( ) ;
2014-03-07 03:39:28 +01:00
}