Added option to control which models to export to HTML.

This commit is contained in:
leo 2016-05-30 22:41:03 +00:00
parent 1e8adcd880
commit d8191b0758
8 changed files with 342 additions and 260 deletions

View file

@ -3,7 +3,7 @@
// Image Options
#define LC_IMAGE_TRANSPARENT 0x2000
#define LC_IMAGE_MASK 0x7000
//#define LC_IMAGE_MASK 0x7000
enum LC_IMAGE_FORMAT
{

View file

@ -37,8 +37,9 @@ struct lcImageDialogOptions
struct lcHTMLDialogOptions
{
QString PathName;
LC_IMAGE_FORMAT ImageFormat;
bool TransparentImages;
bool SubModels;
bool CurrentOnly;
bool SinglePage;
bool IndexPage;
int StepImagesWidth;

View file

@ -2729,6 +2729,21 @@ lcModel* lcModel::GetFirstSelectedSubmodel() const
return NULL;
}
void lcModel::GetSubModels(lcArray<lcModel*> SubModels) const
{
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
{
lcPiece* Piece = mPieces[PieceIdx];
if (Piece->mPieceInfo->IsModel())
{
lcModel* SubModel = Piece->mPieceInfo->GetModel();
if (SubModels.FindIndex(SubModel) != -1)
SubModels.Add(SubModel);
}
}
}
bool lcModel::GetMoveRotateTransform(lcVector3& Center, lcMatrix33& RelativeRotation) const
{
bool Relative = gMainWindow->GetRelativeTransform();

View file

@ -229,6 +229,7 @@ public:
bool AnyPiecesSelected() const;
bool AnyObjectsSelected() const;
lcModel* GetFirstSelectedSubmodel() const;
void GetSubModels(lcArray<lcModel*> SubModels) const;
bool GetMoveRotateTransform(lcVector3& Center, lcMatrix33& RelativeRotation) const;
bool GetPieceFocusOrSelectionCenter(lcVector3& Center) const;
lcVector3 GetSelectionOrModelCenter() const;

View file

@ -969,7 +969,7 @@ void Project::ExportCSV()
setlocale(LC_NUMERIC, OldLocale);
}
void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep Step, bool Images, const QString& ImageExtension)
void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep Step, bool Images)
{
int* ColorsUsed = new int[gColorList.GetSize()];
memset(ColorsUsed, 0, sizeof(ColorsUsed[0]) * gColorList.GetSize());
@ -1018,7 +1018,7 @@ void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep St
if (Add)
{
if (Images)
Stream << QString("<tr><td><IMG SRC=\"%1%2\" ALT=\"%3\"></td>\n").arg(pInfo->m_strName, ImageExtension, pInfo->m_strDescription);
Stream << QString("<tr><td><IMG SRC=\"%1.png\" ALT=\"%2\"></td>\n").arg(pInfo->m_strName, pInfo->m_strDescription);
else
Stream << QString("<tr><td>%1</td>\r\n").arg(pInfo->m_strDescription);
@ -1063,8 +1063,9 @@ void Project::ExportHTML()
int ImageOptions = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS);
int HTMLOptions = lcGetProfileInt(LC_PROFILE_HTML_OPTIONS);
Options.ImageFormat = (LC_IMAGE_FORMAT)(ImageOptions & ~(LC_IMAGE_MASK));
Options.TransparentImages = (ImageOptions & LC_IMAGE_TRANSPARENT) != 0;
Options.SubModels = (HTMLOptions & (LC_HTML_SUBMODELS)) != 0;
Options.CurrentOnly = (HTMLOptions & LC_HTML_CURRENT_ONLY) != 0;
Options.SinglePage = (HTMLOptions & LC_HTML_SINGLEPAGE) != 0;
Options.IndexPage = (HTMLOptions & LC_HTML_INDEX) != 0;
Options.StepImagesWidth = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_WIDTH);
@ -1082,6 +1083,10 @@ void Project::ExportHTML()
HTMLOptions = 0;
if (Options.SubModels)
HTMLOptions |= LC_HTML_SUBMODELS;
if (Options.CurrentOnly)
HTMLOptions |= LC_HTML_CURRENT_ONLY;
if (Options.SinglePage)
HTMLOptions |= LC_HTML_SINGLEPAGE;
if (Options.IndexPage)
@ -1095,12 +1100,7 @@ void Project::ExportHTML()
if (Options.PartsListImages)
HTMLOptions |= LC_HTML_IMAGES;
ImageOptions = Options.ImageFormat;
if (Options.TransparentImages)
ImageOptions |= LC_IMAGE_TRANSPARENT;
lcSetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS, ImageOptions);
lcSetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS, Options.TransparentImages ? LC_IMAGE_TRANSPARENT : 0);
lcSetProfileInt(LC_PROFILE_HTML_OPTIONS, HTMLOptions);
lcSetProfileInt(LC_PROFILE_HTML_IMAGE_WIDTH, Options.StepImagesWidth);
lcSetProfileInt(LC_PROFILE_HTML_IMAGE_HEIGHT, Options.StepImagesHeight);
@ -1111,31 +1111,217 @@ void Project::ExportHTML()
QDir Dir(Options.PathName);
Dir.mkpath(QLatin1String("."));
QString Title = GetTitle();
QString BaseName = Title.left(Title.length() - QFileInfo(Title).suffix().length() - 1);
QString HTMLExtension = QLatin1String(".html");
QString ImageExtension;
lcArray<lcModel*> Models;
switch (Options.ImageFormat)
if (Options.CurrentOnly)
Models.Add(mActiveModel);
else if (Options.SubModels)
{
case LC_IMAGE_BMP:
ImageExtension = QLatin1String(".bmp");
break;
case LC_IMAGE_JPG:
ImageExtension = QLatin1String(".jpg");
break;
default:
case LC_IMAGE_PNG:
ImageExtension = QLatin1String(".png");
break;
Models.Add(mActiveModel);
mActiveModel->GetSubModels(Models);
}
lcModel* Model = mModels[0];
lcStep LastStep = Model->GetLastStep();
else
Models = mModels;
if (Options.SinglePage)
QString ProjectTitle = GetTitle();
for (int ModelIdx = 0; ModelIdx < Models.GetSize(); ModelIdx++)
{
QString FileName = QFileInfo(Dir, BaseName + HTMLExtension).absoluteFilePath();
lcModel* Model = mModels[ModelIdx];
QString BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1);
lcStep LastStep = Model->GetLastStep();
QString PageTitle;
if (Models.GetSize() > 1)
{
BaseName += '-' + Model->GetProperties().mName;
PageTitle = Model->GetProperties().mName;
}
else
PageTitle = ProjectTitle;
BaseName.replace('#', '_');
if (Options.SinglePage)
{
QString FileName = QFileInfo(Dir, BaseName + QLatin1String(".html")).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(PageTitle);
for (lcStep Step = 1; Step <= LastStep; Step++)
{
QString StepString = QString::fromLatin1("%1").arg(Step, 2, 10, QLatin1Char('0'));
Stream << QString::fromLatin1("<IMG SRC=\"%1-%2.png\" ALT=\"Step %3\" WIDTH=%4 HEIGHT=%5><BR><BR>\r\n").arg(BaseName, StepString, StepString, QString::number(Options.StepImagesWidth), QString::number(Options.StepImagesHeight));
if (Options.PartsListStep)
CreateHTMLPieceList(Stream, Model, Step, Options.PartsListImages);
}
if (Options.PartsListEnd)
CreateHTMLPieceList(Stream, Model, 0, Options.PartsListImages);
Stream << QLatin1String("</CENTER>\n<BR><HR><BR><B><I>Created by <A HREF=\"http://www.leocad.org\">LeoCAD</A></B></I><BR></HTML>\r\n");
}
else
{
if (Options.IndexPage)
{
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-index.html")).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(PageTitle);
for (lcStep Step = 1; Step <= LastStep; Step++)
Stream << QString::fromLatin1("<A HREF=\"%1-%2.html\">Step %3<BR>\r\n</A>").arg(BaseName, QString("%1").arg(Step, 2, 10, QLatin1Char('0')), QString::number(Step));
if (Options.PartsListEnd)
Stream << QString::fromLatin1("<A HREF=\"%1-pieces.html\">Pieces Used</A><BR>\r\n").arg(BaseName);
Stream << QLatin1String("</CENTER>\r\n<BR><HR><BR><B><I>Created by <A HREF=\"http://www.leocad.org\">LeoCAD</A></B></I><BR></HTML>\r\n");
}
for (lcStep Step = 1; Step <= LastStep; Step++)
{
QString StepString = QString::fromLatin1("%1").arg(Step, 2, 10, QLatin1Char('0'));
QString FileName = QFileInfo(Dir, QString("%1-%2.html").arg(BaseName, StepString)).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>%1 - Step %2</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(PageTitle, QString::number(Step));
Stream << QString::fromLatin1("<IMG SRC=\"%1-%2.png\" ALT=\"Step %3\" WIDTH=%4 HEIGHT=%5><BR><BR>\r\n").arg(BaseName, StepString, StepString, QString::number(Options.StepImagesWidth), QString::number(Options.StepImagesHeight));
if (Options.PartsListStep)
CreateHTMLPieceList(Stream, Model, Step, Options.PartsListImages);
Stream << QLatin1String("</CENTER>\r\n<BR><HR><BR>");
if (Step != 1)
Stream << QString::fromLatin1("<A HREF=\"%1-%2.html\">Previous</A> ").arg(BaseName, QString("%1").arg(Step - 1, 2, 10, QLatin1Char('0')));
if (Options.IndexPage)
Stream << QString::fromLatin1("<A HREF=\"%1-index.html\">Index</A> ").arg(BaseName);
if (Step != LastStep)
Stream << QString::fromLatin1("<A HREF=\"%1-%2.html\">Next</A>").arg(BaseName, QString("%1").arg(Step + 1, 2, 10, QLatin1Char('0')));
else if (Options.PartsListEnd)
Stream << QString::fromLatin1("<A HREF=\"%1-pieces.html\">Pieces Used</A>").arg(BaseName);
Stream << QLatin1String("<BR></HTML>\r\n");
}
if (Options.PartsListEnd)
{
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-pieces.html")).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>Pieces used by %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\n").arg(PageTitle);
CreateHTMLPieceList(Stream, Model, 0, Options.PartsListImages);
Stream << QLatin1String("</CENTER>\n<BR><HR><BR>");
Stream << QString::fromLatin1("<A HREF=\"%1-%2.html\">Previous</A> ").arg(BaseName, QString("%1").arg(LastStep, 2, 10, QLatin1Char('0')));
if (Options.IndexPage)
Stream << QString::fromLatin1("<A HREF=\"%1-index.html\">Index</A> ").arg(BaseName);
Stream << QLatin1String("<BR></HTML>\r\n");
}
}
QString StepImageBaseName = QFileInfo(Dir, BaseName + QLatin1String("-%1.png")).absoluteFilePath();
Model->SaveStepImages(StepImageBaseName, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep);
if (Options.PartsListImages)
{
gMainWindow->mPreviewWidget->MakeCurrent();
lcContext* Context = gMainWindow->mPreviewWidget->mContext;
int Width = Options.PartImagesWidth;
int Height = Options.PartImagesHeight;
if (!Context->BeginRenderToTexture(Width, Height))
{
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Error creating images."));
return;
}
float aspect = (float)Width / (float)Height;
Context->SetViewport(0, 0, Width, Height);
lcArray<lcPartsListEntry> PartsList;
Model->GetPartsList(gDefaultColor, PartsList);
lcMatrix44 ProjectionMatrix = lcMatrix44Perspective(30.0f, aspect, 1.0f, 2500.0f);
lcMatrix44 ViewMatrix;
Context->SetDefaultState();
Context->SetProjectionMatrix(ProjectionMatrix);
Context->SetProgram(LC_PROGRAM_SIMPLE);
for (int PieceIdx = 0; PieceIdx < PartsList.GetSize(); PieceIdx++)
{
PieceInfo* Info = PartsList[PieceIdx].Info;
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
lcVector3 CameraPosition(-100.0f, -100.0f, 75.0f);
Info->ZoomExtents(ProjectionMatrix, ViewMatrix, CameraPosition);
lcScene Scene;
Scene.Begin(ViewMatrix);
Info->AddRenderMeshes(Scene, lcMatrix44Identity(), Options.PartImagesColor, false, false);
Scene.End();
Context->SetViewMatrix(ViewMatrix);
Context->DrawOpaqueMeshes(Scene.mOpaqueMeshes);
Context->DrawTranslucentMeshes(Scene.mTranslucentMeshes);
Context->UnbindMesh(); // context remove
QString FileName = QFileInfo(Dir, QLatin1String(Info->m_strName) + QLatin1String(".png")).absoluteFilePath();
if (!Context->SaveRenderToTextureImage(FileName, Width, Height))
break;
}
Context->EndRenderToTexture();
}
}
if (Models.GetSize() > 1)
{
QString BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1);
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-index.html")).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
@ -1146,168 +1332,24 @@ void Project::ExportHTML()
QTextStream Stream(&File);
Stream << QString("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(Title);
Stream << QString::fromLatin1("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(ProjectTitle);
for (lcStep Step = 1; Step <= LastStep; Step++)
for (int ModelIdx = 0; ModelIdx < Models.GetSize(); ModelIdx++)
{
QString StepString = QString("%1").arg(Step, 2, 10, QLatin1Char('0'));
Stream << QString("<IMG SRC=\"%1-%2%3\" ALT=\"Step %4\" WIDTH=%5 HEIGHT=%6><BR><BR>\r\n").arg(BaseName, StepString, ImageExtension, StepString, QString::number(Options.StepImagesWidth), QString::number(Options.StepImagesHeight));
lcModel* Model = Models[ModelIdx];
QString BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1) + '-' + Model->GetProperties().mName;
BaseName.replace('#', '_');
if (Options.PartsListStep)
CreateHTMLPieceList(Stream, Model, Step, Options.PartsListImages, ImageExtension);
if (Options.SinglePage)
FileName = BaseName + QLatin1String(".html");
else
FileName = BaseName + QLatin1String("-index.html");
Stream << QString::fromLatin1("<p><a href=\"%1\">%2</a>").arg(FileName, Model->GetProperties().mName);
}
if (Options.PartsListEnd)
CreateHTMLPieceList(Stream, Model, 0, Options.PartsListImages, ImageExtension);
Stream << QLatin1String("</CENTER>\n<BR><HR><BR><B><I>Created by <A HREF=\"http://www.leocad.org\">LeoCAD</A></B></I><BR></HTML>\r\n");
}
else
{
if (Options.IndexPage)
{
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-index") + HTMLExtension).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString("<HTML>\r\n<HEAD>\r\n<TITLE>Instructions for %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(Title);
for (lcStep Step = 1; Step <= LastStep; Step++)
Stream << QString("<A HREF=\"%1-%2.html\">Step %3<BR>\r\n</A>").arg(BaseName, QString("%1").arg(Step, 2, 10, QLatin1Char('0')), QString::number(Step));
if (Options.PartsListEnd)
Stream << QString("<A HREF=\"%1-pieces.html\">Pieces Used</A><BR>\r\n").arg(BaseName);
Stream << QLatin1String("</CENTER>\r\n<BR><HR><BR><B><I>Created by <A HREF=\"http://www.leocad.org\">LeoCAD</A></B></I><BR></HTML>\r\n");
}
for (lcStep Step = 1; Step <= LastStep; Step++)
{
QString StepString = QString("%1").arg(Step, 2, 10, QLatin1Char('0'));
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-") + StepString + HTMLExtension).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString("<HTML>\r\n<HEAD>\r\n<TITLE>%1 - Step %2</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\r\n").arg(Title, QString::number(Step));
Stream << QString("<IMG SRC=\"%1-%2%3\" ALT=\"Step %4\" WIDTH=%5 HEIGHT=%6><BR><BR>\r\n").arg(BaseName, StepString, ImageExtension, StepString, QString::number(Options.StepImagesWidth), QString::number(Options.StepImagesHeight));
if (Options.PartsListStep)
CreateHTMLPieceList(Stream, Model, Step, Options.PartsListImages, ImageExtension);
Stream << QLatin1String("</CENTER>\r\n<BR><HR><BR>");
if (Step != 1)
Stream << QString("<A HREF=\"%1-%2.html\">Previous</A> ").arg(BaseName, QString("%1").arg(Step - 1, 2, 10, QLatin1Char('0')));
if (Options.IndexPage)
Stream << QString("<A HREF=\"%1-index.html\">Index</A> ").arg(BaseName);
if (Step != LastStep)
Stream << QString("<A HREF=\"%1-%2.html\">Next</A>").arg(BaseName, QString("%1").arg(Step + 1, 2, 10, QLatin1Char('0')));
else if (Options.PartsListEnd)
Stream << QString("<A HREF=\"%1-pieces.html\">Pieces Used</A>").arg(BaseName);
Stream << QLatin1String("<BR></HTML>\r\n");
}
if (Options.PartsListEnd)
{
QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-pieces") + HTMLExtension).absoluteFilePath();
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
QTextStream Stream(&File);
Stream << QString("<HTML>\r\n<HEAD>\r\n<TITLE>Pieces used by %1</TITLE>\r\n</HEAD>\r\n<BR>\r\n<CENTER>\n").arg(Title);
CreateHTMLPieceList(Stream, Model, 0, Options.PartsListImages, ImageExtension);
Stream << QLatin1String("</CENTER>\n<BR><HR><BR>");
Stream << QString("<A HREF=\"%1-%2.html\">Previous</A> ").arg(BaseName, QString("%1").arg(LastStep, 2, 10, QLatin1Char('0')));
if (Options.IndexPage)
Stream << QString("<A HREF=\"%1-index.html\">Index</A> ").arg(BaseName);
Stream << QLatin1String("<BR></HTML>\r\n");
}
}
QString StepImageBaseName = QFileInfo(Dir, BaseName + QLatin1String("-%1") + ImageExtension).absoluteFilePath();
Model->SaveStepImages(StepImageBaseName, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep);
if (Options.PartsListImages)
{
gMainWindow->mPreviewWidget->MakeCurrent();
lcContext* Context = gMainWindow->mPreviewWidget->mContext;
int Width = Options.PartImagesWidth;
int Height = Options.PartImagesHeight;
if (!Context->BeginRenderToTexture(Width, Height))
{
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Error creating images."));
return;
}
float aspect = (float)Width/(float)Height;
Context->SetViewport(0, 0, Width, Height);
lcArray<lcPartsListEntry> PartsList;
Model->GetPartsList(gDefaultColor, PartsList);
lcMatrix44 ProjectionMatrix = lcMatrix44Perspective(30.0f, aspect, 1.0f, 2500.0f);
lcMatrix44 ViewMatrix;
Context->SetDefaultState();
Context->SetProjectionMatrix(ProjectionMatrix);
Context->SetProgram(LC_PROGRAM_SIMPLE);
for (int PieceIdx = 0; PieceIdx < PartsList.GetSize(); PieceIdx++)
{
PieceInfo* Info = PartsList[PieceIdx].Info;
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
lcVector3 CameraPosition(-100.0f, -100.0f, 75.0f);
Info->ZoomExtents(ProjectionMatrix, ViewMatrix, CameraPosition);
lcScene Scene;
Scene.Begin(ViewMatrix);
Info->AddRenderMeshes(Scene, lcMatrix44Identity(), Options.PartImagesColor, false, false);
Scene.End();
Context->SetViewMatrix(ViewMatrix);
Context->DrawOpaqueMeshes(Scene.mOpaqueMeshes);
Context->DrawTranslucentMeshes(Scene.mTranslucentMeshes);
Context->UnbindMesh(); // context remove
QString FileName = QFileInfo(Dir, Info->m_strName + ImageExtension).absoluteFilePath();
if (!Context->SaveRenderToTextureImage(FileName, Width, Height))
break;
}
Context->EndRenderToTexture();
}
}
void Project::ExportPOVRay()

