mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
More project cleanup.
This commit is contained in:
parent
56b09b03b0
commit
6684abf96a
7 changed files with 168 additions and 174 deletions
|
@ -752,6 +752,71 @@ lcMatrix44 lcModel::GetRelativeRotation() const
|
||||||
return lcMatrix44Identity();
|
return lcMatrix44Identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lcModel::RemoveSelectedObjects()
|
||||||
|
{
|
||||||
|
bool RemovedPiece = false;
|
||||||
|
bool RemovedCamera = false;
|
||||||
|
bool RemovedLight = false;
|
||||||
|
|
||||||
|
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
||||||
|
{
|
||||||
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
|
if (Piece->IsSelected())
|
||||||
|
{
|
||||||
|
RemovedPiece = true;
|
||||||
|
mPieces.Remove(Piece);
|
||||||
|
delete Piece;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
PieceIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); )
|
||||||
|
{
|
||||||
|
lcCamera* Camera = mCameras[CameraIdx];
|
||||||
|
|
||||||
|
if (Camera->IsSelected())
|
||||||
|
{
|
||||||
|
const lcArray<View*> Views = gMainWindow->GetViews();
|
||||||
|
for (int ViewIdx = 0; ViewIdx < Views.GetSize(); ViewIdx++)
|
||||||
|
{
|
||||||
|
View* View = Views[ViewIdx];
|
||||||
|
|
||||||
|
if (Camera == View->mCamera)
|
||||||
|
View->SetCamera(Camera, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemovedCamera = true;
|
||||||
|
mCameras.RemoveIndex(CameraIdx);
|
||||||
|
delete Camera;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CameraIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RemovedCamera)
|
||||||
|
gMainWindow->UpdateCameraMenu();
|
||||||
|
|
||||||
|
for (int LightIdx = 0; LightIdx < mLights.GetSize(); )
|
||||||
|
{
|
||||||
|
lcLight* Light = mLights[LightIdx];
|
||||||
|
|
||||||
|
if (Light->IsSelected())
|
||||||
|
{
|
||||||
|
RemovedLight = true;
|
||||||
|
mLights.RemoveIndex(LightIdx);
|
||||||
|
delete Light;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LightIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveEmptyGroups();
|
||||||
|
|
||||||
|
return RemovedPiece || RemovedCamera || RemovedLight;
|
||||||
|
}
|
||||||
|
|
||||||
bool lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance)
|
bool lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance)
|
||||||
{
|
{
|
||||||
lcMatrix44 RelativeRotation = GetRelativeRotation();
|
lcMatrix44 RelativeRotation = GetRelativeRotation();
|
||||||
|
@ -911,6 +976,32 @@ bool lcModel::RotateSelectedPieces(const lcVector3& Angles)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lcModel::AnyPiecesSelected() const
|
||||||
|
{
|
||||||
|
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||||
|
if (mPieces[PieceIdx]->IsSelected())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lcModel::AnyObjectsSelected() const
|
||||||
|
{
|
||||||
|
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||||
|
if (mPieces[PieceIdx]->IsSelected())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||||
|
if (mCameras[CameraIdx]->IsSelected())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||||
|
if (mLights[LightIdx]->IsSelected())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
lcObject* lcModel::GetFocusObject() const
|
lcObject* lcModel::GetFocusObject() const
|
||||||
{
|
{
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||||
|
@ -940,6 +1031,34 @@ lcObject* lcModel::GetFocusObject() const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcVector3 lcModel::GetFocusOrSelectionCenter() const
|
||||||
|
{
|
||||||
|
lcVector3 Center;
|
||||||
|
|
||||||
|
if (GetFocusPosition(Center))
|
||||||
|
return Center;
|
||||||
|
|
||||||
|
GetSelectionCenter(Center);
|
||||||
|
|
||||||
|
return Center;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lcModel::GetFocusPosition(lcVector3& Position) const
|
||||||
|
{
|
||||||
|
lcObject* FocusObject = GetFocusObject();
|
||||||
|
|
||||||
|
if (FocusObject)
|
||||||
|
{
|
||||||
|
Position = FocusObject->GetSectionPosition(FocusObject->GetFocusSection());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Position = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool lcModel::GetSelectionCenter(lcVector3& Center) const
|
bool lcModel::GetSelectionCenter(lcVector3& Center) const
|
||||||
{
|
{
|
||||||
float Bounds[6] = { FLT_MAX, FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX };
|
float Bounds[6] = { FLT_MAX, FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX };
|
||||||
|
|
|
@ -146,6 +146,10 @@ public:
|
||||||
void RayTest(lcObjectRayTest& ObjectRayTest) const;
|
void RayTest(lcObjectRayTest& ObjectRayTest) const;
|
||||||
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
||||||
|
|
||||||
|
bool AnyPiecesSelected() const;
|
||||||
|
bool AnyObjectsSelected() const;
|
||||||
|
lcVector3 GetFocusOrSelectionCenter() const;
|
||||||
|
bool GetFocusPosition(lcVector3& Position) const;
|
||||||
lcObject* GetFocusObject() const;
|
lcObject* GetFocusObject() const;
|
||||||
bool GetSelectionCenter(lcVector3& Center) const;
|
bool GetSelectionCenter(lcVector3& Center) const;
|
||||||
void FocusOrDeselectObject(const lcObjectSection& ObjectSection);
|
void FocusOrDeselectObject(const lcObjectSection& ObjectSection);
|
||||||
|
@ -191,6 +195,7 @@ protected:
|
||||||
void LoadCheckPoint(lcModelHistoryEntry* CheckPoint);
|
void LoadCheckPoint(lcModelHistoryEntry* CheckPoint);
|
||||||
|
|
||||||
void RemoveEmptyGroups();
|
void RemoveEmptyGroups();
|
||||||
|
bool RemoveSelectedObjects();
|
||||||
bool MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance);
|
bool MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance);
|
||||||
bool RotateSelectedPieces(const lcVector3& Angles);
|
bool RotateSelectedPieces(const lcVector3& Angles);
|
||||||
void CalculateStep();
|
void CalculateStep();
|
||||||
|
|
|
@ -77,7 +77,6 @@ void PiecePreview::SetCurrentPiece(PieceInfo *pInfo)
|
||||||
if (m_PieceInfo != NULL)
|
if (m_PieceInfo != NULL)
|
||||||
{
|
{
|
||||||
m_PieceInfo->AddRef();
|
m_PieceInfo->AddRef();
|
||||||
lcGetActiveProject()->SetCurrentPiece(m_PieceInfo);
|
|
||||||
Redraw();
|
Redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
#include "lc_global.h"
|
#include "lc_global.h"
|
||||||
#include "lc_math.h"
|
#include "lc_math.h"
|
||||||
#include "lc_mesh.h"
|
#include "lc_mesh.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "pieceinf.h"
|
#include "pieceinf.h"
|
||||||
|
@ -1239,7 +1234,7 @@ void Project::RenderSceneObjects(View* view)
|
||||||
Context->SetWorldViewMatrix(lcMul(WorldMatrix, ViewMatrix));
|
Context->SetWorldViewMatrix(lcMul(WorldMatrix, ViewMatrix));
|
||||||
|
|
||||||
Context->SetLineWidth(2.0f * Preferences.mLineWidth);
|
Context->SetLineWidth(2.0f * Preferences.mLineWidth);
|
||||||
m_pCurPiece->RenderPiece(gMainWindow->mColorIndex);
|
gMainWindow->mPreviewWidget->GetCurrentPiece()->RenderPiece(gMainWindow->mColorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||||
|
@ -1287,17 +1282,18 @@ bool Project::GetPiecesBoundingBox(View* view, float BoundingBox[6])
|
||||||
lcVector3 Position;
|
lcVector3 Position;
|
||||||
lcVector4 Rotation;
|
lcVector4 Rotation;
|
||||||
GetPieceInsertPosition(view, Position, Rotation);
|
GetPieceInsertPosition(view, Position, Rotation);
|
||||||
|
PieceInfo* CurPiece = gMainWindow->mPreviewWidget->GetCurrentPiece();
|
||||||
|
|
||||||
lcVector3 Points[8] =
|
lcVector3 Points[8] =
|
||||||
{
|
{
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[5]),
|
lcVector3(CurPiece->m_fDimensions[0], CurPiece->m_fDimensions[1], CurPiece->m_fDimensions[5]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[5]),
|
lcVector3(CurPiece->m_fDimensions[3], CurPiece->m_fDimensions[1], CurPiece->m_fDimensions[5]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[2]),
|
lcVector3(CurPiece->m_fDimensions[0], CurPiece->m_fDimensions[1], CurPiece->m_fDimensions[2]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[5]),
|
lcVector3(CurPiece->m_fDimensions[3], CurPiece->m_fDimensions[4], CurPiece->m_fDimensions[5]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[2]),
|
lcVector3(CurPiece->m_fDimensions[3], CurPiece->m_fDimensions[4], CurPiece->m_fDimensions[2]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[2]),
|
lcVector3(CurPiece->m_fDimensions[0], CurPiece->m_fDimensions[4], CurPiece->m_fDimensions[2]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[5]),
|
lcVector3(CurPiece->m_fDimensions[0], CurPiece->m_fDimensions[4], CurPiece->m_fDimensions[5]),
|
||||||
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[2])
|
lcVector3(CurPiece->m_fDimensions[3], CurPiece->m_fDimensions[1], CurPiece->m_fDimensions[2])
|
||||||
};
|
};
|
||||||
|
|
||||||
lcMatrix44 ModelWorld = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR);
|
lcMatrix44 ModelWorld = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR);
|
||||||
|
@ -1319,71 +1315,6 @@ bool Project::GetPiecesBoundingBox(View* view, float BoundingBox[6])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::RemoveSelectedObjects()
|
|
||||||
{
|
|
||||||
bool RemovedPiece = false;
|
|
||||||
bool RemovedCamera = false;
|
|
||||||
bool RemovedLight = false;
|
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); )
|
|
||||||
{
|
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
|
||||||
|
|
||||||
if (Piece->IsSelected())
|
|
||||||
{
|
|
||||||
RemovedPiece = true;
|
|
||||||
mPieces.Remove(Piece);
|
|
||||||
delete Piece;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
PieceIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); )
|
|
||||||
{
|
|
||||||
lcCamera* Camera = mCameras[CameraIdx];
|
|
||||||
|
|
||||||
if (Camera->IsSelected())
|
|
||||||
{
|
|
||||||
const lcArray<View*> Views = gMainWindow->GetViews();
|
|
||||||
for (int ViewIdx = 0; ViewIdx < Views.GetSize(); ViewIdx++)
|
|
||||||
{
|
|
||||||
View* View = Views[ViewIdx];
|
|
||||||
|
|
||||||
if (Camera == View->mCamera)
|
|
||||||
View->SetCamera(Camera, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
RemovedCamera = true;
|
|
||||||
mCameras.RemoveIndex(CameraIdx);
|
|
||||||
delete Camera;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
CameraIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RemovedCamera)
|
|
||||||
gMainWindow->UpdateCameraMenu();
|
|
||||||
|
|
||||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); )
|
|
||||||
{
|
|
||||||
lcLight* Light = mLights[LightIdx];
|
|
||||||
|
|
||||||
if (Light->IsSelected())
|
|
||||||
{
|
|
||||||
RemovedLight = true;
|
|
||||||
mLights.RemoveIndex(LightIdx);
|
|
||||||
delete Light;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
LightIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveEmptyGroups();
|
|
||||||
|
|
||||||
return RemovedPiece || RemovedCamera || RemovedLight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::ZoomExtents(int FirstView, int LastView)
|
void Project::ZoomExtents(int FirstView, int LastView)
|
||||||
{
|
{
|
||||||
if (mPieces.IsEmpty())
|
if (mPieces.IsEmpty())
|
||||||
|
@ -2378,14 +2309,12 @@ void Project::HandleCommand(LC_COMMANDS id)
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case LC_FILE_SAVE:
|
case LC_FILE_SAVE:
|
||||||
{
|
|
||||||
DoSave(m_strPathName);
|
DoSave(m_strPathName);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
case LC_FILE_SAVEAS:
|
case LC_FILE_SAVEAS:
|
||||||
{
|
|
||||||
DoSave(NULL);
|
DoSave(NULL);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
case LC_FILE_SAVE_IMAGE:
|
case LC_FILE_SAVE_IMAGE:
|
||||||
{
|
{
|
||||||
|
@ -3466,10 +3395,13 @@ void Project::HandleCommand(LC_COMMANDS id)
|
||||||
|
|
||||||
case LC_PIECE_INSERT:
|
case LC_PIECE_INSERT:
|
||||||
{
|
{
|
||||||
if (m_pCurPiece == NULL)
|
PieceInfo* CurPiece = gMainWindow->mPreviewWidget->GetCurrentPiece();
|
||||||
|
|
||||||
|
if (!CurPiece)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
lcPiece* Last = mPieces.IsEmpty() ? NULL : mPieces[mPieces.GetSize() - 1];
|
lcPiece* Last = mPieces.IsEmpty() ? NULL : mPieces[mPieces.GetSize() - 1];
|
||||||
lcPiece* pPiece = new lcPiece(m_pCurPiece);
|
lcPiece* pPiece = new lcPiece(CurPiece);
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||||
{
|
{
|
||||||
|
@ -4550,58 +4482,11 @@ lcGroup* Project::AddGroup(lcGroup* Parent)
|
||||||
return NewGroup;
|
return NewGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcVector3 Project::GetFocusOrSelectionCenter() const
|
|
||||||
{
|
|
||||||
lcVector3 Center;
|
|
||||||
|
|
||||||
if (GetFocusPosition(Center))
|
|
||||||
return Center;
|
|
||||||
|
|
||||||
GetSelectionCenter(Center);
|
|
||||||
|
|
||||||
return Center;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Project::GetFocusPosition(lcVector3& Position) const
|
|
||||||
{
|
|
||||||
lcObject* FocusObject = GetFocusObject();
|
|
||||||
|
|
||||||
if (FocusObject)
|
|
||||||
{
|
|
||||||
Position = FocusObject->GetSectionPosition(FocusObject->GetFocusSection());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Position = lcVector3(0.0f, 0.0f, 0.0f);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Project::AnyObjectsSelected(bool PiecesOnly) const
|
|
||||||
{
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
|
||||||
if (mPieces[PieceIdx]->IsSelected())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!PiecesOnly)
|
|
||||||
{
|
|
||||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
|
||||||
if (mCameras[CameraIdx]->IsSelected())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
|
||||||
if (mLights[LightIdx]->IsSelected())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a good starting position/orientation relative to an existing piece.
|
// Find a good starting position/orientation relative to an existing piece.
|
||||||
void Project::GetPieceInsertPosition(lcPiece* OffsetPiece, lcVector3& Position, lcVector4& Rotation)
|
void Project::GetPieceInsertPosition(lcPiece* OffsetPiece, lcVector3& Position, lcVector4& Rotation)
|
||||||
{
|
{
|
||||||
lcVector3 Dist(0, 0, OffsetPiece->mPieceInfo->m_fDimensions[2] - m_pCurPiece->m_fDimensions[5]);
|
PieceInfo* CurPiece = gMainWindow->mPreviewWidget->GetCurrentPiece();
|
||||||
|
lcVector3 Dist(0, 0, OffsetPiece->mPieceInfo->m_fDimensions[2] - CurPiece->m_fDimensions[5]);
|
||||||
Dist = SnapPosition(Dist);
|
Dist = SnapPosition(Dist);
|
||||||
|
|
||||||
Position = lcMul31(Dist, OffsetPiece->mModelWorld);
|
Position = lcMul31(Dist, OffsetPiece->mModelWorld);
|
||||||
|
@ -4624,8 +4509,10 @@ void Project::GetPieceInsertPosition(View* view, lcVector3& Position, lcVector4&
|
||||||
lcVector3 ClickPoints[2] = { lcVector3((float)view->mInputState.x, (float)view->mInputState.y, 0.0f), lcVector3((float)view->mInputState.x, (float)view->mInputState.y, 1.0f) };
|
lcVector3 ClickPoints[2] = { lcVector3((float)view->mInputState.x, (float)view->mInputState.y, 0.0f), lcVector3((float)view->mInputState.x, (float)view->mInputState.y, 1.0f) };
|
||||||
view->UnprojectPoints(ClickPoints, 2);
|
view->UnprojectPoints(ClickPoints, 2);
|
||||||
|
|
||||||
|
PieceInfo* CurPiece = gMainWindow->mPreviewWidget->GetCurrentPiece();
|
||||||
lcVector3 Intersection;
|
lcVector3 Intersection;
|
||||||
if (lcLinePlaneIntersection(&Intersection, ClickPoints[0], ClickPoints[1], lcVector4(0, 0, 1, m_pCurPiece->m_fDimensions[5])))
|
|
||||||
|
if (lcLinePlaneIntersection(&Intersection, ClickPoints[0], ClickPoints[1], lcVector4(0, 0, 1, CurPiece->m_fDimensions[5])))
|
||||||
{
|
{
|
||||||
Intersection = SnapPosition(Intersection);
|
Intersection = SnapPosition(Intersection);
|
||||||
Position = Intersection;
|
Position = Intersection;
|
||||||
|
|
|
@ -70,23 +70,20 @@ enum lcObjectProperty
|
||||||
|
|
||||||
class Project : public lcModel
|
class Project : public lcModel
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Project)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Project();
|
Project();
|
||||||
~Project();
|
~Project();
|
||||||
|
|
||||||
public:
|
|
||||||
void SetCurrentStep(lcStep Step)
|
void SetCurrentStep(lcStep Step)
|
||||||
{
|
{
|
||||||
mCurrentStep = Step;
|
mCurrentStep = Step;
|
||||||
CalculateStep();
|
CalculateStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCurrentPiece(PieceInfo* pInfo)
|
|
||||||
{ m_pCurPiece = pInfo; }
|
|
||||||
float* GetBackgroundColor() // todo: remove
|
float* GetBackgroundColor() // todo: remove
|
||||||
{ return mProperties.mBackgroundSolidColor; }
|
{
|
||||||
|
return mProperties.mBackgroundSolidColor;
|
||||||
|
}
|
||||||
|
|
||||||
int GetGroupIndex(lcGroup* Group) const
|
int GetGroupIndex(lcGroup* Group) const
|
||||||
{
|
{
|
||||||
|
@ -99,30 +96,20 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LoadDefaults();
|
void LoadDefaults();
|
||||||
|
|
||||||
bool GetPiecesBoundingBox(View* view, float BoundingBox[6]);
|
bool GetPiecesBoundingBox(View* view, float BoundingBox[6]);
|
||||||
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
||||||
void CreateImages(Image* images, int width, int height, lcStep from, lcStep to, bool hilite);
|
void CreateImages(Image* images, int width, int height, lcStep from, lcStep to, bool hilite);
|
||||||
void Render(View* view, bool bToMemory);
|
void Render(View* view, bool bToMemory);
|
||||||
lcVector3 GetFocusOrSelectionCenter() const;
|
|
||||||
bool GetFocusPosition(lcVector3& Position) const;
|
|
||||||
bool AnyObjectsSelected(bool PiecesOnly) const;
|
|
||||||
lcGroup* AddGroup(lcGroup* Parent);
|
lcGroup* AddGroup(lcGroup* Parent);
|
||||||
void TransformSelectedObjects(lcTransformType Type, const lcVector3& Transform);
|
void TransformSelectedObjects(lcTransformType Type, const lcVector3& Transform);
|
||||||
void ModifyObject(lcObject* Object, lcObjectProperty Property, void* Value);
|
void ModifyObject(lcObject* Object, lcObjectProperty Property, void* Value);
|
||||||
void ZoomActiveView(int Amount);
|
void ZoomActiveView(int Amount);
|
||||||
|
|
||||||
char m_strTitle[LC_MAXPATH];
|
|
||||||
char m_strPathName[LC_MAXPATH];
|
|
||||||
|
|
||||||
void GetPieceInsertPosition(View* view, lcVector3& Position, lcVector4& Orientation);
|
void GetPieceInsertPosition(View* view, lcVector3& Position, lcVector4& Orientation);
|
||||||
|
|
||||||
void HandleCommand(LC_COMMANDS id);
|
void HandleCommand(LC_COMMANDS id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CheckPoint(const char* Description);
|
void CheckPoint(const char* Description);
|
||||||
|
|
||||||
bool RemoveSelectedObjects();
|
|
||||||
void GetPieceInsertPosition(lcPiece* OffsetPiece, lcVector3& Position, lcVector4& Rotation);
|
void GetPieceInsertPosition(lcPiece* OffsetPiece, lcVector3& Position, lcVector4& Rotation);
|
||||||
|
|
||||||
static int InstanceOfName(const String& existingString, const String& candidateString, String& baseNameOut);
|
static int InstanceOfName(const String& existingString, const String& candidateString, String& baseNameOut);
|
||||||
|
@ -136,15 +123,14 @@ protected:
|
||||||
void ExportPOVRay(lcFile& File);
|
void ExportPOVRay(lcFile& File);
|
||||||
void ZoomExtents(int FirstView, int LastView);
|
void ZoomExtents(int FirstView, int LastView);
|
||||||
|
|
||||||
protected:
|
|
||||||
PieceInfo* m_pCurPiece;
|
|
||||||
// lcuint16 m_nMoveSnap;
|
|
||||||
|
|
||||||
bool DoSave(const char* FileName);
|
bool DoSave(const char* FileName);
|
||||||
bool FileLoad(lcFile* file, bool bUndo, bool bMerge);
|
bool FileLoad(lcFile* file, bool bUndo, bool bMerge);
|
||||||
void FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, lcArray<LC_FILEENTRY*>& FileArray);
|
void FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, lcArray<LC_FILEENTRY*>& FileArray);
|
||||||
void FileReadMPD(lcFile& MPD, lcArray<LC_FILEENTRY*>& FileArray) const;
|
void FileReadMPD(lcFile& MPD, lcArray<LC_FILEENTRY*>& FileArray) const;
|
||||||
|
|
||||||
|
char m_strTitle[LC_MAXPATH];
|
||||||
|
char m_strPathName[LC_MAXPATH];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool OnNewDocument();
|
bool OnNewDocument();
|
||||||
bool OnOpenDocument(const char* FileName);
|
bool OnOpenDocument(const char* FileName);
|
||||||
|
|
|
@ -224,11 +224,11 @@ void View::OnDraw()
|
||||||
|
|
||||||
lcTool Tool = gMainWindow->GetTool();
|
lcTool Tool = gMainWindow->GetTool();
|
||||||
|
|
||||||
if ((Tool == LC_TOOL_SELECT || Tool == LC_TOOL_MOVE) && mTrackButton == LC_TRACKBUTTON_NONE && mProject->AnyObjectsSelected(false))
|
if ((Tool == LC_TOOL_SELECT || Tool == LC_TOOL_MOVE) && mTrackButton == LC_TRACKBUTTON_NONE && mProject->AnyObjectsSelected())
|
||||||
DrawSelectMoveOverlay();
|
DrawSelectMoveOverlay();
|
||||||
else if (GetCurrentTool() == LC_TOOL_MOVE && mTrackButton != LC_TRACKBUTTON_NONE)
|
else if (GetCurrentTool() == LC_TOOL_MOVE && mTrackButton != LC_TRACKBUTTON_NONE)
|
||||||
DrawSelectMoveOverlay();
|
DrawSelectMoveOverlay();
|
||||||
else if ((Tool == LC_TOOL_ROTATE || (Tool == LC_TOOL_SELECT && mTrackButton != LC_TRACKBUTTON_NONE && mTrackTool >= LC_TRACKTOOL_ROTATE_X && mTrackTool <= LC_TRACKTOOL_ROTATE_XYZ)) && mProject->AnyObjectsSelected(true))
|
else if ((Tool == LC_TOOL_ROTATE || (Tool == LC_TOOL_SELECT && mTrackButton != LC_TRACKBUTTON_NONE && mTrackTool >= LC_TRACKTOOL_ROTATE_X && mTrackTool <= LC_TRACKTOOL_ROTATE_XYZ)) && mProject->AnyPiecesSelected())
|
||||||
DrawRotateOverlay();
|
DrawRotateOverlay();
|
||||||
else if ((mTrackTool == LC_TRACKTOOL_SELECT || mTrackTool == LC_TRACKTOOL_ZOOM_REGION) && mTrackButton == LC_TRACKBUTTON_LEFT)
|
else if ((mTrackTool == LC_TRACKTOOL_SELECT || mTrackTool == LC_TRACKTOOL_ZOOM_REGION) && mTrackButton == LC_TRACKBUTTON_LEFT)
|
||||||
DrawSelectZoomRegionOverlay();
|
DrawSelectZoomRegionOverlay();
|
||||||
|
@ -259,7 +259,7 @@ void View::DrawSelectMoveOverlay()
|
||||||
|
|
||||||
lcMatrix44 RelativeRotation = mProject->GetRelativeRotation();
|
lcMatrix44 RelativeRotation = mProject->GetRelativeRotation();
|
||||||
lcVector3 OverlayCenter = mProject->GetFocusOrSelectionCenter();
|
lcVector3 OverlayCenter = mProject->GetFocusOrSelectionCenter();
|
||||||
bool AnyPiecesSelected = mProject->AnyObjectsSelected(true);
|
bool AnyPiecesSelected = mProject->AnyPiecesSelected();
|
||||||
|
|
||||||
// Draw the arrows.
|
// Draw the arrows.
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
|
@ -1746,7 +1746,7 @@ void View::OnLeftButtonDown()
|
||||||
case LC_TRACKTOOL_MOVE_XZ:
|
case LC_TRACKTOOL_MOVE_XZ:
|
||||||
case LC_TRACKTOOL_MOVE_YZ:
|
case LC_TRACKTOOL_MOVE_YZ:
|
||||||
case LC_TRACKTOOL_MOVE_XYZ:
|
case LC_TRACKTOOL_MOVE_XYZ:
|
||||||
if (mProject->AnyObjectsSelected(false))
|
if (mProject->AnyObjectsSelected())
|
||||||
StartTracking(LC_TRACKBUTTON_LEFT);
|
StartTracking(LC_TRACKBUTTON_LEFT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1755,7 +1755,7 @@ void View::OnLeftButtonDown()
|
||||||
case LC_TRACKTOOL_ROTATE_Z:
|
case LC_TRACKTOOL_ROTATE_Z:
|
||||||
case LC_TRACKTOOL_ROTATE_XY:
|
case LC_TRACKTOOL_ROTATE_XY:
|
||||||
case LC_TRACKTOOL_ROTATE_XYZ:
|
case LC_TRACKTOOL_ROTATE_XYZ:
|
||||||
if (mProject->AnyObjectsSelected(true))
|
if (mProject->AnyPiecesSelected())
|
||||||
StartTracking(LC_TRACKBUTTON_LEFT);
|
StartTracking(LC_TRACKBUTTON_LEFT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1856,7 +1856,7 @@ void View::OnRightButtonDown()
|
||||||
case LC_TRACKTOOL_MOVE_XZ:
|
case LC_TRACKTOOL_MOVE_XZ:
|
||||||
case LC_TRACKTOOL_MOVE_YZ:
|
case LC_TRACKTOOL_MOVE_YZ:
|
||||||
case LC_TRACKTOOL_MOVE_XYZ:
|
case LC_TRACKTOOL_MOVE_XYZ:
|
||||||
if (mProject->AnyObjectsSelected(false))
|
if (mProject->AnyObjectsSelected())
|
||||||
StartTracking(LC_TRACKBUTTON_RIGHT);
|
StartTracking(LC_TRACKBUTTON_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1865,7 +1865,7 @@ void View::OnRightButtonDown()
|
||||||
case LC_TRACKTOOL_ROTATE_Z:
|
case LC_TRACKTOOL_ROTATE_Z:
|
||||||
case LC_TRACKTOOL_ROTATE_XY:
|
case LC_TRACKTOOL_ROTATE_XY:
|
||||||
case LC_TRACKTOOL_ROTATE_XYZ:
|
case LC_TRACKTOOL_ROTATE_XYZ:
|
||||||
if (mProject->AnyObjectsSelected(true))
|
if (mProject->AnyPiecesSelected())
|
||||||
StartTracking(LC_TRACKBUTTON_RIGHT);
|
StartTracking(LC_TRACKBUTTON_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,6 @@ lcQMainWindow::lcQMainWindow(QWidget *parent)
|
||||||
|
|
||||||
if (Info)
|
if (Info)
|
||||||
{
|
{
|
||||||
lcGetActiveProject()->SetCurrentPiece(Info);
|
|
||||||
PiecePreview* Preview = (PiecePreview*)piecePreview->widget;
|
PiecePreview* Preview = (PiecePreview*)piecePreview->widget;
|
||||||
gMainWindow->mPreviewWidget = Preview;
|
gMainWindow->mPreviewWidget = Preview;
|
||||||
Preview->SetCurrentPiece(Info);
|
Preview->SetCurrentPiece(Info);
|
||||||
|
@ -594,7 +593,6 @@ void lcQMainWindow::partsTreeItemChanged(QTreeWidgetItem *current, QTreeWidgetIt
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
{
|
{
|
||||||
lcGetActiveProject()->SetCurrentPiece(info);
|
|
||||||
PiecePreview* preview = (PiecePreview*)piecePreview->widget;
|
PiecePreview* preview = (PiecePreview*)piecePreview->widget;
|
||||||
preview->SetCurrentPiece(info);
|
preview->SetCurrentPiece(info);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue