#include <sstream>
#include <iterator>
+#include <iostream>
+
#ifdef TINSPECTOR
#include <Model_Session.h>
#include <TDocStd_Application.hxx>
aFOperation->setGrantedOperationIds(aGrantedIds);
}
+//******************************************************
+void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomShapePtr>>& theSelectedObjects, int theThickness)
+{
+ const bool isSubShapeWithEdgeThickness = Config_PropManager::boolean("Visualization", "result_subshape_with_edge_thickness");
+
+ // 3. Abort previous operation and start a new one.
+ SessionPtr session = ModelAPI_Session::get();
+ QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text();
+ session->startOperation(description.toStdString());
+
+ // 4. Set new value to all results and subshapes of results.
+ foreach(ResultPtr result, theSelectedObjects.keys()) {
+ if (!result)
+ continue;
+
+ ResultBodyPtr bodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(result);
+ foreach(GeomShapePtr shape, theSelectedObjects[result]) {
+ if (result->shape()->impl<TopoDS_Shape>().IsEqual(shape->impl<TopoDS_Shape>()) || !isSubShapeWithEdgeThickness) {
+ if (result) {
+ // Change edge thickness for all sub-solids.
+ std::list<ResultPtr> allSubResults;
+ ModelAPI_Tools::allSubs(bodyResult, allSubResults);
+ for (auto itSubRes = allSubResults.begin(); itSubRes != allSubResults.end(); itSubRes++) {
+ ModelAPI_Tools::setEdgeThickness(*itSubRes, theThickness);
+ }
+
+ ModelAPI_Tools::setEdgeThickness(result, theThickness);
+ }
+
+ if (!isSubShapeWithEdgeThickness)
+ break;
+ }
+ else if (!shape->isNull())
+ ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, theThickness);
+ }
+ }
+
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ session->finishOperation();
+ updateCommandStatus();
+ myViewerProxy->update();
+}
+
//******************************************************
void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
{
const auto dialog = new XGUI_PropertyDialog(desktop());
dialog->setWindowTitle(tr("Edge Thickness"));
XGUI_EdgeThicknessWidget* edgeThicknessWidget = new XGUI_EdgeThicknessWidget(dialog);
- connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged()), this, SLOT(onEdgeThicknessValueChanged()));
+ mySelectedObjects = theSelectedObjects;
+ connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged(int)), this, SLOT(onEdgeThicknessValueChanged(int)));
dialog->setContent(edgeThicknessWidget);
edgeThicknessWidget->setValue(thickness);
if (dialog->exec() != QDialog::Accepted)
- return;
-
- // 3. Abort previous operation and start a new one.
- SessionPtr session = ModelAPI_Session::get();
- QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text();
- session->startOperation(description.toStdString());
-
- // 4. Set new value to all results and subshapes of results.
- int newThickness = edgeThicknessWidget->getValue();
- foreach(ResultPtr result, theSelectedObjects.keys()) {
- if (!result)
- continue;
-
- ResultBodyPtr bodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(result);
- foreach(GeomShapePtr shape, theSelectedObjects[result]) {
- if (result->shape()->impl<TopoDS_Shape>().IsEqual(shape->impl<TopoDS_Shape>()) || !isSubShapeWithEdgeThickness) {
- if (result) {
- // Change edge thickness for all sub-solids.
- std::list<ResultPtr> allSubResults;
- ModelAPI_Tools::allSubs(bodyResult, allSubResults);
- for (auto itSubRes = allSubResults.begin(); itSubRes != allSubResults.end(); itSubRes++) {
- ModelAPI_Tools::setEdgeThickness(*itSubRes, newThickness);
- }
-
- ModelAPI_Tools::setEdgeThickness(result, newThickness);
- }
-
- if (!isSubShapeWithEdgeThickness)
- break;
- }
- else if (!shape->isNull())
- ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, newThickness);
- }
- }
-
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- session->finishOperation();
- updateCommandStatus();
- myViewerProxy->update();
+ applyEdgeThicknessToCanvas(theSelectedObjects, thickness);
}
//**************************************************************
-void XGUI_Workshop::onEdgeThicknessValueChanged()
+void XGUI_Workshop::onEdgeThicknessValueChanged(int theThickness)
{
+ // std::cout << "XGUI_Workshop::onEdgeThicknessValueChanged(" << theThickness << ")" << std::endl;
+
+ /*
XGUI_EdgeThicknessWidget* aWidget = (XGUI_EdgeThicknessWidget*)sender();
if (!aWidget)
return;
Events_Loop::loop()->flush(kRedisplayEvent);
myViewerProxy->update();
+ */
+
+
+ applyEdgeThicknessToCanvas(mySelectedObjects, theThickness);
}
//******************************************************
/// Apply the current transparency value if preview in transparency dialog is switched on
void onTransparencyValueChanged();
- void onEdgeThicknessValueChanged();
+ void onEdgeThicknessValueChanged(int theThickness);
protected:
/// Sets the granted operations for the parameter operation. Firstly, it finds the nested features
void setGrantedFeatures(ModuleBase_Operation* theOperation);
private:
+ void applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomShapePtr>>& theSelectedObjects, int theThickness);
+
/// Display results from document
/// \param theDoc a document
void displayDocumentResults(DocumentPtr theDoc);
Config_DataModelReader* myDataModelXMLReader; ///< XML reader of data model
XGUI_InspectionPanel* myInspectionPanel; ///< container of feature attributes widgets
QTemporaryDir myTmpDir; ///< a direcory for uncompressed files
+
+ QMap<std::shared_ptr<ModelAPI_Result>, QList<std::shared_ptr<GeomAPI_Shape>>> mySelectedObjects;
};
#endif