mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Added view cube preferences.
This commit is contained in:
parent
69d46cc4c4
commit
15d5e89cee
7 changed files with 162 additions and 63 deletions
|
@ -25,6 +25,8 @@ void lcPreferences::LoadDefaults()
|
|||
mDrawGridLines = lcGetProfileInt(LC_PROFILE_GRID_LINES);
|
||||
mGridLineSpacing = lcGetProfileInt(LC_PROFILE_GRID_LINE_SPACING);
|
||||
mGridLineColor = lcGetProfileInt(LC_PROFILE_GRID_LINE_COLOR);
|
||||
mViewCubeLocation = (lcViewCubeLocation)lcGetProfileInt(LC_PROFILE_VIEW_CUBE_LOCATION);
|
||||
mViewCubeSize = lcGetProfileInt(LC_PROFILE_VIEW_CUBE_SIZE);
|
||||
}
|
||||
|
||||
void lcPreferences::SaveDefaults()
|
||||
|
@ -40,6 +42,8 @@ void lcPreferences::SaveDefaults()
|
|||
lcSetProfileInt(LC_PROFILE_GRID_LINES, mDrawGridLines);
|
||||
lcSetProfileInt(LC_PROFILE_GRID_LINE_SPACING, mGridLineSpacing);
|
||||
lcSetProfileInt(LC_PROFILE_GRID_LINE_COLOR, mGridLineColor);
|
||||
lcSetProfileInt(LC_PROFILE_VIEW_CUBE_LOCATION, (int)mViewCubeLocation);
|
||||
lcSetProfileInt(LC_PROFILE_VIEW_CUBE_SIZE, mViewCubeSize);
|
||||
}
|
||||
|
||||
lcApplication::lcApplication(int& Argc, char** Argv)
|
||||
|
|
|
@ -14,6 +14,15 @@ enum lcShadingMode
|
|||
LC_NUM_SHADING_MODES
|
||||
};
|
||||
|
||||
enum class lcViewCubeLocation
|
||||
{
|
||||
DISABLED,
|
||||
TOP_LEFT,
|
||||
TOP_RIGHT,
|
||||
BOTTOM_LEFT,
|
||||
BOTTOM_RIGHT
|
||||
};
|
||||
|
||||
class lcPreferences
|
||||
{
|
||||
public:
|
||||
|
@ -31,6 +40,8 @@ public:
|
|||
int mGridLineSpacing;
|
||||
quint32 mGridLineColor;
|
||||
bool mFixedAxes;
|
||||
lcViewCubeLocation mViewCubeLocation;
|
||||
int mViewCubeSize;
|
||||
};
|
||||
|
||||
class lcApplication : public QApplication
|
||||
|
|
|
@ -66,6 +66,8 @@ lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
|
|||
lcProfileEntry("Settings", "GridLineSpacing", 5), // LC_PROFILE_GRID_LINE_SPACING
|
||||
lcProfileEntry("Settings", "GridLineColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_GRID_LINE_COLOR
|
||||
lcProfileEntry("Settings", "AASamples", 1), // LC_PROFILE_ANTIALIASING_SAMPLES
|
||||
lcProfileEntry("Settings", "ViewCubeLocation", (int)lcViewCubeLocation::TOP_RIGHT), // LC_PROFILE_VIEW_CUBE_LOCATION
|
||||
lcProfileEntry("Settings", "ViewCubeSize", 100), // LC_PROFILE_VIEW_CUBE_SIZE
|
||||
|
||||
lcProfileEntry("Settings", "CheckUpdates", 1), // LC_PROFILE_CHECK_UPDATES
|
||||
lcProfileEntry("Settings", "ProjectsPath", ""), // LC_PROFILE_PROJECTS_PATH
|
||||
|
|
|
@ -14,6 +14,8 @@ enum LC_PROFILE_KEY
|
|||
LC_PROFILE_GRID_LINE_SPACING,
|
||||
LC_PROFILE_GRID_LINE_COLOR,
|
||||
LC_PROFILE_ANTIALIASING_SAMPLES,
|
||||
LC_PROFILE_VIEW_CUBE_LOCATION,
|
||||
LC_PROFILE_VIEW_CUBE_SIZE,
|
||||
|
||||
LC_PROFILE_CHECK_UPDATES,
|
||||
LC_PROFILE_PROJECTS_PATH,
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "view.h"
|
||||
#include "lc_context.h"
|
||||
#include "texfont.h"
|
||||
#include "lc_application.h"
|
||||
|
||||
//todo: move these and add preferences
|
||||
const int ViewportSize = 100;
|
||||
//todo: move these
|
||||
const float BoxSize = 10.0f;
|
||||
|
||||
lcViewCube::lcViewCube(View* View)
|
||||
|
@ -28,11 +28,20 @@ lcMatrix44 lcViewCube::GetProjectionMatrix() const
|
|||
|
||||
void lcViewCube::Draw()
|
||||
{
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
lcViewCubeLocation Location = Preferences.mViewCubeLocation;
|
||||
|
||||
if (Location == lcViewCubeLocation::DISABLED)
|
||||
return;
|
||||
|
||||
lcContext* Context = mView->mContext;
|
||||
int Width = mView->mWidth;
|
||||
int Height = mView->mHeight;
|
||||
int ViewportSize = Preferences.mViewCubeSize;
|
||||
|
||||
Context->SetViewport(Width - ViewportSize, Height - ViewportSize, ViewportSize, ViewportSize);
|
||||
int Left = (Location == lcViewCubeLocation::BOTTOM_LEFT || Location == lcViewCubeLocation::TOP_LEFT) ? 0 : Width - ViewportSize;
|
||||
int Bottom = (Location == lcViewCubeLocation::BOTTOM_LEFT || Location == lcViewCubeLocation::BOTTOM_RIGHT) ? 0 : Height - ViewportSize;
|
||||
Context->SetViewport(Left, Bottom, ViewportSize, ViewportSize);
|
||||
|
||||
const lcVector3 BoxVerts[8] =
|
||||
{
|
||||
|
@ -226,6 +235,10 @@ void lcViewCube::Draw()
|
|||
|
||||
bool lcViewCube::OnLeftButtonUp()
|
||||
{
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
if (Preferences.mViewCubeLocation == lcViewCubeLocation::DISABLED)
|
||||
return false;
|
||||
|
||||
if (!mIntersectionFlags.any())
|
||||
return false;
|
||||
|
||||
|
@ -246,12 +259,21 @@ bool lcViewCube::OnLeftButtonUp()
|
|||
|
||||
bool lcViewCube::OnMouseMove()
|
||||
{
|
||||
int x = mView->mInputState.x;
|
||||
int y = mView->mInputState.y;
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
lcViewCubeLocation Location = Preferences.mViewCubeLocation;
|
||||
|
||||
if (Location == lcViewCubeLocation::DISABLED)
|
||||
return false;
|
||||
|
||||
int Width = mView->mWidth;
|
||||
int Height = mView->mHeight;
|
||||
int ViewportSize = Preferences.mViewCubeSize;
|
||||
int Left = (Location == lcViewCubeLocation::BOTTOM_LEFT || Location == lcViewCubeLocation::TOP_LEFT) ? 0 : Width - ViewportSize;
|
||||
int Bottom = (Location == lcViewCubeLocation::BOTTOM_LEFT || Location == lcViewCubeLocation::BOTTOM_RIGHT) ? 0 : Height - ViewportSize;
|
||||
int x = mView->mInputState.x - Left;
|
||||
int y = mView->mInputState.y - Bottom;
|
||||
|
||||
if (x < Width - ViewportSize || x > Width || y < Height - ViewportSize || y > Height)
|
||||
if (x < 0 || x > Width || y < 0 || y > Height)
|
||||
{
|
||||
if (mIntersectionFlags.any())
|
||||
{
|
||||
|
@ -262,9 +284,6 @@ bool lcViewCube::OnMouseMove()
|
|||
return false;
|
||||
}
|
||||
|
||||
x -= Width - ViewportSize;
|
||||
y -= Height - ViewportSize;
|
||||
|
||||
lcVector3 StartEnd[2] = { lcVector3(x, y, 0), lcVector3(x, y, 1) };
|
||||
const int Viewport[4] = { 0, 0, ViewportSize, ViewportSize };
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) :
|
|||
ui->gridLines->setChecked(options->Preferences.mDrawGridLines);
|
||||
ui->gridLineSpacing->setText(QString::number(options->Preferences.mGridLineSpacing));
|
||||
ui->axisIcon->setChecked(options->Preferences.mDrawAxes);
|
||||
ui->ViewCubeLocationCombo->setCurrentIndex((int)options->Preferences.mViewCubeLocation);
|
||||
ui->ViewCubeSizeEdit->setText(QString::number(options->Preferences.mViewCubeSize));
|
||||
|
||||
if (!gSupportsShaderObjects)
|
||||
ui->ShadingMode->removeItem(LC_SHADING_DEFAULT_LIGHTS);
|
||||
|
@ -132,6 +134,8 @@ void lcQPreferencesDialog::accept()
|
|||
options->Preferences.mGridLineSpacing = gridLineSpacing;
|
||||
|
||||
options->Preferences.mDrawAxes = ui->axisIcon->isChecked();
|
||||
options->Preferences.mViewCubeLocation = (lcViewCubeLocation)ui->ViewCubeLocationCombo->currentIndex();
|
||||
options->Preferences.mViewCubeSize = ui->ViewCubeSizeEdit->text().toInt();
|
||||
options->Preferences.mShadingMode = (lcShadingMode)ui->ShadingMode->currentIndex();
|
||||
|
||||
QDialog::accept();
|
||||
|
|
|
@ -324,6 +324,61 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="ViewCubeGroup">
|
||||
<property name="title">
|
||||
<string>View Cube</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Location</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="ViewCubeLocationCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom Right</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="ViewCubeSizeEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -873,6 +928,8 @@
|
|||
<tabstop>gridLines</tabstop>
|
||||
<tabstop>gridLineSpacing</tabstop>
|
||||
<tabstop>gridLineColor</tabstop>
|
||||
<tabstop>ViewCubeLocationCombo</tabstop>
|
||||
<tabstop>ViewCubeSizeEdit</tabstop>
|
||||
<tabstop>categoriesTree</tabstop>
|
||||
<tabstop>partsTree</tabstop>
|
||||
<tabstop>importCategories</tabstop>
|
||||
|
|
Loading…
Reference in a new issue