mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
POVRay lights - POV file preferences
This commit is contained in:
parent
1f075624b8
commit
d29c5b9323
3 changed files with 133 additions and 8 deletions
|
@ -107,6 +107,86 @@ void lcModelProperties::ParseLDrawLine(QTextStream& Stream)
|
|||
}
|
||||
}
|
||||
|
||||
lcPOVRayOptions::lcPOVRayOptions() :
|
||||
UseLGEO(false),
|
||||
ExcludeFloor(false),
|
||||
ExcludeBackground(false),
|
||||
NoReflection(false),
|
||||
NoShadow(false),
|
||||
FloorAxis(1),
|
||||
FloorAmbient(0.4f),
|
||||
FloorDiffuse(0.4f),
|
||||
FloorColor(0.8f,0.8f,0.8f)
|
||||
{}
|
||||
|
||||
void lcPOVRayOptions::ParseLDrawLine(QTextStream& LineStream)
|
||||
{
|
||||
QString Token;
|
||||
LineStream >> Token;
|
||||
|
||||
if (Token == QLatin1String("HEADER_INCLUDE_FILE"))
|
||||
{
|
||||
LineStream >> HeaderIncludeFile;
|
||||
if (!QFileInfo(HeaderIncludeFile).isReadable())
|
||||
HeaderIncludeFile.clear();
|
||||
}
|
||||
else if (Token == QLatin1String("FOOTER_INCLUDE_FILE"))
|
||||
{
|
||||
LineStream >> FooterIncludeFile;
|
||||
if (!QFileInfo(FooterIncludeFile).isReadable())
|
||||
FooterIncludeFile.clear();
|
||||
}
|
||||
else if (Token == QLatin1String("FLOOR_AXIS"))
|
||||
{
|
||||
LineStream >> FloorAxis;
|
||||
if (FloorAxis < 0 || FloorAxis > 2)
|
||||
FloorAxis = 1; // y
|
||||
}
|
||||
else if (Token == QLatin1String("FLOOR_COLOR_RGB"))
|
||||
LineStream >> FloorColor[0] >> FloorColor[1] >> FloorColor[2];
|
||||
else if (Token == QLatin1String("FLOOR_AMBIENT"))
|
||||
LineStream >> FloorAmbient;
|
||||
else if (Token == QLatin1String("FLOOR_DIFFUSE"))
|
||||
LineStream >> FloorDiffuse;
|
||||
else if (Token == QLatin1String("EXCLUDE_FLOOR"))
|
||||
ExcludeFloor = true;
|
||||
else if (Token == QLatin1String("EXCLUDE_BACKGROUND"))
|
||||
ExcludeFloor = true;
|
||||
else if (Token == QLatin1String("NO_REFLECTION"))
|
||||
NoReflection = true;
|
||||
else if (Token == QLatin1String("NO_SHADOWS"))
|
||||
NoShadow = true;
|
||||
else if (Token == QLatin1String("USE_LGEO"))
|
||||
UseLGEO = true;
|
||||
}
|
||||
|
||||
void lcPOVRayOptions::SaveLDraw(QTextStream& Stream) const
|
||||
{
|
||||
const QLatin1String LineEnding("\r\n");
|
||||
if (!HeaderIncludeFile.isEmpty())
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY HEADER_INCLUDE_FILE ") << QDir::toNativeSeparators(HeaderIncludeFile) << LineEnding;
|
||||
if (!FooterIncludeFile.isEmpty())
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY FOOTER_INCLUDE_FILE ") << QDir::toNativeSeparators(FooterIncludeFile) << LineEnding;
|
||||
if (FloorAxis != 1)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY FLOOR_AXIS ") << FloorAxis << LineEnding;
|
||||
if (FloorColor != lcVector3(0.8f,0.8f,0.8f))
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY FLOOR_COLOR_RGB ") << FloorColor[0] << ' ' << FloorColor[1] << ' ' << FloorColor[2] << LineEnding;
|
||||
if (FloorAmbient != 0.4f)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY FLOOR_AMBIENT ") << FloorAmbient << LineEnding;
|
||||
if (FloorDiffuse != 0.4f)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY FLOOR_DIFFUSE ") << FloorDiffuse << LineEnding;
|
||||
if (ExcludeFloor)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY EXCLUDE_FLOOR") << LineEnding;
|
||||
if (ExcludeBackground)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY EXCLUDE_BACKGROUND") << LineEnding;
|
||||
if (NoReflection)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY NO_REFLECTION") << LineEnding;
|
||||
if (NoShadow)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY NO_SHADOWS") << LineEnding;
|
||||
if (UseLGEO)
|
||||
Stream << QLatin1String("0 !LEOCAD POV_RAY USE_LGEO") << LineEnding;
|
||||
}
|
||||
|
||||
lcModel::lcModel(const QString& FileName, Project* Project, bool Preview)
|
||||
: mProject(Project), mIsPreview(Preview)
|
||||
{
|
||||
|
@ -581,6 +661,10 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
|||
Light = nullptr;
|
||||
}
|
||||
}
|
||||
else if (Token == QLatin1String("POV_RAY"))
|
||||
{
|
||||
mPOVRayOptions.ParseLDrawLine(LineStream);
|
||||
}
|
||||
else if (Token == QLatin1String("GROUP"))
|
||||
{
|
||||
LineStream >> Token;
|
||||
|
|
|
@ -67,6 +67,26 @@ public:
|
|||
lcVector3 mAmbientColor;
|
||||
};
|
||||
|
||||
class lcPOVRayOptions
|
||||
{
|
||||
public:
|
||||
lcPOVRayOptions();
|
||||
void ParseLDrawLine(QTextStream& LineStream);
|
||||
void SaveLDraw(QTextStream& Stream) const;
|
||||
|
||||
bool UseLGEO;
|
||||
bool ExcludeFloor;
|
||||
bool ExcludeBackground;
|
||||
bool NoReflection;
|
||||
bool NoShadow;
|
||||
int FloorAxis;
|
||||
float FloorAmbient;
|
||||
float FloorDiffuse;
|
||||
lcVector3 FloorColor;
|
||||
QString HeaderIncludeFile;
|
||||
QString FooterIncludeFile;
|
||||
};
|
||||
|
||||
struct lcModelHistoryEntry
|
||||
{
|
||||
QByteArray File;
|
||||
|
@ -136,6 +156,11 @@ public:
|
|||
return mProperties;
|
||||
}
|
||||
|
||||
const lcPOVRayOptions& GetPOVRayOptions() const
|
||||
{
|
||||
return mPOVRayOptions;
|
||||
}
|
||||
|
||||
void SetFileName(const QString& FileName)
|
||||
{
|
||||
if (mProperties.mModelName == mProperties.mFileName)
|
||||
|
@ -366,6 +391,7 @@ protected:
|
|||
void AddPiece(lcPiece* Piece);
|
||||
void InsertPiece(lcPiece* Piece, int Index);
|
||||
|
||||
lcPOVRayOptions mPOVRayOptions;
|
||||
lcModelProperties mProperties;
|
||||
Project* const mProject;
|
||||
PieceInfo* mPieceInfo;
|
||||
|
|
|
@ -348,14 +348,6 @@ void lcRenderDialog::on_RenderButton_clicked()
|
|||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!LGEOPath.isEmpty())
|
||||
{
|
||||
Arguments.append(QString::fromLatin1("+L%1lg/").arg(LGEOPath));
|
||||
Arguments.append(QString::fromLatin1("+L%1ar/").arg(LGEOPath));
|
||||
}
|
||||
*/
|
||||
|
||||
QString POVRayPath;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -372,6 +364,29 @@ void lcRenderDialog::on_RenderButton_clicked()
|
|||
POVRayPath = QDir::cleanPath(QCoreApplication::applicationDirPath() + QLatin1String("/povray"));
|
||||
#endif
|
||||
|
||||
const QString POVRayDir = QFileInfo(POVRayPath).absolutePath();
|
||||
const QString IncludePath = QDir::cleanPath(POVRayDir + "/include");
|
||||
if (QFileInfo(IncludePath).exists())
|
||||
Arguments.append(QString("+L\"%1\"").arg(IncludePath));
|
||||
const QString IniPath = QDir::cleanPath(POVRayDir + "/ini");
|
||||
if (QFileInfo(IniPath).exists())
|
||||
Arguments.append(QString("+L\"%1\"").arg(IniPath));
|
||||
if (lcGetActiveProject()->GetModels()[0]->GetPOVRayOptions().UseLGEO) {
|
||||
const QString LGEOPath = lcGetProfileString(LC_PROFILE_POVRAY_LGEO_PATH);
|
||||
if (QFileInfo(LGEOPath).exists())
|
||||
{
|
||||
const QString LgPath = QDir::cleanPath(LGEOPath + "/lg");
|
||||
if (QFileInfo(LgPath).exists())
|
||||
Arguments.append(QString("+L\"%1\"").arg(LgPath));
|
||||
const QString ArPath = QDir::cleanPath(LGEOPath + "/ar");
|
||||
if (QFileInfo(ArPath).exists())
|
||||
Arguments.append(QString("+L\"%1\"").arg(ArPath));
|
||||
const QString StlPath = QDir::cleanPath(LGEOPath + "/stl");
|
||||
if (QFileInfo(StlPath).exists())
|
||||
Arguments.append(QString("+L\"%1\"").arg(StlPath));
|
||||
}
|
||||
}
|
||||
|
||||
mProcess = new lcRenderProcess(this);
|
||||
#ifdef Q_OS_LINUX
|
||||
connect(mProcess, SIGNAL(readyReadStandardError()), this, SLOT(ReadStdErr()));
|
||||
|
|
Loading…
Add table
Reference in a new issue