mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Allow different cameras for each submodel.
This commit is contained in:
parent
635d408101
commit
7440111b64
3 changed files with 38 additions and 5 deletions
|
@ -66,7 +66,11 @@ void lcApplication::SetProject(Project* Project)
|
|||
|
||||
const lcArray<View*>& Views = gMainWindow->GetViews();
|
||||
for (int ViewIdx = 0; ViewIdx < Views.GetSize(); ViewIdx++)
|
||||
Views[ViewIdx]->SetModel(lcGetActiveModel());
|
||||
{
|
||||
View* View = Views[ViewIdx];
|
||||
View->ClearCameras();
|
||||
View->SetModel(lcGetActiveModel());
|
||||
}
|
||||
|
||||
lcGetPiecesLibrary()->RemoveTemporaryPieces();
|
||||
lcGetActiveModel()->UpdateInterface();
|
||||
|
|
|
@ -33,8 +33,9 @@ View::~View()
|
|||
if (gMainWindow)
|
||||
gMainWindow->RemoveView(this);
|
||||
|
||||
if (mCamera && mCamera->IsSimple())
|
||||
delete mCamera;
|
||||
foreach (lcCamera* Camera, mCameras)
|
||||
if (Camera && Camera->IsSimple())
|
||||
delete Camera;
|
||||
}
|
||||
|
||||
void View::SetModel(lcModel* Model)
|
||||
|
@ -44,14 +45,28 @@ void View::SetModel(lcModel* Model)
|
|||
|
||||
mModel = Model;
|
||||
|
||||
if (mCamera && !mCamera->IsSimple())
|
||||
lcCamera* Camera = mCameras.value(mModel);
|
||||
|
||||
if (Camera)
|
||||
mCamera = Camera;
|
||||
else
|
||||
{
|
||||
lcCamera* Camera = mCamera;
|
||||
Camera = mCamera;
|
||||
mCamera = new lcCamera(true);
|
||||
|
||||
if (Camera)
|
||||
mCamera->CopyPosition(Camera);
|
||||
else
|
||||
mCamera->SetViewpoint(LC_VIEWPOINT_HOME);
|
||||
}
|
||||
|
||||
mCameras[mModel] = mCamera;
|
||||
}
|
||||
|
||||
void View::ClearCameras()
|
||||
{
|
||||
mCamera = NULL;
|
||||
mCameras.clear();
|
||||
}
|
||||
|
||||
void View::RemoveCamera()
|
||||
|
@ -64,6 +79,10 @@ void View::RemoveCamera()
|
|||
|
||||
if (Camera)
|
||||
mCamera->CopyPosition(Camera);
|
||||
else
|
||||
mCamera->SetViewpoint(LC_VIEWPOINT_HOME);
|
||||
|
||||
mCameras[mModel] = mCamera;
|
||||
|
||||
gMainWindow->UpdateCurrentCamera(-1);
|
||||
Redraw();
|
||||
|
@ -85,6 +104,8 @@ void View::SetCamera(lcCamera* Camera, bool ForceCopy)
|
|||
|
||||
mCamera = Camera;
|
||||
}
|
||||
|
||||
mCameras[mModel] = mCamera;
|
||||
}
|
||||
|
||||
void View::SetCameraIndex(int Index)
|
||||
|
@ -104,7 +125,10 @@ void View::SetCameraIndex(int Index)
|
|||
void View::SetViewpoint(lcViewpoint Viewpoint)
|
||||
{
|
||||
if (!mCamera || !mCamera->IsSimple())
|
||||
{
|
||||
mCamera = new lcCamera(true);
|
||||
mCameras[mModel] = mCamera;
|
||||
}
|
||||
|
||||
mCamera->SetViewpoint(Viewpoint);
|
||||
ZoomExtents();
|
||||
|
@ -114,7 +138,10 @@ void View::SetViewpoint(lcViewpoint Viewpoint)
|
|||
void View::SetDefaultCamera()
|
||||
{
|
||||
if (!mCamera || !mCamera->IsSimple())
|
||||
{
|
||||
mCamera = new lcCamera(true);
|
||||
mCameras[mModel] = mCamera;
|
||||
}
|
||||
|
||||
mCamera->SetViewpoint(LC_VIEWPOINT_HOME);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
void LookAt();
|
||||
void ZoomExtents();
|
||||
|
||||
void ClearCameras();
|
||||
void RemoveCamera();
|
||||
void SetCamera(lcCamera* Camera, bool ForceCopy);
|
||||
void SetCameraIndex(int Index);
|
||||
|
@ -95,6 +96,7 @@ public:
|
|||
|
||||
lcModel* mModel;
|
||||
lcCamera* mCamera;
|
||||
QMap<lcModel*, lcCamera*> mCameras;
|
||||
|
||||
lcVector3 ProjectPoint(const lcVector3& Point) const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue