Added actions for mouse drag changes.

This commit is contained in:
Leonardo Zide
2025-11-23 20:33:59 -08:00
parent 3ff6f06f04
commit 3bf01f2095
13 changed files with 496 additions and 48 deletions
+13
View File
@@ -56,6 +56,19 @@ lcCamera::~lcCamera()
{
}
void lcCamera::CopyProperties(const lcCamera& Other)
{
m_fovy = Other.m_fovy;
m_zNear = Other.m_zNear;
m_zFar = Other.m_zFar;
mPosition = Other.mPosition;
mTargetPosition = Other.mTargetPosition;
mUpVector = Other.mUpVector;
SetOrtho(Other.IsOrtho());
}
QString lcCamera::GetCameraTypeString(lcCameraType CameraType)
{
switch (CameraType)
+3 -1
View File
@@ -48,7 +48,7 @@ class lcCamera : public lcObject
public:
lcCamera(bool Simple);
lcCamera(float ex, float ey, float ez, float tx, float ty, float tz);
~lcCamera();
virtual ~lcCamera();
lcCamera(const lcCamera&) = delete;
lcCamera(lcCamera&&) = delete;
@@ -59,6 +59,8 @@ public:
static QStringList GetCameraTypeStrings();
static lcViewpoint GetViewpoint(const QString& ViewpointName);
void CopyProperties(const lcCamera& Other);
QString GetName() const override
{
return mName;
+1 -1
View File
@@ -179,7 +179,7 @@ bool lcImportLXFMLFile(const QString& FileData, std::vector<lcPiece*>& Pieces, s
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, QString(), false);
Piece->SetPieceInfo(Info, QString(), false, true);
Piece->Initialize(lcMatrix44LDrawToLeoCAD(WorldMatrix), 1);
Piece->SetColorCode(ColorCode);
Pieces.push_back(Piece);
+248 -22
View File
@@ -331,6 +331,15 @@ void lcModel::UpdatePieceInfo(std::vector<lcModel*>& UpdatedModels)
mPieceInfo->SetBoundingBox(Min, Max);
}
lcCamera* lcModel::GetCamera(const QString& Name) const
{
for (const std::unique_ptr<lcCamera>& Camera : mCameras)
if (Camera->GetName() == Name)
return Camera.get();
return nullptr;
}
void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) const
{
const QLatin1String LineEnding("\r\n");
@@ -737,7 +746,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, PartId, false);
Piece->SetPieceInfo(Info, PartId, false, true);
Piece->Initialize(Transform, CurrentStep);
Piece->SetColorCode(ColorCode);
Piece->VerifyControlPoints(ControlPoints);
@@ -1073,7 +1082,7 @@ bool lcModel::LoadInventory(const QByteArray& Inventory)
while (Quantity--)
{
lcPiece* Piece = new lcPiece(nullptr);
Piece->SetPieceInfo(Info, QString(), false);
Piece->SetPieceInfo(Info, QString(), false, true);
Piece->Initialize(lcMatrix44Identity(), 1);
Piece->SetColorCode(ColorCode);
AddPiece(Piece);
@@ -1714,6 +1723,167 @@ void lcModel::RunSelectionAction(const lcModelActionSelection* ModelActionSelect
}
}
void lcModel::BeginMouseToolAction(lcTool Tool, lcView* View)
{
std::unique_ptr<lcModelActionMouseTool> ModelActionMouseTool = std::make_unique<lcModelActionMouseTool>(Tool);
switch (Tool)
{
case lcTool::Insert:
case lcTool::PointLight:
case lcTool::SpotLight:
case lcTool::DirectionalLight:
case lcTool::AreaLight:
break;
// case lcTool::Camera:
// SaveCheckpoint(tr("New Camera"));
// break;
case lcTool::Select:
break;
case lcTool::Move:
case lcTool::Rotate:
ModelActionMouseTool->SaveSelectionStartState(this);
break;
case lcTool::Eraser:
case lcTool::Paint:
case lcTool::ColorPicker:
break;
case lcTool::Zoom:
case lcTool::Pan:
case lcTool::RotateView:
case lcTool::Roll:
ModelActionMouseTool->SetCameraStartState(View->GetCamera());
break;
case lcTool::ZoomRegion:
break;
case lcTool::Count:
break;
}
mActionSequence.emplace_back(std::move(ModelActionMouseTool));
}
void lcModel::EndMouseToolAction(lcTool Tool, lcView* View, const QString& Description)
{
if (mActionSequence.empty())
return;
lcModelActionMouseTool* ModelActionMouseTool = dynamic_cast<lcModelActionMouseTool*>(mActionSequence.back().get());
if (!ModelActionMouseTool || Tool != ModelActionMouseTool->GetTool())
return;
switch (Tool)
{
case lcTool::Insert:
case lcTool::PointLight:
case lcTool::SpotLight:
case lcTool::DirectionalLight:
case lcTool::AreaLight:
break;
// case lcTool::Camera:
// SaveCheckpoint(tr("New Camera"));
// break;
case lcTool::Select:
break;
case lcTool::Move:
case lcTool::Rotate:
ModelActionMouseTool->SaveSelectionEndState(this);
break;
case lcTool::Eraser:
case lcTool::Paint:
case lcTool::ColorPicker:
break;
case lcTool::Zoom:
case lcTool::Pan:
case lcTool::RotateView:
case lcTool::Roll:
ModelActionMouseTool->SetCameraEndState(View->GetCamera());
break;
case lcTool::ZoomRegion:
break;
case lcTool::Count:
break;
}
RecordSelectionAction(lcModelActionSelectionMode::Set);
EndActionSequence(Description);
}
void lcModel::RunMouseToolAction(const lcModelActionMouseTool* ModelActionMouseTool, bool Apply)
{
if (!ModelActionMouseTool)
return;
lcTool Tool = ModelActionMouseTool->GetTool();
switch (Tool)
{
case lcTool::Insert:
case lcTool::PointLight:
case lcTool::SpotLight:
case lcTool::DirectionalLight:
case lcTool::AreaLight:
break;
// case lcTool::Camera:
// SaveCheckpoint(tr("New Camera"));
// break;
case lcTool::Select:
break;
case lcTool::Move:
case lcTool::Rotate:
if (Apply)
ModelActionMouseTool->LoadSelectionEndState(this);
else
ModelActionMouseTool->LoadSelectionStartState(this);
SetCurrentStep(mCurrentStep);
break;
case lcTool::Eraser:
case lcTool::Paint:
case lcTool::ColorPicker:
break;
case lcTool::Zoom:
case lcTool::Pan:
case lcTool::RotateView:
case lcTool::Roll:
if (lcCamera* Camera = GetCamera(ModelActionMouseTool->GetCameraName()))
{
const QByteArray& State = Apply ? ModelActionMouseTool->GetEndState() : ModelActionMouseTool->GetStartState();
QDataStream Stream(const_cast<QByteArray*>(&State), QIODevice::ReadOnly);
Camera->LoadKeyFrames(Stream);
SetCurrentStep(mCurrentStep);
}
break;
case lcTool::ZoomRegion:
break;
case lcTool::Count:
break;
}
}
void lcModel::RecordAddPiecesAction(const std::vector<lcInsertPieceInfo>& PieceInfoTransforms, lcModelActionAddPieceSelectionMode SelectionMode)
{
std::unique_ptr<lcModelActionAddPieces> ModelActionAddPieces = std::make_unique<lcModelActionAddPieces>(mCurrentStep, SelectionMode);
@@ -2168,6 +2338,8 @@ void lcModel::PerformActionSequence(const std::vector<std::unique_ptr<lcModelAct
{
if (const lcModelActionSelection* ModelActionSelection = dynamic_cast<const lcModelActionSelection*>(ModelAction))
RunSelectionAction(ModelActionSelection, Apply);
else if (const lcModelActionMouseTool* ModelActionMouseTool = dynamic_cast<const lcModelActionMouseTool*>(ModelAction))
RunMouseToolAction(ModelActionMouseTool, Apply);
else if (const lcModelActionAddPieces* ModelActionAddPieces = dynamic_cast<const lcModelActionAddPieces*>(ModelAction))
RunAddPiecesAction(ModelActionAddPieces, Apply);
else if (const lcModelActionAddLight* ModelActionAddLight = dynamic_cast<const lcModelActionAddLight*>(ModelAction))
@@ -2215,8 +2387,11 @@ void lcModel::EndActionSequence(const QString& Description)
gMainWindow->UpdateUndoRedo(!mUndoHistory.empty() ? mUndoHistory.front()->Description : nullptr, !mRedoHistory.empty() ? mRedoHistory.front()->Description : nullptr);
}
void lcModel::CancelActionSequence()
void lcModel::RevertActionSequence()
{
PerformActionSequence(mActionSequence, false);
mActionSequence.clear();
}
void lcModel::SaveCheckpoint(const QString& )
@@ -3328,7 +3503,7 @@ void lcModel::InlineSelectedModels()
if (ColorIndex == gDefaultColor)
ColorIndex = Piece->GetColorIndex();
NewPiece->SetPieceInfo(ModelPiece->mPieceInfo, ModelPiece->GetID(), true);
NewPiece->SetPieceInfo(ModelPiece->mPieceInfo, ModelPiece->GetID(), true, true);
NewPiece->Initialize(lcMul(ModelPiece->mModelWorld, Piece->mModelWorld), Piece->GetStepShow());
NewPiece->SetColorIndex(ColorIndex);
NewPiece->UpdatePosition(mCurrentStep);
@@ -3916,7 +4091,7 @@ void lcModel::EndPropertyEdit(lcObjectPropertyId PropertyId, bool Accept)
{
if (!Accept)
{
CancelActionSequence();
RevertActionSequence();
return;
}
@@ -4858,7 +5033,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace)
Piece->SetColorIndex(Params.ReplaceColorIndex);
if (ReplacePieceInfo)
Piece->SetPieceInfo(Params.ReplacePieceInfo, QString(), true);
Piece->SetPieceInfo(Params.ReplacePieceInfo, QString(), true, true);
};
size_t StartIndex = mPieces.size() - 1;
@@ -4979,17 +5154,68 @@ void lcModel::RedoAction()
gMainWindow->UpdateUndoRedo(!mUndoHistory.empty() ? mUndoHistory.front()->Description : nullptr, !mRedoHistory.empty() ? mRedoHistory.front()->Description : nullptr);
}
void lcModel::BeginMouseTool()
void lcModel::BeginMouseTool(lcTool Tool, lcView* View)
{
switch (Tool)
{
case lcTool::Insert:
case lcTool::PointLight:
case lcTool::SpotLight:
case lcTool::DirectionalLight:
case lcTool::AreaLight:
break;
// case lcTool::Camera:
// {
// lcVector3 Position = GetCameraLightInsertPosition();
// lcVector3 Target = Position + lcVector3(0.1f, 0.1f, 0.1f);
// ActiveModel->BeginCameraTool(Position, Target);
// }
// break;
case lcTool::Select:
break;
case lcTool::Move:
case lcTool::Rotate:
BeginActionSequence();
RecordSelectionAction(lcModelActionSelectionMode::Set);
BeginMouseToolAction(Tool, View);
break;
case lcTool::Eraser:
case lcTool::Paint:
case lcTool::ColorPicker:
break;
case lcTool::Pan:
case lcTool::Zoom:
case lcTool::RotateView:
case lcTool::Roll:
if (!View->GetCamera()->IsSimple())
{
BeginActionSequence();
RecordSelectionAction(lcModelActionSelectionMode::Set);
BeginMouseToolAction(Tool, View);
}
break;
case lcTool::ZoomRegion:
break;
case lcTool::Count:
break;
}
mMouseToolDistance = lcVector3(0.0f, 0.0f, 0.0f);
mMouseToolFirstMove = true;
}
void lcModel::EndMouseTool(lcTool Tool, bool Accept)
void lcModel::EndMouseTool(lcTool Tool, lcView* View, bool Accept)
{
if (!Accept)
{
CancelActionSequence();
RevertActionSequence();
return;
}
@@ -5002,19 +5228,19 @@ void lcModel::EndMouseTool(lcTool Tool, bool Accept)
case lcTool::AreaLight:
break;
case lcTool::Camera:
SaveCheckpoint(tr("New Camera"));
break;
// case lcTool::Camera:
// SaveCheckpoint(tr("New Camera"));
// break;
case lcTool::Select:
break;
case lcTool::Move:
SaveCheckpoint(tr("Move"));
EndMouseToolAction(Tool, View, tr("Move"));
break;
case lcTool::Rotate:
SaveCheckpoint(tr("Rotate"));
EndMouseToolAction(Tool, View, tr("Rotate"));
break;
case lcTool::Eraser:
@@ -5023,23 +5249,23 @@ void lcModel::EndMouseTool(lcTool Tool, bool Accept)
break;
case lcTool::Zoom:
if (!gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Zoom"));
if (!View->GetCamera()->IsSimple())
EndMouseToolAction(Tool, View, tr("Zoom"));
break;
case lcTool::Pan:
if (!gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Pan"));
if (!View->GetCamera()->IsSimple())
EndMouseToolAction(Tool, View, tr("Pan"));
break;
case lcTool::RotateView:
if (!gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Orbit"));
if (!View->GetCamera()->IsSimple())
EndMouseToolAction(Tool, View, tr("Orbit"));
break;
case lcTool::Roll:
if (!gMainWindow->GetActiveView()->GetCamera()->IsSimple())
SaveCheckpoint(tr("Roll"));
if (!View->GetCamera()->IsSimple())
EndMouseToolAction(Tool, View, tr("Roll"));
break;
case lcTool::ZoomRegion:
+9 -3
View File
@@ -6,6 +6,7 @@
enum class lcObjectPropertyId;
class lcModelAction;
class lcModelActionSelection;
class lcModelActionMouseTool;
class lcModelActionAddPieces;
class lcModelActionAddLight;
class lcModelActionGroupPieces;
@@ -168,6 +169,8 @@ public:
return mCameras;
}
lcCamera* GetCamera(const QString& Name) const;
const std::vector<std::unique_ptr<lcLight>>& GetLights() const
{
return mLights;
@@ -351,8 +354,8 @@ public:
return mMouseToolDistance;
}
void BeginMouseTool();
void EndMouseTool(lcTool Tool, bool Accept);
void BeginMouseTool(lcTool Tool, lcView* View);
void EndMouseTool(lcTool Tool, lcView* View, bool Accept);
void InsertPieceToolClicked(const std::vector<lcInsertPieceInfo>& PieceInfoTransforms);
void InsertLightToolClicked(const lcVector3& Position, lcLightType LightType);
void BeginCameraTool(const lcVector3& Position, const lcVector3& Target);
@@ -407,6 +410,9 @@ protected:
void RecordSelectionAction(lcModelActionSelectionMode ModelActionSelectionMode);
void RunSelectionAction(const lcModelActionSelection* ModelActionSelection, bool Apply);
void BeginMouseToolAction(lcTool Tool, lcView* View);
void EndMouseToolAction(lcTool Tool, lcView* View, const QString& Description);
void RunMouseToolAction(const lcModelActionMouseTool* ModelActionMouseTool, bool Apply);
void RecordAddPiecesAction(const std::vector<lcInsertPieceInfo>& PieceInfoTransforms, lcModelActionAddPieceSelectionMode SelectionMode);
void RunAddPiecesAction(const lcModelActionAddPieces* ModelActionAddPieces, bool Apply);
void RecordAddLightAction(const lcVector3& Position, lcLightType LightType);
@@ -423,7 +429,7 @@ protected:
void PerformActionSequence(const std::vector<std::unique_ptr<lcModelAction>>& ActionSequence, bool Apply);
void BeginActionSequence();
void EndActionSequence(const QString& Description);
void CancelActionSequence();
void RevertActionSequence();
void SaveCheckpoint(const QString& Description);
void LoadCheckPoint(lcModelHistoryEntry* CheckPoint, bool Apply);
+99
View File
@@ -107,6 +107,105 @@ std::tuple<std::vector<lcObject*>, lcObject*, uint32_t> lcModelActionSelection::
return { SelectedObjects, FocusObject, mFocusSection };
}
lcModelActionMouseTool::lcModelActionMouseTool(lcTool Tool)
: mTool( Tool )
{
}
void lcModelActionMouseTool::SetCameraStartState(const lcCamera* Camera)
{
QDataStream Stream(&mStartState, QIODevice::WriteOnly);
Camera->SaveKeyFrames(Stream);
mCameraName = Camera->GetName();
}
void lcModelActionMouseTool::SetCameraEndState(const lcCamera* Camera)
{
QDataStream Stream(&mEndState, QIODevice::WriteOnly);
Camera->SaveKeyFrames(Stream);
}
void lcModelActionMouseTool::SaveSelectionStartState(const lcModel* Model)
{
SaveSelectionState(Model, mStartState);
}
void lcModelActionMouseTool::LoadSelectionStartState(lcModel* Model) const
{
LoadSelectionState(Model, mStartState);
}
void lcModelActionMouseTool::LoadSelectionEndState(lcModel* Model) const
{
LoadSelectionState(Model, mEndState);
}
void lcModelActionMouseTool::SaveSelectionEndState(const lcModel* Model)
{
SaveSelectionState(Model, mEndState);
}
void lcModelActionMouseTool::SaveSelectionState(const lcModel* Model, QByteArray& State)
{
QTextStream Stream(&State, QIODevice::WriteOnly);
Model->SaveLDraw(Stream, false, 0);
}
void lcModelActionMouseTool::LoadSelectionState(lcModel* Model, const QByteArray& State)
{
QBuffer Buffer(const_cast<QByteArray*>(&State));
Buffer.open(QIODevice::ReadOnly);
std::unique_ptr<lcModel> SavedModel = std::make_unique<lcModel>(QString(), Model->GetProject(), false);
SavedModel->LoadLDraw(Buffer, Model->GetProject());
const std::vector<std::unique_ptr<lcPiece>>& Pieces = Model->GetPieces();
const std::vector<std::unique_ptr<lcPiece>>& SavedPieces = SavedModel->GetPieces();
if (Pieces.size() != SavedPieces.size())
return;
for (size_t PieceIndex = 0; PieceIndex < Pieces.size(); PieceIndex++)
{
lcPiece* Piece = Pieces[PieceIndex].get();
if (Piece->IsSelected())
Piece->CopyProperties(*SavedPieces[PieceIndex].get());
}
const std::vector<std::unique_ptr<lcCamera>>& Cameras = Model->GetCameras();
const std::vector<std::unique_ptr<lcCamera>>& SavedCameras = SavedModel->GetCameras();
if (Cameras.size() != SavedCameras.size())
return;
for (size_t CameraIndex = 0; CameraIndex < Cameras.size(); CameraIndex++)
{
lcCamera* Camera = Cameras[CameraIndex].get();
if (Camera->IsSelected())
Camera->CopyProperties(*SavedCameras[CameraIndex].get());
}
const std::vector<std::unique_ptr<lcLight>>& Lights = Model->GetLights();
const std::vector<std::unique_ptr<lcLight>>& SavedLights = SavedModel->GetLights();
if (Lights.size() != SavedLights.size())
return;
for (size_t LightIndex = 0; LightIndex < Lights.size(); LightIndex++)
{
lcLight* Light = Lights[LightIndex].get();
if (Light->IsSelected())
Light->CopyProperties(*SavedLights[LightIndex].get());
}
}
lcModelActionAddPieces::lcModelActionAddPieces(lcStep Step, lcModelActionAddPieceSelectionMode SelectionMode)
: mStep(Step), mSelectionMode(SelectionMode)
{
+45
View File
@@ -5,6 +5,7 @@
struct lcInsertPieceInfo;
enum class lcObjectType;
enum class lcLightType;
enum class lcTool;
class lcModelAction
{
@@ -45,6 +46,50 @@ protected:
lcModelActionSelectionMode mMode = lcModelActionSelectionMode::Clear;
};
class lcModelActionMouseTool : public lcModelAction
{
public:
lcModelActionMouseTool(lcTool Tool);
virtual ~lcModelActionMouseTool() = default;
void SaveSelectionStartState(const lcModel* Model);
void LoadSelectionStartState(lcModel* Model) const;
void SaveSelectionEndState(const lcModel* Model);
void LoadSelectionEndState(lcModel* Model) const;
void SetCameraStartState(const lcCamera* Camera);
void SetCameraEndState(const lcCamera* Camera);
const QByteArray& GetStartState() const
{
return mStartState;
}
const QByteArray& GetEndState() const
{
return mEndState;
}
lcTool GetTool() const
{
return mTool;
}
const QString& GetCameraName() const
{
return mCameraName;
}
protected:
static void SaveSelectionState(const lcModel* Model, QByteArray& State);
static void LoadSelectionState(lcModel* Model, const QByteArray& State);
lcTool mTool;
QString mCameraName;
QByteArray mStartState;
QByteArray mEndState;
};
enum class lcModelActionAddPieceSelectionMode
{
FocusLast,
+5 -1
View File
@@ -321,13 +321,17 @@ void lcObjectProperty<T>::SaveToDataStream(QDataStream& Stream) const
size_t KeyCount = mKeys.size();
size_t DataSize = KeyCount * sizeof(lcObjectPropertyKey<T>);
Stream.writeRawData(reinterpret_cast<char*>(&KeyCount), sizeof(KeyCount));
Stream.writeRawData(reinterpret_cast<const char*>(&mValue), sizeof(mValue));
Stream.writeRawData(reinterpret_cast<const char*>(&KeyCount), sizeof(KeyCount));
Stream.writeRawData(reinterpret_cast<const char*>(mKeys.data()), DataSize);
}
template<typename T>
bool lcObjectProperty<T>::LoadFromDataStream(QDataStream& Stream)
{
if (Stream.readRawData(reinterpret_cast<char*>(&mValue), sizeof(mValue)) != sizeof(mValue))
return false;
size_t KeyCount;
if (Stream.readRawData(reinterpret_cast<char*>(&KeyCount), sizeof(KeyCount)) != sizeof(KeyCount))
+8 -8
View File
@@ -2276,7 +2276,7 @@ void lcView::StartPanGesture()
lcModel* ActiveModel = GetActiveModel();
StartPan(mWidth / 2, mHeight / 2);
ActiveModel->BeginMouseTool();
ActiveModel->BeginMouseTool(lcTool::Pan, this);
}
void lcView::UpdatePanGesture(int dx, int dy)
@@ -2336,7 +2336,7 @@ void lcView::EndPanGesture(bool Accept)
{
lcModel* ActiveModel = GetActiveModel();
ActiveModel->EndMouseTool(lcTool::Pan, Accept);
ActiveModel->EndMouseTool(lcTool::Pan, this, Accept);
}
void lcView::StartTracking(lcTrackButton TrackButton)
@@ -2370,7 +2370,7 @@ void lcView::StartTracking(lcTrackButton TrackButton)
case lcTool::Move:
case lcTool::Rotate:
ActiveModel->BeginMouseTool();
ActiveModel->BeginMouseTool(Tool, this);
break;
case lcTool::Eraser:
@@ -2380,13 +2380,13 @@ void lcView::StartTracking(lcTrackButton TrackButton)
case lcTool::Pan:
StartPan(mMouseX, mMouseY);
ActiveModel->BeginMouseTool();
ActiveModel->BeginMouseTool(Tool, this);
break;
case lcTool::Zoom:
case lcTool::RotateView:
case lcTool::Roll:
ActiveModel->BeginMouseTool();
ActiveModel->BeginMouseTool(Tool, this);
break;
case lcTool::ZoomRegion:
@@ -2417,7 +2417,7 @@ void lcView::StopTracking(bool Accept)
case lcTool::DirectionalLight:
case lcTool::AreaLight:
case lcTool::Camera:
ActiveModel->EndMouseTool(Tool, Accept);
ActiveModel->EndMouseTool(Tool, this, Accept);
break;
case lcTool::Select:
@@ -2436,7 +2436,7 @@ void lcView::StopTracking(bool Accept)
case lcTool::Move:
case lcTool::Rotate:
ActiveModel->EndMouseTool(Tool, Accept);
ActiveModel->EndMouseTool(Tool, this, Accept);
break;
case lcTool::Eraser:
@@ -2448,7 +2448,7 @@ void lcView::StopTracking(bool Accept)
case lcTool::Pan:
case lcTool::RotateView:
case lcTool::Roll:
ActiveModel->EndMouseTool(Tool, Accept);
ActiveModel->EndMouseTool(Tool, this, Accept);
break;
case lcTool::ZoomRegion:
+23
View File
@@ -31,6 +31,29 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType)
UpdatePosition(1);
}
void lcLight::CopyProperties(const lcLight& Other)
{
mLightType = Other.mLightType;
mCastShadow = Other.mCastShadow;
mPosition = Other.mPosition;
mRotation = Other.mRotation;
mColor = Other.mColor;
mBlenderPower = Other.mBlenderPower;
mBlenderRadius = Other.mBlenderRadius;
mBlenderAngle = Other.mBlenderAngle;
mPOVRayPower = Other.mPOVRayPower;
mPOVRayFadeDistance = Other.mPOVRayFadeDistance;
mPOVRayFadePower = Other.mPOVRayFadePower;
mSpotConeAngle = Other.mSpotConeAngle;
mSpotPenumbraAngle = Other.mSpotPenumbraAngle;
mPOVRaySpotTightness = Other.mPOVRaySpotTightness;
mAreaShape = Other.mAreaShape;
mAreaSizeX = Other.mAreaSizeX;
mAreaSizeY = Other.mAreaSizeY;
mPOVRayAreaGridX = Other.mPOVRayAreaGridX;
mPOVRayAreaGridY = Other.mPOVRayAreaGridY;
}
QString lcLight::GetLightTypeString(lcLightType LightType)
{
switch (LightType)
+2
View File
@@ -47,6 +47,8 @@ public:
static QString GetAreaShapeString(lcLightAreaShape LightAreaShape);
static QStringList GetAreaShapeStrings();
void CopyProperties(const lcLight& Other);
bool IsPointLight() const
{
return mLightType == lcLightType::Point;
+36 -10
View File
@@ -21,7 +21,7 @@ constexpr float LC_PIECE_CONTROL_POINT_SIZE = 10.0f;
lcPiece::lcPiece(PieceInfo* Info)
: lcObject(lcObjectType::Piece)
{
SetPieceInfo(Info, QString(), true);
SetPieceInfo(Info, QString(), true, true);
mColorIndex = gDefaultColor;
mColorCode = 16;
mStepShow = 1;
@@ -33,7 +33,7 @@ lcPiece::lcPiece(PieceInfo* Info)
lcPiece::lcPiece(const lcPiece& Other)
: lcObject(lcObjectType::Piece)
{
SetPieceInfo(Other.mPieceInfo, Other.mID, true);
SetPieceInfo(Other.mPieceInfo, Other.mID, true, true);
mHidden = Other.mHidden;
mSelected = Other.mSelected;
mColorIndex = Other.mColorIndex;
@@ -63,7 +63,29 @@ lcPiece::~lcPiece()
delete mMesh;
}
void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait)
void lcPiece::CopyProperties(const lcPiece& Other)
{
SetPieceInfo(Other.mPieceInfo, Other.mID, true, false);
mPosition = Other.mPosition;
mRotation = Other.mRotation;
mColorIndex = Other.mColorIndex;
mColorCode = Other.mColorCode;
mStepShow = Other.mStepShow;
mStepHide = Other.mStepHide;
mPivotPointValid = Other.mPivotPointValid;
mPivotMatrix = Other.mPivotMatrix;
mControlPoints = Other.mControlPoints;
mTrainTrackConnections = Other.mTrainTrackConnections;
UpdateMesh();
}
void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait, bool UpdateSynthInfo)
{
lcPiecesLibrary* Library = lcGetPiecesLibrary();
@@ -79,15 +101,19 @@ void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait)
mID.clear();
mControlPoints.clear();
delete mMesh;
mMesh = nullptr;
const lcSynthInfo* SynthInfo = mPieceInfo ? mPieceInfo->GetSynthInfo() : nullptr;
if (SynthInfo)
if (UpdateSynthInfo)
{
SynthInfo->GetDefaultControlPoints(mControlPoints);
UpdateMesh();
const lcSynthInfo* SynthInfo = mPieceInfo ? mPieceInfo->GetSynthInfo() : nullptr;
if (SynthInfo)
{
SynthInfo->GetDefaultControlPoints(mControlPoints);
UpdateMesh();
}
}
}
@@ -98,7 +124,7 @@ bool lcPiece::SetPieceId(PieceInfo* Info)
lcPiecesLibrary* Library = lcGetPiecesLibrary();
Library->ReleasePieceInfo(mPieceInfo);
SetPieceInfo(Info, QString(), true);
SetPieceInfo(Info, QString(), true, true);
return true;
}
@@ -313,7 +339,7 @@ bool lcPiece::FileLoad(lcFile& file)
strcat(name, ".dat");
PieceInfo* pInfo = lcGetPiecesLibrary()->FindPiece(name, nullptr, true, false);
SetPieceInfo(pInfo, QString(), true);
SetPieceInfo(pInfo, QString(), true, true);
// 11 (0.77)
if (version < 11)
+4 -2
View File
@@ -28,12 +28,14 @@ class lcPiece : public lcObject
public:
lcPiece(PieceInfo* Info);
lcPiece(const lcPiece& Other);
~lcPiece();
virtual ~lcPiece();
lcPiece(lcPiece&&) = delete;
lcPiece& operator=(const lcPiece&) = delete;
lcPiece& operator=(lcPiece&&) = delete;
void CopyProperties(const lcPiece& Other);
bool IsSelected() const override
{
return mSelected;
@@ -182,7 +184,7 @@ public:
void Initialize(const lcMatrix44& WorldMatrix, lcStep Step);
const lcBoundingBox& GetBoundingBox() const;
void CompareBoundingBox(lcVector3& Min, lcVector3& Max) const;
void SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait);
void SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait, bool UpdateSynthInfo);
bool SetPieceId(PieceInfo* Info);
bool FileLoad(lcFile& file);