mirror of
https://github.com/leozide/leocad.git
synced 2026-07-28 04:07:11 +00:00
Preserve case of part names in files.
This commit is contained in:
+1
-1
@@ -186,7 +186,7 @@ bool lcImportLXFMLFile(const QString& FileData, lcArray<lcPiece*>& Pieces, lcArr
|
||||
lcVector4(-WorldMatrix[2][0], WorldMatrix[2][1], WorldMatrix[2][2], 0.0f), lcVector4(WorldMatrix[3][0] * 25.0f, -WorldMatrix[3][1] * 25.0f, -WorldMatrix[3][2] * 25.0f, 1.0f));
|
||||
|
||||
lcPiece* Piece = new lcPiece(nullptr);
|
||||
Piece->SetPieceInfo(Info, false);
|
||||
Piece->SetPieceInfo(Info, QString(), false);
|
||||
Piece->Initialize(lcMatrix44LDrawToLeoCAD(WorldMatrix), 1);
|
||||
Piece->SetColorCode(ColorCode);
|
||||
Pieces.Add(Piece);
|
||||
|
||||
@@ -1590,7 +1590,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
|
||||
if ((Selection.GetSize() == 1) && Focus)
|
||||
{
|
||||
if (Focus->IsPiece())
|
||||
Message = tr("%1 (ID: %2)").arg(Focus->GetName(), ((lcPiece*)Focus)->mPieceInfo->m_strName);
|
||||
Message = tr("%1 (ID: %2)").arg(Focus->GetName(), ((lcPiece*)Focus)->GetID());
|
||||
else
|
||||
Message = Focus->GetName();
|
||||
}
|
||||
@@ -1600,7 +1600,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
|
||||
|
||||
if (Focus && Focus->IsPiece())
|
||||
{
|
||||
Message.append(tr(" - %1 (ID: %2)").arg(Focus->GetName(), ((lcPiece*)Focus)->mPieceInfo->m_strName));
|
||||
Message.append(tr(" - %1 (ID: %2)").arg(Focus->GetName(), ((lcPiece*)Focus)->GetID()));
|
||||
|
||||
const lcGroup* Group = ((lcPiece*)Focus)->GetGroup();
|
||||
if (Group && !Group->mName.isEmpty())
|
||||
|
||||
+17
-12
@@ -621,7 +621,8 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||
lcMatrix44 IncludeTransform(lcVector4(IncludeMatrix[3], IncludeMatrix[6], IncludeMatrix[9], 0.0f), lcVector4(IncludeMatrix[4], IncludeMatrix[7], IncludeMatrix[10], 0.0f),
|
||||
lcVector4(IncludeMatrix[5], IncludeMatrix[8], IncludeMatrix[11], 0.0f), lcVector4(IncludeMatrix[0], IncludeMatrix[1], IncludeMatrix[2], 1.0f));
|
||||
|
||||
QString File = LineStream.readAll().trimmed().toUpper();
|
||||
QString OriginalID = LineStream.readAll().trimmed();
|
||||
QString File = OriginalID.toUpper();
|
||||
QString PartID = File;
|
||||
PartID.replace('\\', '/');
|
||||
|
||||
@@ -650,7 +651,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
||||
lcVector4(-Matrix[4], -Matrix[6], Matrix[5], 0.0f), lcVector4(Matrix[12], Matrix[14], -Matrix[13], 1.0f));
|
||||
|
||||
Piece->SetFileLine(mFileLines.size());
|
||||
Piece->SetPieceInfo(Info, false);
|
||||
Piece->SetPieceInfo(Info, OriginalID, false);
|
||||
Piece->Initialize(Transform, CurrentStep);
|
||||
Piece->SetColorCode(ColorCode);
|
||||
Piece->SetControlPoints(ControlPoints);
|
||||
@@ -2293,19 +2294,22 @@ void lcModel::InlineSelectedModels()
|
||||
|
||||
mPieces.RemoveIndex(PieceIdx);
|
||||
|
||||
lcArray<lcModelPartsEntry> ModelParts;
|
||||
Piece->mPieceInfo->GetModelParts(Piece->mModelWorld, Piece->mColorIndex, ModelParts);
|
||||
lcModel* Model = Piece->mPieceInfo->GetModel();
|
||||
|
||||
for (int InsertIdx = 0; InsertIdx < ModelParts.GetSize(); InsertIdx++)
|
||||
for (const lcPiece* ModelPiece : Model->mPieces)
|
||||
{
|
||||
lcModelPartsEntry& Entry = ModelParts[InsertIdx];
|
||||
|
||||
lcPiece* NewPiece = new lcPiece(Entry.Info);
|
||||
lcPiece* NewPiece = new lcPiece(nullptr);
|
||||
|
||||
// todo: recreate in groups in the current model
|
||||
|
||||
NewPiece->Initialize(Entry.WorldMatrix, Piece->GetStepShow());
|
||||
NewPiece->SetColorIndex(Entry.ColorIndex);
|
||||
int ColorIndex = ModelPiece->mColorIndex;
|
||||
|
||||
if (ColorIndex == gDefaultColor)
|
||||
ColorIndex = Piece->mColorIndex;
|
||||
|
||||
NewPiece->SetPieceInfo(ModelPiece->mPieceInfo, ModelPiece->GetID(), true);
|
||||
NewPiece->Initialize(lcMul(ModelPiece->mModelWorld, Piece->mModelWorld), Piece->GetStepShow());
|
||||
NewPiece->SetColorIndex(ColorIndex);
|
||||
NewPiece->UpdatePosition(mCurrentStep);
|
||||
|
||||
NewPieces.Add(NewPiece);
|
||||
@@ -2625,7 +2629,7 @@ void lcModel::SetSelectedPiecesPieceInfo(PieceInfo* Info)
|
||||
{
|
||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
Library->ReleasePieceInfo(Piece->mPieceInfo);
|
||||
Piece->SetPieceInfo(Info, true);
|
||||
Piece->SetPieceInfo(Info, QString(), true);
|
||||
Modified = true;
|
||||
}
|
||||
}
|
||||
@@ -3971,7 +3975,8 @@ void lcModel::ShowArrayDialog()
|
||||
Position = lcVector3(ModelWorld.r[3].x, ModelWorld.r[3].y, ModelWorld.r[3].z);
|
||||
ModelWorld.SetTranslation(Position + Offset);
|
||||
|
||||
lcPiece* NewPiece = new lcPiece(Piece->mPieceInfo);
|
||||
lcPiece* NewPiece = new lcPiece(nullptr);
|
||||
NewPiece->SetPieceInfo(Piece->mPieceInfo, Piece->GetID(), true);
|
||||
NewPiece->Initialize(ModelWorld, mCurrentStep);
|
||||
NewPiece->SetColorIndex(Piece->mColorIndex);
|
||||
|
||||
|
||||
+12
-5
@@ -21,7 +21,7 @@ lcPiece::lcPiece(PieceInfo* Info)
|
||||
: lcObject(LC_OBJECT_PIECE)
|
||||
{
|
||||
mMesh = nullptr;
|
||||
SetPieceInfo(Info, true);
|
||||
SetPieceInfo(Info, QString(), true);
|
||||
mState = 0;
|
||||
mColorIndex = gDefaultColor;
|
||||
mColorCode = 16;
|
||||
@@ -39,7 +39,7 @@ lcPiece::lcPiece(const lcPiece& Other)
|
||||
: lcObject(LC_OBJECT_PIECE)
|
||||
{
|
||||
mMesh = nullptr;
|
||||
SetPieceInfo(Other.mPieceInfo, true);
|
||||
SetPieceInfo(Other.mPieceInfo, Other.mID, true);
|
||||
mState = 0;
|
||||
mColorIndex = Other.mColorIndex;
|
||||
mColorCode = Other.mColorCode;
|
||||
@@ -67,7 +67,7 @@ lcPiece::~lcPiece()
|
||||
delete mMesh;
|
||||
}
|
||||
|
||||
void lcPiece::SetPieceInfo(PieceInfo* Info, bool Wait)
|
||||
void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait)
|
||||
{
|
||||
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||
|
||||
@@ -75,6 +75,13 @@ void lcPiece::SetPieceInfo(PieceInfo* Info, bool Wait)
|
||||
if (mPieceInfo)
|
||||
Library->LoadPieceInfo(mPieceInfo, Wait, true);
|
||||
|
||||
if (!ID.isEmpty())
|
||||
mID = ID;
|
||||
else if (mPieceInfo)
|
||||
mID = mPieceInfo->GetSaveID();
|
||||
else
|
||||
mID.clear();
|
||||
|
||||
mControlPoints.RemoveAll();
|
||||
delete mMesh;
|
||||
mMesh = nullptr;
|
||||
@@ -125,7 +132,7 @@ void lcPiece::SaveLDraw(QTextStream& Stream) const
|
||||
for (int NumberIdx = 0; NumberIdx < 12; NumberIdx++)
|
||||
Stream << lcFormatValue(Numbers[NumberIdx]) << ' ';
|
||||
|
||||
Stream << mPieceInfo->GetSaveID() << LineEnding;
|
||||
Stream << mID << LineEnding;
|
||||
}
|
||||
|
||||
bool lcPiece::ParseLDrawLine(QTextStream& Stream)
|
||||
@@ -293,7 +300,7 @@ bool lcPiece::FileLoad(lcFile& file)
|
||||
file.ReadBuffer(name, LC_PIECE_NAME_LEN);
|
||||
|
||||
PieceInfo* pInfo = lcGetPiecesLibrary()->FindPiece(name, nullptr, true, false);
|
||||
SetPieceInfo(pInfo, true);
|
||||
SetPieceInfo(pInfo, QString(), true);
|
||||
|
||||
// 11 (0.77)
|
||||
if (version < 11)
|
||||
|
||||
+7
-2
@@ -384,12 +384,17 @@ public:
|
||||
UpdateMesh();
|
||||
}
|
||||
|
||||
const QString& GetID() const
|
||||
{
|
||||
return mID;
|
||||
}
|
||||
|
||||
const char* GetName() const override;
|
||||
bool IsVisible(lcStep Step);
|
||||
void Initialize(const lcMatrix44& WorldMatrix, lcStep Step);
|
||||
const lcBoundingBox& GetBoundingBox() const;
|
||||
void CompareBoundingBox(lcVector3& Min, lcVector3& Max) const;
|
||||
void SetPieceInfo(PieceInfo* Info, bool Wait);
|
||||
void SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait);
|
||||
bool FileLoad(lcFile& file);
|
||||
|
||||
void UpdatePosition(lcStep Step);
|
||||
@@ -552,6 +557,7 @@ protected:
|
||||
lcArray<lcObjectKey<lcMatrix33>> mRotationKeys;
|
||||
|
||||
int mFileLine;
|
||||
QString mID;
|
||||
|
||||
lcGroup* mGroup;
|
||||
|
||||
@@ -562,4 +568,3 @@ protected:
|
||||
lcArray<lcPieceControlPoint> mControlPoints;
|
||||
lcMesh* mMesh;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ QString PieceInfo::GetSaveID() const
|
||||
if (mFlags & (LC_PIECE_MODEL | LC_PIECE_PROJECT))
|
||||
return QString::fromLatin1(m_strName);
|
||||
|
||||
return QString::fromLatin1(m_strName) + QLatin1String(".DAT");
|
||||
return QString::fromLatin1(m_strName) + QLatin1String(".dat");
|
||||
}
|
||||
|
||||
void PieceInfo::SetMesh(lcMesh* Mesh)
|
||||
|
||||
Reference in New Issue
Block a user