Attacher: UI improve status message display
Before, message used to display 'Selection accepted', when attachment actually failed. Shouldn't happen anymore.
This commit is contained in:
parent
a392927750
commit
ebd5414a61
|
@ -29,6 +29,7 @@
|
|||
# include <QTextStream>
|
||||
# include <QMessageBox>
|
||||
# include <Precision.hxx>
|
||||
# include <Standard_Failure.hxx>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -221,6 +222,7 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
|
|||
|
||||
updateUI();
|
||||
updateListOfModes(eMapMode(pcDatum->MapMode.getValue()));
|
||||
updatePreview();
|
||||
|
||||
//temporary show coordinate systems for selection
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf(DatumView->getObject());
|
||||
|
@ -288,17 +290,8 @@ const QString makeHintText(std::set<eRefType> hint)
|
|||
return result;
|
||||
}
|
||||
|
||||
void TaskDatumParameters::updateUI(std::string message, bool error)
|
||||
void TaskDatumParameters::updateUI()
|
||||
{
|
||||
//set text if available
|
||||
if(!message.empty()) {
|
||||
ui->message->setText(QString::fromStdString(message));
|
||||
if(error)
|
||||
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: red;}"));
|
||||
else
|
||||
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: green;}"));
|
||||
}
|
||||
|
||||
ui->checkBoxFlip->setVisible(false);
|
||||
|
||||
ui->labelOffset->setVisible(true);
|
||||
|
@ -326,8 +319,9 @@ void TaskDatumParameters::updateUI(std::string message, bool error)
|
|||
pcDatum->attacher().suggestMapModes(this->lastSuggestResult);
|
||||
|
||||
if (this->lastSuggestResult.message != SuggestResult::srOK) {
|
||||
if(this->lastSuggestResult.nextRefTypeHint.size() > 0)
|
||||
message = "Need more references";
|
||||
if(this->lastSuggestResult.nextRefTypeHint.size() > 0){
|
||||
//message = "Need more references";
|
||||
}
|
||||
} else {
|
||||
completed = true;
|
||||
}
|
||||
|
@ -345,6 +339,36 @@ void TaskDatumParameters::updateUI(std::string message, bool error)
|
|||
updateRefButton(3);
|
||||
}
|
||||
|
||||
bool TaskDatumParameters::updatePreview()
|
||||
{
|
||||
Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
|
||||
QString errMessage;
|
||||
try{
|
||||
pcDatum->positionBySupport();
|
||||
} catch (Base::Exception &err){
|
||||
errMessage = QString::fromLatin1(err.what());
|
||||
} catch (Standard_Failure &err){
|
||||
errMessage = tr("OCC error: %1").arg(QString::fromLatin1(err.GetMessageString()));
|
||||
} catch (...) {
|
||||
errMessage = tr("unknown error");
|
||||
}
|
||||
if (errMessage.length()>0){
|
||||
ui->message->setText(tr("Attachment mode failed: %1").arg(errMessage));
|
||||
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: red;}"));
|
||||
return false;
|
||||
} else {
|
||||
if (pcDatum->MapMode.getValue() == mmDeactivated){
|
||||
ui->message->setText(tr("Not attached"));
|
||||
ui->message->setStyleSheet(QString());
|
||||
} else {
|
||||
std::vector<QString> strs = AttacherGui::getUIStrings(pcDatum->attacher().getTypeId(),eMapMode(pcDatum->MapMode.getValue()));
|
||||
ui->message->setText(tr("Attached with mode %1").arg(strs[0]));
|
||||
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: green;}"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QLineEdit* TaskDatumParameters::getLine(unsigned idx)
|
||||
{
|
||||
switch(idx) {
|
||||
|
@ -399,23 +423,23 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
}
|
||||
|
||||
bool error = false;
|
||||
std::string message("Selection accepted");
|
||||
try {
|
||||
pcDatum->Support.setValues(refs, refnames);
|
||||
updateListOfModes();
|
||||
eMapMode mmode = getActiveMapMode();//will be mmDeactivated, if no modes are available
|
||||
if(mmode == mmDeactivated){
|
||||
message = "Selection invalid";
|
||||
error = true;
|
||||
this->completed = false;
|
||||
} else {
|
||||
this->completed = true;
|
||||
}
|
||||
pcDatum->MapMode.setValue(mmode);
|
||||
updatePreview();
|
||||
}
|
||||
catch(Base::Exception& e) {
|
||||
error = true;
|
||||
message = std::string(e.what());
|
||||
ui->message->setText(QString::fromLatin1(e.what()));
|
||||
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: red;}"));
|
||||
}
|
||||
|
||||
QLineEdit* line = getLine(iActiveRef);
|
||||
|
@ -436,7 +460,7 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
}
|
||||
}
|
||||
|
||||
updateUI(message, error);
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,6 +555,7 @@ void TaskDatumParameters::onModeSelect()
|
|||
{
|
||||
Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
|
||||
pcDatum->MapMode.setValue(getActiveMapMode());
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
void TaskDatumParameters::onRefName(const QString& text, unsigned idx)
|
||||
|
@ -556,6 +581,8 @@ void TaskDatumParameters::onRefName(const QString& text, unsigned idx)
|
|||
updateListOfModes();
|
||||
pcDatum->MapMode.setValue(getActiveMapMode());
|
||||
|
||||
updatePreview();
|
||||
|
||||
// Update the UI
|
||||
std::vector<QString> refstrings;
|
||||
makeRefStrings(refstrings, newrefnames);
|
||||
|
|
|
@ -92,7 +92,13 @@ private:
|
|||
void resetViewMode();
|
||||
void objectDeleted(const Gui::ViewProviderDocumentObject&);
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
void updateUI(std::string message = std::string(), bool isWarning = false);
|
||||
void updateUI();
|
||||
|
||||
/**
|
||||
* @brief updatePreview: calculate attachment, update 3d view, update status message
|
||||
* @return true if attachment calculation was successful, false otherwise
|
||||
*/
|
||||
bool updatePreview();
|
||||
|
||||
void makeRefStrings(std::vector<QString>& refstrings, std::vector<std::string>& refnames);
|
||||
QLineEdit* getLine(unsigned idx);
|
||||
|
|
Loading…
Reference in New Issue
Block a user