Config_Prop::Double,
ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+ Config_PropManager::registerProp("Visualization", "default_transparency",
+ "Default transparency", Config_Prop::Double, "0");
+
}
return MY_MANAGER;
}
<qresource>
<file>icons/activate.png</file>
<file>icons/angle_32x32.png</file>
- <file>icons/color.png</file>
<file>icons/concealed_on.png</file>
<file>icons/concealed_off.png</file>
<file>icons/deactivate.png</file>
aAction = ModuleBase_Tools::createAction(QIcon(""), tr("Deflection..."), aDesktop);
addAction("DEFLECTION_CMD", aAction);
-#ifdef USE_TRANSPARENCY
aAction = ModuleBase_Tools::createAction(QIcon(":pictures/transparency.png"),
tr("Transparency..."), aDesktop);
addAction("TRANSPARENCY_CMD", aAction);
-#endif
aAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), aDesktop);
addAction("SHOW_CMD", aAction);
action("COLOR_CMD")->setEnabled(myWorkshop->canChangeProperty("COLOR_CMD"));
action("DEFLECTION_CMD")->setEnabled(myWorkshop->canChangeProperty("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
action("TRANSPARENCY_CMD")->setEnabled(myWorkshop->canChangeProperty("TRANSPARENCY_CMD"));
-#endif
#ifdef _DEBUG
#ifdef TINSPECTOR
action("TINSPECTOR_VIEW")->setEnabled(true);
if (myWorkshop->canChangeProperty("DEFLECTION_CMD"))
action("DEFLECTION_CMD")->setEnabled(true);
-#ifdef USE_TRANSPARENCY
if (myWorkshop->canChangeProperty("TRANSPARENCY_CMD"))
action("TRANSPARENCY_CMD")->setEnabled(true);
-#endif
action("DELETE_CMD")->setEnabled(true);
}
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
aList.append(action("TRANSPARENCY_CMD"));
-#endif
aList.append(action("SHOW_FEATURE_CMD"));
aList.append(mySeparator2);
aList.append(action("DELETE_CMD"));
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
aList.append(action("TRANSPARENCY_CMD"));
-#endif
aList.append(action("SHOW_FEATURE_CMD"));
aList.append(mySeparator3);
aList.append(action("DELETE_CMD"));
aList.append(mySeparator1);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
aList.append(action("TRANSPARENCY_CMD"));
-#endif
myViewerMenu[ModelAPI_ResultConstruction::group()] = aList;
// Result part menu
myViewerMenu[ModelAPI_ResultPart::group()] = aList;
aList.append(mySeparator2);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
aList.append(action("TRANSPARENCY_CMD"));
-#endif
myViewerMenu[ModelAPI_ResultBody::group()] = aList;
// Group menu
myViewerMenu[ModelAPI_ResultGroup::group()] = aList;
//aActions.append(action("MOVE_CMD"));
aActions.append(action("COLOR_CMD"));
aActions.append(action("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
aActions.append(action("TRANSPARENCY_CMD"));
-#endif
aActions.append(action("CLEAN_HISTORY_CMD"));
aActions.append(action("DELETE_CMD"));
}
aActions.append(action("HIDEALL_CMD"));
aActions.append(action("COLOR_CMD"));
aActions.append(action("DEFLECTION_CMD"));
-#ifdef USE_TRANSPARENCY
aActions.append(action("TRANSPARENCY_CMD"));
-#endif
theMenu->addActions(aActions);
QMap<int, QAction*> aMenuActions;
double getDefaultTransparency(const ResultPtr& theResult)
{
- return 0;
+ return Config_PropManager::real("Visualization", "default_transparency");
}
XGUI_CustomPrs::XGUI_CustomPrs(XGUI_Workshop* theWorkshop)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <XGUI_PropertyDialog.h>
+#include "XGUI_PropertyDialog.h"
+#include <ModuleBase_Tools.h>
#include <QDialogButtonBox>
#include <QLabel>
#include <QCheckBox>
#include <QDoubleSpinBox>
+#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
XGUI_TransparencyWidget::XGUI_TransparencyWidget(QWidget* theParent, const QString& theLabelText)
: QWidget(theParent)
{
- QHBoxLayout* aLay = new QHBoxLayout(this);
+ QVBoxLayout* aLay = new QVBoxLayout(this);
aLay->setContentsMargins(0, 0, 0, 0);
- mySpinValue = new QDoubleSpinBox(this);
- mySpinValue->setRange(0, 1);
- mySpinValue->setSingleStep(0.1);
- mySliderValue = new QSlider(Qt::Horizontal, this);
- mySliderValue->setRange(0, 100);
+ QWidget* aInfoWgt = new QWidget(this);
+ QHBoxLayout* aInfoLay = new QHBoxLayout(aInfoWgt);
+ aInfoLay->setContentsMargins(0, 0, 0, 0);
+
+ aInfoLay->addWidget(new QLabel(tr("Opaque")));
+
+ myValLbl = new QLabel("0%", aInfoWgt);
+ myValLbl->setAlignment(Qt::AlignCenter);
+ aInfoLay->addWidget(myValLbl, 1);
- myPreview = new QCheckBox("Preview", this);
- myPreview->setChecked(true);
+ aInfoLay->addWidget(new QLabel(tr("Transparent")));
+ aLay->addWidget(aInfoWgt);
- if (!theLabelText.isEmpty())
- aLay->addWidget(new QLabel(theLabelText, this));
- aLay->addWidget(mySpinValue);
+ mySliderValue = new QSlider(Qt::Horizontal, this);
+ mySliderValue->setRange(0, 100);
aLay->addWidget(mySliderValue);
- aLay->addWidget(myPreview);
- connect(mySpinValue, SIGNAL(valueChanged(double)), this, SLOT(onSpinValueChanged(double)));
connect(mySliderValue, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
- connect(myPreview, SIGNAL(toggled(bool)), this, SIGNAL(previewStateChanged()));
}
void XGUI_TransparencyWidget::setValue(double theValue)
{
- bool isSpinBlocked = mySpinValue->blockSignals(true);
bool isSliderBlocked = mySliderValue->blockSignals(true);
-
- mySpinValue->setValue(theValue);
- mySliderValue->setValue(theValue * 100);
-
- mySpinValue->blockSignals(isSpinBlocked);
+ int aVal = theValue * 100;
+ mySliderValue->setValue(aVal);
+ myValLbl->setText(QString("%1%").arg(aVal));
mySliderValue->blockSignals(isSliderBlocked);
}
double XGUI_TransparencyWidget::getValue() const
{
- return mySpinValue->value();
-}
-
-bool XGUI_TransparencyWidget::isPreviewNeeded() const
-{
- return myPreview->isChecked();
-}
-
-void XGUI_TransparencyWidget::onSpinValueChanged(double theValue)
-{
- setValue(theValue);
- emit transparencyValueChanged();
+ return mySliderValue->value() / 100.;
}
void XGUI_TransparencyWidget::onSliderValueChanged(int theValue)
{
- setValue((double)theValue / 100);
+ myValLbl->setText(QString("%1%").arg(theValue));
emit transparencyValueChanged();
}
#include <QWidget>
-class QDoubleSpinBox;
class QSlider;
-class QCheckBox;
+class QLabel;
/**
* \ingroup GUI
/// \return value
double getValue() const;
- /// Returns true if the value should be applyed immediatelly
- /// \return state of preview check control
- bool isPreviewNeeded() const;
-
signals:
void transparencyValueChanged();
- void previewStateChanged();
private slots:
- /// Update slider value by spin value
- /// \param theValue the new spin value
- void onSpinValueChanged(double theValue);
-
/// Update spin value by slider value
/// \param theValue the new slider value
void onSliderValueChanged(int theValue);
private:
- QDoubleSpinBox* mySpinValue; /// value control
QSlider* mySliderValue; /// slider to select value
- QCheckBox* myPreview; /// do preview immediatelly
+ QLabel* myValLbl;
};
#endif
changeColor(aObjects);
else if (theId == "DEFLECTION_CMD")
changeDeflection(aObjects);
-#ifdef USE_TRANSPARENCY
else if (theId == "TRANSPARENCY_CMD")
changeTransparency(aObjects);
-#endif
else if (theId == "SHOW_CMD") {
showObjects(aObjects, true);
mySelector->updateSelectionBy(ModuleBase_ISelection::Browser);
bool XGUI_Workshop::canChangeProperty(const QString& theActionName) const
{
if (theActionName == "COLOR_CMD" ||
- theActionName == "DEFLECTION_CMD"
-#ifdef USE_TRANSPARENCY
- || theActionName == "TRANSPARENCY_CMD"
-#endif
- ) {
+ theActionName == "DEFLECTION_CMD" ||
+ theActionName == "TRANSPARENCY_CMD") {
QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
std::set<std::string> aTypes;
if (aResult.get()) {
aCurrentValue = XGUI_CustomPrs::getResultTransparency(aResult);
}
- else {
- // TODO: remove the obtaining a property from the AIS object
- // this does not happen never because:
- // 1. The property can be changed only on results
- // 2. The result can be not visualized in the viewer(e.g. Origin Construction)
- AISObjectPtr anAISObj = myDisplayer->getAISObject(anObject);
- if (anAISObj.get()) {
- aCurrentValue = anAISObj->getDeflection();
- }
- }
if (aCurrentValue > 0)
break;
}
return;
if (!abortAllOperations())
- return;
+ return;
// 2. show the dialog to change the value
XGUI_PropertyDialog* aDlg = new XGUI_PropertyDialog(desktop());
XGUI_TransparencyWidget* aTransparencyWidget = new XGUI_TransparencyWidget(aDlg);
connect(aTransparencyWidget, SIGNAL(transparencyValueChanged()),
this, SLOT(onTransparencyValueChanged()));
- connect(aTransparencyWidget, SIGNAL(previewStateChanged()),
- this, SLOT(onPreviewStateChanged()));
aDlg->setContent(aTransparencyWidget);
aTransparencyWidget->setValue(aCurrentValue);
QString aDescription = contextMenuMgr()->action("TRANSPARENCY_CMD")->text();
aMgr->startOperation(aDescription.toStdString());
- aDlg->move(QCursor::pos());
- bool isDone = aDlg->exec() == QDialog::Accepted;
- if (!isDone)
+ if (aDlg->exec() != QDialog::Accepted)
return;
// 4. set the value to all results
void XGUI_Workshop::onTransparencyValueChanged()
{
XGUI_TransparencyWidget* aTransparencyWidget = (XGUI_TransparencyWidget*)sender();
- if (!aTransparencyWidget || !aTransparencyWidget->isPreviewNeeded())
- return;
-
- QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
- setTransparency(aTransparencyWidget->getValue(), anObjects);
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-}
-
-//**************************************************************
-void XGUI_Workshop::onPreviewStateChanged()
-{
- XGUI_TransparencyWidget* aTransparencyWidget = (XGUI_TransparencyWidget*)sender();
- if (!aTransparencyWidget || !aTransparencyWidget->isPreviewNeeded())
+ if (!aTransparencyWidget)
return;
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
/// Apply the current transparency value if preview in transparency dialog is switched on
void onTransparencyValueChanged();
- /// Switch on/off preview of transparency change
- void onPreviewStateChanged();
-
protected:
/// Sets the granted operations for the parameter operation. Firstly, it finds the nested features
/// and set them into the operation. Secondly, it asks the module about ids of granted operations.
<file>pictures/arrow-up.png</file>
<file>pictures/arrow-down.png</file>
<file>pictures/configure_toolbars.png</file>
+ <file>pictures/color.png</file>
</qresource>
</RCC>