mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Fixed edge around parts list images.
This commit is contained in:
parent
6b6f7d60b1
commit
601eb56322
6 changed files with 35 additions and 40 deletions
|
@ -4425,6 +4425,18 @@ void lcModel::SetMinifig(const lcMinifig& Minifig)
|
||||||
SetSelectionAndFocus(Pieces, nullptr, 0, false);
|
SetSelectionAndFocus(Pieces, nullptr, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcModel::SetPreviewPieceInfo(PieceInfo* Info, int ColorIndex)
|
||||||
|
{
|
||||||
|
DeleteModel();
|
||||||
|
|
||||||
|
lcPiece* Piece = new lcPiece(Info);
|
||||||
|
|
||||||
|
Piece->Initialize(lcMatrix44Identity(), 1);
|
||||||
|
Piece->SetColorIndex(ColorIndex);
|
||||||
|
AddPiece(Piece);
|
||||||
|
Piece->UpdatePosition(1);
|
||||||
|
}
|
||||||
|
|
||||||
void lcModel::UpdateInterface()
|
void lcModel::UpdateInterface()
|
||||||
{
|
{
|
||||||
if (!gMainWindow)
|
if (!gMainWindow)
|
||||||
|
|
|
@ -226,10 +226,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMinifig(const lcMinifig& Minifig);
|
void SetMinifig(const lcMinifig& Minifig);
|
||||||
void SetPreviewPiece(lcPiece* Piece)
|
void SetPreviewPieceInfo(PieceInfo* Info, int ColorIndex);
|
||||||
{
|
|
||||||
AddPiece(Piece);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cut();
|
void Cut();
|
||||||
void Copy();
|
void Copy();
|
||||||
|
|
|
@ -8,11 +8,10 @@
|
||||||
#include "lc_model.h"
|
#include "lc_model.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "pieceinf.h"
|
#include "pieceinf.h"
|
||||||
|
#include "camera.h"
|
||||||
#include "lc_scene.h"
|
#include "lc_scene.h"
|
||||||
#include "lc_view.h"
|
#include "lc_view.h"
|
||||||
#include "lc_glextensions.h"
|
#include "lc_glextensions.h"
|
||||||
#include "lc_viewwidget.h"
|
|
||||||
#include "lc_previewwidget.h"
|
|
||||||
#include "lc_category.h"
|
#include "lc_category.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QList<int>)
|
Q_DECLARE_METATYPE(QList<int>)
|
||||||
|
@ -67,6 +66,9 @@ lcPartSelectionListModel::lcPartSelectionListModel(QObject* Parent)
|
||||||
lcPartSelectionListModel::~lcPartSelectionListModel()
|
lcPartSelectionListModel::~lcPartSelectionListModel()
|
||||||
{
|
{
|
||||||
ClearRequests();
|
ClearRequests();
|
||||||
|
|
||||||
|
mView.reset();
|
||||||
|
mModel.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcPartSelectionListModel::ClearRequests()
|
void lcPartSelectionListModel::ClearRequests()
|
||||||
|
@ -395,10 +397,13 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex)
|
||||||
|
|
||||||
if (!mView)
|
if (!mView)
|
||||||
{
|
{
|
||||||
mView = std::unique_ptr<lcView>(new lcView(lcViewType::PartsList, nullptr));
|
if (!mModel)
|
||||||
|
mModel = std::unique_ptr<lcModel>(new lcModel(QString(), nullptr, true));
|
||||||
|
mView = std::unique_ptr<lcView>(new lcView(lcViewType::PartsList, mModel.get()));
|
||||||
|
|
||||||
mView->SetOffscreenContext();
|
mView->SetOffscreenContext();
|
||||||
mView->MakeCurrent();
|
mView->MakeCurrent();
|
||||||
|
mView->SetSize(Width, Height);
|
||||||
|
|
||||||
if (!mView->BeginRenderToImage(Width, Height))
|
if (!mView->BeginRenderToImage(Width, Height))
|
||||||
{
|
{
|
||||||
|
@ -410,34 +415,20 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex)
|
||||||
mView->MakeCurrent();
|
mView->MakeCurrent();
|
||||||
mView->BindRenderFramebuffer();
|
mView->BindRenderFramebuffer();
|
||||||
|
|
||||||
lcContext* Context = mView->mContext;
|
const uint BackgroundColor = mListView->palette().color(QPalette::Base).rgba();
|
||||||
|
mView->SetBackgroundColorOverride(LC_RGBA(qRed(BackgroundColor), qGreen(BackgroundColor), qBlue(BackgroundColor), 0));
|
||||||
|
|
||||||
const float Aspect = (float)Width / (float)Height;
|
|
||||||
Context->SetViewport(0, 0, Width, Height);
|
|
||||||
|
|
||||||
Context->SetDefaultState();
|
|
||||||
|
|
||||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
|
||||||
PieceInfo* Info = mParts[InfoIndex].first;
|
PieceInfo* Info = mParts[InfoIndex].first;
|
||||||
|
mModel->SetPreviewPieceInfo(Info, mColorIndex);
|
||||||
|
|
||||||
Context->ClearColorAndDepth(lcVector4(1.0f, 1.0f, 1.0f, 0.0f));
|
const lcVector3 Center = (Info->GetBoundingBox().Min + Info->GetBoundingBox().Max) / 2.0f;
|
||||||
|
const lcVector3 Position = Center + lcVector3(100.0f, -100.0f, 75.0f);
|
||||||
|
|
||||||
lcMatrix44 ProjectionMatrix, ViewMatrix;
|
mView->GetCamera()->SetViewpoint(Position, Center, lcVector3(0, 0, 1));
|
||||||
|
mView->GetCamera()->m_fovy = 20.0f;
|
||||||
|
mView->ZoomExtents();
|
||||||
|
|
||||||
Info->ZoomExtents(20.0f, Aspect, ProjectionMatrix, ViewMatrix);
|
mView->OnDraw();
|
||||||
|
|
||||||
Context->SetProjectionMatrix(ProjectionMatrix);
|
|
||||||
|
|
||||||
lcScene Scene;
|
|
||||||
Scene.SetAllowWireframe(false);
|
|
||||||
Scene.SetAllowLOD(false);
|
|
||||||
Scene.Begin(ViewMatrix);
|
|
||||||
|
|
||||||
Info->AddRenderMeshes(&Scene, lcMatrix44Identity(), mColorIndex, lcRenderMeshState::Default, false);
|
|
||||||
|
|
||||||
Scene.End();
|
|
||||||
|
|
||||||
Scene.Draw(Context);
|
|
||||||
|
|
||||||
mView->UnbindRenderFramebuffer();
|
mView->UnbindRenderFramebuffer();
|
||||||
|
|
||||||
|
@ -445,9 +436,7 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex)
|
||||||
|
|
||||||
mParts[InfoIndex].second = QPixmap::fromImage(Image).scaled(mIconSize, mIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
mParts[InfoIndex].second = QPixmap::fromImage(Image).scaled(mIconSize, mIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
|
||||||
Library->ReleasePieceInfo(Info);
|
lcGetPiecesLibrary()->ReleasePieceInfo(Info);
|
||||||
|
|
||||||
Context->ClearResources();
|
|
||||||
|
|
||||||
emit dataChanged(index(InfoIndex, 0), index(InfoIndex, 0), QVector<int>() << Qt::DecorationRole);
|
emit dataChanged(index(InfoIndex, 0), index(InfoIndex, 0), QVector<int>() << Qt::DecorationRole);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,7 @@ protected:
|
||||||
bool mShowPartAliases;
|
bool mShowPartAliases;
|
||||||
QByteArray mFilter;
|
QByteArray mFilter;
|
||||||
std::unique_ptr<lcView> mView;
|
std::unique_ptr<lcView> mView;
|
||||||
|
std::unique_ptr<lcModel> mModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class lcPartSelectionListView : public QListView
|
class lcPartSelectionListView : public QListView
|
||||||
|
|
|
@ -115,14 +115,9 @@ bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode)
|
||||||
Library->LoadPieceInfo(Info, false, true);
|
Library->LoadPieceInfo(Info, false, true);
|
||||||
Library->WaitForLoadQueue();
|
Library->WaitForLoadQueue();
|
||||||
|
|
||||||
lcStep CurrentStep = 1;
|
mModel->SetPreviewPieceInfo(Info, lcGetColorIndex(ColorCode));
|
||||||
lcPiece* Piece = new lcPiece(nullptr);
|
|
||||||
|
|
||||||
Piece->SetPieceInfo(Info, PartType, false);
|
Library->ReleasePieceInfo(Info);
|
||||||
Piece->Initialize(lcMatrix44Identity(), CurrentStep);
|
|
||||||
Piece->SetColorCode(ColorCode);
|
|
||||||
|
|
||||||
mModel->SetPreviewPiece(Piece);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -835,6 +835,7 @@ void lcView::OnDraw()
|
||||||
const bool DrawOverlays = mWidget != nullptr;
|
const bool DrawOverlays = mWidget != nullptr;
|
||||||
const bool DrawInterface = mWidget != nullptr && mViewType == lcViewType::View;
|
const bool DrawInterface = mWidget != nullptr && mViewType == lcViewType::View;
|
||||||
|
|
||||||
|
mScene->SetAllowWireframe(mWidget != nullptr);
|
||||||
mScene->SetAllowLOD(Preferences.mAllowLOD && mWidget != nullptr);
|
mScene->SetAllowLOD(Preferences.mAllowLOD && mWidget != nullptr);
|
||||||
mScene->SetLODDistance(Preferences.mMeshLODDistance);
|
mScene->SetLODDistance(Preferences.mMeshLODDistance);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue