Skip to content

Commit

Permalink
Added manual scaling to axonometric view
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dowsett committed Dec 15, 2013
1 parent 7d15936 commit 7348d0d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
41 changes: 37 additions & 4 deletions src/Mod/Drawing/Gui/TaskOrthoViews.cpp
Expand Up @@ -463,6 +463,8 @@ TaskOrthoViews::TaskOrthoViews(QWidget *parent)
connect(ui->axoTop, SIGNAL(activated(int)), this, SLOT(axoTopChanged(int)));
connect(ui->axoLeft, SIGNAL(activated(int)), this, SLOT(axoChanged(int)));
connect(ui->flip, SIGNAL(clicked()), this, SLOT(axo_flip()));
connect(ui->axoScale, SIGNAL(editingFinished()), this, SLOT(axoScale()));

//these matrices contain information relating relative position on page to which view appears there, and in which orientation

//first matrix is for front, right, back, left. Only needs to contain positions above and below primary since in positions horizontally
Expand Down Expand Up @@ -762,15 +764,25 @@ void TaskOrthoViews::autodims()

void TaskOrthoViews::compute()
{
float temp_scale = scale;
if (autoscale)
autodims();

for (int i = 0; i < 4; i++)
{
views[i]->setScale(scale);
if (i == axo && i > 0)
{
if (temp_scale == ui->axoScale->text().toFloat())
{
views[i]->setScale(scale); // only update the axonometric scale if it wasn't manually changed
ui->axoScale->setText(QString::number(scale));
}
}
else
views[i]->setScale(scale);

views[i]->setPos(x_pos + view_status[i][2] * horiz, y_pos + view_status[i][3] * vert);
}

Command::updateActive();
Command::commitCommand();
}
Expand Down Expand Up @@ -845,6 +857,7 @@ void TaskOrthoViews::cb_toggled(bool toggle)
{
axo = i;
ui->tabWidget->setTabEnabled(1,true);
ui->axoScale->setText(QString::number(scale));
set_axo();
}
else
Expand Down Expand Up @@ -1055,6 +1068,22 @@ void TaskOrthoViews::axoChanged(int i)
}


void TaskOrthoViews::axoScale()
{
bool ok;
QString temp = ui->axoScale->text();

float value = temp.toFloat(&ok);
if (ok)
{
views[axo]->setScale(value);
compute();
}
else
ui->axoScale->setText(temp);
}


void TaskOrthoViews::set_axo()
{
float v[3];
Expand Down Expand Up @@ -1132,7 +1161,7 @@ void TaskOrthoViews::toggle_auto(int i)

void TaskOrthoViews::data_entered()
{
Command::doCommand(Command::Doc,"#1");
//Command::doCommand(Command::Doc,"#1");
bool ok;

QString name = sender()->objectName().right(1);
Expand All @@ -1149,7 +1178,6 @@ void TaskOrthoViews::data_entered()
return;
}
compute();
Command::doCommand(Command::Doc,"#2");
}


Expand All @@ -1168,6 +1196,11 @@ bool TaskOrthoViews::user_input()
break; //stop checking
}
}
if (ui->axoScale->isModified())
{
ui->axoScale->setModified(false);
modified = true;
}
return modified;
}

Expand Down
1 change: 1 addition & 0 deletions src/Mod/Drawing/Gui/TaskOrthoViews.h
Expand Up @@ -99,6 +99,7 @@ protected Q_SLOTS:
void axoChanged(int);
void axoTopChanged(int);
void axo_flip();
void axoScale();

protected:
void changeEvent(QEvent *);
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Drawing/Gui/TaskOrthoViews.ui
Expand Up @@ -636,7 +636,7 @@
<item row="3" column="1">
<widget class="QLineEdit" name="axoScale">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down

0 comments on commit 7348d0d

Please sign in to comment.