mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +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()
|
||||
{
|
||||
m_fovy = 30.0f;
|
||||
|
|
|
@ -25,7 +25,8 @@ enum class lcViewpoint
|
|||
Bottom,
|
||||
Left,
|
||||
Right,
|
||||
Home
|
||||
Home,
|
||||
Count
|
||||
};
|
||||
|
||||
enum lcCameraSection
|
||||
|
@ -43,9 +44,9 @@ public:
|
|||
~lcCamera();
|
||||
|
||||
lcCamera(const lcCamera&) = delete;
|
||||
lcCamera(lcCamera&&) = delete;
|
||||
lcCamera& operator=(const lcCamera&) = delete;
|
||||
lcCamera& operator=(lcCamera&&) = delete;
|
||||
|
||||
static lcViewpoint GetViewpoint(const QString& ViewpointName);
|
||||
|
||||
QString GetName() const override
|
||||
{
|
||||
|
|
|
@ -345,12 +345,12 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
float CameraLatLon[2] = {0.0f, 0.0f};
|
||||
float FoV = 0.0f;
|
||||
float ZPlanes[2] = {0.0f, 0.0f};
|
||||
lcViewpoint Viewpoint = lcViewpoint::Count;
|
||||
quint32 FadeStepsColor = mPreferences.mFadeStepsColor;
|
||||
quint32 HighlightColor = mPreferences.mHighlightNewPartsColor;
|
||||
QString ImageName;
|
||||
QString ModelName;
|
||||
QString CameraName;
|
||||
QString ViewpointName;
|
||||
QString ProjectName;
|
||||
QString SaveWavefrontName;
|
||||
QString Save3DSName;
|
||||
|
@ -550,18 +550,17 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
ParseString(CameraName, true);
|
||||
else if (Param == QLatin1String("--viewpoint"))
|
||||
{
|
||||
if (ParseString(ViewpointName, true)
|
||||
// TODO: move the string checks into view or camera
|
||||
&& ViewpointName != QLatin1String("front")
|
||||
&& ViewpointName != QLatin1String("back")
|
||||
&& ViewpointName != QLatin1String("top")
|
||||
&& ViewpointName != QLatin1String("bottom")
|
||||
&& ViewpointName != QLatin1String("left")
|
||||
&& ViewpointName != QLatin1String("right")
|
||||
&& ViewpointName != QLatin1String("home"))
|
||||
QString ViewpointName;
|
||||
|
||||
if (ParseString(ViewpointName, true))
|
||||
{
|
||||
printf("Invalid parameter value specified for the '%s' option: '%s'.\n", Param.toLatin1().constData(), Arguments[ArgIdx].toLatin1().constData());
|
||||
ParseOK = false;
|
||||
Viewpoint = lcCamera::GetViewpoint(ViewpointName);
|
||||
|
||||
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"))
|
||||
|
@ -814,7 +813,7 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
{
|
||||
ActiveView->SetCamera(CameraName);
|
||||
|
||||
if (!ViewpointName.isEmpty())
|
||||
if (Viewpoint != lcViewpoint::Count)
|
||||
printf("Warning: --viewpoint is ignored when --camera is set.\n");
|
||||
|
||||
if (Orthographic)
|
||||
|
@ -841,25 +840,9 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
Camera->m_zFar = ZPlanes[1];
|
||||
}
|
||||
|
||||
if (!ViewpointName.isEmpty())
|
||||
if (Viewpoint != lcViewpoint::Count)
|
||||
{
|
||||
if (ViewpointName == QLatin1String("front"))
|
||||
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
|
||||
ActiveView->SetViewpoint(Viewpoint);
|
||||
|
||||
if (SetCameraAngles)
|
||||
printf("Warning: --camera-angles is ignored when --viewpoint is set.\n");
|
||||
|
|
Loading…
Reference in a new issue