mirror of
https://github.com/leozide/leocad
synced 2024-12-28 22:23:35 +01:00
Viewpoint name parsing cleanup.
This commit is contained in:
parent
3d77537408
commit
6b2f8fa68c
3 changed files with 40 additions and 34 deletions
|
@ -62,6 +62,28 @@ lcCamera::~lcCamera()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcViewpoint lcCamera::GetViewpoint(const QString& ViewpointName)
|
||||||
|
{
|
||||||
|
const QLatin1String ViewpointNames[] =
|
||||||
|
{
|
||||||
|
QLatin1String("front"),
|
||||||
|
QLatin1String("back"),
|
||||||
|
QLatin1String("top"),
|
||||||
|
QLatin1String("bottom"),
|
||||||
|
QLatin1String("left"),
|
||||||
|
QLatin1String("right"),
|
||||||
|
QLatin1String("home")
|
||||||
|
};
|
||||||
|
|
||||||
|
LC_ARRAY_SIZE_CHECK(ViewpointNames, lcViewpoint::Count);
|
||||||
|
|
||||||
|
for (int ViewpointIndex = 0; ViewpointIndex < static_cast<int>(lcViewpoint::Count); ViewpointIndex++)
|
||||||
|
if (ViewpointNames[ViewpointIndex] == ViewpointName)
|
||||||
|
return static_cast<lcViewpoint>(ViewpointIndex);
|
||||||
|
|
||||||
|
return lcViewpoint::Count;
|
||||||
|
}
|
||||||
|
|
||||||
void lcCamera::Initialize()
|
void lcCamera::Initialize()
|
||||||
{
|
{
|
||||||
m_fovy = 30.0f;
|
m_fovy = 30.0f;
|
||||||
|
|
|
@ -25,7 +25,8 @@ enum class lcViewpoint
|
||||||
Bottom,
|
Bottom,
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
Home
|
Home,
|
||||||
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lcCameraSection
|
enum lcCameraSection
|
||||||
|
@ -43,9 +44,9 @@ public:
|
||||||
~lcCamera();
|
~lcCamera();
|
||||||
|
|
||||||
lcCamera(const lcCamera&) = delete;
|
lcCamera(const lcCamera&) = delete;
|
||||||
lcCamera(lcCamera&&) = delete;
|
|
||||||
lcCamera& operator=(const lcCamera&) = delete;
|
lcCamera& operator=(const lcCamera&) = delete;
|
||||||
lcCamera& operator=(lcCamera&&) = delete;
|
|
||||||
|
static lcViewpoint GetViewpoint(const QString& ViewpointName);
|
||||||
|
|
||||||
QString GetName() const override
|
QString GetName() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -345,12 +345,12 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
||||||
float CameraLatLon[2] = {0.0f, 0.0f};
|
float CameraLatLon[2] = {0.0f, 0.0f};
|
||||||
float FoV = 0.0f;
|
float FoV = 0.0f;
|
||||||
float ZPlanes[2] = {0.0f, 0.0f};
|
float ZPlanes[2] = {0.0f, 0.0f};
|
||||||
|
lcViewpoint Viewpoint = lcViewpoint::Count;
|
||||||
quint32 FadeStepsColor = mPreferences.mFadeStepsColor;
|
quint32 FadeStepsColor = mPreferences.mFadeStepsColor;
|
||||||
quint32 HighlightColor = mPreferences.mHighlightNewPartsColor;
|
quint32 HighlightColor = mPreferences.mHighlightNewPartsColor;
|
||||||
QString ImageName;
|
QString ImageName;
|
||||||
QString ModelName;
|
QString ModelName;
|
||||||
QString CameraName;
|
QString CameraName;
|
||||||
QString ViewpointName;
|
|
||||||
QString ProjectName;
|
QString ProjectName;
|
||||||
QString SaveWavefrontName;
|
QString SaveWavefrontName;
|
||||||
QString Save3DSName;
|
QString Save3DSName;
|
||||||
|
@ -550,18 +550,17 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
||||||
ParseString(CameraName, true);
|
ParseString(CameraName, true);
|
||||||
else if (Param == QLatin1String("--viewpoint"))
|
else if (Param == QLatin1String("--viewpoint"))
|
||||||
{
|
{
|
||||||
if (ParseString(ViewpointName, true)
|
QString ViewpointName;
|
||||||
// TODO: move the string checks into view or camera
|
|
||||||
&& ViewpointName != QLatin1String("front")
|
if (ParseString(ViewpointName, true))
|
||||||
&& 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());
|
Viewpoint = lcCamera::GetViewpoint(ViewpointName);
|
||||||
ParseOK = false;
|
|
||||||
|
if (Viewpoint == lcViewpoint::Count)
|
||||||
|
{
|
||||||
|
printf("Invalid parameter value specified for the '%s' option: '%s'.\n", Param.toLatin1().constData(), Arguments[ArgIdx].toLatin1().constData());
|
||||||
|
ParseOK = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Param == QLatin1String("--camera-angles"))
|
else if (Param == QLatin1String("--camera-angles"))
|
||||||
|
@ -814,7 +813,7 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
||||||
{
|
{
|
||||||
ActiveView->SetCamera(CameraName);
|
ActiveView->SetCamera(CameraName);
|
||||||
|
|
||||||
if (!ViewpointName.isEmpty())
|
if (Viewpoint != lcViewpoint::Count)
|
||||||
printf("Warning: --viewpoint is ignored when --camera is set.\n");
|
printf("Warning: --viewpoint is ignored when --camera is set.\n");
|
||||||
|
|
||||||
if (Orthographic)
|
if (Orthographic)
|
||||||
|
@ -841,25 +840,9 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
||||||
Camera->m_zFar = ZPlanes[1];
|
Camera->m_zFar = ZPlanes[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ViewpointName.isEmpty())
|
if (Viewpoint != lcViewpoint::Count)
|
||||||
{
|
{
|
||||||
if (ViewpointName == QLatin1String("front"))
|
ActiveView->SetViewpoint(Viewpoint);
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Front);
|
|
||||||
else if (ViewpointName == QLatin1String("back"))
|
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Back);
|
|
||||||
else if (ViewpointName == QLatin1String("top"))
|
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Top);
|
|
||||||
else if (ViewpointName == QLatin1String("bottom"))
|
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Bottom);
|
|
||||||
else if (ViewpointName == QLatin1String("left"))
|
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Left);
|
|
||||||
else if (ViewpointName == QLatin1String("right"))
|
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Right);
|
|
||||||
else if (ViewpointName == QLatin1String("home"))
|
|
||||||
ActiveView->SetViewpoint(lcViewpoint::Home);
|
|
||||||
else
|
|
||||||
printf("Warning: unknown viewpoint: '%s'\n", ViewpointName.toLatin1().constData());
|
|
||||||
// TODO: move the above into view or camera
|
|
||||||
|
|
||||||
if (SetCameraAngles)
|
if (SetCameraAngles)
|
||||||
printf("Warning: --camera-angles is ignored when --viewpoint is set.\n");
|
printf("Warning: --camera-angles is ignored when --viewpoint is set.\n");
|
||||||
|
|
Loading…
Reference in a new issue