View file

@ -10,14 +10,14 @@
#define LC_SCENE_BG_TILE 0x040 // Tile bg image
#define LC_SCENE_GRADIENT 0x100 // Draw gradient
#define LC_HTML_SINGLEPAGE 0x01
#define LC_HTML_INDEX 0x02
#define LC_HTML_IMAGES 0x04
#define LC_HTML_LISTEND 0x08
#define LC_HTML_LISTSTEP 0x10
#define LC_HTML_HIGHLIGHT 0x20
//#define LC_HTML_HTMLEXT 0x40
//#define LC_HTML_LISTID 0x80
#define LC_HTML_SINGLEPAGE 0x01
#define LC_HTML_INDEX 0x02
#define LC_HTML_IMAGES 0x04
#define LC_HTML_LISTEND 0x08
#define LC_HTML_LISTSTEP 0x10
#define LC_HTML_HIGHLIGHT 0x20
#define LC_HTML_SUBMODELS 0x40
#define LC_HTML_CURRENT_ONLY 0x80
enum LC_MOUSE_TRACK
{
@ -70,7 +70,7 @@ public:
protected:
QString GetExportFileName(const QString& FileName, const QString& DefaultExtension, const QString& DialogTitle, const QString& DialogFilter) const;
void GetModelParts(lcArray<lcModelPartsEntry>& ModelParts);
void CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep Step, bool Images, const QString& ImageExtension);
void CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep Step, bool Images);
bool mModified;
QString mFileName;

