mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Added background override.
This commit is contained in:
parent
5058455666
commit
e6397a98ac
3 changed files with 30 additions and 4 deletions
|
@ -1,10 +1,9 @@
|
||||||
#include "lc_global.h"
|
#include "lc_global.h"
|
||||||
#include "lc_instructionsdialog.h"
|
#include "lc_instructionsdialog.h"
|
||||||
#include "lc_collapsiblewidget.h"
|
#include "lc_pagesetupdialog.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "lc_model.h"
|
#include "lc_model.h"
|
||||||
#include "lc_qutils.h"
|
#include "lc_view.h"
|
||||||
#include "lc_pagesetupdialog.h"
|
|
||||||
|
|
||||||
lcInstructionsPageWidget::lcInstructionsPageWidget(QWidget* Parent, lcInstructions* Instructions)
|
lcInstructionsPageWidget::lcInstructionsPageWidget(QWidget* Parent, lcInstructions* Instructions)
|
||||||
: QGraphicsView(Parent), mInstructions(Instructions)
|
: QGraphicsView(Parent), mInstructions(Instructions)
|
||||||
|
@ -32,7 +31,19 @@ void lcInstructionsPageWidget::SetCurrentPage(const lcInstructionsPage* Page)
|
||||||
const float StepWidth = MarginsRect.width() * Step.Rect.width();
|
const float StepWidth = MarginsRect.width() * Step.Rect.width();
|
||||||
const float StepHeight = MarginsRect.height() * Step.Rect.height();
|
const float StepHeight = MarginsRect.height() * Step.Rect.height();
|
||||||
|
|
||||||
QImage StepImage = Step.Model->GetStepImage(false, StepWidth, StepHeight, Step.Step); // todo: override background color and opacity
|
lcView View(lcViewType::View, Step.Model);
|
||||||
|
|
||||||
|
View.SetOffscreenContext();
|
||||||
|
View.MakeCurrent();
|
||||||
|
// View.SetBackgroundColorOverride(LC_RGBA(255, 255, 0, 255));
|
||||||
|
View.SetSize(StepWidth, StepHeight);
|
||||||
|
|
||||||
|
std::vector<QImage> Images = View.GetStepImages(Step.Step, Step.Step);
|
||||||
|
|
||||||
|
if (Images.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QImage& StepImage = Images.front();
|
||||||
|
|
||||||
QGraphicsPixmapItem* StepImageItem = new QGraphicsPixmapItem(QPixmap::fromImage(StepImage), PageItem);
|
QGraphicsPixmapItem* StepImageItem = new QGraphicsPixmapItem(QPixmap::fromImage(StepImage), PageItem);
|
||||||
StepImageItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
StepImageItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
||||||
|
|
|
@ -1028,6 +1028,13 @@ void lcView::OnDraw()
|
||||||
|
|
||||||
void lcView::DrawBackground() const
|
void lcView::DrawBackground() const
|
||||||
{
|
{
|
||||||
|
if (mOverrideBackgroundColor)
|
||||||
|
{
|
||||||
|
lcVector4 BackgroundColor(lcVector4FromColor(mBackgroundColor));
|
||||||
|
mContext->ClearColorAndDepth(BackgroundColor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const lcPreferences& Preferences = lcGetPreferences();
|
const lcPreferences& Preferences = lcGetPreferences();
|
||||||
|
|
||||||
if (!Preferences.mBackgroundGradient)
|
if (!Preferences.mBackgroundGradient)
|
||||||
|
|
|
@ -168,6 +168,12 @@ public:
|
||||||
return mMouseY;
|
return mMouseY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetBackgroundColorOverride(quint32 BackgroundColor)
|
||||||
|
{
|
||||||
|
mOverrideBackgroundColor = true;
|
||||||
|
mBackgroundColor = BackgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
static void UpdateProjectViews(const Project* Project);
|
static void UpdateProjectViews(const Project* Project);
|
||||||
static void UpdateAllViews();
|
static void UpdateAllViews();
|
||||||
|
|
||||||
|
@ -313,6 +319,8 @@ protected:
|
||||||
#else
|
#else
|
||||||
std::pair<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
|
std::pair<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
|
||||||
#endif
|
#endif
|
||||||
|
bool mOverrideBackgroundColor = false;
|
||||||
|
quint32 mBackgroundColor = 0;
|
||||||
|
|
||||||
std::unique_ptr<lcScene> mScene;
|
std::unique_ptr<lcScene> mScene;
|
||||||
std::unique_ptr<lcViewSphere> mViewSphere;
|
std::unique_ptr<lcViewSphere> mViewSphere;
|
||||||
|
|
Loading…
Add table
Reference in a new issue