2012-03-20 01:57:42 +01:00
# include "lc_global.h"
2013-08-16 03:25:51 +02:00
# include "lc_mainwindow.h"
2015-01-25 02:34:13 +01:00
# include "lc_qmainwindow.h"
# include "lc_qimagedialog.h"
# include "lc_qhtmldialog.h"
# include "lc_qpovraydialog.h"
# include "lc_qpropertiesdialog.h"
# include "lc_qfinddialog.h"
# include "lc_qselectdialog.h"
# include "lc_qminifigdialog.h"
# include "lc_qarraydialog.h"
# include "lc_qgroupdialog.h"
# include "lc_qeditgroupsdialog.h"
# include "lc_qpreferencesdialog.h"
# include "lc_qupdatedialog.h"
# include "lc_qaboutdialog.h"
2013-08-09 06:57:18 +02:00
# include "lc_profile.h"
# include "preview.h"
2014-05-03 23:16:48 +02:00
# include "view.h"
2014-12-08 08:32:39 +01:00
# include "project.h"
# include "lc_colors.h"
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
lcMainWindow * gMainWindow ;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
lcMainWindow : : lcMainWindow ( )
2014-05-03 23:16:48 +02:00
{
2015-01-25 02:34:13 +01:00
mHandle = NULL ;
2014-05-03 23:16:48 +02:00
mActiveView = NULL ;
2013-08-09 06:57:18 +02:00
mPreviewWidget = NULL ;
2014-08-27 18:17:09 +02:00
mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION ;
2011-09-07 23:06:51 +02:00
2014-12-08 08:32:39 +01:00
mColorIndex = lcGetColorIndex ( 4 ) ;
mTool = LC_TOOL_SELECT ;
2014-05-21 00:15:42 +02:00
mAddKeys = false ;
2014-10-05 07:21:51 +02:00
mMoveXYSnapIndex = 4 ;
mMoveZSnapIndex = 3 ;
mAngleSnapIndex = 5 ;
mLockX = false ;
mLockY = false ;
mLockZ = false ;
2015-01-18 06:36:14 +01:00
mRelativeTransform = true ;
2014-10-05 07:21:51 +02:00
2014-09-21 03:31:01 +02:00
memset ( & mSearchOptions , 0 , sizeof ( mSearchOptions ) ) ;
2014-05-21 00:15:42 +02:00
2013-08-09 06:57:18 +02:00
for ( int FileIdx = 0 ; FileIdx < LC_MAX_RECENT_FILES ; FileIdx + + )
2014-10-12 19:34:18 +02:00
mRecentFiles [ FileIdx ] = lcGetProfileString ( ( LC_PROFILE_KEY ) ( LC_PROFILE_RECENT_FILE1 + FileIdx ) ) ;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
gMainWindow = this ;
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00
lcMainWindow : : ~ lcMainWindow ( )
2011-09-07 23:06:51 +02:00
{
2015-01-07 17:52:42 +01:00
delete mPreviewWidget ;
mPreviewWidget = NULL ;
2013-08-09 06:57:18 +02:00
for ( int FileIdx = 0 ; FileIdx < LC_MAX_RECENT_FILES ; FileIdx + + )
lcSetProfileString ( ( LC_PROFILE_KEY ) ( LC_PROFILE_RECENT_FILE1 + FileIdx ) , mRecentFiles [ FileIdx ] ) ;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
gMainWindow = NULL ;
}
2011-09-07 23:06:51 +02:00
2015-01-25 02:34:13 +01:00
int lcMainWindow : : DoMessageBox ( const char * Text , const char * Caption , int Flags )
{
QMessageBox : : StandardButton Result ;
QMessageBox : : StandardButtons Buttons ;
switch ( Flags & LC_MB_TYPEMASK )
{
default :
case LC_MB_OK :
Buttons = QMessageBox : : Ok ;
break ;
case LC_MB_OKCANCEL :
Buttons = QMessageBox : : Ok | QMessageBox : : Cancel ;
break ;
case LC_MB_YESNOCANCEL :
Buttons = QMessageBox : : Yes | QMessageBox : : No | QMessageBox : : Cancel ;
break ;
case LC_MB_YESNO :
Buttons = QMessageBox : : Yes | QMessageBox : : No ;
break ;
}
switch ( Flags & LC_MB_ICONMASK )
{
default :
case LC_MB_ICONINFORMATION :
Result = QMessageBox : : information ( mHandle , Caption , Text , Buttons ) ;
break ;
case LC_MB_ICONQUESTION :
Result = QMessageBox : : question ( mHandle , Caption , Text , Buttons ) ;
break ;
case LC_MB_ICONWARNING :
Result = QMessageBox : : warning ( mHandle , Caption , Text , Buttons ) ;
break ;
case LC_MB_ICONERROR :
Result = QMessageBox : : critical ( mHandle , Caption , Text , Buttons ) ;
break ;
}
switch ( Result )
{
default :
case QMessageBox : : Ok :
return LC_OK ;
case QMessageBox : : Cancel :
return LC_CANCEL ;
case QMessageBox : : Yes :
return LC_YES ;
case QMessageBox : : No :
return LC_NO ;
}
}
bool lcMainWindow : : DoDialog ( LC_DIALOG_TYPE Type , void * Data )
{
switch ( Type )
{
case LC_DIALOG_EXPORT_3DSTUDIO :
case LC_DIALOG_EXPORT_BRICKLINK :
case LC_DIALOG_EXPORT_CSV :
{
char * FileName = ( char * ) Data ;
QString Result ;
switch ( Type )
{
case LC_DIALOG_EXPORT_3DSTUDIO :
Result = QFileDialog : : getSaveFileName ( mHandle , tr ( " Export 3D Studio " ) , FileName , tr ( " 3DS Files (*.3ds);;All Files (*.*) " ) ) ;
break ;
case LC_DIALOG_EXPORT_BRICKLINK :
Result = QFileDialog : : getSaveFileName ( mHandle , tr ( " Export BrickLink " ) , FileName , tr ( " XML Files (*.xml);;All Files (*.*) " ) ) ;
break ;
case LC_DIALOG_EXPORT_CSV :
Result = QFileDialog : : getSaveFileName ( mHandle , tr ( " Export CSV " ) , FileName , tr ( " CSV Files (*.csv);;All Files (*.*) " ) ) ;
break ;
default :
break ;
}
if ( ! Result . isEmpty ( ) )
{
strcpy ( FileName , Result . toLocal8Bit ( ) . data ( ) ) ;
return true ;
}
} break ;
case LC_DIALOG_SAVE_IMAGE :
{
lcQImageDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_EXPORT_HTML :
{
lcQHTMLDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_EXPORT_POVRAY :
{
lcQPOVRayDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_PROPERTIES :
{
lcQPropertiesDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_PRINT :
{
lcQMainWindow * MainWindow = ( lcQMainWindow * ) mHandle ;
MainWindow - > showPrintDialog ( ) ;
return true ;
} break ;
case LC_DIALOG_FIND :
{
lcQFindDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_SELECT_BY_NAME :
{
lcQSelectDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_MINIFIG :
{
lcQMinifigDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_PIECE_ARRAY :
{
lcQArrayDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_PIECE_GROUP :
{
lcQGroupDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_EDIT_GROUPS :
{
lcQEditGroupsDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_PREFERENCES :
{
lcQPreferencesDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_ABOUT :
{
lcQAboutDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
case LC_DIALOG_CHECK_UPDATES :
{
lcQUpdateDialog Dialog ( mHandle , Data ) ;
return Dialog . exec ( ) = = QDialog : : Accepted ;
} break ;
}
return false ;
}
2015-01-16 03:07:31 +01:00
void lcMainWindow : : ResetCameras ( )
{
for ( int ViewIdx = 0 ; ViewIdx < mViews . GetSize ( ) ; ViewIdx + + )
mViews [ ViewIdx ] - > SetDefaultCamera ( ) ;
lcGetActiveModel ( ) - > DeleteAllCameras ( ) ;
}
2014-05-03 23:16:48 +02:00
void lcMainWindow : : AddView ( View * View )
{
mViews . Add ( View ) ;
View - > MakeCurrent ( ) ;
if ( ! mActiveView )
{
mActiveView = View ;
UpdatePerspective ( ) ;
}
}
void lcMainWindow : : RemoveView ( View * View )
{
if ( View = = mActiveView )
mActiveView = NULL ;
mViews . Remove ( View ) ;
}
void lcMainWindow : : SetActiveView ( View * ActiveView )
{
if ( mActiveView = = ActiveView )
return ;
mActiveView = ActiveView ;
UpdateCameraMenu ( ) ;
UpdatePerspective ( ) ;
}
void lcMainWindow : : UpdateAllViews ( )
{
for ( int ViewIdx = 0 ; ViewIdx < mViews . GetSize ( ) ; ViewIdx + + )
mViews [ ViewIdx ] - > Redraw ( ) ;
}
2014-05-23 02:02:21 +02:00
void lcMainWindow : : SetTool ( lcTool Tool )
{
mTool = Tool ;
UpdateAction ( mTool ) ;
UpdateAllViews ( ) ;
}
2013-08-09 06:57:18 +02:00
void lcMainWindow : : SetColorIndex ( int ColorIndex )
2014-05-03 23:16:48 +02:00
{
2013-08-09 06:57:18 +02:00
mColorIndex = ColorIndex ;
if ( mPreviewWidget )
mPreviewWidget - > Redraw ( ) ;
2015-01-17 03:02:30 +01:00
UpdateColor ( ) ;
2011-09-07 23:06:51 +02:00
}
2014-10-05 07:21:51 +02:00
void lcMainWindow : : SetMoveXYSnapIndex ( int Index )
{
mMoveXYSnapIndex = Index ;
UpdateSnap ( ) ;
}
void lcMainWindow : : SetMoveZSnapIndex ( int Index )
{
mMoveZSnapIndex = Index ;
UpdateSnap ( ) ;
}
void lcMainWindow : : SetAngleSnapIndex ( int Index )
{
mAngleSnapIndex = Index ;
UpdateSnap ( ) ;
}
void lcMainWindow : : SetLockX ( bool LockX )
{
mLockX = LockX ;
UpdateLockSnap ( ) ;
}
void lcMainWindow : : SetLockY ( bool LockY )
{
mLockY = LockY ;
UpdateLockSnap ( ) ;
}
void lcMainWindow : : SetLockZ ( bool LockZ )
{
mLockZ = LockZ ;
UpdateLockSnap ( ) ;
}
2015-01-18 06:36:14 +01:00
void lcMainWindow : : SetRelativeTransform ( bool RelativeTransform )
{
mRelativeTransform = RelativeTransform ;
UpdateLockSnap ( ) ;
UpdateAllViews ( ) ;
}
2014-10-12 19:34:18 +02:00
void lcMainWindow : : AddRecentFile ( const QString & FileName )
2011-09-07 23:06:51 +02:00
{
2014-10-12 19:34:18 +02:00
QString SavedName = FileName ;
2013-08-09 06:57:18 +02:00
int FileIdx ;
2011-09-07 23:06:51 +02:00
2014-12-31 17:38:30 +01:00
QFileInfo FileInfo ( FileName ) ;
2013-08-09 06:57:18 +02:00
for ( FileIdx = 0 ; FileIdx < LC_MAX_RECENT_FILES ; FileIdx + + )
2014-12-31 17:38:30 +01:00
if ( QFileInfo ( mRecentFiles [ FileIdx ] ) = = FileInfo )
2011-09-07 23:06:51 +02:00
break ;
2013-08-09 06:57:18 +02:00
for ( FileIdx = lcMin ( FileIdx , LC_MAX_RECENT_FILES - 1 ) ; FileIdx > 0 ; FileIdx - - )
2014-10-12 19:34:18 +02:00
mRecentFiles [ FileIdx ] = mRecentFiles [ FileIdx - 1 ] ;
2011-09-07 23:06:51 +02:00
2014-10-12 19:34:18 +02:00
mRecentFiles [ 0 ] = SavedName ;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
UpdateRecentFiles ( ) ;
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00
void lcMainWindow : : RemoveRecentFile ( int FileIndex )
2011-09-07 23:06:51 +02:00
{
2013-08-09 06:57:18 +02:00
for ( int FileIdx = FileIndex ; FileIdx < LC_MAX_RECENT_FILES - 1 ; FileIdx + + )
2014-10-12 19:34:18 +02:00
mRecentFiles [ FileIdx ] = mRecentFiles [ FileIdx + 1 ] ;
2011-09-07 23:06:51 +02:00
2014-10-12 19:34:18 +02:00
mRecentFiles [ LC_MAX_RECENT_FILES - 1 ] . clear ( ) ;
2013-08-09 06:57:18 +02:00
UpdateRecentFiles ( ) ;
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00
2014-12-04 02:47:28 +01:00
void lcMainWindow : : NewProject ( )
{
if ( ! SaveProjectIfModified ( ) )
return ;
Project * NewProject = new Project ( ) ;
g_App - > SetProject ( NewProject ) ;
}
bool lcMainWindow : : OpenProject ( const QString & FileName )
{
if ( ! SaveProjectIfModified ( ) )
return false ;
QString LoadFileName = FileName ;
if ( LoadFileName . isEmpty ( ) )
{
LoadFileName = lcGetActiveProject ( ) - > GetFileName ( ) ;
if ( LoadFileName . isEmpty ( ) )
LoadFileName = lcGetProfileString ( LC_PROFILE_PROJECTS_PATH ) ;
LoadFileName = QFileDialog : : getOpenFileName ( mHandle , tr ( " Open Project " ) , LoadFileName , tr ( " Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*) " ) ) ;
if ( LoadFileName . isEmpty ( ) )
return false ;
}
Project * NewProject = new Project ( ) ;
if ( NewProject - > Load ( LoadFileName ) )
{
2014-12-31 00:45:27 +01:00
NewProject - > SetActiveModel ( 0 ) ;
2014-12-04 02:47:28 +01:00
g_App - > SetProject ( NewProject ) ;
AddRecentFile ( LoadFileName ) ;
2014-12-31 00:45:27 +01:00
for ( int ViewIdx = 0 ; ViewIdx < mViews . GetSize ( ) ; ViewIdx + + )
{
View * View = mViews [ ViewIdx ] ;
if ( ! View - > mCamera - > IsSimple ( ) )
View - > SetDefaultCamera ( ) ;
View - > ZoomExtents ( ) ;
}
gMainWindow - > UpdateAllViews ( ) ;
2014-12-04 02:47:28 +01:00
return true ;
}
QMessageBox : : information ( mHandle , tr ( " LeoCAD " ) , tr ( " Error loading '%1'. " ) . arg ( LoadFileName ) ) ;
delete NewProject ;
return false ;
}
2014-12-16 00:55:17 +01:00
void lcMainWindow : : MergeProject ( )
{
2014-12-23 18:02:23 +01:00
QString LoadFileName = lcGetActiveProject ( ) - > GetFileName ( ) ;
2014-12-16 00:55:17 +01:00
if ( LoadFileName . isEmpty ( ) )
2014-12-23 18:02:23 +01:00
LoadFileName = lcGetProfileString ( LC_PROFILE_PROJECTS_PATH ) ;
2014-12-16 00:55:17 +01:00
2014-12-23 18:02:23 +01:00
LoadFileName = QFileDialog : : getOpenFileName ( mHandle , tr ( " Open Project " ) , LoadFileName , tr ( " Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*) " ) ) ;
2014-12-16 00:55:17 +01:00
2014-12-23 18:02:23 +01:00
if ( LoadFileName . isEmpty ( ) )
return ;
2014-12-16 00:55:17 +01:00
Project * NewProject = new Project ( ) ;
if ( NewProject - > Load ( LoadFileName ) )
{
2014-12-23 18:02:23 +01:00
int NumModels = NewProject - > GetModels ( ) . GetSize ( ) ;
2014-12-16 00:55:17 +01:00
2014-12-23 18:02:23 +01:00
lcGetActiveProject ( ) - > Merge ( NewProject ) ;
2014-12-16 00:55:17 +01:00
2014-12-23 18:02:23 +01:00
if ( NumModels = = 1 )
QMessageBox : : information ( mHandle , tr ( " LeoCAD " ) , tr ( " Merged 1 model. " ) ) ;
else
QMessageBox : : information ( mHandle , tr ( " LeoCAD " ) , tr ( " Merged %1 models. " ) . arg ( NumModels ) ) ;
}
else
{
QMessageBox : : information ( mHandle , tr ( " LeoCAD " ) , tr ( " Error loading '%1'. " ) . arg ( LoadFileName ) ) ;
delete NewProject ;
}
2014-12-16 00:55:17 +01:00
}
2014-12-04 02:47:28 +01:00
bool lcMainWindow : : SaveProject ( const QString & FileName )
{
QString SaveFileName ;
Project * Project = lcGetActiveProject ( ) ;
if ( ! FileName . isEmpty ( ) )
SaveFileName = FileName ;
else
{
2014-12-08 20:30:53 +01:00
SaveFileName = Project - > GetFileName ( ) ;
2014-12-04 02:47:28 +01:00
if ( SaveFileName . isEmpty ( ) )
SaveFileName = QFileInfo ( QDir ( lcGetProfileString ( LC_PROFILE_PROJECTS_PATH ) ) , Project - > GetTitle ( ) ) . absoluteFilePath ( ) ;
2014-12-26 18:09:11 +01:00
SaveFileName = QFileDialog : : getSaveFileName ( mHandle , tr ( " Save Project " ) , SaveFileName , tr ( " Supported Files (*.ldr *.dat *.mpd);;All Files (*.*) " ) ) ;
2014-12-04 02:47:28 +01:00
if ( SaveFileName . isEmpty ( ) )
return false ;
}
if ( QFileInfo ( SaveFileName ) . suffix ( ) . toLower ( ) = = QLatin1String ( " lcd " ) )
{
QMessageBox : : warning ( mHandle , tr ( " Error " ) , tr ( " Saving files in LCD format is no longer supported, please use the LDR format instead. " ) ) ;
return false ;
}
2014-12-08 08:32:39 +01:00
if ( ! Project - > Save ( SaveFileName ) )
2014-12-04 02:47:28 +01:00
return false ;
AddRecentFile ( SaveFileName ) ;
2014-12-08 08:32:39 +01:00
UpdateTitle ( ) ;
2014-12-04 02:47:28 +01:00
return true ;
}
bool lcMainWindow : : SaveProjectIfModified ( )
{
Project * Project = lcGetActiveProject ( ) ;
if ( ! Project - > IsModified ( ) )
return true ;
switch ( QMessageBox : : question ( mHandle , tr ( " Save Project " ) , tr ( " Save changes to '%1'? " ) . arg ( Project - > GetTitle ( ) ) , QMessageBox : : Yes | QMessageBox : : No | QMessageBox : : Cancel ) )
{
default :
case QMessageBox : : Cancel :
return false ;
case QMessageBox : : Yes :
if ( ! SaveProject ( Project - > GetFileName ( ) ) )
return false ;
break ;
case QMessageBox : : No :
break ;
}
return true ;
}
void lcMainWindow : : HandleCommand ( lcCommandId CommandId )
{
switch ( CommandId )
{
case LC_FILE_NEW :
NewProject ( ) ;
break ;
case LC_FILE_OPEN :
OpenProject ( QString ( ) ) ;
break ;
2014-12-16 00:55:17 +01:00
case LC_FILE_MERGE :
MergeProject ( ) ;
break ;
2014-12-04 02:47:28 +01:00
case LC_FILE_SAVE :
SaveProject ( lcGetActiveProject ( ) - > GetFileName ( ) ) ;
break ;
case LC_FILE_SAVEAS :
SaveProject ( QString ( ) ) ;
break ;
case LC_FILE_SAVE_IMAGE :
lcGetActiveProject ( ) - > SaveImage ( ) ;
break ;
2014-12-30 17:30:12 +01:00
2014-12-04 02:47:28 +01:00
case LC_FILE_EXPORT_3DS :
lcGetActiveProject ( ) - > Export3DStudio ( ) ;
break ;
2015-01-12 05:49:30 +01:00
2014-12-04 02:47:28 +01:00
case LC_FILE_EXPORT_HTML :
lcGetActiveProject ( ) - > ExportHTML ( ) ;
break ;
2015-01-12 05:49:30 +01:00
2014-12-04 02:47:28 +01:00
case LC_FILE_EXPORT_BRICKLINK :
lcGetActiveProject ( ) - > ExportBrickLink ( ) ;
break ;
case LC_FILE_EXPORT_CSV :
lcGetActiveProject ( ) - > ExportCSV ( ) ;
break ;
case LC_FILE_EXPORT_POVRAY :
lcGetActiveProject ( ) - > ExportPOVRay ( ) ;
break ;
case LC_FILE_EXPORT_WAVEFRONT :
2015-01-23 02:58:33 +01:00
lcGetActiveProject ( ) - > ExportWavefront ( QString ( ) ) ;
2014-12-04 02:47:28 +01:00
break ;
2014-12-30 17:30:12 +01:00
2014-12-04 02:47:28 +01:00
case LC_FILE_PRINT_PREVIEW :
TogglePrintPreview ( ) ;
break ;
case LC_FILE_PRINT :
DoDialog ( LC_DIALOG_PRINT , NULL ) ;
break ;
// TODO: printing
case LC_FILE_PRINT_BOM :
break ;
case LC_FILE_RECENT1 :
case LC_FILE_RECENT2 :
case LC_FILE_RECENT3 :
case LC_FILE_RECENT4 :
if ( ! OpenProject ( mRecentFiles [ CommandId - LC_FILE_RECENT1 ] ) )
RemoveRecentFile ( CommandId - LC_FILE_RECENT1 ) ;
break ;
case LC_FILE_EXIT :
Close ( ) ;
break ;
case LC_EDIT_UNDO :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > UndoAction ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_REDO :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > RedoAction ( ) ;
2014-12-04 02:47:28 +01:00
break ;
2014-12-16 00:55:17 +01:00
case LC_EDIT_CUT :
lcGetActiveModel ( ) - > Cut ( ) ;
break ;
2014-12-04 02:47:28 +01:00
2014-12-16 00:55:17 +01:00
case LC_EDIT_COPY :
lcGetActiveModel ( ) - > Copy ( ) ;
break ;
2014-12-04 02:47:28 +01:00
2014-12-16 00:55:17 +01:00
case LC_EDIT_PASTE :
lcGetActiveModel ( ) - > Paste ( ) ;
break ;
2014-12-04 02:47:28 +01:00
case LC_EDIT_FIND :
if ( gMainWindow - > DoDialog ( LC_DIALOG_FIND , & gMainWindow - > mSearchOptions ) )
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > FindPiece ( true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_FIND_NEXT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > FindPiece ( false , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_FIND_PREVIOUS :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > FindPiece ( false , false ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_SELECT_ALL :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > SelectAllPieces ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_SELECT_NONE :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ClearSelection ( true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_SELECT_INVERT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > InvertSelection ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_SELECT_BY_NAME :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowSelectByNameDialog ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_SPLIT_HORIZONTAL :
SplitHorizontal ( ) ;
break ;
case LC_VIEW_SPLIT_VERTICAL :
SplitVertical ( ) ;
break ;
case LC_VIEW_REMOVE_VIEW :
RemoveView ( ) ;
break ;
case LC_VIEW_RESET_VIEWS :
ResetViews ( ) ;
break ;
case LC_VIEW_FULLSCREEN :
ToggleFullScreen ( ) ;
break ;
case LC_VIEW_PROJECTION_PERSPECTIVE :
mActiveView - > SetProjection ( false ) ;
break ;
case LC_VIEW_PROJECTION_ORTHO :
mActiveView - > SetProjection ( true ) ;
break ;
2015-01-17 19:36:09 +01:00
2014-12-04 02:47:28 +01:00
case LC_PIECE_INSERT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > AddPiece ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_DELETE :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > DeleteSelectedObjects ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MOVE_PLUSX :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > MoveSelectedObjects ( mActiveView - > GetMoveDirection ( lcVector3 ( lcMax ( GetMoveXYSnap ( ) , 0.01f ) , 0.0f , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MOVE_MINUSX :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > MoveSelectedObjects ( mActiveView - > GetMoveDirection ( lcVector3 ( - lcMax ( GetMoveXYSnap ( ) , 0.01f ) , 0.0f , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MOVE_PLUSY :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > MoveSelectedObjects ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , lcMax ( GetMoveXYSnap ( ) , 0.01f ) , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MOVE_MINUSY :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > MoveSelectedObjects ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , - lcMax ( GetMoveXYSnap ( ) , 0.01f ) , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MOVE_PLUSZ :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > MoveSelectedObjects ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , 0.0f , lcMax ( GetMoveZSnap ( ) , 0.01f ) ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MOVE_MINUSZ :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > MoveSelectedObjects ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , 0.0f , - lcMax ( GetMoveZSnap ( ) , 0.01f ) ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ROTATE_PLUSX :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > RotateSelectedPieces ( mActiveView - > GetMoveDirection ( lcVector3 ( lcMax ( GetAngleSnap ( ) , 1.0f ) , 0.0f , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ROTATE_MINUSX :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > RotateSelectedPieces ( mActiveView - > GetMoveDirection ( - lcVector3 ( lcMax ( GetAngleSnap ( ) , 1.0f ) , 0.0f , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ROTATE_PLUSY :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > RotateSelectedPieces ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , lcMax ( GetAngleSnap ( ) , 1.0f ) , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ROTATE_MINUSY :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > RotateSelectedPieces ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , - lcMax ( GetAngleSnap ( ) , 1.0f ) , 0.0f ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ROTATE_PLUSZ :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > RotateSelectedPieces ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , 0.0f , lcMax ( GetAngleSnap ( ) , 1.0f ) ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ROTATE_MINUSZ :
2015-01-18 05:59:02 +01:00
lcGetActiveModel ( ) - > RotateSelectedPieces ( mActiveView - > GetMoveDirection ( lcVector3 ( 0.0f , 0.0f , - lcMax ( GetAngleSnap ( ) , 1.0f ) ) ) , true , true ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_MINIFIG_WIZARD :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowMinifigDialog ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_ARRAY :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowArrayDialog ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_GROUP :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > GroupSelection ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_UNGROUP :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > UngroupSelection ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_GROUP_ADD :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > AddSelectedPiecesToGroup ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_GROUP_REMOVE :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > RemoveFocusPieceFromGroup ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_GROUP_EDIT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowEditGroupsDialog ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_HIDE_SELECTED :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > HideSelectedPieces ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_HIDE_UNSELECTED :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > HideUnselectedPieces ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_UNHIDE_ALL :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > UnhideAllPieces ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_SHOW_EARLIER :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowSelectedPiecesEarlier ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_PIECE_SHOW_LATER :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowSelectedPiecesLater ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_PREFERENCES :
g_App - > ShowPreferencesDialog ( ) ;
break ;
case LC_VIEW_ZOOM_IN :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > Zoom ( mActiveView - > mCamera , - 10.0f ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_ZOOM_OUT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > Zoom ( mActiveView - > mCamera , 10.0f ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_ZOOM_EXTENTS :
mActiveView - > ZoomExtents ( ) ;
break ;
case LC_VIEW_LOOK_AT :
mActiveView - > LookAt ( ) ;
break ;
case LC_VIEW_TIME_NEXT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowNextStep ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_TIME_PREVIOUS :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowPreviousStep ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_TIME_FIRST :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowFirstStep ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_TIME_LAST :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > ShowLastStep ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_TIME_INSERT :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > InsertStep ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_TIME_DELETE :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > RemoveStep ( ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_VIEW_VIEWPOINT_FRONT :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_FRONT ) ;
break ;
case LC_VIEW_VIEWPOINT_BACK :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_BACK ) ;
break ;
case LC_VIEW_VIEWPOINT_TOP :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_TOP ) ;
break ;
case LC_VIEW_VIEWPOINT_BOTTOM :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_BOTTOM ) ;
break ;
case LC_VIEW_VIEWPOINT_LEFT :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_LEFT ) ;
break ;
case LC_VIEW_VIEWPOINT_RIGHT :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_RIGHT ) ;
break ;
case LC_VIEW_VIEWPOINT_HOME :
mActiveView - > SetViewpoint ( LC_VIEWPOINT_HOME ) ;
break ;
case LC_VIEW_CAMERA_NONE :
mActiveView - > RemoveCamera ( ) ;
break ;
case LC_VIEW_CAMERA1 :
case LC_VIEW_CAMERA2 :
case LC_VIEW_CAMERA3 :
case LC_VIEW_CAMERA4 :
case LC_VIEW_CAMERA5 :
case LC_VIEW_CAMERA6 :
case LC_VIEW_CAMERA7 :
case LC_VIEW_CAMERA8 :
case LC_VIEW_CAMERA9 :
case LC_VIEW_CAMERA10 :
case LC_VIEW_CAMERA11 :
case LC_VIEW_CAMERA12 :
case LC_VIEW_CAMERA13 :
case LC_VIEW_CAMERA14 :
case LC_VIEW_CAMERA15 :
case LC_VIEW_CAMERA16 :
mActiveView - > SetCameraIndex ( CommandId - LC_VIEW_CAMERA1 ) ;
break ;
2015-01-16 03:07:31 +01:00
case LC_VIEW_CAMERA_RESET :
ResetCameras ( ) ;
break ;
2014-12-04 02:47:28 +01:00
2014-12-13 00:42:09 +01:00
case LC_MODEL_NEW :
lcGetActiveProject ( ) - > CreateNewModel ( ) ;
break ;
2014-12-31 18:05:23 +01:00
case LC_MODEL_PROPERTIES :
lcGetActiveModel ( ) - > ShowPropertiesDialog ( ) ;
break ;
2014-12-13 00:42:09 +01:00
case LC_MODEL_LIST :
lcGetActiveProject ( ) - > ShowModelListDialog ( ) ;
break ;
case LC_MODEL_01 :
case LC_MODEL_02 :
case LC_MODEL_03 :
case LC_MODEL_04 :
case LC_MODEL_05 :
case LC_MODEL_06 :
case LC_MODEL_07 :
case LC_MODEL_08 :
case LC_MODEL_09 :
case LC_MODEL_10 :
case LC_MODEL_11 :
case LC_MODEL_12 :
case LC_MODEL_13 :
case LC_MODEL_14 :
case LC_MODEL_15 :
case LC_MODEL_16 :
lcGetActiveProject ( ) - > SetActiveModel ( CommandId - LC_MODEL_01 ) ;
break ;
2014-12-04 02:47:28 +01:00
case LC_HELP_HOMEPAGE :
g_App - > OpenURL ( " http://www.leocad.org/ " ) ;
break ;
case LC_HELP_EMAIL :
g_App - > OpenURL ( " mailto:leozide@gmail.com?subject=LeoCAD " ) ;
break ;
case LC_HELP_UPDATES :
DoDialog ( LC_DIALOG_CHECK_UPDATES , NULL ) ;
break ;
case LC_HELP_ABOUT :
DoDialog ( LC_DIALOG_ABOUT , NULL ) ;
case LC_VIEW_TIME_ADD_KEYS :
SetAddKeys ( ! GetAddKeys ( ) ) ;
break ;
2015-01-18 06:36:14 +01:00
case LC_EDIT_TRANSFORM_RELATIVE :
SetRelativeTransform ( ! GetRelativeTransform ( ) ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_LOCK_X :
SetLockX ( ! GetLockX ( ) ) ;
break ;
case LC_EDIT_LOCK_Y :
SetLockY ( ! GetLockY ( ) ) ;
break ;
case LC_EDIT_LOCK_Z :
SetLockZ ( ! GetLockZ ( ) ) ;
break ;
case LC_EDIT_LOCK_NONE :
SetLockX ( false ) ;
SetLockY ( false ) ;
SetLockZ ( false ) ;
break ;
case LC_EDIT_SNAP_MOVE_XY0 :
case LC_EDIT_SNAP_MOVE_XY1 :
case LC_EDIT_SNAP_MOVE_XY2 :
case LC_EDIT_SNAP_MOVE_XY3 :
case LC_EDIT_SNAP_MOVE_XY4 :
case LC_EDIT_SNAP_MOVE_XY5 :
case LC_EDIT_SNAP_MOVE_XY6 :
case LC_EDIT_SNAP_MOVE_XY7 :
case LC_EDIT_SNAP_MOVE_XY8 :
case LC_EDIT_SNAP_MOVE_XY9 :
SetMoveXYSnapIndex ( CommandId - LC_EDIT_SNAP_MOVE_XY0 ) ;
break ;
case LC_EDIT_SNAP_MOVE_Z0 :
case LC_EDIT_SNAP_MOVE_Z1 :
case LC_EDIT_SNAP_MOVE_Z2 :
case LC_EDIT_SNAP_MOVE_Z3 :
case LC_EDIT_SNAP_MOVE_Z4 :
case LC_EDIT_SNAP_MOVE_Z5 :
case LC_EDIT_SNAP_MOVE_Z6 :
case LC_EDIT_SNAP_MOVE_Z7 :
case LC_EDIT_SNAP_MOVE_Z8 :
case LC_EDIT_SNAP_MOVE_Z9 :
SetMoveZSnapIndex ( CommandId - LC_EDIT_SNAP_MOVE_Z0 ) ;
break ;
case LC_EDIT_SNAP_ANGLE0 :
case LC_EDIT_SNAP_ANGLE1 :
case LC_EDIT_SNAP_ANGLE2 :
case LC_EDIT_SNAP_ANGLE3 :
case LC_EDIT_SNAP_ANGLE4 :
case LC_EDIT_SNAP_ANGLE5 :
case LC_EDIT_SNAP_ANGLE6 :
case LC_EDIT_SNAP_ANGLE7 :
case LC_EDIT_SNAP_ANGLE8 :
case LC_EDIT_SNAP_ANGLE9 :
SetAngleSnapIndex ( CommandId - LC_EDIT_SNAP_ANGLE0 ) ;
break ;
case LC_EDIT_TRANSFORM :
2014-12-08 08:32:39 +01:00
lcGetActiveModel ( ) - > TransformSelectedObjects ( GetTransformType ( ) , GetTransformAmount ( ) ) ;
2014-12-04 02:47:28 +01:00
break ;
case LC_EDIT_TRANSFORM_ABSOLUTE_TRANSLATION :
case LC_EDIT_TRANSFORM_RELATIVE_TRANSLATION :
case LC_EDIT_TRANSFORM_ABSOLUTE_ROTATION :
case LC_EDIT_TRANSFORM_RELATIVE_ROTATION :
SetTransformType ( ( lcTransformType ) ( CommandId - LC_EDIT_TRANSFORM_ABSOLUTE_TRANSLATION ) ) ;
break ;
case LC_EDIT_ACTION_SELECT :
SetTool ( LC_TOOL_SELECT ) ;
break ;
case LC_EDIT_ACTION_INSERT :
SetTool ( LC_TOOL_INSERT ) ;
break ;
case LC_EDIT_ACTION_LIGHT :
SetTool ( LC_TOOL_LIGHT ) ;
break ;
case LC_EDIT_ACTION_SPOTLIGHT :
SetTool ( LC_TOOL_SPOTLIGHT ) ;
break ;
case LC_EDIT_ACTION_CAMERA :
SetTool ( LC_TOOL_CAMERA ) ;
break ;
case LC_EDIT_ACTION_MOVE :
SetTool ( LC_TOOL_MOVE ) ;
break ;
case LC_EDIT_ACTION_ROTATE :
SetTool ( LC_TOOL_ROTATE ) ;
break ;
case LC_EDIT_ACTION_DELETE :
SetTool ( LC_TOOL_ERASER ) ;
break ;
case LC_EDIT_ACTION_PAINT :
SetTool ( LC_TOOL_PAINT ) ;
break ;
case LC_EDIT_ACTION_ZOOM :
SetTool ( LC_TOOL_ZOOM ) ;
break ;
case LC_EDIT_ACTION_ZOOM_REGION :
SetTool ( LC_TOOL_ZOOM_REGION ) ;
break ;
case LC_EDIT_ACTION_PAN :
SetTool ( LC_TOOL_PAN ) ;
break ;
case LC_EDIT_ACTION_ROTATE_VIEW :
SetTool ( LC_TOOL_ROTATE_VIEW ) ;
break ;
case LC_EDIT_ACTION_ROLL :
SetTool ( LC_TOOL_ROLL ) ;
break ;
case LC_EDIT_CANCEL :
mActiveView - > CancelTrackingOrClearSelection ( ) ;
break ;
case LC_NUM_COMMANDS :
break ;
}
}