View file

@ -17,7 +17,14 @@ lcQHTMLDialog::lcQHTMLDialog(QWidget *parent, void *data) :
options = (lcHTMLDialogOptions*)data;
ui->outputFolder->setText(QDir::toNativeSeparators(options->PathName));
ui->imageFormat->setCurrentIndex(options->ImageFormat);
if (options->CurrentOnly)
ui->currentModelOnly->setChecked(true);
else if (options->SubModels)
ui->currentModelSubmodels->setChecked(true);
else
ui->allModels->setChecked(true);
ui->transparentImages->setChecked(options->TransparentImages);
ui->singlePage->setChecked(options->SinglePage);
ui->oneStepPerPage->setChecked(!options->SinglePage);
@ -49,7 +56,8 @@ void lcQHTMLDialog::accept()
}
options->PathName = pathName;
options->ImageFormat = (LC_IMAGE_FORMAT)ui->imageFormat->currentIndex();
options->SubModels = ui->currentModelSubmodels->isChecked();
options->CurrentOnly = ui->currentModelOnly->isChecked();
options->TransparentImages = ui->transparentImages->isChecked();
options->SinglePage = ui->singlePage->isChecked();
options->IndexPage = ui->indexPage->isChecked();

View file

@ -7,34 +7,43 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>553</height>
<height>617</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>HTML Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>General</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Output folder:</string>
</property>
<property name="buddy">
<cstring>outputFolder</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Output folder:</string>
</property>
<property name="buddy">
<cstring>outputFolder</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="outputFolder"/>
</item>
@ -47,37 +56,41 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Image format:</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item>
<widget class="QCheckBox" name="transparentImages">
<property name="text">
<string>Transparent image background</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="imageFormat">
<item>
<property name="text">
<string>BMP</string>
</property>
</item>
<item>
<property name="text">
<string>JPEG</string>
</property>
</item>
<item>
<property name="text">
<string>PNG</string>
</property>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Models</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="allModels">
<property name="text">
<string>All Models</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="currentModelSubmodels">
<property name="text">
<string>Current Model and Submodels</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="currentModelOnly">
<property name="text">
<string>Current Model Only</string>
</property>
</widget>
</item>
</layout>
@ -86,20 +99,27 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Layout</string>
<string>Steps</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="singlePage">
<property name="text">
<string>Single page</string>
<string>Single Page</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="oneStepPerPage">
<property name="text">
<string>One step per page</string>
<string>One Step per Page</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="indexPage">
<property name="text">
<string>Index page</string>
</property>
</widget>
</item>
@ -113,16 +133,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height:</string>
</property>
<property name="buddy">
<cstring>stepHeight</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="stepWidth">
<property name="maximumSize">
@ -133,6 +143,16 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height:</string>
</property>
<property name="buddy">
<cstring>stepHeight</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="stepHeight">
<property name="maximumSize">
@ -143,13 +163,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="indexPage">
<property name="text">
<string>Index page</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="highlightNewParts">
<property name="text">
@ -294,11 +307,12 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>outputFolder</tabstop>
<tabstop>outputFolderBrowse</tabstop>
<tabstop>imageFormat</tabstop>
<tabstop>transparentImages</tabstop>
<tabstop>allModels</tabstop>
<tabstop>currentModelSubmodels</tabstop>
<tabstop>currentModelOnly</tabstop>
<tabstop>singlePage</tabstop>
<tabstop>oneStepPerPage</tabstop>
<tabstop>indexPage</tabstop>
@ -308,6 +322,7 @@
<tabstop>partsAfterEachStep</tabstop>
<tabstop>partsAtTheEnd</tabstop>
<tabstop>partImages</tabstop>
<tabstop>partColor</tabstop>
<tabstop>partImagesWidth</tabstop>
<tabstop>partImagesHeight</tabstop>
</tabstops>