mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Changed startup order to fix saving images from the command line.
This commit is contained in:
parent
817ffce7ef
commit
257672a64f
5 changed files with 49 additions and 71 deletions
|
@ -277,49 +277,30 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
|
||||||
// Create a new project.
|
// Create a new project.
|
||||||
mProject = new Project();
|
mProject = new Project();
|
||||||
|
|
||||||
GL_DisableVertexBufferObject();
|
|
||||||
|
|
||||||
// Load project.
|
// Load project.
|
||||||
if (ProjectName && gMainWindow->OpenProject(ProjectName))
|
if (ProjectName && gMainWindow->OpenProject(ProjectName))
|
||||||
{
|
{
|
||||||
if (!SaveImage)
|
if (!SaveImage)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Check if there's a file name and it has an extension.
|
QString FileName;
|
||||||
bool NeedExt = true;
|
|
||||||
String FileName;
|
|
||||||
|
|
||||||
if (!ImageName)
|
if (ImageName)
|
||||||
{
|
FileName = ImageName;
|
||||||
|
else
|
||||||
FileName = ProjectName;
|
FileName = ProjectName;
|
||||||
|
|
||||||
int i = FileName.ReverseFind('.');
|
QString Extension = QFileInfo(FileName).suffix().toLower();
|
||||||
if (i != -1)
|
|
||||||
FileName[i] = 0;
|
if (Extension.isEmpty())
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
FileName = ImageName;
|
|
||||||
|
|
||||||
int i = FileName.ReverseFind('.');
|
|
||||||
String Ext;
|
|
||||||
|
|
||||||
if (i != -1)
|
|
||||||
{
|
|
||||||
Ext = FileName.Right(FileName.GetLength() - i);
|
|
||||||
Ext.MakeLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Ext == "bmp")
|
|
||||||
NeedExt = false;
|
|
||||||
else if ((Ext == "jpg") || (Ext == "jpeg"))
|
|
||||||
NeedExt = false;
|
|
||||||
else if (Ext == "png")
|
|
||||||
NeedExt = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NeedExt)
|
|
||||||
FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
|
FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
|
||||||
|
}
|
||||||
|
else if (Extension != "bmp" && Extension != "jpg" && Extension != "jpeg" && Extension != "png")
|
||||||
|
{
|
||||||
|
FileName = FileName.left(FileName.length() - Extension.length() - 1);
|
||||||
|
FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
|
||||||
|
}
|
||||||
|
|
||||||
if (ImageEnd < ImageStart)
|
if (ImageEnd < ImageStart)
|
||||||
ImageEnd = ImageStart;
|
ImageEnd = ImageStart;
|
||||||
|
@ -345,18 +326,17 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
|
||||||
if (ImageEnd > 255)
|
if (ImageEnd > 255)
|
||||||
ImageEnd = 255;
|
ImageEnd = 255;
|
||||||
|
|
||||||
String Frame;
|
QString Frame;
|
||||||
|
|
||||||
if (ImageStart != ImageEnd)
|
if (ImageStart != ImageEnd)
|
||||||
{
|
{
|
||||||
int Ext = FileName.ReverseFind('.');
|
QString Extension = QFileInfo(FileName).suffix();
|
||||||
|
Frame = FileName.left(FileName.length() - Extension.length() - 1) + QLatin1String("%1.") + Extension;
|
||||||
Frame = FileName.Left(Ext) + "%1" + FileName.Right(FileName.GetLength() - Ext);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Frame = FileName;
|
Frame = FileName;
|
||||||
|
|
||||||
lcGetActiveModel()->SaveStepImages(Frame.Buffer(), ImageWidth, ImageHeight, ImageStart, ImageEnd);
|
lcGetActiveModel()->SaveStepImages(Frame, ImageWidth, ImageHeight, ImageStart, ImageEnd);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1072,7 +1072,13 @@ void lcModel::SaveStepImages(const QString& BaseName, int Width, int Height, lcS
|
||||||
SetCurrentStep(Step);
|
SetCurrentStep(Step);
|
||||||
View.OnDraw();
|
View.OnDraw();
|
||||||
|
|
||||||
QString FileName = BaseName.arg(Step, 2, 10, QLatin1Char('0'));
|
QString FileName;
|
||||||
|
|
||||||
|
if (Start == End)
|
||||||
|
FileName = BaseName;
|
||||||
|
else
|
||||||
|
FileName = BaseName.arg(Step, 2, 10, QLatin1Char('0'));
|
||||||
|
|
||||||
if (!Context->SaveRenderToTextureImage(FileName, Width, Height))
|
if (!Context->SaveRenderToTextureImage(FileName, Width, Height))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,37 +43,14 @@ lcQMainWindow::lcQMainWindow(QWidget *parent)
|
||||||
QGridLayout *previewLayout = new QGridLayout(previewFrame);
|
QGridLayout *previewLayout = new QGridLayout(previewFrame);
|
||||||
previewLayout->setContentsMargins(0, 0, 0, 0);
|
previewLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
QWidget *viewWidget = new lcQGLWidget(previewFrame, piecePreview, new View(lcGetActiveModel()), true);
|
QWidget *viewWidget = new lcQGLWidget(previewFrame, piecePreview, new View(NULL), true);
|
||||||
previewLayout->addWidget(viewWidget, 0, 0, 1, 1);
|
previewLayout->addWidget(viewWidget, 0, 0, 1, 1);
|
||||||
|
|
||||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardChanged()));
|
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardChanged()));
|
||||||
clipboardChanged();
|
clipboardChanged();
|
||||||
|
|
||||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
PiecePreview* Preview = (PiecePreview*)piecePreview->widget;
|
||||||
PieceInfo* Info = Library->FindPiece("3005", false);
|
gMainWindow->mPreviewWidget = Preview;
|
||||||
|
|
||||||
GL_EnableVertexBufferObject();
|
|
||||||
|
|
||||||
if (!lcGetActiveModel()->GetPieces().IsEmpty())
|
|
||||||
{
|
|
||||||
for (int PieceIdx = 0; PieceIdx < Library->mPieces.GetSize(); PieceIdx++)
|
|
||||||
{
|
|
||||||
lcMesh* Mesh = Library->mPieces[PieceIdx]->GetMesh();
|
|
||||||
|
|
||||||
if (Mesh)
|
|
||||||
Mesh->UpdateBuffers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Info)
|
|
||||||
Info = Library->mPieces[0];
|
|
||||||
|
|
||||||
if (Info)
|
|
||||||
{
|
|
||||||
PiecePreview* Preview = (PiecePreview*)piecePreview->widget;
|
|
||||||
gMainWindow->mPreviewWidget = Preview;
|
|
||||||
Preview->SetCurrentPiece(Info);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup("MainWindow");
|
settings.beginGroup("MainWindow");
|
||||||
|
@ -88,6 +65,23 @@ lcQMainWindow::~lcQMainWindow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcQMainWindow::LibraryLoaded()
|
||||||
|
{
|
||||||
|
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||||
|
PieceInfo* Info = Library->FindPiece("3005", false);
|
||||||
|
|
||||||
|
if (!Info)
|
||||||
|
Info = Library->mPieces[0];
|
||||||
|
|
||||||
|
if (Info)
|
||||||
|
gMainWindow->mPreviewWidget->SetCurrentPiece(Info);
|
||||||
|
|
||||||
|
QCompleter *completer = new QCompleter(this);
|
||||||
|
completer->setModel(new lcQPartsListModel(completer));
|
||||||
|
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
partSearch->setCompleter(completer);
|
||||||
|
}
|
||||||
|
|
||||||
void lcQMainWindow::createActions()
|
void lcQMainWindow::createActions()
|
||||||
{
|
{
|
||||||
for (int Command = 0; Command < LC_NUM_COMMANDS; Command++)
|
for (int Command = 0; Command < LC_NUM_COMMANDS; Command++)
|
||||||
|
@ -502,11 +496,6 @@ void lcQMainWindow::createToolBars()
|
||||||
connect(partSearch, SIGNAL(returnPressed()), this, SLOT(partSearchReturn()));
|
connect(partSearch, SIGNAL(returnPressed()), this, SLOT(partSearchReturn()));
|
||||||
connect(partSearch, SIGNAL(textChanged(QString)), this, SLOT(partSearchChanged(QString)));
|
connect(partSearch, SIGNAL(textChanged(QString)), this, SLOT(partSearchChanged(QString)));
|
||||||
|
|
||||||
QCompleter *completer = new QCompleter(this);
|
|
||||||
completer->setModel(new lcQPartsListModel(completer));
|
|
||||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
partSearch->setCompleter(completer);
|
|
||||||
|
|
||||||
QFrame *colorFrame = new QFrame(partsSplitter);
|
QFrame *colorFrame = new QFrame(partsSplitter);
|
||||||
colorFrame->setFrameShape(QFrame::StyledPanel);
|
colorFrame->setFrameShape(QFrame::StyledPanel);
|
||||||
colorFrame->setFrameShadow(QFrame::Sunken);
|
colorFrame->setFrameShadow(QFrame::Sunken);
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
explicit lcQMainWindow(QWidget *parent = 0);
|
explicit lcQMainWindow(QWidget *parent = 0);
|
||||||
~lcQMainWindow();
|
~lcQMainWindow();
|
||||||
|
|
||||||
|
void LibraryLoaded();
|
||||||
|
|
||||||
void showPrintDialog();
|
void showPrintDialog();
|
||||||
|
|
||||||
void splitHorizontal();
|
void splitHorizontal();
|
||||||
|
|
|
@ -176,12 +176,13 @@ int main(int argc, char *argv[])
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkpath(cachePath);
|
dir.mkpath(cachePath);
|
||||||
gMainWindow = new lcMainWindow();
|
gMainWindow = new lcMainWindow();
|
||||||
|
lcQMainWindow w;
|
||||||
|
gMainWindow->mHandle = &w;
|
||||||
|
|
||||||
if (!g_App->Initialize(argc, argv, libPath, LDrawPath, cachePath.toLocal8Bit().data()))
|
if (!g_App->Initialize(argc, argv, libPath, LDrawPath, cachePath.toLocal8Bit().data()))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
lcQMainWindow w;
|
w.LibraryLoaded();
|
||||||
gMainWindow->mHandle = &w;
|
|
||||||
lcGetActiveModel()->UpdateInterface();
|
lcGetActiveModel()->UpdateInterface();
|
||||||
gMainWindow->SetColorIndex(lcGetColorIndex(4));
|
gMainWindow->SetColorIndex(lcGetColorIndex(4));
|
||||||
gMainWindow->UpdateRecentFiles();
|
gMainWindow->UpdateRecentFiles();
|
||||||
|
|
Loading…
Reference in a new issue