Whitespace cleanup.
This commit is contained in:
+15
-15
@@ -160,7 +160,7 @@ bool lcCamera::SetProjection(lcCameraProjection CameraProjection)
|
||||
|
||||
if (GetProjection() == CameraProjection)
|
||||
return false;
|
||||
|
||||
|
||||
mProjection = CameraProjection;
|
||||
|
||||
return true;
|
||||
@@ -427,7 +427,7 @@ void lcCamera::MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance)
|
||||
{
|
||||
mTargetPosition.ChangeKey(mTargetPosition + Distance, Step, AddKey);
|
||||
}
|
||||
|
||||
|
||||
if (FocusSection == LC_CAMERA_SECTION_UPVECTOR)
|
||||
{
|
||||
mUpVector.ChangeKey(lcNormalize(mUpVector + Distance), Step, AddKey);
|
||||
@@ -472,7 +472,7 @@ void lcCamera::Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix
|
||||
SetTargetPosition(Center + Distance, Step, AddKey);
|
||||
|
||||
lcVector3 UpVector = mUpVector;
|
||||
|
||||
|
||||
UpVector = lcMul(UpVector, WorldToLocalMatrix);
|
||||
UpVector = lcMul(UpVector, NewLocalToWorldMatrix);
|
||||
|
||||
@@ -565,7 +565,7 @@ void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const
|
||||
*CurVert++ = 0.0f; *CurVert++ = 0.0f; *CurVert++ = -Length;
|
||||
*CurVert++ = 0.0f; *CurVert++ = 25.0f; *CurVert++ = 0.0f;
|
||||
|
||||
const GLushort Indices[40 + 24 + 24 + 4 + 16] =
|
||||
const GLushort Indices[40 + 24 + 24 + 4 + 16] =
|
||||
{
|
||||
0, 1, 1, 2, 2, 3, 3, 0,
|
||||
4, 5, 5, 6, 6, 7, 7, 4,
|
||||
@@ -924,7 +924,7 @@ void lcCamera::RemoveKeyFrames()
|
||||
lcCameraHistoryState lcCamera::GetHistoryState([[maybe_unused]] const lcModel* Model) const
|
||||
{
|
||||
lcCameraHistoryState State;
|
||||
|
||||
|
||||
State.Id = mId;
|
||||
State.Hidden = mHidden;
|
||||
State.Simple = mSimple;
|
||||
@@ -936,7 +936,7 @@ lcCameraHistoryState lcCamera::GetHistoryState([[maybe_unused]] const lcModel* M
|
||||
State.TargetPosition = mTargetPosition;
|
||||
State.UpVector = mUpVector;
|
||||
State.Name = mName;
|
||||
|
||||
|
||||
return State;
|
||||
}
|
||||
|
||||
@@ -1082,7 +1082,7 @@ void lcCamera::RemoveTime(lcStep Start, lcStep Time)
|
||||
void lcCamera::ZoomExtents(float AspectRatio, const lcVector3& Center, const std::vector<lcVector3>& Points, lcStep Step, bool AddKey)
|
||||
{
|
||||
lcVector3 Position, TargetPosition;
|
||||
|
||||
|
||||
if (GetProjection() == lcCameraProjection::Orthographic)
|
||||
{
|
||||
float MinX = FLT_MAX, MaxX = -FLT_MAX, MinY = FLT_MAX, MaxY = -FLT_MAX;
|
||||
@@ -1096,28 +1096,28 @@ void lcCamera::ZoomExtents(float AspectRatio, const lcVector3& Center, const std
|
||||
MaxX = lcMax(MaxX, Point.x);
|
||||
MaxY = lcMax(MaxY, Point.y);
|
||||
}
|
||||
|
||||
|
||||
float Width = fabsf(MaxX - MinX);
|
||||
float Height = fabsf(MaxY - MinY);
|
||||
|
||||
const lcVector3 ViewCenter = lcMul30(Center, mWorldView);
|
||||
|
||||
|
||||
float OffsetX = (fabsf(MaxX - ViewCenter.x) - fabsf(ViewCenter.x - MinX)) / 2.0f;
|
||||
float OffsetY = (fabsf(MaxY - ViewCenter.y) - fabsf(ViewCenter.y - MinY)) / 2.0f;
|
||||
lcVector3 ViewOffset(OffsetX, OffsetY, 0.0f);
|
||||
|
||||
|
||||
lcMatrix44 ViewWorldMatrix = lcMatrix44AffineInverse(mWorldView);
|
||||
ViewWorldMatrix.SetTranslation(lcVector3(0, 0, 0));
|
||||
|
||||
|
||||
lcVector3 WorldOffset = lcMul30(ViewOffset, ViewWorldMatrix);
|
||||
|
||||
|
||||
if (Width > Height * AspectRatio)
|
||||
Height = Width / AspectRatio;
|
||||
|
||||
const float f = Height / (m_fovy * (LC_PI / 180.0f));
|
||||
|
||||
const lcVector3 FrontVector(mTargetPosition - mPosition);
|
||||
|
||||
|
||||
TargetPosition = Center + WorldOffset;
|
||||
Position = TargetPosition - lcNormalize(FrontVector) * f;
|
||||
}
|
||||
@@ -1142,7 +1142,7 @@ void lcCamera::ZoomExtents(float AspectRatio, const lcVector3& Center, const std
|
||||
void lcCamera::ZoomRegion(float AspectRatio, const lcVector3& Position, const lcVector3& TargetPosition, const lcVector3* Corners, lcStep Step, bool AddKey)
|
||||
{
|
||||
lcVector3 NewPosition;
|
||||
|
||||
|
||||
if (GetProjection() == lcCameraProjection::Orthographic)
|
||||
{
|
||||
float MinX = FLT_MAX, MaxX = -FLT_MAX, MinY = FLT_MAX, MaxY = -FLT_MAX;
|
||||
@@ -1202,7 +1202,7 @@ void lcCamera::Zoom(float Distance, lcStep Step, bool AddKey)
|
||||
AddKey = false;
|
||||
|
||||
mPosition.ChangeKey(mPosition + FrontVector, Step, AddKey);
|
||||
|
||||
|
||||
if (GetProjection() != lcCameraProjection::Orthographic)
|
||||
mTargetPosition.ChangeKey(mTargetPosition + FrontVector, Step, AddKey);
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ struct lcCameraHistoryState
|
||||
lcObjectProperty<lcVector3> TargetPosition;
|
||||
lcObjectProperty<lcVector3> UpVector;
|
||||
QString Name;
|
||||
|
||||
|
||||
bool operator==(const lcCameraHistoryState& Other) const
|
||||
{
|
||||
return Id == Other.Id && Hidden == Other.Hidden && Simple == Other.Simple && Fovy == Other.Fovy &&
|
||||
|
||||
+5
-5
@@ -66,15 +66,15 @@ void lcGroup::CreateName(const std::vector<std::unique_ptr<lcGroup>>& Groups)
|
||||
lcGroupHistoryState lcGroup::GetHistoryState(const lcModel* Model) const
|
||||
{
|
||||
lcGroupHistoryState State;
|
||||
|
||||
|
||||
State.Id = mId;
|
||||
State.ParentIndex = ~0U;
|
||||
State.Name = mName;
|
||||
|
||||
|
||||
if (mGroup)
|
||||
{
|
||||
const std::vector<std::unique_ptr<lcGroup>>& Groups = Model->GetGroups();
|
||||
|
||||
|
||||
for (size_t GroupIndex = 0; GroupIndex < Groups.size(); GroupIndex++)
|
||||
{
|
||||
if (Groups[GroupIndex].get() == mGroup)
|
||||
@@ -84,14 +84,14 @@ lcGroupHistoryState lcGroup::GetHistoryState(const lcModel* Model) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return State;
|
||||
}
|
||||
|
||||
void lcGroup::SetHistoryState(const lcGroupHistoryState& State, const lcModel* Model)
|
||||
{
|
||||
const std::vector<std::unique_ptr<lcGroup>>& Groups = Model->GetGroups();
|
||||
|
||||
|
||||
mId = State.Id;
|
||||
mName = State.Name;
|
||||
mGroup = (State.ParentIndex < Groups.size()) ? Groups[State.ParentIndex].get() : nullptr;
|
||||
|
||||
+7
-7
@@ -9,7 +9,7 @@ struct lcGroupHistoryState
|
||||
lcGroupId Id;
|
||||
uint32_t ParentIndex;
|
||||
QString Name;
|
||||
|
||||
|
||||
bool operator==(const lcGroupHistoryState& Other) const
|
||||
{
|
||||
return Id == Other.Id && ParentIndex == Other.ParentIndex && Name == Other.Name;
|
||||
@@ -25,23 +25,23 @@ public:
|
||||
{
|
||||
return mGroup ? mGroup->GetTopGroup() : this;
|
||||
}
|
||||
|
||||
|
||||
lcGroupId GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
|
||||
void FileLoad(lcFile* File);
|
||||
void CreateName(const std::vector<std::unique_ptr<lcGroup>>& Groups);
|
||||
|
||||
|
||||
lcGroupHistoryState GetHistoryState(const lcModel* Model) const;
|
||||
void SetHistoryState(const lcGroupHistoryState& State, const lcModel* Model);
|
||||
|
||||
|
||||
lcGroup* mGroup = nullptr;
|
||||
QString mName;
|
||||
|
||||
|
||||
protected:
|
||||
lcGroupId mId = static_cast<lcGroupId>(0);
|
||||
|
||||
|
||||
static lcGroupId mNextId;
|
||||
};
|
||||
|
||||
@@ -21,12 +21,12 @@ lcAboutDialog::lcAboutDialog(QWidget* Parent)
|
||||
QOpenGLContext* Context = Widget->context();
|
||||
QOpenGLFunctions* Functions = Context->functions();
|
||||
QSurfaceFormat Format = Context->format();
|
||||
|
||||
|
||||
int ColorDepth = Format.redBufferSize() + Format.greenBufferSize() + Format.blueBufferSize() + Format.alphaBufferSize();
|
||||
|
||||
const QString QtVersionFormat = tr("Qt Version %1 (compiled with %2)\n\n");
|
||||
const QString QtVersion = QtVersionFormat.arg(qVersion(), QT_VERSION_STR);
|
||||
|
||||
|
||||
const QString VersionFormat = tr("OpenGL Version %1 (GLSL %2)\n%3 - %4\n\n");
|
||||
const QString GLVersion(reinterpret_cast<const char*>(Functions->glGetString(GL_VERSION)));
|
||||
const QString ShaderVersion(reinterpret_cast<const char*>(Functions->glGetString(GL_SHADING_LANGUAGE_VERSION)));
|
||||
|
||||
@@ -2720,7 +2720,7 @@ void lcBlenderPreferences::SaveSettings()
|
||||
lcSetProfileString(LC_PROFILE_BLENDER_VERSION, Value);
|
||||
|
||||
const QString BlenderConfigDir = QString("%1/Blender/addons/%2/config").arg(gAddonPreferences->mDataDir, LC_BLENDER_ADDON_RENDER_FOLDER);
|
||||
|
||||
|
||||
Value = lcGetProfileString(LC_PROFILE_BLENDER_LDRAW_CONFIG_PATH);
|
||||
if (!Value.contains(LC_BLENDER_ADDON_RENDER_FOLDER))
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ class lcCategoryDialog;
|
||||
class lcCategoryDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit lcCategoryDialog(QWidget* Parent, lcLibraryCategory* Category);
|
||||
virtual ~lcCategoryDialog();
|
||||
|
||||
@@ -422,7 +422,7 @@ QString lcGetColorToolTip(int ColorIndex)
|
||||
|
||||
QPainter Painter(&Image);
|
||||
Painter.setPen(Qt::darkGray);
|
||||
|
||||
|
||||
if (Color->Code != LC_COLOR_NOCOLOR)
|
||||
Painter.drawRect(0, 0, Image.width() - 1, Image.height() - 1);
|
||||
else
|
||||
|
||||
@@ -219,7 +219,7 @@ bool lcDoubleSpinBox::event(QEvent* Event)
|
||||
else if (Event->type() == QEvent::ShortcutOverride)
|
||||
{
|
||||
QKeyEvent* KeyEvent = static_cast<QKeyEvent*>(Event);
|
||||
|
||||
|
||||
switch (KeyEvent->key())
|
||||
{
|
||||
case Qt::Key_Up:
|
||||
@@ -228,12 +228,12 @@ bool lcDoubleSpinBox::event(QEvent* Event)
|
||||
case Qt::Key_PageDown:
|
||||
Event->accept();
|
||||
return true;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return QDoubleSpinBox::event(Event);
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -107,41 +107,41 @@ bool lcFilter::Match(const char* String) const
|
||||
}
|
||||
|
||||
// Copyright 2018 IBM Corporation
|
||||
//
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Compares two text strings. Accepts '?' as a single-character wildcard.
|
||||
// For each '*' wildcard, seeks out a matching sequence of any characters
|
||||
// beyond it. Otherwise compares the strings a character at a time.
|
||||
// Compares two text strings. Accepts '?' as a single-character wildcard.
|
||||
// For each '*' wildcard, seeks out a matching sequence of any characters
|
||||
// beyond it. Otherwise compares the strings a character at a time.
|
||||
//
|
||||
bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
{
|
||||
const char* WildSequence; // Points to prospective wild string match after '*'
|
||||
const char* TameSequence; // Points to prospective tame string match
|
||||
|
||||
|
||||
auto NotEquals=[](char a, char b)
|
||||
{
|
||||
// Lowercase the characters to be compared.
|
||||
if (a >= 'A' && a <= 'Z')
|
||||
a += ('a' - 'A');
|
||||
|
||||
|
||||
if (b >= 'A' && b <= 'Z')
|
||||
b += ('a' - 'A');
|
||||
|
||||
return a != b;
|
||||
};
|
||||
|
||||
// Find a first wildcard, if one exists, and the beginning of any
|
||||
// Find a first wildcard, if one exists, and the beginning of any
|
||||
// prospectively matching sequence after it.
|
||||
do
|
||||
{
|
||||
@@ -157,7 +157,7 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
return true; // "ab" matches "ab*".
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false; // "abcd" doesn't match "abc".
|
||||
}
|
||||
else
|
||||
@@ -172,12 +172,12 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!*Wild)
|
||||
{
|
||||
return true; // "abc*" matches "abcd".
|
||||
}
|
||||
|
||||
|
||||
// Search for the next prospective match.
|
||||
if (*Wild != '?')
|
||||
{
|
||||
@@ -189,7 +189,7 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Keep fallback positions for retry in case of incomplete match.
|
||||
WildSequence = Wild;
|
||||
TameSequence = Tame;
|
||||
@@ -199,11 +199,11 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
{
|
||||
return false; // "abc" doesn't match "abd".
|
||||
}
|
||||
|
||||
|
||||
++Wild; // Everything's a match, so far.
|
||||
++Tame;
|
||||
} while (true);
|
||||
|
||||
|
||||
// Find any further wildcards and any further matching sequences.
|
||||
do
|
||||
{
|
||||
@@ -214,17 +214,17 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!*Wild)
|
||||
{
|
||||
return true; // "ab*c*" matches "abcd".
|
||||
}
|
||||
|
||||
|
||||
if (!*Tame)
|
||||
{
|
||||
return false; // "*bcd*" doesn't match "abc".
|
||||
}
|
||||
|
||||
|
||||
// Search for the next prospective match.
|
||||
if (*Wild != '?')
|
||||
{
|
||||
@@ -236,7 +236,7 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Keep the new fallback positions.
|
||||
WildSequence = Wild;
|
||||
TameSequence = Tame;
|
||||
@@ -248,16 +248,16 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
{
|
||||
return false; // "*bcd" doesn't match "abc".
|
||||
}
|
||||
|
||||
|
||||
// A fine time for questions.
|
||||
while (*WildSequence == '?')
|
||||
{
|
||||
++WildSequence;
|
||||
++TameSequence;
|
||||
}
|
||||
|
||||
|
||||
Wild = WildSequence;
|
||||
|
||||
|
||||
// Fall back, but never so far again.
|
||||
while (NotEquals(*Wild, *(++TameSequence)))
|
||||
{
|
||||
@@ -266,10 +266,10 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
return false; // "*a*b" doesn't match "ac".
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tame = TameSequence;
|
||||
}
|
||||
|
||||
|
||||
// Another check for the end, at the end.
|
||||
if (!*Tame)
|
||||
{
|
||||
@@ -282,7 +282,7 @@ bool lcFilter::FastWildCompare(const char* Tame, const char* Wild)
|
||||
return false; // "*bc" doesn't match "abcd".
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
++Wild; // Everything's still a match.
|
||||
++Tame;
|
||||
} while (true);
|
||||
|
||||
@@ -56,21 +56,21 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
||||
ReplaceColorPicker = new lcColorPicker(this, true);
|
||||
ReplaceColorPicker->setToolTip(tr("Replacement Color"));
|
||||
Layout->addWidget(ReplaceColorPicker, 1, 1);
|
||||
|
||||
|
||||
QPixmap Pixmap(1, 1);
|
||||
Pixmap.fill(QColor::fromRgba64(0, 0, 0, 0));
|
||||
|
||||
|
||||
mReplacePartButton = new lcElidableToolButton(this);
|
||||
mReplacePartButton->setToolTip(tr("Replacement Part"));
|
||||
|
||||
|
||||
QSizePolicy PieceButtonSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
PieceButtonSizePolicy.setHorizontalStretch(2);
|
||||
PieceButtonSizePolicy.setVerticalStretch(0);
|
||||
mReplacePartButton->setSizePolicy(PieceButtonSizePolicy);
|
||||
|
||||
|
||||
mReplacePartButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
mReplacePartButton->setIcon(Pixmap);
|
||||
|
||||
|
||||
Layout->addWidget(mReplacePartButton, 1, 2);
|
||||
|
||||
QToolButton* ReplaceNextButton = new QToolButton(this);
|
||||
@@ -166,7 +166,7 @@ void lcFindReplaceWidget::ReplaceButtonClicked()
|
||||
|
||||
std::optional<PieceInfo*> Result = lcShowPartSelectionPopup(Params.ReplacePieceInfo, std::vector<std::pair<PieceInfo*, std::string>>(),
|
||||
gDefaultColor, mReplacePartButton, mReplacePartButton->mapToGlobal(mReplacePartButton->rect().bottomLeft()));
|
||||
|
||||
|
||||
if (!Result.has_value())
|
||||
return;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ void lcGroupDialog::accept()
|
||||
QMessageBox::information(this, "LeoCAD", tr("Name cannot be empty."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcGroup>& Group : mGroups)
|
||||
{
|
||||
if (Group->mName == Name)
|
||||
@@ -33,8 +33,8 @@ void lcGroupDialog::accept()
|
||||
QMessageBox::information(this, "LeoCAD", tr("A group with this name already exists."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mName = Name;
|
||||
|
||||
QDialog::accept();
|
||||
|
||||
@@ -291,7 +291,7 @@ lcInstructionsPropertiesWidget::lcInstructionsPropertiesWidget(QWidget* Parent,
|
||||
QWidget* CentralWidget = new QWidget(this);
|
||||
setWidget(CentralWidget);
|
||||
setWindowTitle(tr("Properties"));
|
||||
|
||||
|
||||
QGridLayout* Layout = new QGridLayout(CentralWidget);
|
||||
Layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
@@ -343,7 +343,7 @@ void lcInstructionsPropertiesWidget::AddColorProperty(lcInstructionsPropertyType
|
||||
Pixmap.fill(Color);
|
||||
ColorButton->setIcon(Pixmap);
|
||||
};
|
||||
|
||||
|
||||
UpdateButton();
|
||||
|
||||
connect(ColorButton, &QToolButton::clicked, [this, Type, UpdateButton]()
|
||||
@@ -651,7 +651,7 @@ void lcInstructionsDialog::Print(QPrinter* Printer)
|
||||
if (Printer->printerState() == QPrinter::Aborted || Printer->printerState() == QPrinter::Error)
|
||||
{
|
||||
delete Scene;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void lcLadderWidget::Show()
|
||||
|
||||
if (Position.y() + HalfHeight > Desktop.bottom())
|
||||
Position.setY(Desktop.bottom() - HalfHeight);
|
||||
|
||||
|
||||
move(Position);
|
||||
|
||||
mLastMousePositionX = mapFromGlobal(QCursor::pos()).x();
|
||||
@@ -97,7 +97,7 @@ void lcLadderWidget::UpdateMousePosition()
|
||||
{
|
||||
int CellHeight = height() / static_cast<int>(mSteps.size());
|
||||
int CurrentStep = MousePosition.y() / CellHeight;
|
||||
|
||||
|
||||
if (CurrentStep != mCurrentStep)
|
||||
{
|
||||
mCurrentStep = CurrentStep;
|
||||
|
||||
@@ -1281,7 +1281,7 @@ bool lcPiecesLibrary::LoadPieceData(PieceInfo* Info)
|
||||
{
|
||||
char FileName[LC_MAXPATH];
|
||||
lcDiskFile PieceFile;
|
||||
|
||||
|
||||
snprintf(FileName, sizeof(FileName), "parts/%s", Info->mFileName);
|
||||
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
|
||||
if (PieceFile.Open(QIODevice::ReadOnly))
|
||||
@@ -1355,7 +1355,7 @@ void lcPiecesLibrary::GetPieceFile(const char* PieceName, std::function<void(lcF
|
||||
lcDiskFile IncludeFile;
|
||||
char FileName[LC_MAXPATH];
|
||||
bool Found = false;
|
||||
|
||||
|
||||
snprintf(FileName, sizeof(FileName), "parts/%s", Info->mFileName);
|
||||
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
|
||||
Found = IncludeFile.Open(QIODevice::ReadOnly);
|
||||
@@ -1530,7 +1530,7 @@ bool lcPiecesLibrary::LoadTexture(lcTexture* Texture)
|
||||
if (mZipFiles[static_cast<int>(lcZipFileType::Official)])
|
||||
{
|
||||
lcMemFile TextureFile;
|
||||
|
||||
|
||||
snprintf(FileName, sizeof(FileName), "ldraw/parts/textures/%s.png", Texture->mName);
|
||||
|
||||
if (!mZipFiles[static_cast<int>(lcZipFileType::Official)]->ExtractFile(FileName, TextureFile))
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ bool lcImportLXFMLFile(const QString& FileData, std::vector<lcPiece*>& Pieces, s
|
||||
Pieces.push_back(Piece);
|
||||
NumBrickPieces++;
|
||||
}
|
||||
|
||||
|
||||
if (NumBrickPieces > 1)
|
||||
{
|
||||
std::vector<lcPiece*> Group;
|
||||
|
||||
+1
-1
@@ -297,7 +297,7 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** Color
|
||||
{
|
||||
const lcVertex* Verts = GetVertexData();
|
||||
const IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType);
|
||||
|
||||
|
||||
if (NumSections > 1)
|
||||
File.WriteLine(" mesh {\n");
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
|
||||
for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices)
|
||||
{
|
||||
lcVector3 Position[4];
|
||||
|
||||
|
||||
Position[0] = lcMul31(DataVertex.Position[0], Transform);
|
||||
Position[1] = lcMul31(DataVertex.Position[1], Transform);
|
||||
Position[2] = lcMul31(DataVertex.Position[2], Transform);
|
||||
@@ -370,15 +370,15 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
|
||||
if (SrcSection->mMaterial->Type != lcMeshLoaderMaterialType::Solid)
|
||||
{
|
||||
lcMeshLoaderTextureParams DstTextureMap;
|
||||
|
||||
|
||||
if (TextureMap)
|
||||
DstTextureMap = *TextureMap;
|
||||
else
|
||||
DstTextureMap = *SrcSection->mMaterial;
|
||||
|
||||
|
||||
for (lcVector3& Point : DstTextureMap.Points)
|
||||
Point = lcMul31(Point, Transform);
|
||||
|
||||
|
||||
DstSection = AddSection(PrimitiveType, mMeshData->GetTexturedMaterial(ColorCode, DstTextureMap));
|
||||
}
|
||||
else if (TextureMap && SrcSection->mPrimitiveType == LC_MESH_TRIANGLES)
|
||||
@@ -458,7 +458,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
|
||||
if (SrcSection->mMaterial->Type != lcMeshLoaderMaterialType::Solid)
|
||||
{
|
||||
lcMeshLoaderTextureParams DstTextureMap;
|
||||
|
||||
|
||||
if (TextureMap)
|
||||
DstTextureMap = *TextureMap;
|
||||
else
|
||||
|
||||
@@ -134,9 +134,9 @@ lcMinifigDialog::lcMinifigDialog(QWidget* Parent)
|
||||
mMinifigWizard->Calculate();
|
||||
mView->GetCamera()->SetViewpoint(lcVector3(0.0f, -270.0f, 90.0f));
|
||||
mView->ZoomExtents();
|
||||
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setFocus();
|
||||
|
||||
|
||||
connect(ui->TemplateComboBox, &QComboBox::currentTextChanged, this, &lcMinifigDialog::TemplateComboBoxCurrentTextChanged);
|
||||
connect(ui->TemplateSaveButton, &QPushButton::clicked, this, &lcMinifigDialog::TemplateSaveButtonClicked);
|
||||
connect(ui->TemplateDeleteButton, &QPushButton::clicked, this, &lcMinifigDialog::TemplateDeleteButtonClicked);
|
||||
@@ -196,7 +196,7 @@ void lcMinifigDialog::TemplateComboBoxCurrentTextChanged(const QString& Template
|
||||
UpdateTemplateCombo();
|
||||
|
||||
const lcMinifigTemplate& Template = Position->second;
|
||||
|
||||
|
||||
mView->MakeCurrent();
|
||||
|
||||
mMinifigWizard->LoadTemplate(TemplateName);
|
||||
@@ -387,7 +387,7 @@ void lcMinifigDialog::PieceButtonClicked()
|
||||
return;
|
||||
|
||||
PieceInfo* NewPiece = Result.value();
|
||||
|
||||
|
||||
SetCurrentTemplateModified();
|
||||
UpdateTemplateCombo();
|
||||
|
||||
|
||||
+303
-306
File diff suppressed because it is too large
Load Diff
+8
-8
@@ -135,10 +135,10 @@ public:
|
||||
{
|
||||
return mActive;
|
||||
}
|
||||
|
||||
|
||||
bool IsModified() const;
|
||||
void SetSaved();
|
||||
|
||||
|
||||
bool GetPieceWorldMatrix(lcPiece* Piece, lcMatrix44& ParentWorldMatrix) const;
|
||||
bool IncludesModel(const lcModel* Model) const;
|
||||
void CreatePieceInfo(Project* Project);
|
||||
@@ -225,12 +225,12 @@ public:
|
||||
void ShowNextStep();
|
||||
void InsertStep(lcStep Step);
|
||||
void RemoveStep(lcStep Step);
|
||||
|
||||
|
||||
template<typename StateType, typename ObjectType>
|
||||
void LoadObjectHistoryState(const std::vector<StateType>& ObjectStates, std::vector<std::unique_ptr<ObjectType>>& Objects);
|
||||
void LoadHistoryState(const lcModelHistoryState& HistoryState);
|
||||
void SetModelProperties(const lcModelProperties& ModelProperties);
|
||||
|
||||
|
||||
lcPiece* AddPiece(PieceInfo* Info, quint32 Section);
|
||||
void AddPiece(std::unique_ptr<lcPiece> Piece, size_t PieceIndex);
|
||||
void DeleteSelectedObjects();
|
||||
@@ -266,7 +266,7 @@ public:
|
||||
bool LoadInventory(const QByteArray& Inventory);
|
||||
int SplitMPD(QIODevice& Device);
|
||||
void Merge(std::unique_ptr<lcModel> Other);
|
||||
|
||||
|
||||
void SetMinifig(const lcMinifig& Minifig);
|
||||
void SetPreviewPieceInfo(PieceInfo* Info, int ColorIndex);
|
||||
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
void GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList, bool Cumulative) const;
|
||||
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector<lcModelPartsEntry>& ModelParts) const;
|
||||
void GetSelectionInformation(int* Flags, std::vector<lcObject*>& Selection, lcObject** Focus) const;
|
||||
|
||||
|
||||
void ClearSelection();
|
||||
void SetSelectionAndFocus(const std::vector<lcObject*>& Selection, lcObject* Focus, quint32 Section, lcSelectionMode SelectionMode);
|
||||
void FocusOrDeselectObject(lcObject* Object, uint32_t Section, lcSelectionMode SelectionMode);
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
|
||||
protected:
|
||||
void DeleteModel();
|
||||
|
||||
|
||||
void RecordSelectionAction(std::function<void()> Callback);
|
||||
void RecordClearSelectionAction();
|
||||
void RecordSetFocusAction(lcObject* FocusObject, uint32_t FocusSection, lcSelectionMode SelectionMode);
|
||||
@@ -416,7 +416,7 @@ protected:
|
||||
void RemoveEmptyGroups();
|
||||
bool RemoveSelectedObjects();
|
||||
void RemoveCameraFromViews(lcCamera* Camera);
|
||||
|
||||
|
||||
std::vector<lcObject*> GetSelectionModePieces(lcSelectionMode SelectionMode, const lcPiece* SelectedPiece) const;
|
||||
void DeselectAllObjects();
|
||||
void SetFocusedObject(lcObject* FocusObject, uint32_t FocusSection, lcSelectionMode SelectionMode);
|
||||
|
||||
+10
-10
@@ -110,7 +110,7 @@ void lcModelActionSelection::LoadState(const lcModelActionSelectionState& State,
|
||||
lcPiece* Piece = Pieces[PieceIndex].get();
|
||||
|
||||
Piece->SetSelected(State.PieceSelection[PieceIndex]);
|
||||
|
||||
|
||||
if (State.FocusObjectType == lcObjectType::Piece && State.FocusIndex == PieceIndex)
|
||||
Piece->SetFocused(State.FocusSection, true);
|
||||
else
|
||||
@@ -122,7 +122,7 @@ void lcModelActionSelection::LoadState(const lcModelActionSelectionState& State,
|
||||
lcCamera* Camera = Cameras[CameraIndex].get();
|
||||
|
||||
Camera->SetSelected(State.CameraSelection[CameraIndex]);
|
||||
|
||||
|
||||
if (State.FocusObjectType == lcObjectType::Camera && State.FocusIndex == CameraIndex)
|
||||
Camera->SetFocused(State.FocusSection, true);
|
||||
else
|
||||
@@ -134,7 +134,7 @@ void lcModelActionSelection::LoadState(const lcModelActionSelectionState& State,
|
||||
lcLight* Light = Lights[LightIndex].get();
|
||||
|
||||
Light->SetSelected(State.LightSelection[LightIndex]);
|
||||
|
||||
|
||||
if (State.FocusObjectType == lcObjectType::Light && State.FocusIndex == LightIndex)
|
||||
Light->SetFocused(State.FocusSection, true);
|
||||
else
|
||||
@@ -159,22 +159,22 @@ lcModelActionObjectEdit::~lcModelActionObjectEdit()
|
||||
void lcModelActionObjectEdit::SaveState(lcModelHistoryState& State, const lcModel* Model)
|
||||
{
|
||||
const std::vector<std::unique_ptr<lcGroup>>& Groups = Model->GetGroups();
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcGroup>& Group : Groups)
|
||||
State.Groups.emplace_back(Group->GetHistoryState(Model));
|
||||
|
||||
|
||||
const std::vector<std::unique_ptr<lcPiece>>& Pieces = Model->GetPieces();
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : Pieces)
|
||||
State.Pieces.emplace_back(Piece->GetHistoryState(Model));
|
||||
|
||||
|
||||
const std::vector<std::unique_ptr<lcCamera>>& Cameras = Model->GetCameras();
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcCamera>& Camera : Cameras)
|
||||
State.Cameras.emplace_back(Camera->GetHistoryState(Model));
|
||||
|
||||
|
||||
const std::vector<std::unique_ptr<lcLight>>& Lights = Model->GetLights();
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcLight>& Light : Lights)
|
||||
State.Lights.emplace_back(Light->GetHistoryState(Model));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class lcModelAction
|
||||
public:
|
||||
lcModelAction() = default;
|
||||
virtual ~lcModelAction() = default;
|
||||
|
||||
|
||||
virtual void SaveStartState(const lcModel* Model) = 0;
|
||||
virtual void SaveEndState(const lcModel* Model) = 0;
|
||||
virtual void LoadStartState(lcModel* Model) const = 0;
|
||||
@@ -51,7 +51,7 @@ class lcModelActionSelection : public lcModelAction
|
||||
public:
|
||||
lcModelActionSelection() = default;
|
||||
virtual ~lcModelActionSelection() = default;
|
||||
|
||||
|
||||
void SaveStartState(const lcModel* Model) override;
|
||||
void SaveEndState(const lcModel* Model) override;
|
||||
void LoadStartState(lcModel* Model) const override;
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
protected:
|
||||
static void SaveState(lcModelActionSelectionState& State, const lcModel* Model);
|
||||
static void LoadState(const lcModelActionSelectionState& State, lcModel* Model);
|
||||
|
||||
|
||||
lcModelActionSelectionState mStartState;
|
||||
lcModelActionSelectionState mEndState;
|
||||
};
|
||||
@@ -98,7 +98,7 @@ class lcModelActionObjectEdit: public lcModelAction
|
||||
public:
|
||||
lcModelActionObjectEdit(lcModelActionEditMerge ModelActionEditMerge);
|
||||
virtual ~lcModelActionObjectEdit();
|
||||
|
||||
|
||||
void SaveStartState(const lcModel* Model) override;
|
||||
void SaveEndState(const lcModel* Model) override;
|
||||
void LoadStartState(lcModel* Model) const override;
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
protected:
|
||||
static void SaveState(lcModelHistoryState& State, const lcModel* Model);
|
||||
static void LoadState(const lcModelHistoryState& State, lcModel* Model);
|
||||
|
||||
|
||||
lcModelHistoryState mStartState;
|
||||
lcModelHistoryState mEndState;
|
||||
lcModelActionEditMerge mMerge;
|
||||
|
||||
@@ -68,12 +68,12 @@ class lcObjectProperty
|
||||
{
|
||||
public:
|
||||
lcObjectProperty() = default;
|
||||
|
||||
|
||||
explicit lcObjectProperty(const T& DefaultValue)
|
||||
: mValue(DefaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
operator const T& () const
|
||||
{
|
||||
return mValue;
|
||||
|
||||
@@ -249,7 +249,7 @@ void lcPartSelectionListModel::SetCustomParts(const std::vector<std::pair<PieceI
|
||||
for (const auto& [Info, Description] : Parts)
|
||||
{
|
||||
lcPartSelectionListModelEntry& Entry = mParts.emplace_back();
|
||||
|
||||
|
||||
Entry.Info = Info;
|
||||
Entry.Description = Description;
|
||||
|
||||
@@ -299,7 +299,7 @@ void lcPartSelectionListModel::SetFilter(const QString& FilterString)
|
||||
|
||||
Visible = (mPartDescriptionFilter && Description.contains(FilterRx)) || (mFileNameFilter && QString(Info->mFileName).contains(FilterRx));
|
||||
}
|
||||
|
||||
|
||||
mListView->setRowHidden((int)PartIdx, !Visible);
|
||||
}
|
||||
}
|
||||
@@ -662,7 +662,7 @@ void lcPartSelectionListView::SetCurrentPart(PieceInfo* Info)
|
||||
{
|
||||
setCurrentIndex(Index);
|
||||
scrollTo(Index, QAbstractItemView::EnsureVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lcPartSelectionListView::SetNoIcons()
|
||||
@@ -771,13 +771,13 @@ void lcPartSelectionListView::SetIconSize(int Size)
|
||||
{
|
||||
setIconSize(QSize(Size, Size));
|
||||
lcSetProfileInt(LC_PROFILE_PARTS_LIST_ICONS, Size);
|
||||
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
float DeviceScale = devicePixelRatioF();
|
||||
#else
|
||||
float DeviceScale = devicePixelRatio();
|
||||
#endif
|
||||
|
||||
|
||||
mListModel->SetIconSize(Size, DeviceScale);
|
||||
UpdateViewMode();
|
||||
|
||||
@@ -990,18 +990,18 @@ void lcPartSelectionWidget::SetCategory(lcPartCategoryType Type, int Index)
|
||||
{
|
||||
QTreeWidgetItem* Item = mCategoriesWidget->topLevelItem(Row);
|
||||
lcPartCategoryType ItemType = static_cast<lcPartCategoryType>(Item->data(0, static_cast<int>(lcPartCategoryRole::Type)).toInt());
|
||||
|
||||
|
||||
if (ItemType != Type)
|
||||
continue;
|
||||
|
||||
|
||||
if (Type == lcPartCategoryType::Palette || Type == lcPartCategoryType::Category)
|
||||
{
|
||||
int ItemIndex = Item->data(0, static_cast<int>(lcPartCategoryRole::Index)).toInt();
|
||||
|
||||
|
||||
if (ItemIndex != Index)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
mCategoriesWidget->setCurrentItem(Item);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ void lcPropertiesWidget::ChangeFloatValue(lcObjectPropertyId PropertyId, float V
|
||||
void lcPropertiesWidget::UpdateFloat(lcObjectPropertyId PropertyId, float Value)
|
||||
{
|
||||
lcDoubleSpinBox* Widget = qobject_cast<lcDoubleSpinBox*>(mPropertyWidgets[static_cast<int>(PropertyId)].Editor);
|
||||
|
||||
|
||||
if (Widget)
|
||||
{
|
||||
QSignalBlocker Blocker(Widget);
|
||||
@@ -1083,7 +1083,7 @@ void lcPropertiesWidget::PieceIdButtonClicked()
|
||||
PieceInfo* Info = Partial ? nullptr : static_cast<PieceInfo*>(Value.value<void*>());
|
||||
|
||||
std::tie(Value, Partial) = GetUpdateValue(lcObjectPropertyId::PieceColor);
|
||||
|
||||
|
||||
int ColorIndex = Partial ? gDefaultColor : Value.toInt();
|
||||
|
||||
std::optional<PieceInfo*> Result = lcShowPartSelectionPopup(Info, std::vector<std::pair<PieceInfo*, std::string>>(), ColorIndex, PieceIdButton, PieceIdButton->mapToGlobal(PieceIdButton->rect().bottomLeft()));
|
||||
@@ -1314,7 +1314,7 @@ void lcPropertiesWidget::SetPiece(const std::vector<lcObject*>& Selection, lcObj
|
||||
|
||||
if (!Model)
|
||||
return;
|
||||
|
||||
|
||||
Model->GetMoveRotateTransform(Position, RelativeRotation);
|
||||
|
||||
UpdateFloat(lcObjectPropertyId::ObjectPositionX, Position[0]);
|
||||
|
||||
@@ -173,7 +173,7 @@ bool lcMouseShortcuts::Save(const QString& FileName)
|
||||
return false;
|
||||
|
||||
QTextStream Stream(&File);
|
||||
|
||||
|
||||
for (const QString& Shortcut : std::as_const(Shortcuts))
|
||||
Stream << Shortcut << QLatin1String("\n");
|
||||
|
||||
|
||||
+12
-12
@@ -4,7 +4,7 @@
|
||||
char* lcstrcasestr(const char* s, const char* find)
|
||||
{
|
||||
char c, sc;
|
||||
|
||||
|
||||
if ((c = *find++) != 0)
|
||||
{
|
||||
c = tolower((unsigned char)c);
|
||||
@@ -26,7 +26,7 @@ char* lcstrupr(char* string)
|
||||
{
|
||||
for (char* c = string; *c; c++)
|
||||
*c = toupper(*c);
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -34,19 +34,19 @@ size_t lcstrcpy(char* dest, const char* source, size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
dest[i] = source[i];
|
||||
|
||||
|
||||
if (source[i] == '\0')
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dest[--size] = '\0';
|
||||
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -56,16 +56,16 @@ size_t lcstrcat(char* dest, const char* source, size_t size)
|
||||
const char* s = source;
|
||||
size_t n = size;
|
||||
size_t dlen;
|
||||
|
||||
|
||||
while (n-- != 0 && *d != '\0')
|
||||
d++;
|
||||
|
||||
|
||||
dlen = d - dest;
|
||||
n = size - dlen;
|
||||
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + strlen(s));
|
||||
|
||||
|
||||
while (*s != '\0')
|
||||
{
|
||||
if (n != 1)
|
||||
@@ -75,8 +75,8 @@ size_t lcstrcat(char* dest, const char* source, size_t size)
|
||||
}
|
||||
s++;
|
||||
}
|
||||
|
||||
|
||||
*d = '\0';
|
||||
|
||||
|
||||
return (dlen + (s - source));
|
||||
}
|
||||
|
||||
+2
-2
@@ -1187,7 +1187,7 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||
char Line[256];
|
||||
const int NumEdgeParts = 6;
|
||||
|
||||
lcMatrix33 EdgeTransforms[6] =
|
||||
lcMatrix33 EdgeTransforms[6] =
|
||||
{
|
||||
lcMatrix33(lcVector3(-1.0f, 0.0f, 0.0f), lcVector3(0.0f, -5.0f, 0.0f), lcVector3(0.0f, 0.0f, 1.0f)),
|
||||
lcMatrix33(lcVector3( 0.0f, 1.0f, 0.0f), lcVector3(1.0f, 0.0f, 0.0f), lcVector3(0.0f, 0.0f, -1.0f)),
|
||||
@@ -1282,7 +1282,7 @@ void lcSynthInfoFlexibleAxle::AddParts(lcMemFile& File, lcLibraryMeshData& MeshD
|
||||
for (size_t SectionIndex = 1; SectionIndex < Sections.size() - 1; SectionIndex++)
|
||||
{
|
||||
const int Indices[] = { 1, 3, 5, 8, 10, 12, 15, 17, 19, 22, 24, 26 };
|
||||
|
||||
|
||||
for (int VertexIdx = 0; VertexIdx < 12; VertexIdx++)
|
||||
{
|
||||
*IndexBuffer++ = BaseLinesVertex + Indices[VertexIdx];
|
||||
|
||||
@@ -174,13 +174,13 @@ bool lcTexture::Load(const QString& FileName, int Flags)
|
||||
|
||||
if (!Image.FileLoad(FileName))
|
||||
return false;
|
||||
|
||||
|
||||
mLoading = true;
|
||||
|
||||
|
||||
SetImage(std::move(Image), Flags);
|
||||
|
||||
mLoading = false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -190,13 +190,13 @@ bool lcTexture::Load(lcMemFile& File, int Flags)
|
||||
|
||||
if (!Image.FileLoad(File))
|
||||
return false;
|
||||
|
||||
|
||||
mLoading = true;
|
||||
|
||||
|
||||
SetImage(std::move(Image), Flags);
|
||||
|
||||
|
||||
mLoading = false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ void lcThumbnailManager::DrawThumbnail(lcPartThumbnailId ThumbnailId, lcPartThum
|
||||
IconName = ":/resources/part_flexible.png";
|
||||
else if (Info->GetTrainTrackInfo())
|
||||
IconName = ":/resources/part_traintrack.png";
|
||||
|
||||
|
||||
if (IconName)
|
||||
{
|
||||
QPainter Painter(&Image);
|
||||
@@ -146,11 +146,11 @@ void lcThumbnailManager::DrawThumbnail(lcPartThumbnailId ThumbnailId, lcPartThum
|
||||
Painter.drawImage(QPoint(0, 0), Icon);
|
||||
Painter.end();
|
||||
}
|
||||
|
||||
|
||||
Image.setDevicePixelRatio(Thumbnail.DeviceScale);
|
||||
|
||||
|
||||
float ScaledSize = Thumbnail.Size * Thumbnail.DeviceScale;
|
||||
|
||||
|
||||
Thumbnail.Pixmap = QPixmap::fromImage(Image).scaled(ScaledSize, ScaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
mLibrary->ReleasePieceInfo(Info);
|
||||
|
||||
@@ -247,7 +247,7 @@ void lcTimelineWidget::Update(bool Clear, bool UpdateItems)
|
||||
StepItem = topLevelItem(Step - 1);
|
||||
PieceItemIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
UpdateCurrentStepItem();
|
||||
|
||||
blockSignals(Blocked);
|
||||
@@ -553,10 +553,10 @@ void lcTimelineWidget::ItemSelectionChanged()
|
||||
}
|
||||
|
||||
Model->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION, lcSelectionMode::Single);
|
||||
|
||||
|
||||
mIgnoreUpdates = false;
|
||||
blockSignals(Blocked);
|
||||
|
||||
|
||||
UpdateSelection();
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -267,7 +267,7 @@ lcMatrix44 lcView::GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, in
|
||||
|
||||
double ImageLeft, ImageRight, ImageBottom, ImageTop, Near, Far;
|
||||
double AspectRatio = (double)ImageWidth / (double)ImageHeight;
|
||||
|
||||
|
||||
if (mCamera->GetProjection() == lcCameraProjection::Orthographic)
|
||||
{
|
||||
float OrthoHeight = mCamera->GetOrthoHeight() / 2.0f;
|
||||
@@ -300,7 +300,7 @@ lcMatrix44 lcView::GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, in
|
||||
double Right = Left + (ImageRight - ImageLeft) * CurrentTileWidth / ImageWidth;
|
||||
double Bottom = ImageBottom + (ImageTop - ImageBottom) * (CurrentRow * mHeight) / ImageHeight;
|
||||
double Top = Bottom + (ImageTop - ImageBottom) * CurrentTileHeight / ImageHeight;
|
||||
|
||||
|
||||
if (mCamera->GetProjection() == lcCameraProjection::Orthographic)
|
||||
return lcMatrix44Ortho(Left, Right, Bottom, Top, Near, Far);
|
||||
else
|
||||
@@ -807,7 +807,7 @@ bool lcView::BeginRenderToImage(int Width, int Height)
|
||||
{
|
||||
lcContext* Context = lcContext::GetGlobalOffscreenContext();
|
||||
GLint MaxTexture;
|
||||
|
||||
|
||||
Context->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexture);
|
||||
MaxTexture = qMin(MaxTexture, 2048);
|
||||
|
||||
@@ -1153,7 +1153,7 @@ void lcView::DrawViewport() const
|
||||
float Scale = GetUIScale();
|
||||
float Width = mWidth / Scale;
|
||||
float Height = mHeight / Scale;
|
||||
|
||||
|
||||
mContext->SetWorldMatrix(lcMatrix44Identity());
|
||||
mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0)));
|
||||
mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, Width, 0.0f, Height, -1.0f, 1.0f));
|
||||
@@ -1268,7 +1268,7 @@ void lcView::DrawAxes() const
|
||||
TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, mHeight - 36, 0.0f) / Scale);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
lcMatrix44 WorldViewMatrix = mCamera->mWorldView;
|
||||
WorldViewMatrix.SetTranslation(lcVector3(0, 0, 0));
|
||||
|
||||
@@ -1523,18 +1523,18 @@ void lcView::DrawGrid()
|
||||
|
||||
if (Preferences.mDrawGridLines)
|
||||
VertexBufferSize += 2 * (MaxX - MinX + MaxY - MinY + 2) * 3 * sizeof(float);
|
||||
|
||||
|
||||
float* Verts = nullptr;
|
||||
|
||||
|
||||
if (VertexBufferSize)
|
||||
{
|
||||
Verts = static_cast<float*>(malloc(VertexBufferSize));
|
||||
|
||||
|
||||
if (!Verts)
|
||||
return;
|
||||
|
||||
|
||||
float* CurVert = Verts;
|
||||
|
||||
|
||||
if (Preferences.mDrawGridStuds)
|
||||
{
|
||||
float Left = MinX * 20.0f * Spacing;
|
||||
@@ -1544,36 +1544,36 @@ void lcView::DrawGrid()
|
||||
float Z = 0;
|
||||
float U = (MaxX - MinX) * Spacing;
|
||||
float V = (MaxY - MinY) * Spacing;
|
||||
|
||||
|
||||
*CurVert++ = Left;
|
||||
*CurVert++ = Top;
|
||||
*CurVert++ = Z;
|
||||
*CurVert++ = 0.0f;
|
||||
*CurVert++ = V;
|
||||
|
||||
|
||||
*CurVert++ = Right;
|
||||
*CurVert++ = Top;
|
||||
*CurVert++ = Z;
|
||||
*CurVert++ = U;
|
||||
*CurVert++ = V;
|
||||
|
||||
|
||||
*CurVert++ = Left;
|
||||
*CurVert++ = Bottom;
|
||||
*CurVert++ = Z;
|
||||
*CurVert++ = 0.0f;
|
||||
*CurVert++ = 0.0f;
|
||||
|
||||
|
||||
*CurVert++ = Right;
|
||||
*CurVert++ = Bottom;
|
||||
*CurVert++ = Z;
|
||||
*CurVert++ = U;
|
||||
*CurVert++ = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
if (Preferences.mDrawGridLines)
|
||||
{
|
||||
float LineSpacing = Spacing * 20.0f;
|
||||
|
||||
|
||||
for (int Step = MinX; Step < MaxX + 1; Step++)
|
||||
{
|
||||
*CurVert++ = Step * LineSpacing;
|
||||
@@ -1583,7 +1583,7 @@ void lcView::DrawGrid()
|
||||
*CurVert++ = MaxY * LineSpacing;
|
||||
*CurVert++ = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
for (int Step = MinY; Step < MaxY + 1; Step++)
|
||||
{
|
||||
*CurVert++ = MinX * LineSpacing;
|
||||
@@ -1726,7 +1726,7 @@ float lcView::GetOverlayScale() const
|
||||
lcVector3 Point = UnprojectPoint(ScreenPos);
|
||||
|
||||
lcVector3 Dist(Point - WorldMatrix.GetTranslation());
|
||||
|
||||
|
||||
return Dist.Length() * 5.0f * GetUIScale();
|
||||
}
|
||||
|
||||
@@ -1896,7 +1896,7 @@ void lcView::SetCameraProjection(lcCameraProjection CameraProjection)
|
||||
else
|
||||
{
|
||||
lcModel* ActiveModel = GetActiveModel();
|
||||
|
||||
|
||||
if (ActiveModel)
|
||||
ActiveModel->SetCameraProjection(mCamera, CameraProjection);
|
||||
}
|
||||
@@ -2571,10 +2571,10 @@ void lcView::OnButtonDown(lcTrackButton TrackButton)
|
||||
case lcTrackTool::Camera:
|
||||
{
|
||||
ActiveModel->InsertCameraToolClicked(GetCameraLightInsertPosition());
|
||||
|
||||
|
||||
if ((mMouseModifiers & Qt::ControlModifier) == 0)
|
||||
gMainWindow->SetTool(lcTool::Select);
|
||||
|
||||
|
||||
mToolClicked = true;
|
||||
UpdateTrackTool();
|
||||
}
|
||||
|
||||
+1
-1
@@ -263,7 +263,7 @@ public:
|
||||
void ShowContextMenu() const;
|
||||
bool CloseFindReplaceDialog();
|
||||
void ShowFindReplaceWidget(bool Replace);
|
||||
|
||||
|
||||
float GetUIScale() const;
|
||||
float GetOverlayScale() const;
|
||||
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
||||
|
||||
@@ -515,7 +515,7 @@ void lcViewManipulator::DrawTrainTrack(lcPiece* Piece, lcContext* Context, lcTra
|
||||
else if (TrackTool == lcTrackTool::RotateTrainTrackLeft)
|
||||
{
|
||||
Context->DrawIndexedPrimitives(GL_TRIANGLES, 96, GL_UNSIGNED_SHORT, (108 + 360 + 12) * 2);
|
||||
|
||||
|
||||
if (CanAdd)
|
||||
Context->DrawIndexedPrimitives(GL_TRIANGLES, 72, GL_UNSIGNED_SHORT, (108 + 360 + 12 + 192) * 2);
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ void lcViewWidget::initializeGL()
|
||||
void lcViewWidget::resizeGL(int Width, int Height)
|
||||
{
|
||||
const float Scale = GetDeviceScale();
|
||||
|
||||
|
||||
mView->SetSize(Width * Scale, Height * Scale);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
return devicePixelRatio();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
void resizeGL(int Width, int Height) override;
|
||||
|
||||
+3
-3
@@ -496,7 +496,7 @@ void lcLight::MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance,
|
||||
WorldMatrix.Orthonormalize();
|
||||
|
||||
SetRotation(WorldMatrix, Step, AddKey);
|
||||
|
||||
|
||||
mWorldMatrix = lcMatrix44(WorldMatrix, mWorldMatrix.GetTranslation());
|
||||
}
|
||||
}
|
||||
@@ -1250,7 +1250,7 @@ bool lcLight::SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool
|
||||
|
||||
case lcObjectPropertyId::LightColor:
|
||||
return SetColor(Value.value<lcVector3>(), Step, AddKey);
|
||||
|
||||
|
||||
case lcObjectPropertyId::LightBlenderPower:
|
||||
return SetBlenderPower(Value.toFloat(), Step, AddKey);
|
||||
|
||||
@@ -1514,7 +1514,7 @@ void lcLight::RemoveKeyFrames()
|
||||
lcLightHistoryState lcLight::GetHistoryState([[maybe_unused]] const lcModel* Model) const
|
||||
{
|
||||
lcLightHistoryState State;
|
||||
|
||||
|
||||
State.Id = mId;
|
||||
State.Hidden = mHidden;
|
||||
State.Name = mName;
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ struct lcLightHistoryState
|
||||
lcObjectProperty<float> AreaSizeY;
|
||||
lcObjectProperty<int> POVRayAreaGridX;
|
||||
lcObjectProperty<int> POVRayAreaGridY;
|
||||
|
||||
|
||||
bool operator==(const lcLightHistoryState& Other) const
|
||||
{
|
||||
return Id == Other.Id && Hidden == Other.Hidden && Name == Other.Name && LightType == Other.LightType &&
|
||||
@@ -365,7 +365,7 @@ protected:
|
||||
lcObjectProperty<float> mAreaSizeY = lcObjectProperty<float>(250.0f);
|
||||
lcObjectProperty<int> mPOVRayAreaGridX = lcObjectProperty<int>(2);
|
||||
lcObjectProperty<int> mPOVRayAreaGridY = lcObjectProperty<int>(2);
|
||||
|
||||
|
||||
lcVector3 mTargetMovePosition = lcVector3(0.0f, 0.0f, 0.0f);
|
||||
lcMatrix44 mWorldMatrix;
|
||||
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ void MinifigWizard::ParseSettings(lcFile& Settings)
|
||||
int Flags;
|
||||
|
||||
if (sscanf(NameEnd, "%d %g %g %g %g %g %g %g %g %g %g %g %g",
|
||||
&Flags, &Mat[0], &Mat[1], &Mat[2], &Mat[3], &Mat[4], &Mat[5], &Mat[6],
|
||||
&Flags, &Mat[0], &Mat[1], &Mat[2], &Mat[3], &Mat[4], &Mat[5], &Mat[6],
|
||||
&Mat[7], &Mat[8], &Mat[9], &Mat[10], &Mat[11]) != 13)
|
||||
continue;
|
||||
|
||||
|
||||
+11
-11
@@ -90,35 +90,35 @@ public:
|
||||
{
|
||||
return mObjectType;
|
||||
}
|
||||
|
||||
|
||||
lcObjectId GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
|
||||
bool IsSelected() const
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
|
||||
void SetSelected(bool Selected)
|
||||
{
|
||||
mSelected = Selected;
|
||||
|
||||
|
||||
if (!Selected)
|
||||
mFocusedSection = LC_OBJECT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
|
||||
bool IsFocused() const
|
||||
{
|
||||
return mFocusedSection != LC_OBJECT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
|
||||
bool IsFocused(quint32 Section) const
|
||||
{
|
||||
return mFocusedSection == Section;
|
||||
}
|
||||
|
||||
|
||||
void SetFocused(quint32 Section, bool Focused)
|
||||
{
|
||||
if (Focused)
|
||||
@@ -129,12 +129,12 @@ public:
|
||||
else
|
||||
mFocusedSection = LC_OBJECT_SECTION_INVALID;
|
||||
}
|
||||
|
||||
|
||||
quint32 GetFocusSection() const
|
||||
{
|
||||
return mFocusedSection;
|
||||
}
|
||||
|
||||
|
||||
virtual void UpdatePosition(lcStep Step) = 0;
|
||||
virtual quint32 GetAllowedTransforms() const = 0;
|
||||
virtual lcVector3 GetSectionPosition(quint32 Section) const = 0;
|
||||
@@ -151,12 +151,12 @@ public:
|
||||
|
||||
private:
|
||||
lcObjectType mObjectType;
|
||||
|
||||
|
||||
protected:
|
||||
bool mHidden = false;
|
||||
bool mSelected = false;
|
||||
quint32 mFocusedSection = LC_OBJECT_SECTION_INVALID;
|
||||
lcObjectId mId = static_cast<lcObjectId>(0);
|
||||
|
||||
|
||||
static lcObjectId mNextId;
|
||||
};
|
||||
|
||||
+9
-9
@@ -918,7 +918,7 @@ void lcPiece::RemoveKeyFrames()
|
||||
lcPieceHistoryState lcPiece::GetHistoryState(const lcModel* Model) const
|
||||
{
|
||||
lcPieceHistoryState State;
|
||||
|
||||
|
||||
State.Id = mId;
|
||||
State.Hidden = mHidden;
|
||||
State.FileLine = mFileLine;
|
||||
@@ -933,9 +933,9 @@ lcPieceHistoryState lcPiece::GetHistoryState(const lcModel* Model) const
|
||||
State.ControlPoints = mControlPoints;
|
||||
State.Position = mPosition;
|
||||
State.Rotation = mRotation;
|
||||
|
||||
|
||||
const std::vector<std::unique_ptr<lcGroup>>& Groups = Model->GetGroups();
|
||||
|
||||
|
||||
if (mGroup)
|
||||
{
|
||||
for (size_t GroupIndex = 0; GroupIndex < Groups.size(); GroupIndex++)
|
||||
@@ -947,14 +947,14 @@ lcPieceHistoryState lcPiece::GetHistoryState(const lcModel* Model) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return State;
|
||||
}
|
||||
|
||||
void lcPiece::SetHistoryState(const lcPieceHistoryState& State, const lcModel* Model)
|
||||
{
|
||||
const std::vector<std::unique_ptr<lcGroup>>& Groups = Model->GetGroups();
|
||||
|
||||
|
||||
mId = State.Id;
|
||||
mHidden = State.Hidden;
|
||||
mFileLine = State.FileLine;
|
||||
@@ -969,13 +969,13 @@ void lcPiece::SetHistoryState(const lcPieceHistoryState& State, const lcModel* M
|
||||
mControlPoints = State.ControlPoints;
|
||||
mPosition = State.Position;
|
||||
mRotation = State.Rotation;
|
||||
|
||||
|
||||
PieceInfo* Info = lcGetPiecesLibrary()->FindPiece(mID.toLatin1(), nullptr, true, false);
|
||||
|
||||
|
||||
SetPieceInfo(Info, mID, true, false);
|
||||
|
||||
|
||||
UpdateMesh();
|
||||
|
||||
|
||||
// std::vector<bool> mTrainTrackConnections;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ struct lcPieceControlPoint
|
||||
{
|
||||
lcMatrix44 Transform;
|
||||
float Scale;
|
||||
|
||||
|
||||
bool operator==(const lcPieceControlPoint& Other) const
|
||||
{
|
||||
return Transform == Other.Transform && Scale == Other.Scale;
|
||||
@@ -44,7 +44,7 @@ struct lcPieceHistoryState
|
||||
std::vector<lcPieceControlPoint> ControlPoints;
|
||||
lcObjectProperty<lcVector3> Position;
|
||||
lcObjectProperty<lcMatrix33> Rotation;
|
||||
|
||||
|
||||
bool operator==(const lcPieceHistoryState& Other) const
|
||||
{
|
||||
return Id == Other.Id && Hidden == Other.Hidden && FileLine == Other.FileLine && PieceId == Other.PieceId &&
|
||||
|
||||
+4
-4
@@ -268,10 +268,10 @@ lcModel* Project::CreateNewModel(bool ShowModel)
|
||||
SetActiveModel(mModels.back().get(), true);
|
||||
|
||||
lcView* ActiveView = gMainWindow ? gMainWindow->GetActiveView() : nullptr;
|
||||
|
||||
|
||||
if (ActiveView)
|
||||
ActiveView->GetCamera()->SetViewpoint(lcViewpoint::Home);
|
||||
|
||||
|
||||
if (gMainWindow)
|
||||
gMainWindow->UpdateTitle();
|
||||
}
|
||||
@@ -1182,7 +1182,7 @@ bool Project::Export3DStudio(const QString& FileName)
|
||||
|
||||
File.WriteU16(0x4130); // CHK_MSH_MAT_GROUP
|
||||
File.WriteU32(6 + MaterialNameLength + 1 + 2 + 2 * Section->NumIndices / 3);
|
||||
|
||||
|
||||
snprintf(MaterialName, sizeof(MaterialName), "Material%03d", MaterialIndex);
|
||||
File.WriteBuffer(MaterialName, MaterialNameLength + 1);
|
||||
|
||||
@@ -1900,7 +1900,7 @@ std::pair<bool, QString> Project::ExportPOVRay(const QString& FileName)
|
||||
float FloorDiffuse = POVRayOptions.FloorDiffuse;
|
||||
const char* FloorLocation;
|
||||
const char* FloorAxis;
|
||||
|
||||
|
||||
if (POVRayOptions.FloorAxis == 0)
|
||||
{
|
||||
FloorAxis = "x";
|
||||
|
||||
+43
-43
@@ -14,21 +14,21 @@ public:
|
||||
: QItemDelegate(Parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void setModelData(QWidget* Editor, QAbstractItemModel* Model, const QModelIndex& Index) const
|
||||
{
|
||||
QLineEdit* LineEdit = qobject_cast<QLineEdit *>(Editor);
|
||||
|
||||
|
||||
if (!LineEdit->isModified())
|
||||
return;
|
||||
|
||||
QString Text = LineEdit->text().trimmed();
|
||||
|
||||
|
||||
lcQEditGroupsDialog* Dialog = qobject_cast<lcQEditGroupsDialog*>(parent());
|
||||
|
||||
|
||||
if (Dialog && !Dialog->CanRenameGroup(Text))
|
||||
return;
|
||||
|
||||
|
||||
QItemDelegate::setModelData(Editor, Model, Index);
|
||||
}
|
||||
};
|
||||
@@ -39,13 +39,13 @@ lcQEditGroupsDialog::lcQEditGroupsDialog(QWidget* Parent, const lcModel* Model)
|
||||
ui = new Ui::lcQEditGroupsDialog;
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
QPushButton* NewGroup = ui->buttonBox->addButton(tr("&New Group"), QDialogButtonBox::ActionRole);
|
||||
|
||||
connect(NewGroup, &QPushButton::clicked, this, &lcQEditGroupsDialog::NewGroupClicked);
|
||||
|
||||
PopulateTree();
|
||||
|
||||
|
||||
ui->treeWidget->setItemDelegate(new lcEditGroupsDialogDelegate(this));
|
||||
ui->treeWidget->expandAll();
|
||||
}
|
||||
@@ -59,67 +59,67 @@ bool lcQEditGroupsDialog::CanRenameGroup(const QString& Text) const
|
||||
{
|
||||
if (Text.isEmpty())
|
||||
return false;
|
||||
|
||||
|
||||
std::function<bool(QTreeWidgetItem*)> ScanGroups = [&ScanGroups, &Text](QTreeWidgetItem* ParentItem)
|
||||
{
|
||||
for (int ChildIndex = 0; ChildIndex < ParentItem->childCount(); ChildIndex++)
|
||||
{
|
||||
QTreeWidgetItem* ChildItem = ParentItem->child(ChildIndex);
|
||||
|
||||
|
||||
if (ChildItem->data(0, GroupRole).value<uintptr_t>())
|
||||
{
|
||||
if (ChildItem->text(0) == Text || !ScanGroups(ChildItem))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
return ScanGroups(ui->treeWidget->invisibleRootItem());
|
||||
}
|
||||
|
||||
void lcQEditGroupsDialog::NewGroupClicked()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = ui->treeWidget->currentItem();
|
||||
|
||||
|
||||
if (CurrentItem && CurrentItem->data(0, PieceRole).value<uintptr_t>())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
|
||||
if (!CurrentItem)
|
||||
CurrentItem = ui->treeWidget->invisibleRootItem();
|
||||
|
||||
|
||||
QString Prefix = tr("Group #");
|
||||
int MaxIndex = 0;
|
||||
|
||||
|
||||
std::function<void(QTreeWidgetItem*)> ScanGroups = [&ScanGroups, &Prefix, &MaxIndex](QTreeWidgetItem* ParentItem)
|
||||
{
|
||||
for (int ChildIndex = 0; ChildIndex < ParentItem->childCount(); ChildIndex++)
|
||||
{
|
||||
QTreeWidgetItem* ChildItem = ParentItem->child(ChildIndex);
|
||||
|
||||
|
||||
if (ChildItem->data(0, GroupRole).value<uintptr_t>())
|
||||
{
|
||||
QString Name = ChildItem->text(0);
|
||||
|
||||
|
||||
if (Name.startsWith(Prefix))
|
||||
{
|
||||
bool Ok = false;
|
||||
int GroupNumber = Name.mid(Prefix.length()).toInt(&Ok);
|
||||
|
||||
|
||||
if (Ok && GroupNumber > MaxIndex)
|
||||
MaxIndex = GroupNumber;
|
||||
}
|
||||
|
||||
|
||||
ScanGroups(ChildItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ScanGroups(ui->treeWidget->invisibleRootItem());
|
||||
|
||||
|
||||
QString Name = Prefix + QString::number(MaxIndex + 1);
|
||||
|
||||
|
||||
QTreeWidgetItem* GroupItem = new QTreeWidgetItem(CurrentItem, QStringList(Name));
|
||||
GroupItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);
|
||||
GroupItem->setData(0, GroupRole, QVariant::fromValue<uintptr_t>(LC_GROUPDIALOG_NEW_GROUP));
|
||||
@@ -129,27 +129,27 @@ void lcQEditGroupsDialog::NewGroupClicked()
|
||||
lcQEditGroupsDialog::GroupInfo lcQEditGroupsDialog::GetGroupInfo(QTreeWidgetItem* ParentItem) const
|
||||
{
|
||||
lcQEditGroupsDialog::GroupInfo GroupInfo;
|
||||
|
||||
|
||||
GroupInfo.Name = ParentItem->text(0);
|
||||
|
||||
|
||||
uintptr_t GroupPointer = ParentItem->data(0, GroupRole).value<uintptr_t>();
|
||||
GroupInfo.Group = (GroupPointer == LC_GROUPDIALOG_NEW_GROUP) ? nullptr : reinterpret_cast<lcGroup*>(GroupPointer);
|
||||
|
||||
|
||||
for (int ChildIndex = 0; ChildIndex < ParentItem->childCount(); ChildIndex++)
|
||||
{
|
||||
QTreeWidgetItem* ChildItem = ParentItem->child(ChildIndex);
|
||||
|
||||
|
||||
if (ChildItem->data(0, GroupRole).value<uintptr_t>())
|
||||
GroupInfo.ChildGroups.emplace_back(GetGroupInfo(ChildItem));
|
||||
else
|
||||
{
|
||||
lcPiece* Piece = reinterpret_cast<lcPiece*>(ChildItem->data(0, PieceRole).value<uintptr_t>());
|
||||
|
||||
|
||||
if (Piece)
|
||||
GroupInfo.ChildPieces.push_back(Piece);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return GroupInfo;
|
||||
}
|
||||
|
||||
@@ -163,33 +163,33 @@ void lcQEditGroupsDialog::PopulateTree()
|
||||
const std::vector<std::unique_ptr<lcGroup>>& Groups = mModel->GetGroups();
|
||||
std::unordered_map<lcGroup*, QTreeWidgetItem*> AddedGroups;
|
||||
std::vector<lcGroup*> GroupsToAdd;
|
||||
|
||||
|
||||
AddedGroups[nullptr] = ui->treeWidget->invisibleRootItem();
|
||||
|
||||
|
||||
auto CreateGroupItem = [&AddedGroups](lcGroup* Group)
|
||||
{
|
||||
QTreeWidgetItem* ParentItem = AddedGroups.find(Group->mGroup)->second;
|
||||
|
||||
|
||||
if (!ParentItem)
|
||||
return false;
|
||||
|
||||
|
||||
QTreeWidgetItem* GroupItem = new QTreeWidgetItem(ParentItem, QStringList(Group->mName));
|
||||
GroupItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);
|
||||
GroupItem->setData(0, GroupRole, QVariant::fromValue<uintptr_t>((uintptr_t)Group));
|
||||
|
||||
|
||||
AddedGroups[Group] = GroupItem;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcGroup>& Group : Groups)
|
||||
if (!CreateGroupItem(Group.get()))
|
||||
GroupsToAdd.push_back(Group.get());
|
||||
|
||||
|
||||
while (!GroupsToAdd.empty())
|
||||
{
|
||||
size_t GroupCount = GroupsToAdd.size();
|
||||
|
||||
|
||||
for (auto GroupIt = GroupsToAdd.begin(); GroupIt != GroupsToAdd.end();)
|
||||
{
|
||||
if (CreateGroupItem(*GroupIt))
|
||||
@@ -197,17 +197,17 @@ void lcQEditGroupsDialog::PopulateTree()
|
||||
else
|
||||
++GroupIt;
|
||||
}
|
||||
|
||||
|
||||
if (GroupCount == GroupsToAdd.size())
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::unique_ptr<lcPiece>>& Pieces = mModel->GetPieces();
|
||||
|
||||
|
||||
for (const std::unique_ptr<lcPiece>& Piece : Pieces)
|
||||
{
|
||||
QTreeWidgetItem* ParentItem = AddedGroups.find(Piece->GetGroup())->second;
|
||||
|
||||
|
||||
if (ParentItem)
|
||||
{
|
||||
QTreeWidgetItem* PieceItem = new QTreeWidgetItem(ParentItem, QStringList(Piece->GetName()));
|
||||
|
||||
@@ -7,11 +7,11 @@ class lcQEditGroupsDialog;
|
||||
class lcQEditGroupsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
lcQEditGroupsDialog(QWidget* Parent, const lcModel* Model);
|
||||
virtual ~lcQEditGroupsDialog();
|
||||
|
||||
|
||||
struct GroupInfo
|
||||
{
|
||||
QString Name;
|
||||
@@ -19,10 +19,10 @@ public:
|
||||
std::vector<GroupInfo> ChildGroups;
|
||||
std::vector<lcPiece*> ChildPieces;
|
||||
};
|
||||
|
||||
|
||||
GroupInfo GetGroups() const;
|
||||
bool CanRenameGroup(const QString& Text) const;
|
||||
|
||||
|
||||
protected slots:
|
||||
void NewGroupClicked();
|
||||
|
||||
@@ -32,10 +32,10 @@ protected:
|
||||
PieceRole = Qt::UserRole,
|
||||
GroupRole
|
||||
};
|
||||
|
||||
|
||||
GroupInfo GetGroupInfo(QTreeWidgetItem* ParentItem) const;
|
||||
void PopulateTree();
|
||||
|
||||
|
||||
Ui::lcQEditGroupsDialog* ui = nullptr;
|
||||
const lcModel* mModel = nullptr;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ class lcQImageDialog;
|
||||
class lcQImageDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
lcQImageDialog(QWidget* Parent);
|
||||
~lcQImageDialog();
|
||||
|
||||
@@ -101,7 +101,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
|
||||
ui->ConditionalLinesCheckBox->setChecked(false);
|
||||
ui->ConditionalLinesCheckBox->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
lcViewWidget* Widget = gMainWindow->GetActiveView()->GetWidget();
|
||||
QOpenGLContext* Context = Widget->context();
|
||||
QOpenGLFunctions* Functions = Context->functions();
|
||||
@@ -912,7 +912,7 @@ void lcQPreferencesDialog::updateCommandList()
|
||||
|
||||
qsizetype pos = identifier.indexOf(QLatin1Char('.'));
|
||||
qsizetype subPos = identifier.indexOf(QLatin1Char('.'), pos + 1);
|
||||
|
||||
|
||||
if (subPos == -1)
|
||||
subPos = pos;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class lcQSelectDialog;
|
||||
class lcQSelectDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
lcQSelectDialog(QWidget* Parent, lcModel* Model);
|
||||
~lcQSelectDialog();
|
||||
|
||||
@@ -14,7 +14,7 @@ void lcDoInitialUpdateCheck();
|
||||
class lcQUpdateDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit lcQUpdateDialog(QWidget* Parent, bool InitialUpdate);
|
||||
~lcQUpdateDialog();
|
||||
|
||||
+8
-8
@@ -152,14 +152,14 @@ void lcQTreeWidgetColumnStretcher::SectionResized(int LogicalIndex, int OldSize,
|
||||
{
|
||||
Q_UNUSED(OldSize)
|
||||
|
||||
if (LogicalIndex == mColumnToStretch)
|
||||
{
|
||||
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(parent());
|
||||
|
||||
if (HeaderView->isVisible())
|
||||
mInteractiveResize = true;
|
||||
|
||||
mStretchWidth = NewSize;
|
||||
if (LogicalIndex == mColumnToStretch)
|
||||
{
|
||||
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(parent());
|
||||
|
||||
if (HeaderView->isVisible())
|
||||
mInteractiveResize = true;
|
||||
|
||||
mStretchWidth = NewSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ bool lcRenderDialog::PromptCancel()
|
||||
{
|
||||
if (!mProcess)
|
||||
return true;
|
||||
|
||||
|
||||
if (QMessageBox::question(this, tr("Cancel Render"), tr("Are you sure you want to cancel the current render?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
||||
return false;
|
||||
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@
|
||||
static TCHAR gMinidumpPath[_MAX_PATH];
|
||||
|
||||
static LONG WINAPI lcSehHandler(PEXCEPTION_POINTERS exceptionPointers)
|
||||
{
|
||||
{
|
||||
if (IsDebuggerPresent())
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
|
||||
#ifdef LC_LDRAW_LIBRARY_PATH
|
||||
LibraryPaths += qMakePair(QString::fromLatin1(LC_LDRAW_LIBRARY_PATH), false);
|
||||
#endif
|
||||
|
||||
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
lcStartupMode StartupMode = Application.Initialize(LibraryPaths);
|
||||
|
||||
Reference in New Issue
Block a user