mirror of
https://github.com/leozide/leocad
synced 2025-02-06 08:46:06 +01:00
Fixed piece drag from list.
This commit is contained in:
parent
d4c3cf8ebe
commit
7d2d338398
9 changed files with 124 additions and 152 deletions
|
@ -78,7 +78,27 @@ public:
|
||||||
lcModel();
|
lcModel();
|
||||||
~lcModel();
|
~lcModel();
|
||||||
|
|
||||||
public:
|
const lcArray<lcPiece*>& GetPieces() const
|
||||||
|
{
|
||||||
|
return mPieces;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lcArray<lcCamera*>& GetCameras() const
|
||||||
|
{
|
||||||
|
return mCameras;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lcArray<lcLight*>& GetLights() const
|
||||||
|
{
|
||||||
|
return mLights;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lcArray<lcGroup*>& GetGroups() const
|
||||||
|
{
|
||||||
|
return mGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
lcModelProperties mProperties;
|
lcModelProperties mProperties;
|
||||||
|
|
||||||
lcArray<lcPiece*> mPieces;
|
lcArray<lcPiece*> mPieces;
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
Project::Project()
|
Project::Project()
|
||||||
{
|
{
|
||||||
m_bModified = false;
|
m_bModified = false;
|
||||||
m_nTracking = LC_TRACK_NONE;
|
|
||||||
mDropPiece = NULL;
|
|
||||||
m_pUndoList = NULL;
|
m_pUndoList = NULL;
|
||||||
m_pRedoList = NULL;
|
m_pRedoList = NULL;
|
||||||
mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION;
|
mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION;
|
||||||
|
@ -1642,13 +1640,11 @@ void Project::RenderSceneObjects(View* view)
|
||||||
RenderDebugPrimitives();
|
RenderDebugPrimitives();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Draw cameras & lights
|
if (view->mTrackTool == LC_TRACKTOOL_INSERT)
|
||||||
if (gMainWindow->GetTool() == LC_TOOL_INSERT || mDropPiece)
|
|
||||||
{
|
{
|
||||||
lcVector3 Position;
|
lcVector3 Position;
|
||||||
lcVector4 Rotation;
|
lcVector4 Rotation;
|
||||||
GetPieceInsertPosition(view, Position, Rotation);
|
GetPieceInsertPosition(view, Position, Rotation);
|
||||||
PieceInfo* PreviewPiece = mDropPiece ? mDropPiece : m_pCurPiece;
|
|
||||||
|
|
||||||
lcMatrix44 WorldMatrix = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR);
|
lcMatrix44 WorldMatrix = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR);
|
||||||
WorldMatrix.SetTranslation(Position);
|
WorldMatrix.SetTranslation(Position);
|
||||||
|
@ -1656,11 +1652,11 @@ 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);
|
||||||
PreviewPiece->RenderPiece(gMainWindow->mColorIndex);
|
m_pCurPiece->RenderPiece(gMainWindow->mColorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||||
glDisable (GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); CameraIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1685,7 +1681,7 @@ void Project::RenderSceneObjects(View* view)
|
||||||
const int Spacing = lcMax(Preferences.mGridLineSpacing, 1);
|
const int Spacing = lcMax(Preferences.mGridLineSpacing, 1);
|
||||||
int MinX = 0, MaxX = 0, MinY = 0, MaxY = 0;
|
int MinX = 0, MaxX = 0, MinY = 0, MaxY = 0;
|
||||||
|
|
||||||
if (!mPieces.IsEmpty() || (gMainWindow->GetTool() == LC_TOOL_INSERT || mDropPiece))
|
if (!mPieces.IsEmpty() || view->mTrackTool == LC_TRACKTOOL_INSERT)
|
||||||
{
|
{
|
||||||
float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 };
|
float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 };
|
||||||
|
|
||||||
|
@ -1697,24 +1693,22 @@ void Project::RenderSceneObjects(View* view)
|
||||||
Piece->CompareBoundingBox(bs);
|
Piece->CompareBoundingBox(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gMainWindow->GetTool() == LC_TOOL_INSERT || mDropPiece)
|
if (view->mTrackTool == LC_TRACKTOOL_INSERT)
|
||||||
{
|
{
|
||||||
lcVector3 Position;
|
lcVector3 Position;
|
||||||
lcVector4 Rotation;
|
lcVector4 Rotation;
|
||||||
GetPieceInsertPosition(view, Position, Rotation);
|
GetPieceInsertPosition(view, Position, Rotation);
|
||||||
|
|
||||||
PieceInfo* PreviewPiece = mDropPiece ? mDropPiece : m_pCurPiece;
|
|
||||||
|
|
||||||
lcVector3 Points[8] =
|
lcVector3 Points[8] =
|
||||||
{
|
{
|
||||||
lcVector3(PreviewPiece->m_fDimensions[0],PreviewPiece->m_fDimensions[1], PreviewPiece->m_fDimensions[5]),
|
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[5]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[3],PreviewPiece->m_fDimensions[1], PreviewPiece->m_fDimensions[5]),
|
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[5]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[0],PreviewPiece->m_fDimensions[1], PreviewPiece->m_fDimensions[2]),
|
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[1], m_pCurPiece->m_fDimensions[2]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[3],PreviewPiece->m_fDimensions[4], PreviewPiece->m_fDimensions[5]),
|
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[5]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[3],PreviewPiece->m_fDimensions[4], PreviewPiece->m_fDimensions[2]),
|
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[2]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[0],PreviewPiece->m_fDimensions[4], PreviewPiece->m_fDimensions[2]),
|
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[2]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[0],PreviewPiece->m_fDimensions[4], PreviewPiece->m_fDimensions[5]),
|
lcVector3(m_pCurPiece->m_fDimensions[0], m_pCurPiece->m_fDimensions[4], m_pCurPiece->m_fDimensions[5]),
|
||||||
lcVector3(PreviewPiece->m_fDimensions[3],PreviewPiece->m_fDimensions[1], PreviewPiece->m_fDimensions[2])
|
lcVector3(m_pCurPiece->m_fDimensions[3], m_pCurPiece->m_fDimensions[1], m_pCurPiece->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);
|
||||||
|
@ -5651,8 +5645,9 @@ void Project::HandleCommand(LC_COMMANDS id)
|
||||||
|
|
||||||
case LC_EDIT_CANCEL:
|
case LC_EDIT_CANCEL:
|
||||||
{
|
{
|
||||||
if (m_nTracking != LC_TRACK_NONE)
|
View* ActiveView = gMainWindow->GetActiveView();
|
||||||
StopTracking(false);
|
if (ActiveView && ActiveView->mTrackButton != LC_TRACKBUTTON_NONE)
|
||||||
|
ActiveView->StopTracking(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SelectAndFocusNone(false);
|
SelectAndFocusNone(false);
|
||||||
|
@ -6061,64 +6056,6 @@ void Project::BoxTest(lcObjectBoxTest& ObjectBoxTest) const
|
||||||
mLights[LightIdx]->BoxTest(ObjectBoxTest);
|
mLights[LightIdx]->BoxTest(ObjectBoxTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::StopTracking(bool bAccept)
|
|
||||||
{
|
|
||||||
if (m_nTracking == LC_TRACK_NONE)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
View* ActiveView = gMainWindow->GetActiveView();
|
|
||||||
|
|
||||||
m_nTracking = LC_TRACK_NONE;
|
|
||||||
|
|
||||||
if (bAccept && mDropPiece)
|
|
||||||
{
|
|
||||||
int x = m_nDownX;
|
|
||||||
int y = m_nDownY;
|
|
||||||
|
|
||||||
if ((x > 0) && (x < ActiveView->mWidth) && (y > 0) && (y < ActiveView->mHeight))
|
|
||||||
{
|
|
||||||
lcVector3 Pos;
|
|
||||||
lcVector4 Rot;
|
|
||||||
|
|
||||||
GetPieceInsertPosition(ActiveView, Pos, Rot);
|
|
||||||
|
|
||||||
Piece* pPiece = new Piece(mDropPiece);
|
|
||||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep);
|
|
||||||
pPiece->SetColorIndex(gMainWindow->mColorIndex);
|
|
||||||
|
|
||||||
pPiece->ChangeKey(m_nCurStep, false, Rot, LC_PK_ROTATION);
|
|
||||||
pPiece->UpdatePosition(m_nCurStep);
|
|
||||||
|
|
||||||
pPiece->CreateName(mPieces);
|
|
||||||
mPieces.Add(pPiece);
|
|
||||||
SystemPieceComboAdd(mDropPiece->m_strDescription);
|
|
||||||
ClearSelectionAndSetFocus(pPiece, LC_PIECE_SECTION_POSITION);
|
|
||||||
|
|
||||||
if (mDropPiece)
|
|
||||||
{
|
|
||||||
mDropPiece->Release();
|
|
||||||
mDropPiece = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetModifiedFlag(true);
|
|
||||||
CheckPoint("Inserting");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mDropPiece)
|
|
||||||
{
|
|
||||||
mDropPiece->Release();
|
|
||||||
mDropPiece = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::StartTracking(int mode)
|
|
||||||
{
|
|
||||||
m_nTracking = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::GetSnapIndex(int* SnapXY, int* SnapZ, int* SnapAngle) const
|
void Project::GetSnapIndex(int* SnapXY, int* SnapZ, int* SnapAngle) const
|
||||||
{
|
{
|
||||||
if (SnapXY)
|
if (SnapXY)
|
||||||
|
@ -6890,42 +6827,6 @@ void Project::ZoomActiveView(int Amount)
|
||||||
gMainWindow->UpdateAllViews();
|
gMainWindow->UpdateAllViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::BeginPieceDrop(PieceInfo* Info)
|
|
||||||
{
|
|
||||||
StartTracking(LC_TRACK_LEFT);
|
|
||||||
|
|
||||||
mDropPiece = Info;
|
|
||||||
mDropPiece->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::OnPieceDropMove(int x, int y)
|
|
||||||
{
|
|
||||||
if (!mDropPiece)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_nDownX != x || m_nDownY != y)
|
|
||||||
{
|
|
||||||
m_nDownX = x;
|
|
||||||
m_nDownY = y;
|
|
||||||
|
|
||||||
gMainWindow->UpdateAllViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::EndPieceDrop(bool Accept)
|
|
||||||
{
|
|
||||||
StopTracking(Accept);
|
|
||||||
|
|
||||||
if (!Accept)
|
|
||||||
gMainWindow->UpdateAllViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::BeginColorDrop()
|
|
||||||
{
|
|
||||||
StartTracking(LC_TRACK_LEFT);
|
|
||||||
gMainWindow->SetTool(LC_TOOL_PAINT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::BeginMouseTool()
|
void Project::BeginMouseTool()
|
||||||
{
|
{
|
||||||
mMouseToolDistance = lcVector3(0.0f, 0.0f, 0.0f);
|
mMouseToolDistance = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
|
@ -210,10 +210,6 @@ public:
|
||||||
public:
|
public:
|
||||||
void DeleteContents(bool bUndo);
|
void DeleteContents(bool bUndo);
|
||||||
void LoadDefaults(bool cameras);
|
void LoadDefaults(bool cameras);
|
||||||
void BeginPieceDrop(PieceInfo* Info);
|
|
||||||
void OnPieceDropMove(int x, int y);
|
|
||||||
void EndPieceDrop(bool Accept);
|
|
||||||
void BeginColorDrop();
|
|
||||||
void RenderInitialize();
|
void RenderInitialize();
|
||||||
|
|
||||||
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
||||||
|
@ -280,12 +276,6 @@ protected:
|
||||||
void ExportPOVRay(lcFile& File);
|
void ExportPOVRay(lcFile& File);
|
||||||
void ZoomExtents(int FirstView, int LastView);
|
void ZoomExtents(int FirstView, int LastView);
|
||||||
|
|
||||||
int m_nTracking;
|
|
||||||
int m_nDownX;
|
|
||||||
int m_nDownY;
|
|
||||||
|
|
||||||
bool StopTracking(bool bAccept);
|
|
||||||
void StartTracking(int mode);
|
|
||||||
void UpdateSelection();
|
void UpdateSelection();
|
||||||
void RemoveEmptyGroups();
|
void RemoveEmptyGroups();
|
||||||
|
|
||||||
|
@ -299,7 +289,6 @@ protected:
|
||||||
// State variables
|
// State variables
|
||||||
int mTransformType;
|
int mTransformType;
|
||||||
PieceInfo* m_pCurPiece;
|
PieceInfo* m_pCurPiece;
|
||||||
PieceInfo* mDropPiece;
|
|
||||||
unsigned char m_nCurStep;
|
unsigned char m_nCurStep;
|
||||||
|
|
||||||
lcuint16 m_nMoveSnap;
|
lcuint16 m_nMoveSnap;
|
||||||
|
|
|
@ -13,6 +13,7 @@ View::View(Project *project)
|
||||||
mProject = project;
|
mProject = project;
|
||||||
mCamera = NULL;
|
mCamera = NULL;
|
||||||
|
|
||||||
|
mDragState = LC_DRAGSTATE_NONE;
|
||||||
mTrackButton = LC_TRACKBUTTON_NONE;
|
mTrackButton = LC_TRACKBUTTON_NONE;
|
||||||
mTrackTool = LC_TRACKTOOL_NONE;
|
mTrackTool = LC_TRACKTOOL_NONE;
|
||||||
|
|
||||||
|
@ -922,6 +923,26 @@ float View::GetOverlayScale() const
|
||||||
return Dist.Length() * 5.0f;
|
return Dist.Length() * 5.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::BeginPieceDrag()
|
||||||
|
{
|
||||||
|
mDragState = LC_DRAGSTATE_PIECE;
|
||||||
|
UpdateTrackTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::EndPieceDrag(bool Accept)
|
||||||
|
{
|
||||||
|
if (Accept)
|
||||||
|
{
|
||||||
|
lcVector3 Position;
|
||||||
|
lcVector4 Rotation;
|
||||||
|
mProject->GetPieceInsertPosition(this, Position, Rotation);
|
||||||
|
mProject->InsertPieceToolClicked(Position, Rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
mDragState = LC_DRAGSTATE_NONE;
|
||||||
|
UpdateTrackTool();
|
||||||
|
}
|
||||||
|
|
||||||
void View::UpdateTrackTool()
|
void View::UpdateTrackTool()
|
||||||
{
|
{
|
||||||
lcTool CurrentTool = gMainWindow->GetTool();
|
lcTool CurrentTool = gMainWindow->GetTool();
|
||||||
|
@ -1240,6 +1261,17 @@ void View::UpdateTrackTool()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (mDragState)
|
||||||
|
{
|
||||||
|
case LC_DRAGSTATE_NONE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_DRAGSTATE_PIECE:
|
||||||
|
NewTrackTool = LC_TRACKTOOL_INSERT;
|
||||||
|
Redraw = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (NewTrackTool != mTrackTool)
|
if (NewTrackTool != mTrackTool)
|
||||||
{
|
{
|
||||||
mTrackTool = NewTrackTool;
|
mTrackTool = NewTrackTool;
|
||||||
|
@ -1641,6 +1673,8 @@ void View::OnMouseMove()
|
||||||
{
|
{
|
||||||
if (mTrackButton == LC_TRACKBUTTON_NONE)
|
if (mTrackButton == LC_TRACKBUTTON_NONE)
|
||||||
{
|
{
|
||||||
|
UpdateTrackTool();
|
||||||
|
|
||||||
if (mTrackTool == LC_TRACKTOOL_INSERT)
|
if (mTrackTool == LC_TRACKTOOL_INSERT)
|
||||||
{
|
{
|
||||||
/* lcVector3 Position;
|
/* lcVector3 Position;
|
||||||
|
@ -1650,11 +1684,8 @@ void View::OnMouseMove()
|
||||||
mProject->mActiveModel->SetPreviewTransform(Position, AxisAngle);
|
mProject->mActiveModel->SetPreviewTransform(Position, AxisAngle);
|
||||||
|
|
||||||
*/ gMainWindow->UpdateAllViews();
|
*/ gMainWindow->UpdateAllViews();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTrackTool();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,13 @@ enum lcTrackTool
|
||||||
LC_TRACKTOOL_ZOOM_REGION
|
LC_TRACKTOOL_ZOOM_REGION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum lcDragState
|
||||||
|
{
|
||||||
|
LC_DRAGSTATE_NONE,
|
||||||
|
LC_DRAGSTATE_PIECE
|
||||||
|
// LC_DRAGSTATE_COLOR
|
||||||
|
};
|
||||||
|
|
||||||
class View : public lcGLWidget
|
class View : public lcGLWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -65,6 +72,9 @@ public:
|
||||||
void OnMouseMove();
|
void OnMouseMove();
|
||||||
void OnMouseWheel(float Direction);
|
void OnMouseWheel(float Direction);
|
||||||
|
|
||||||
|
void BeginPieceDrag();
|
||||||
|
void EndPieceDrag(bool Accept);
|
||||||
|
|
||||||
void SetCamera(Camera* camera, bool ForceCopy);
|
void SetCamera(Camera* camera, bool ForceCopy);
|
||||||
void SetDefaultCamera();
|
void SetDefaultCamera();
|
||||||
lcMatrix44 GetProjectionMatrix() const;
|
lcMatrix44 GetProjectionMatrix() const;
|
||||||
|
@ -107,10 +117,13 @@ protected:
|
||||||
void StartTracking(lcTrackButton TrackButton);
|
void StartTracking(lcTrackButton TrackButton);
|
||||||
void StopTracking(bool Accept);
|
void StopTracking(bool Accept);
|
||||||
|
|
||||||
|
lcDragState mDragState;
|
||||||
lcTrackButton mTrackButton;
|
lcTrackButton mTrackButton;
|
||||||
lcTrackTool mTrackTool;
|
lcTrackTool mTrackTool;
|
||||||
int mMouseDownX;
|
int mMouseDownX;
|
||||||
int mMouseDownY;
|
int mMouseDownY;
|
||||||
|
|
||||||
|
friend class Project;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _VIEW_H_
|
#endif // _VIEW_H_
|
||||||
|
|
|
@ -96,6 +96,8 @@ void lcQEditGroupsDialog::timerEvent(QTimerEvent *event)
|
||||||
void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *parentGroup)
|
void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *parentGroup)
|
||||||
{
|
{
|
||||||
Project *project = lcGetActiveProject();
|
Project *project = lcGetActiveProject();
|
||||||
|
const lcArray<lcPiece*>& pieces = project->GetPieces();
|
||||||
|
const lcArray<lcGroup*>& groups = project->GetGroups();
|
||||||
|
|
||||||
for (int childIndex = 0; childIndex < parentItem->childCount(); childIndex++)
|
for (int childIndex = 0; childIndex < parentItem->childCount(); childIndex++)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +107,7 @@ void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *pare
|
||||||
|
|
||||||
if (itemPiece)
|
if (itemPiece)
|
||||||
{
|
{
|
||||||
int pieceIndex = project->mPieces.FindIndex(itemPiece);
|
int pieceIndex = pieces.FindIndex(itemPiece);
|
||||||
if (pieceIndex != -1)
|
if (pieceIndex != -1)
|
||||||
options->PieceParents[pieceIndex] = parentGroup;
|
options->PieceParents[pieceIndex] = parentGroup;
|
||||||
}
|
}
|
||||||
|
@ -116,9 +118,9 @@ void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *pare
|
||||||
strncpy(itemGroup->m_strName, childItem->text(0).toLocal8Bit(), sizeof(itemGroup->m_strName));
|
strncpy(itemGroup->m_strName, childItem->text(0).toLocal8Bit(), sizeof(itemGroup->m_strName));
|
||||||
itemGroup->m_strName[sizeof(itemGroup->m_strName) - 1] = 0;
|
itemGroup->m_strName[sizeof(itemGroup->m_strName) - 1] = 0;
|
||||||
|
|
||||||
for (int groupIdx = 0; groupIdx < project->mGroups.GetSize(); groupIdx++)
|
for (int groupIdx = 0; groupIdx < groups.GetSize(); groupIdx++)
|
||||||
{
|
{
|
||||||
lcGroup *group = project->mGroups[groupIdx];
|
lcGroup *group = groups[groupIdx];
|
||||||
|
|
||||||
if (itemGroup == group)
|
if (itemGroup == group)
|
||||||
{
|
{
|
||||||
|
@ -135,10 +137,12 @@ void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *pare
|
||||||
void lcQEditGroupsDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGroup)
|
void lcQEditGroupsDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGroup)
|
||||||
{
|
{
|
||||||
Project *project = lcGetActiveProject();
|
Project *project = lcGetActiveProject();
|
||||||
|
const lcArray<lcPiece*>& pieces = project->GetPieces();
|
||||||
|
const lcArray<lcGroup*>& groups = project->GetGroups();
|
||||||
|
|
||||||
for (int groupIdx = 0; groupIdx < project->mGroups.GetSize(); groupIdx++)
|
for (int groupIdx = 0; groupIdx < groups.GetSize(); groupIdx++)
|
||||||
{
|
{
|
||||||
lcGroup *group = project->mGroups[groupIdx];
|
lcGroup *group = groups[groupIdx];
|
||||||
|
|
||||||
if (group->mGroup != parentGroup)
|
if (group->mGroup != parentGroup)
|
||||||
continue;
|
continue;
|
||||||
|
@ -150,9 +154,9 @@ void lcQEditGroupsDialog::addChildren(QTreeWidgetItem *parentItem, Group *parent
|
||||||
addChildren(groupItem, group);
|
addChildren(groupItem, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int pieceIndex = 0; pieceIndex < project->mPieces.GetSize(); pieceIndex++)
|
for (int pieceIndex = 0; pieceIndex < pieces.GetSize(); pieceIndex++)
|
||||||
{
|
{
|
||||||
Piece *piece = project->mPieces[pieceIndex];
|
Piece *piece = pieces[pieceIndex];
|
||||||
|
|
||||||
if (piece->GetGroup() != parentGroup)
|
if (piece->GetGroup() != parentGroup)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "lc_qmainwindow.h"
|
#include "lc_qmainwindow.h"
|
||||||
#include "lc_mainwindow.h"
|
#include "lc_mainwindow.h"
|
||||||
#include "lc_context.h"
|
#include "lc_context.h"
|
||||||
|
#include "view.h"
|
||||||
|
|
||||||
void lcGLWidget::MakeCurrent()
|
void lcGLWidget::MakeCurrent()
|
||||||
{
|
{
|
||||||
|
@ -303,7 +304,7 @@ void lcQGLWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
|
||||||
dataStream >> id;
|
dataStream >> id;
|
||||||
|
|
||||||
lcGetActiveProject()->BeginPieceDrop(lcGetPiecesLibrary()->FindPiece(id.toLocal8Bit().data(), false));
|
((View*)widget)->BeginPieceDrag();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
@ -314,7 +315,7 @@ void lcQGLWidget::dragLeaveEvent(QDragLeaveEvent *event)
|
||||||
if (!isView)
|
if (!isView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcGetActiveProject()->EndPieceDrop(false);
|
((View*)widget)->EndPieceDrag(false);
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -326,7 +327,13 @@ void lcQGLWidget::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
|
||||||
float scale = deviceScale();
|
float scale = deviceScale();
|
||||||
|
|
||||||
lcGetActiveProject()->OnPieceDropMove(event->pos().x() * scale, widget->mHeight - event->pos().y() * scale - 1);
|
widget->mInputState.x = event->pos().x() * scale;
|
||||||
|
widget->mInputState.y = widget->mHeight - event->pos().y() * scale - 1;
|
||||||
|
widget->mInputState.Control = (event->keyboardModifiers() & Qt::ControlModifier) != 0;
|
||||||
|
widget->mInputState.Shift = (event->keyboardModifiers() & Qt::ShiftModifier) != 0;
|
||||||
|
widget->mInputState.Alt = (event->keyboardModifiers() & Qt::AltModifier) != 0;
|
||||||
|
|
||||||
|
widget->OnMouseMove();
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -336,7 +343,7 @@ void lcQGLWidget::dropEvent(QDropEvent *event)
|
||||||
if (!isView || !event->mimeData()->hasFormat("application/vnd.leocad-part"))
|
if (!isView || !event->mimeData()->hasFormat("application/vnd.leocad-part"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcGetActiveProject()->EndPieceDrop(true);
|
((View*)widget)->EndPieceDrag(true);
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ lcQMainWindow::lcQMainWindow(QWidget *parent)
|
||||||
|
|
||||||
GL_EnableVertexBufferObject();
|
GL_EnableVertexBufferObject();
|
||||||
|
|
||||||
if (!lcGetActiveProject()->mPieces.IsEmpty())
|
if (!lcGetActiveProject()->GetPieces().IsEmpty())
|
||||||
{
|
{
|
||||||
for (int PieceIdx = 0; PieceIdx < Library->mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < Library->mPieces.GetSize(); PieceIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1218,7 +1218,7 @@ void lcQMainWindow::updateTransformType(int newType)
|
||||||
|
|
||||||
void lcQMainWindow::updateCameraMenu()
|
void lcQMainWindow::updateCameraMenu()
|
||||||
{
|
{
|
||||||
const lcArray<Camera*>& cameras = lcGetActiveProject()->mCameras;
|
const lcArray<Camera*>& cameras = lcGetActiveProject()->GetCameras();
|
||||||
Camera* currentCamera = gMainWindow->GetActiveView()->mCamera;
|
Camera* currentCamera = gMainWindow->GetActiveView()->mCamera;
|
||||||
int actionIdx, currentIndex = -1;
|
int actionIdx, currentIndex = -1;
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,13 @@ void lcQSelectDialog::saveSelection(QTreeWidgetItem *parentItem)
|
||||||
void lcQSelectDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGroup)
|
void lcQSelectDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGroup)
|
||||||
{
|
{
|
||||||
Project *project = lcGetActiveProject();
|
Project *project = lcGetActiveProject();
|
||||||
|
int numObjects = 0;
|
||||||
|
|
||||||
for (int groupIdx = 0; groupIdx < project->mGroups.GetSize(); groupIdx++)
|
const lcArray<lcGroup*>& groups = project->GetGroups();
|
||||||
|
|
||||||
|
for (int groupIdx = 0; groupIdx < groups.GetSize(); groupIdx++)
|
||||||
{
|
{
|
||||||
lcGroup* group = project->mGroups[groupIdx];
|
lcGroup* group = groups[groupIdx];
|
||||||
|
|
||||||
if (group->mGroup != parentGroup)
|
if (group->mGroup != parentGroup)
|
||||||
continue;
|
continue;
|
||||||
|
@ -162,11 +165,11 @@ void lcQSelectDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGrou
|
||||||
addChildren(groupItem, group);
|
addChildren(groupItem, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numObjects = 0;
|
const lcArray<lcPiece*>& pieces = project->GetPieces();
|
||||||
|
|
||||||
for (int pieceIdx = 0; pieceIdx < project->mPieces.GetSize(); pieceIdx++, numObjects++)
|
for (int pieceIdx = 0; pieceIdx < pieces.GetSize(); pieceIdx++, numObjects++)
|
||||||
{
|
{
|
||||||
lcPiece *piece = project->mPieces[pieceIdx];
|
lcPiece *piece = pieces[pieceIdx];
|
||||||
|
|
||||||
if (piece->GetGroup() != parentGroup)
|
if (piece->GetGroup() != parentGroup)
|
||||||
continue;
|
continue;
|
||||||
|
@ -181,9 +184,11 @@ void lcQSelectDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGrou
|
||||||
|
|
||||||
if (!parentGroup)
|
if (!parentGroup)
|
||||||
{
|
{
|
||||||
for (int cameraIdx = 0; cameraIdx < project->mCameras.GetSize(); cameraIdx++, numObjects++)
|
const lcArray<lcCamera*>& cameras = project->GetCameras();
|
||||||
|
|
||||||
|
for (int cameraIdx = 0; cameraIdx < cameras.GetSize(); cameraIdx++, numObjects++)
|
||||||
{
|
{
|
||||||
lcCamera *camera = project->mCameras[cameraIdx];
|
lcCamera *camera = cameras[cameraIdx];
|
||||||
|
|
||||||
if (!camera->IsVisible())
|
if (!camera->IsVisible())
|
||||||
continue;
|
continue;
|
||||||
|
@ -193,9 +198,11 @@ void lcQSelectDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGrou
|
||||||
cameraItem->setCheckState(0, options->Selection[numObjects] ? Qt::Checked : Qt::Unchecked);
|
cameraItem->setCheckState(0, options->Selection[numObjects] ? Qt::Checked : Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int lightIdx = 0; lightIdx < project->mLights.GetSize(); lightIdx++, numObjects++)
|
const lcArray<lcLight*>& lights = project->GetLights();
|
||||||
|
|
||||||
|
for (int lightIdx = 0; lightIdx < lights.GetSize(); lightIdx++, numObjects++)
|
||||||
{
|
{
|
||||||
lcLight* light = project->mLights[lightIdx];
|
lcLight* light = lights[lightIdx];
|
||||||
|
|
||||||
if (!light->IsVisible())
|
if (!light->IsVisible())
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue