mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Use a regular View for the Minifig Wizard.
This commit is contained in:
parent
fd24accea7
commit
b77210db22
15 changed files with 113 additions and 253 deletions
|
@ -13,8 +13,8 @@
|
|||
lcGLWidget* lcGLWidget::mLastFocusedView;
|
||||
std::vector<lcGLWidget*> lcGLWidget::mViews;
|
||||
|
||||
lcGLWidget::lcGLWidget(lcModel* Model)
|
||||
: mScene(new lcScene()), mModel(Model)
|
||||
lcGLWidget::lcGLWidget(lcViewType ViewType, lcModel* Model)
|
||||
: mScene(new lcScene()), mModel(Model), mViewType(ViewType)
|
||||
{
|
||||
mContext = new lcContext();
|
||||
mViews.push_back(this);
|
||||
|
|
|
@ -80,12 +80,20 @@ enum class lcTrackTool
|
|||
Count
|
||||
};
|
||||
|
||||
enum class lcViewType
|
||||
{
|
||||
View,
|
||||
Preview,
|
||||
Minifig,
|
||||
Count
|
||||
};
|
||||
|
||||
class lcGLWidget : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lcGLWidget(lcModel* Model);
|
||||
lcGLWidget(lcViewType ViewType, lcModel* Model);
|
||||
virtual ~lcGLWidget();
|
||||
|
||||
lcGLWidget(const lcGLWidget&) = delete;
|
||||
|
@ -96,6 +104,11 @@ public:
|
|||
|
||||
lcModel* GetActiveModel() const;
|
||||
|
||||
lcViewType GetViewType() const
|
||||
{
|
||||
return mViewType;
|
||||
}
|
||||
|
||||
lcCamera* GetCamera() const
|
||||
{
|
||||
return mCamera;
|
||||
|
@ -230,6 +243,7 @@ protected:
|
|||
int mWidth = 1;
|
||||
int mHeight = 1;
|
||||
bool mDeleteContext = true;
|
||||
lcViewType mViewType;
|
||||
|
||||
static lcGLWidget* mLastFocusedView;
|
||||
static std::vector<lcGLWidget*> mViews;
|
||||
|
|
|
@ -770,7 +770,7 @@ void lcMainWindow::CreateToolBars()
|
|||
|
||||
View* lcMainWindow::CreateView(lcModel* Model)
|
||||
{
|
||||
View* NewView = new View(Model);
|
||||
View* NewView = new View(lcViewType::View, Model);
|
||||
|
||||
connect(NewView, SIGNAL(CameraChanged()), this, SLOT(ViewCameraChanged()));
|
||||
connect(NewView, SIGNAL(FocusReceived()), this, SLOT(ViewFocusReceived()));
|
||||
|
|
|
@ -1275,7 +1275,7 @@ QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
|
|||
if (Zoom)
|
||||
ZoomExtents(Camera, (float)Width / (float)Height);
|
||||
|
||||
View View(this);
|
||||
View View(lcViewType::View, this);
|
||||
View.SetCamera(Camera, false);
|
||||
View.SetContext(Context);
|
||||
|
||||
|
@ -4418,7 +4418,7 @@ void lcModel::ShowMinifigDialog()
|
|||
|
||||
lcGroup* Group = AddGroup(tr("Minifig #"), nullptr);
|
||||
lcArray<lcObject*> Pieces(LC_MFW_NUMITEMS);
|
||||
lcMinifig& Minifig = Dialog.mMinifigWidget->mMinifig;
|
||||
lcMinifig& Minifig = Dialog.mMinifigWizard->mMinifig;
|
||||
|
||||
for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ void lcPreviewDockWidget::SetPreviewLock()
|
|||
}
|
||||
|
||||
lcPreviewWidget::lcPreviewWidget()
|
||||
: lcGLWidget(nullptr), mLoader(new Project(true))
|
||||
: lcGLWidget(lcViewType::Preview, nullptr), mLoader(new Project(true))
|
||||
{
|
||||
mViewSphere = std::unique_ptr<lcViewSphere>(new lcViewSphere(this));
|
||||
mLoader->SetActiveModel(0);
|
||||
|
|
|
@ -32,17 +32,23 @@ void lcViewSphere::UpdateSettings()
|
|||
{
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
|
||||
if (!mIsPreview)
|
||||
switch (mWidget->GetViewType())
|
||||
{
|
||||
case lcViewType::View:
|
||||
mSize = Preferences.mViewSphereSize;
|
||||
mEnabled = Preferences.mViewSphereEnabled;
|
||||
mLocation = Preferences.mViewSphereLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
case lcViewType::Preview:
|
||||
mSize = Preferences.mPreviewViewSphereSize;
|
||||
mEnabled = Preferences.mPreviewViewSphereEnabled;
|
||||
mLocation = Preferences.mPreviewViewSphereLocation;
|
||||
break;
|
||||
|
||||
case lcViewType::Minifig:
|
||||
case lcViewType::Count:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ protected:
|
|||
bool mIsPreview = false;
|
||||
|
||||
int mSize = 1;
|
||||
bool mEnabled = true;
|
||||
bool mEnabled = false;
|
||||
lcViewSphereLocation mLocation = lcViewSphereLocation::TopRight;
|
||||
|
||||
int mMouseDownX = 0;
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
static QList<lcViewWidget*> gWidgetList;
|
||||
|
||||
lcViewWidget::lcViewWidget(QWidget* Parent, lcGLWidget* Owner)
|
||||
lcViewWidget::lcViewWidget(QWidget* Parent, lcGLWidget* View)
|
||||
: QGLWidget(Parent, gWidgetList.isEmpty() ? nullptr : gWidgetList.first())
|
||||
{
|
||||
mWheelAccumulator = 0;
|
||||
mView = Owner;
|
||||
mView = View;
|
||||
mView->SetWidget(this);
|
||||
|
||||
makeCurrent();
|
||||
|
@ -55,7 +55,7 @@ lcViewWidget::lcViewWidget(QWidget* Parent, lcGLWidget* Owner)
|
|||
|
||||
setMouseTracking(true);
|
||||
|
||||
if (dynamic_cast<View*>(Owner))
|
||||
if (View->GetViewType() == lcViewType::View)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setAcceptDrops(true);
|
||||
|
|
|
@ -36,19 +36,10 @@ const char* MinifigWizard::mSectionNames[LC_MFW_NUMITEMS] =
|
|||
};
|
||||
|
||||
MinifigWizard::MinifigWizard()
|
||||
: lcGLWidget(nullptr)
|
||||
: mModel(new lcModel(QString(), nullptr, false))
|
||||
{
|
||||
LoadSettings();
|
||||
LoadTemplates();
|
||||
|
||||
mModel = new lcModel(QString(), nullptr, false);
|
||||
mCamera = new lcCamera(true);
|
||||
|
||||
mRotateX = 75.0f;
|
||||
mRotateZ = 180.0f;
|
||||
mDistance = 10.0f;
|
||||
mAutoZoom = true;
|
||||
mTracking = LC_TRACK_NONE;
|
||||
}
|
||||
|
||||
MinifigWizard::~MinifigWizard()
|
||||
|
@ -59,9 +50,6 @@ MinifigWizard::~MinifigWizard()
|
|||
if (mMinifig.Parts[i])
|
||||
Library->ReleasePieceInfo(mMinifig.Parts[i]); // todo: don't call ReleasePieceInfo here because it may release textures and they need a GL context current
|
||||
|
||||
delete mModel;
|
||||
delete mCamera;
|
||||
|
||||
SaveTemplates();
|
||||
}
|
||||
|
||||
|
@ -86,11 +74,8 @@ void MinifigWizard::LoadSettings()
|
|||
ParseSettings(MinifigFile);
|
||||
}
|
||||
|
||||
void MinifigWizard::OnInitialUpdate()
|
||||
void MinifigWizard::LoadDefault()
|
||||
{
|
||||
MakeCurrent();
|
||||
mContext->SetDefaultState();
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(MinifigWizard::mSectionNames, LC_MFW_NUMITEMS);
|
||||
|
||||
const int ColorCodes[LC_MFW_NUMITEMS] = { 4, 7, 14, 7, 1, 0, 7, 4, 4, 14, 14, 7, 7, 0, 0, 7, 7 };
|
||||
|
@ -315,156 +300,6 @@ void MinifigWizard::SaveTemplates()
|
|||
#endif
|
||||
}
|
||||
|
||||
void MinifigWizard::OnDraw()
|
||||
{
|
||||
mContext->SetDefaultState();
|
||||
|
||||
mContext->SetViewport(0, 0, mWidth, mHeight);
|
||||
|
||||
DrawBackground();
|
||||
|
||||
DrawViewport();
|
||||
|
||||
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||
|
||||
for (int InfoIdx = 0; InfoIdx < LC_MFW_NUMITEMS; InfoIdx++)
|
||||
{
|
||||
const PieceInfo* const Info = mMinifig.Parts[InfoIdx];
|
||||
|
||||
if (!Info)
|
||||
continue;
|
||||
|
||||
lcVector3 Points[8];
|
||||
lcGetBoxCorners(Info->GetBoundingBox(), Points);
|
||||
|
||||
for (int PointIdx = 0; PointIdx < 8; PointIdx++)
|
||||
{
|
||||
const lcVector3 Point = lcMul31(Points[PointIdx], mMinifig.Matrices[InfoIdx]);
|
||||
|
||||
Min = lcMin(Point, Min);
|
||||
Max = lcMax(Point, Max);
|
||||
}
|
||||
}
|
||||
|
||||
const lcVector3 Center = (Min + Max) / 2.0f;
|
||||
|
||||
lcVector3 Eye(0.0f, 0.0f, 1.0f);
|
||||
|
||||
Eye = lcMul30(Eye, lcMatrix44RotationX(-mRotateX * LC_DTOR));
|
||||
Eye = lcMul30(Eye, lcMatrix44RotationZ(-mRotateZ * LC_DTOR));
|
||||
|
||||
const float Aspect = (float)mWidth / (float)mHeight;
|
||||
const lcMatrix44 Projection = lcMatrix44Perspective(30.0f, Aspect, 1.0f, 2500.0f);
|
||||
mContext->SetProjectionMatrix(Projection);
|
||||
|
||||
lcMatrix44& ViewMatrix = mCamera->mWorldView;
|
||||
|
||||
if (mAutoZoom)
|
||||
{
|
||||
lcVector3 Points[8];
|
||||
lcGetBoxCorners(Min, Max, Points);
|
||||
|
||||
Eye += Center;
|
||||
|
||||
const lcMatrix44 ModelView = lcMatrix44LookAt(Eye, Center, lcVector3(0, 0, 1));
|
||||
std::tie(Eye, std::ignore) = lcZoomExtents(Eye, ModelView, Projection, Points, 8);
|
||||
|
||||
ViewMatrix = lcMatrix44LookAt(Eye, Center, lcVector3(0, 0, 1));
|
||||
|
||||
const lcVector3 d = Eye - Center;
|
||||
mDistance = d.Length();
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewMatrix = lcMatrix44LookAt(Eye * mDistance, Center, lcVector3(0, 0, 1));
|
||||
}
|
||||
|
||||
Calculate();
|
||||
|
||||
mScene->Begin(ViewMatrix);
|
||||
mScene->SetAllowLOD(false);
|
||||
|
||||
mModel->GetScene(mScene.get(), mCamera, false, false);
|
||||
|
||||
mScene->End();
|
||||
|
||||
mScene->Draw(mContext);
|
||||
|
||||
mContext->ClearResources();
|
||||
}
|
||||
|
||||
void MinifigWizard::OnLeftButtonDown()
|
||||
{
|
||||
if (mTracking == LC_TRACK_NONE)
|
||||
{
|
||||
mDownX = mMouseX;
|
||||
mDownY = mMouseY;
|
||||
mTracking = LC_TRACK_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
void MinifigWizard::OnLeftButtonUp()
|
||||
{
|
||||
if (mTracking == LC_TRACK_LEFT)
|
||||
mTracking = LC_TRACK_NONE;
|
||||
}
|
||||
|
||||
void MinifigWizard::OnLeftButtonDoubleClick()
|
||||
{
|
||||
mAutoZoom = true;
|
||||
Redraw();
|
||||
}
|
||||
|
||||
void MinifigWizard::OnRightButtonDown()
|
||||
{
|
||||
if (mTracking == LC_TRACK_NONE)
|
||||
{
|
||||
mDownX = mMouseX;
|
||||
mDownY = mMouseY;
|
||||
mTracking = LC_TRACK_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
void MinifigWizard::OnRightButtonUp()
|
||||
{
|
||||
if (mTracking == LC_TRACK_RIGHT)
|
||||
mTracking = LC_TRACK_NONE;
|
||||
}
|
||||
|
||||
void MinifigWizard::OnMouseMove()
|
||||
{
|
||||
if (mTracking == LC_TRACK_LEFT)
|
||||
{
|
||||
// Rotate.
|
||||
mRotateZ += mMouseX - mDownX;
|
||||
mRotateX += mMouseY - mDownY;
|
||||
|
||||
if (mRotateX > 179.5f)
|
||||
mRotateX = 179.5f;
|
||||
else if (mRotateX < 0.5f)
|
||||
mRotateX = 0.5f;
|
||||
|
||||
mDownX = mMouseX;
|
||||
mDownY = mMouseY;
|
||||
|
||||
Redraw();
|
||||
}
|
||||
else if (mTracking == LC_TRACK_RIGHT)
|
||||
{
|
||||
// Zoom.
|
||||
mDistance += (float)(mDownY - mMouseY) * 0.2f;
|
||||
mAutoZoom = false;
|
||||
|
||||
if (mDistance < 0.5f)
|
||||
mDistance = 0.5f;
|
||||
|
||||
mDownX = mMouseX;
|
||||
mDownY = mMouseY;
|
||||
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void MinifigWizard::Calculate()
|
||||
{
|
||||
float HeadOffset = 0.0f;
|
||||
|
@ -650,7 +485,6 @@ int MinifigWizard::GetSelectionIndex(int Type) const
|
|||
void MinifigWizard::SetSelectionIndex(int Type, int Index)
|
||||
{
|
||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
MakeCurrent();
|
||||
|
||||
if (mMinifig.Parts[Type])
|
||||
Library->ReleasePieceInfo(mMinifig.Parts[Type]);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "lc_glwidget.h"
|
||||
#include "lc_math.h"
|
||||
|
||||
enum LC_MFW_TYPES
|
||||
|
@ -47,16 +46,19 @@ struct lcMinifigTemplate
|
|||
float Angles[LC_MFW_NUMITEMS];
|
||||
};
|
||||
|
||||
class MinifigWizard : public lcGLWidget
|
||||
class MinifigWizard
|
||||
{
|
||||
public:
|
||||
MinifigWizard();
|
||||
~MinifigWizard();
|
||||
|
||||
MinifigWizard(const MinifigWizard&) = delete;
|
||||
MinifigWizard(MinifigWizard&&) = delete;
|
||||
MinifigWizard& operator=(const MinifigWizard&) = delete;
|
||||
MinifigWizard& operator=(MinifigWizard&&) = delete;
|
||||
|
||||
lcModel* GetModel() const
|
||||
{
|
||||
return mModel.get();
|
||||
}
|
||||
|
||||
const std::map<QString, lcMinifigTemplate>& GetTemplates() const
|
||||
{
|
||||
|
@ -68,14 +70,7 @@ public:
|
|||
void AddTemplatesJson(const QByteArray& TemplateData);
|
||||
QByteArray GetTemplatesJson() const;
|
||||
|
||||
void OnDraw() override;
|
||||
void OnLeftButtonDown() override;
|
||||
void OnLeftButtonUp() override;
|
||||
void OnLeftButtonDoubleClick() override;
|
||||
void OnRightButtonDown() override;
|
||||
void OnRightButtonUp() override;
|
||||
void OnMouseMove() override;
|
||||
void OnInitialUpdate() override;
|
||||
void LoadDefault();
|
||||
|
||||
void Calculate();
|
||||
int GetSelectionIndex(int Type) const;
|
||||
|
@ -83,26 +78,18 @@ public:
|
|||
void SetColor(int Type, int Color);
|
||||
void SetAngle(int Type, float Angle);
|
||||
|
||||
void ParseSettings(lcFile& Settings);
|
||||
|
||||
std::vector<lcMinifigPieceInfo> mSettings[LC_MFW_NUMITEMS];
|
||||
|
||||
lcMinifig mMinifig;
|
||||
|
||||
int mTracking;
|
||||
int mDownX;
|
||||
int mDownY;
|
||||
|
||||
float mDistance;
|
||||
float mRotateX;
|
||||
float mRotateZ;
|
||||
bool mAutoZoom;
|
||||
|
||||
protected:
|
||||
void LoadSettings();
|
||||
void ParseSettings(lcFile& Settings);
|
||||
|
||||
void LoadTemplates();
|
||||
void SaveTemplates();
|
||||
|
||||
std::unique_ptr<lcModel> mModel;
|
||||
std::map<QString, lcMinifigTemplate> mTemplates;
|
||||
static const char* mSectionNames[LC_MFW_NUMITEMS];
|
||||
};
|
||||
|
|
|
@ -29,13 +29,6 @@ public:
|
|||
bool PartsListEnd;
|
||||
};
|
||||
|
||||
enum LC_MOUSE_TRACK
|
||||
{
|
||||
LC_TRACK_NONE,
|
||||
LC_TRACK_LEFT,
|
||||
LC_TRACK_RIGHT
|
||||
};
|
||||
|
||||
struct lcInstructionsPageLayout;
|
||||
|
||||
class Project
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
lcVertexBuffer View::mRotateMoveVertexBuffer;
|
||||
lcIndexBuffer View::mRotateMoveIndexBuffer;
|
||||
|
||||
View::View(lcModel* Model)
|
||||
: lcGLWidget(Model)
|
||||
View::View(lcViewType ViewType, lcModel* Model)
|
||||
: lcGLWidget(ViewType, Model)
|
||||
{
|
||||
mViewSphere = std::unique_ptr<lcViewSphere>(new lcViewSphere(this));
|
||||
memset(mGridSettings, 0, sizeof(mGridSettings));
|
||||
|
@ -638,7 +638,7 @@ void View::OnDraw()
|
|||
}
|
||||
}
|
||||
|
||||
if (DrawInterface)
|
||||
if (DrawInterface && mViewType == lcViewType::View)
|
||||
mScene->SetPreTranslucentCallback([this]() { DrawGrid(); });
|
||||
|
||||
mScene->End();
|
||||
|
@ -730,6 +730,8 @@ void View::OnDraw()
|
|||
|
||||
mContext->SetLineWidth(1.0f);
|
||||
|
||||
if (mViewType == lcViewType::View)
|
||||
{
|
||||
if (Preferences.mDrawAxes)
|
||||
DrawAxes();
|
||||
|
||||
|
@ -748,6 +750,8 @@ void View::OnDraw()
|
|||
DrawRotateViewOverlay();
|
||||
|
||||
mViewSphere->Draw();
|
||||
}
|
||||
|
||||
DrawViewport();
|
||||
}
|
||||
|
||||
|
@ -1693,6 +1697,13 @@ void View::Zoom(float Amount)
|
|||
|
||||
void View::UpdateTrackTool()
|
||||
{
|
||||
if (mViewType != lcViewType::View)
|
||||
{
|
||||
mTrackTool = lcTrackTool::None;
|
||||
UpdateCursor();
|
||||
return;
|
||||
}
|
||||
|
||||
lcTool CurrentTool = gMainWindow->GetTool();
|
||||
lcTrackTool NewTrackTool = mTrackTool;
|
||||
int x = mMouseX;
|
||||
|
|
|
@ -8,7 +8,7 @@ class View : public lcGLWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
View(lcModel* Model);
|
||||
View(lcViewType ViewType, lcModel* Model);
|
||||
~View();
|
||||
|
||||
View(const View&) = delete;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "lc_application.h"
|
||||
#include "pieceinf.h"
|
||||
#include "lc_library.h"
|
||||
#include "view.h"
|
||||
#include "camera.h"
|
||||
|
||||
lcQMinifigDialog::lcQMinifigDialog(QWidget* Parent)
|
||||
: QDialog(Parent), ui(new Ui::lcQMinifigDialog)
|
||||
|
@ -44,15 +46,19 @@ lcQMinifigDialog::lcQMinifigDialog(QWidget* Parent)
|
|||
QGridLayout* PreviewLayout = new QGridLayout(ui->minifigFrame);
|
||||
PreviewLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
mMinifigWidget = new MinifigWizard();
|
||||
mMinifigWizard = new MinifigWizard();
|
||||
mView = new View(lcViewType::Minifig, mMinifigWizard->GetModel());
|
||||
|
||||
lcViewWidget* ViewWidget = new lcViewWidget(nullptr, mMinifigWidget);
|
||||
lcViewWidget* ViewWidget = new lcViewWidget(nullptr, mView);
|
||||
ViewWidget->setMinimumWidth(100);
|
||||
PreviewLayout->addWidget(ViewWidget);
|
||||
|
||||
mView->MakeCurrent();
|
||||
mMinifigWizard->LoadDefault();
|
||||
|
||||
for (int ItemIndex = 0; ItemIndex < LC_MFW_NUMITEMS; ItemIndex++)
|
||||
{
|
||||
std::vector<lcMinifigPieceInfo>& PartList = mMinifigWidget->mSettings[ItemIndex];
|
||||
std::vector<lcMinifigPieceInfo>& PartList = mMinifigWizard->mSettings[ItemIndex];
|
||||
QStringList ItemStrings;
|
||||
QVector<int> Separators;
|
||||
|
||||
|
@ -72,12 +78,12 @@ lcQMinifigDialog::lcQMinifigDialog(QWidget* Parent)
|
|||
ItemCombo->addItems(ItemStrings);
|
||||
for (int SeparatorIndex = Separators.size() - 1; SeparatorIndex >= 0; SeparatorIndex--)
|
||||
ItemCombo->insertSeparator(Separators[SeparatorIndex]);
|
||||
ItemCombo->setCurrentIndex(mMinifigWidget->GetSelectionIndex(ItemIndex));
|
||||
ItemCombo->setCurrentIndex(mMinifigWizard->GetSelectionIndex(ItemIndex));
|
||||
ItemCombo->blockSignals(false);
|
||||
|
||||
lcQColorPicker *colorPicker = mColorPickers[ItemIndex];
|
||||
colorPicker->blockSignals(true);
|
||||
colorPicker->setCurrentColor(mMinifigWidget->mMinifig.Colors[ItemIndex]);
|
||||
colorPicker->setCurrentColor(mMinifigWizard->mMinifig.Colors[ItemIndex]);
|
||||
colorPicker->blockSignals(false);
|
||||
}
|
||||
|
||||
|
@ -85,12 +91,16 @@ lcQMinifigDialog::lcQMinifigDialog(QWidget* Parent)
|
|||
ui->TemplateGroup->hide();
|
||||
#endif
|
||||
|
||||
mMinifigWidget->OnInitialUpdate();
|
||||
UpdateTemplateCombo();
|
||||
|
||||
mMinifigWizard->Calculate();
|
||||
mView->GetCamera()->SetViewpoint(lcVector3(0.0f, -270.0f, 90.0f));
|
||||
mView->ZoomExtents();
|
||||
}
|
||||
|
||||
lcQMinifigDialog::~lcQMinifigDialog()
|
||||
{
|
||||
delete mMinifigWizard;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -98,7 +108,7 @@ void lcQMinifigDialog::UpdateTemplateCombo()
|
|||
{
|
||||
ui->TemplateComboBox->clear();
|
||||
|
||||
const auto& Templates = mMinifigWidget->GetTemplates();
|
||||
const auto& Templates = mMinifigWizard->GetTemplates();
|
||||
for (const auto& Template : Templates)
|
||||
ui->TemplateComboBox->addItem(Template.first);
|
||||
}
|
||||
|
@ -106,7 +116,7 @@ void lcQMinifigDialog::UpdateTemplateCombo()
|
|||
void lcQMinifigDialog::on_TemplateComboBox_currentIndexChanged(const QString& TemplateName)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
const auto& Templates = mMinifigWidget->GetTemplates();
|
||||
const auto& Templates = mMinifigWizard->GetTemplates();
|
||||
const auto& Position = Templates.find(TemplateName);
|
||||
if (Position == Templates.end())
|
||||
return;
|
||||
|
@ -121,7 +131,7 @@ void lcQMinifigDialog::on_TemplateComboBox_currentIndexChanged(const QString& Te
|
|||
|
||||
if (Info)
|
||||
{
|
||||
for (const lcMinifigPieceInfo& MinifigPieceInfo : mMinifigWidget->mSettings[PartIdx])
|
||||
for (const lcMinifigPieceInfo& MinifigPieceInfo : mMinifigWizard->mSettings[PartIdx])
|
||||
{
|
||||
if (Info == MinifigPieceInfo.Info)
|
||||
{
|
||||
|
@ -142,6 +152,8 @@ void lcQMinifigDialog::on_TemplateComboBox_currentIndexChanged(const QString& Te
|
|||
if (AngleSpinBox)
|
||||
AngleSpinBox->setValue(Template.Angles[PartIdx]);
|
||||
}
|
||||
|
||||
mMinifigWizard->Calculate();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -172,13 +184,13 @@ void lcQMinifigDialog::on_TemplateSaveButton_clicked()
|
|||
|
||||
for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++)
|
||||
{
|
||||
Template.Parts[PartIdx] = mMinifigWidget->mSettings[PartIdx][mComboBoxes[PartIdx]->currentIndex()].Info->mFileName;
|
||||
Template.Parts[PartIdx] = mMinifigWizard->mSettings[PartIdx][mComboBoxes[PartIdx]->currentIndex()].Info->mFileName;
|
||||
Template.Colors[PartIdx] = mColorPickers[PartIdx]->currentColorCode();
|
||||
QDoubleSpinBox* AngleSpinBox = mSpinBoxes[PartIdx];
|
||||
Template.Angles[PartIdx] = AngleSpinBox ? AngleSpinBox->value() : 0.0f;
|
||||
}
|
||||
|
||||
mMinifigWidget->SaveTemplate(TemplateName, Template);
|
||||
mMinifigWizard->SaveTemplate(TemplateName, Template);
|
||||
|
||||
ui->TemplateComboBox->blockSignals(true);
|
||||
UpdateTemplateCombo();
|
||||
|
@ -195,7 +207,7 @@ void lcQMinifigDialog::on_TemplateDeleteButton_clicked()
|
|||
if (QMessageBox::question(this, tr("Delete Template"), Question, QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
mMinifigWidget->DeleteTemplate(Template);
|
||||
mMinifigWizard->DeleteTemplate(Template);
|
||||
|
||||
UpdateTemplateCombo();
|
||||
}
|
||||
|
@ -216,7 +228,7 @@ void lcQMinifigDialog::on_TemplateImportButton_clicked()
|
|||
}
|
||||
|
||||
QByteArray FileData = File.readAll();
|
||||
mMinifigWidget->AddTemplatesJson(FileData);
|
||||
mMinifigWizard->AddTemplatesJson(FileData);
|
||||
|
||||
UpdateTemplateCombo();
|
||||
}
|
||||
|
@ -236,7 +248,7 @@ void lcQMinifigDialog::on_TemplateExportButton_clicked()
|
|||
return;
|
||||
}
|
||||
|
||||
QByteArray Templates = mMinifigWidget->GetTemplatesJson();
|
||||
QByteArray Templates = mMinifigWizard->GetTemplatesJson();
|
||||
File.write(Templates);
|
||||
}
|
||||
|
||||
|
@ -247,8 +259,9 @@ void lcQMinifigDialog::TypeChanged(int Index)
|
|||
if (Search == mComboBoxes.end())
|
||||
return;
|
||||
|
||||
mMinifigWidget->SetSelectionIndex(std::distance(mComboBoxes.begin(), Search), Index);
|
||||
mMinifigWidget->Redraw();
|
||||
mView->MakeCurrent();
|
||||
mMinifigWizard->SetSelectionIndex(std::distance(mComboBoxes.begin(), Search), Index);
|
||||
mView->Redraw();
|
||||
}
|
||||
|
||||
void lcQMinifigDialog::ColorChanged(int Index)
|
||||
|
@ -258,8 +271,8 @@ void lcQMinifigDialog::ColorChanged(int Index)
|
|||
if (Search == mColorPickers.end())
|
||||
return;
|
||||
|
||||
mMinifigWidget->SetColor(std::distance(mColorPickers.begin(), Search), Index);
|
||||
mMinifigWidget->Redraw();
|
||||
mMinifigWizard->SetColor(std::distance(mColorPickers.begin(), Search), Index);
|
||||
mView->Redraw();
|
||||
}
|
||||
|
||||
void lcQMinifigDialog::AngleChanged(double Value)
|
||||
|
@ -269,6 +282,6 @@ void lcQMinifigDialog::AngleChanged(double Value)
|
|||
if (Search == mSpinBoxes.end())
|
||||
return;
|
||||
|
||||
mMinifigWidget->SetAngle(std::distance(mSpinBoxes.begin(), Search), Value);
|
||||
mMinifigWidget->Redraw();
|
||||
mMinifigWizard->SetAngle(std::distance(mSpinBoxes.begin(), Search), Value);
|
||||
mView->Redraw();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "minifig.h"
|
||||
class lcQColorPicker;
|
||||
class View;
|
||||
|
||||
namespace Ui {
|
||||
class lcQMinifigDialog;
|
||||
|
@ -15,7 +16,7 @@ public:
|
|||
explicit lcQMinifigDialog(QWidget* Parent);
|
||||
~lcQMinifigDialog();
|
||||
|
||||
MinifigWizard* mMinifigWidget;
|
||||
MinifigWizard* mMinifigWizard;
|
||||
|
||||
protected slots:
|
||||
void on_TemplateComboBox_currentIndexChanged(const QString& TemplateName);
|
||||
|
@ -32,6 +33,7 @@ protected:
|
|||
|
||||
Ui::lcQMinifigDialog* ui;
|
||||
|
||||
View* mView;
|
||||
std::array<QComboBox*, LC_MFW_NUMITEMS> mComboBoxes;
|
||||
std::array<lcQColorPicker*, LC_MFW_NUMITEMS> mColorPickers;
|
||||
std::array<QDoubleSpinBox*, LC_MFW_NUMITEMS> mSpinBoxes;
|
||||
|
|
Loading…
Add table
Reference in a new issue