mirror of
https://github.com/leozide/leocad
synced 2025-01-27 19:58:20 +01:00
Moved search out of the project.
This commit is contained in:
parent
641a476726
commit
d1f1401ca3
8 changed files with 79 additions and 120 deletions
|
@ -13,6 +13,7 @@ lcMainWindow::lcMainWindow()
|
|||
mTransformType = LC_TRANSFORM_RELATIVE_TRANSLATION;
|
||||
|
||||
mAddKeys = false;
|
||||
memset(&mSearchOptions, 0, sizeof(mSearchOptions));
|
||||
|
||||
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
|
||||
strcpy(mRecentFiles[FileIdx], lcGetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx)));
|
||||
|
|
|
@ -10,9 +10,19 @@ class PiecePreview;
|
|||
|
||||
#define LC_MAX_RECENT_FILES 4
|
||||
|
||||
struct lcSearchOptions
|
||||
{
|
||||
bool MatchInfo;
|
||||
bool MatchColor;
|
||||
bool MatchName;
|
||||
PieceInfo* Info;
|
||||
int ColorIndex;
|
||||
char Name[256];
|
||||
};
|
||||
|
||||
class lcMainWindow : public lcBaseWindow
|
||||
{
|
||||
public:
|
||||
public:
|
||||
lcMainWindow();
|
||||
~lcMainWindow();
|
||||
|
||||
|
@ -85,6 +95,7 @@ class lcMainWindow : public lcBaseWindow
|
|||
char mRecentFiles[LC_MAX_RECENT_FILES][LC_MAXPATH];
|
||||
PiecePreview* mPreviewWidget;
|
||||
int mColorIndex;
|
||||
lcSearchOptions mSearchOptions;
|
||||
|
||||
protected:
|
||||
View* mActiveView;
|
||||
|
|
|
@ -744,3 +744,59 @@ void lcModel::AddToSelection(const lcArray<lcObjectSection>& ObjectSections)
|
|||
gMainWindow->UpdateAllViews();
|
||||
gMainWindow->UpdateFocusObject(GetFocusObject());
|
||||
}
|
||||
|
||||
void lcModel::FindPiece(bool FindFirst, bool SearchForward)
|
||||
{
|
||||
if (mPieces.IsEmpty())
|
||||
return;
|
||||
|
||||
int StartIdx = mPieces.GetSize() - 1;
|
||||
if (!FindFirst)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused() && Piece->IsVisible(mCurrentStep))
|
||||
{
|
||||
StartIdx = PieceIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CurrentIdx = StartIdx;
|
||||
lcObject* Focus = NULL;
|
||||
const lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (SearchForward)
|
||||
CurrentIdx++;
|
||||
else
|
||||
CurrentIdx--;
|
||||
|
||||
if (CurrentIdx < 0)
|
||||
CurrentIdx = mPieces.GetSize() - 1;
|
||||
else if (CurrentIdx >= mPieces.GetSize())
|
||||
CurrentIdx = 0;
|
||||
|
||||
if (CurrentIdx == StartIdx)
|
||||
break;
|
||||
|
||||
lcPiece* Current = mPieces[CurrentIdx];
|
||||
|
||||
if (!Current->IsVisible(mCurrentStep))
|
||||
continue;
|
||||
|
||||
if ((!SearchOptions.MatchInfo || Current->mPieceInfo == SearchOptions.Info) &&
|
||||
(!SearchOptions.MatchColor || Current->mColorIndex == SearchOptions.ColorIndex) &&
|
||||
(!SearchOptions.MatchName || strcasestr(Current->GetName(), SearchOptions.Name)))
|
||||
{
|
||||
Focus = Current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION);
|
||||
}
|
||||
|
|
|
@ -153,6 +153,8 @@ public:
|
|||
void SetSelection(const lcArray<lcObjectSection>& ObjectSections);
|
||||
void AddToSelection(const lcArray<lcObjectSection>& ObjectSections);
|
||||
|
||||
void FindPiece(bool FindFirst, bool SearchForward);
|
||||
|
||||
protected:
|
||||
void SaveCheckpoint(const QString& Description);
|
||||
void CalculateStep();
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
Project::Project()
|
||||
{
|
||||
m_pBackground = new lcTexture();
|
||||
memset(&mSearchOptions, 0, sizeof(mSearchOptions));
|
||||
}
|
||||
|
||||
Project::~Project()
|
||||
|
@ -142,9 +141,6 @@ void Project::LoadDefaults(bool cameras)
|
|||
gMainWindow->UpdateFocusObject(NULL);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Standard file menu commands
|
||||
|
||||
bool Project::FileLoad(lcFile* file, bool bUndo, bool bMerge)
|
||||
{
|
||||
lcint32 i, count;
|
||||
|
@ -868,9 +864,6 @@ bool Project::SaveModified()
|
|||
return true; // keep going
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// File operations
|
||||
|
||||
bool Project::OnNewDocument()
|
||||
{
|
||||
DeleteContents(false);
|
||||
|
@ -1439,9 +1432,6 @@ bool Project::GetPiecesBoundingBox(View* view, float BoundingBox[6])
|
|||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Project functions
|
||||
|
||||
bool Project::RemoveSelectedObjects()
|
||||
{
|
||||
bool RemovedPiece = false;
|
||||
|
@ -1507,97 +1497,6 @@ bool Project::RemoveSelectedObjects()
|
|||
return RemovedPiece || RemovedCamera || RemovedLight;
|
||||
}
|
||||
|
||||
void Project::CheckAutoSave()
|
||||
{
|
||||
/*
|
||||
m_nSaveTimer += 5;
|
||||
if (m_nAutosave & LC_AUTOSAVE_FLAG)
|
||||
{
|
||||
// int nInterval;
|
||||
// nInterval = m_nAutosave & ~LC_AUTOSAVE_FLAG;
|
||||
|
||||
if (m_nSaveTimer >= (m_nAutosave*60))
|
||||
{
|
||||
m_nSaveTimer = 0;
|
||||
|
||||
if (m_strTempFile.IsEmpty())
|
||||
{
|
||||
char tmpFile[_MAX_PATH], out[_MAX_PATH];
|
||||
GetTempPath (_MAX_PATH, out);
|
||||
GetTempFileName (out, "~LC", 0, tmpFile);
|
||||
DeleteFile (tmpFile);
|
||||
if (char *ptr = strchr(tmpFile, '.')) *ptr = 0;
|
||||
strcat (tmpFile, ".lcd");
|
||||
m_strTempFile = tmpFile;
|
||||
}
|
||||
|
||||
CFile file (m_strTempFile, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
|
||||
m_bUndo = TRUE;
|
||||
file.SeekToBegin();
|
||||
CArchive ar(&file, CArchive::store);
|
||||
Serialize(ar);
|
||||
ar.Close();
|
||||
m_bUndo = FALSE;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Project::FindPiece(bool FindFirst, bool SearchForward)
|
||||
{
|
||||
if (mPieces.IsEmpty())
|
||||
return;
|
||||
|
||||
int StartIdx = mPieces.GetSize() - 1;
|
||||
if (!FindFirst)
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
lcPiece* Piece = mPieces[PieceIdx];
|
||||
|
||||
if (Piece->IsFocused() && Piece->IsVisible(mCurrentStep))
|
||||
{
|
||||
StartIdx = PieceIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CurrentIdx = StartIdx;
|
||||
lcObject* Focus = NULL;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (SearchForward)
|
||||
CurrentIdx++;
|
||||
else
|
||||
CurrentIdx--;
|
||||
|
||||
if (CurrentIdx < 0)
|
||||
CurrentIdx = mPieces.GetSize() - 1;
|
||||
else if (CurrentIdx >= mPieces.GetSize())
|
||||
CurrentIdx = 0;
|
||||
|
||||
if (CurrentIdx == StartIdx)
|
||||
break;
|
||||
|
||||
lcPiece* Current = mPieces[CurrentIdx];
|
||||
|
||||
if (!Current->IsVisible(mCurrentStep))
|
||||
continue;
|
||||
|
||||
if ((!mSearchOptions.MatchInfo || Current->mPieceInfo == mSearchOptions.Info) &&
|
||||
(!mSearchOptions.MatchColor || Current->mColorIndex == mSearchOptions.ColorIndex) &&
|
||||
(!mSearchOptions.MatchName || strcasestr(Current->GetName(), mSearchOptions.Name)))
|
||||
{
|
||||
Focus = Current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION);
|
||||
}
|
||||
|
||||
void Project::ZoomExtents(int FirstView, int LastView)
|
||||
{
|
||||
if (mPieces.IsEmpty())
|
||||
|
@ -3524,7 +3423,7 @@ void Project::HandleCommand(LC_COMMANDS id)
|
|||
} break;
|
||||
|
||||
case LC_EDIT_FIND:
|
||||
if (gMainWindow->DoDialog(LC_DIALOG_FIND, &mSearchOptions))
|
||||
if (gMainWindow->DoDialog(LC_DIALOG_FIND, &gMainWindow->mSearchOptions))
|
||||
FindPiece(true, true);
|
||||
break;
|
||||
|
||||
|
|
|
@ -63,16 +63,6 @@ struct lcPiecesUsedEntry
|
|||
int Count;
|
||||
};
|
||||
|
||||
struct lcSearchOptions
|
||||
{
|
||||
bool MatchInfo;
|
||||
bool MatchColor;
|
||||
bool MatchName;
|
||||
PieceInfo* Info;
|
||||
int ColorIndex;
|
||||
char Name[256];
|
||||
};
|
||||
|
||||
enum lcObjectProperty
|
||||
{
|
||||
LC_PIECE_PROPERTY_POSITION,
|
||||
|
@ -161,7 +151,6 @@ public:
|
|||
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const;
|
||||
void CreateImages(Image* images, int width, int height, lcStep from, lcStep to, bool hilite);
|
||||
void Render(View* view, bool bToMemory);
|
||||
void CheckAutoSave();
|
||||
bool GetSelectionCenter(lcVector3& Center) const;
|
||||
lcVector3 GetFocusOrSelectionCenter() const;
|
||||
bool GetFocusPosition(lcVector3& Position) const;
|
||||
|
@ -185,9 +174,6 @@ protected:
|
|||
|
||||
static int InstanceOfName(const String& existingString, const String& candidateString, String& baseNameOut );
|
||||
|
||||
void FindPiece(bool FindFirst, bool SearchForward);
|
||||
lcSearchOptions mSearchOptions;
|
||||
|
||||
// Movement.
|
||||
bool MoveSelectedObjects(lcVector3& Move, lcVector3& Remainder, bool Snap, bool Lock);
|
||||
bool RotateSelectedObjects(lcVector3& Delta, lcVector3& Remainder, bool Snap, bool Lock);
|
||||
|
|
|
@ -32,7 +32,8 @@ isEmpty(QMAKE_LRELEASE) {
|
|||
}
|
||||
}
|
||||
|
||||
lrelease.input = TRANSLATIONS
|
||||
TSFILES = resources/leocad_pt.ts
|
||||
lrelease.input = TSFILES
|
||||
lrelease.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
|
||||
lrelease.commands = $$QMAKE_LRELEASE -silent ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
|
||||
lrelease.CONFIG += no_link target_predeps
|
||||
|
@ -236,4 +237,7 @@ FORMS += \
|
|||
qt/lc_qfinddialog.ui
|
||||
OTHER_FILES +=
|
||||
RESOURCES += leocad.qrc
|
||||
TRANSLATIONS = resources/leocad_pt.ts
|
||||
|
||||
!win32 {
|
||||
TRANSLATIONS = TSFILES
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include "lc_qfinddialog.h"
|
||||
#include "ui_lc_qfinddialog.h"
|
||||
#include "project.h"
|
||||
#include "lc_mainwindow.h"
|
||||
#include "lc_library.h"
|
||||
#include "lc_application.h"
|
||||
#include "pieceinf.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue