-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PartSet_WidgetSketchCreator.cpp
-// Created: 08 June 2015
-// Author: Vitaly SMETANNIKOV
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include "PartSet_WidgetSketchCreator.h"
#include "PartSet_Module.h"
#include <QLabel>
#include <QLineEdit>
+#include <QDoubleValidator>
//#include <QFormLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#define DEBUG_UNDO_INVALID_SKETCH
-PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
+PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
PartSet_Module* theModule,
const Config_WidgetAPI* theData)
: ModuleBase_WidgetSelector(theParent, theModule->workshop(), theData),
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
+ // Size of the View control
+ mySizeOfViewWidget = new QWidget(this);
+ QHBoxLayout* aSizeLayout = new QHBoxLayout(mySizeOfViewWidget);
+ aSizeLayout->addWidget(new QLabel(tr("Size of the view"), mySizeOfViewWidget));
+ mySizeOfView = new QLineEdit(mySizeOfViewWidget);
+
+ QDoubleValidator* aValidator = new QDoubleValidator(0, DBL_MAX, 12, mySizeOfView);
+ aValidator->setLocale(ModuleBase_Tools::doubleLocale());
+ aValidator->setNotation(QDoubleValidator::StandardNotation);
+ mySizeOfView->setValidator(aValidator);
+ aSizeLayout->addWidget(mySizeOfView);
+
myLabel = new QLabel(aLabelText, this);
myLabel->setWordWrap(true);
+
+ aLayout->addWidget(mySizeOfViewWidget);
aLayout->addWidget(myLabel);
aLayout->addStretch(1);
void PartSet_WidgetSketchCreator::activateSelectionControl()
{
+ // reset previously set size of view needed on restart extrusion after Sketch
+ if (myModule->sketchMgr()->previewSketchPlane()->isUseSizeOfView())
+ myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(0, false);
+
// we need to call activate here as the widget has no focus accepted controls
// if these controls are added here, activate will happens automatically after focusIn()
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
if (!aBodyIsVisualized && !aSketchIsVisualized) {
// We have to select a plane before any operation
myPreviewPlanes->showPreviewPlanes(myWorkshop);
+ mySizeOfViewWidget->setVisible(true);
+ }
+ else {
+ mySizeOfViewWidget->setVisible(false);
}
+
} else {
bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
myPreviewPlanes->erasePreviewPlanes(myWorkshop);
bool aDone = false;
if (!startSketchOperation(theValues)) {
myIsCustomAttribute = true;
- QList<ModuleBase_ViewerPrsPtr>::const_iterator
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator
anIt = theValues.begin(), aLast = theValues.end();
bool aProcessed = false;
for (; anIt != aLast; anIt++) {
emit valuesChanged();
updateObject(myFeature);
setVisibleSelectionControl(false);
- // manually deactivation because the widget was
+ // manually deactivation because the widget was
// not activated as has no focus acceptin controls
deactivate();
emit focusOutWidget(this);
}
//********************************************************************
-void PartSet_WidgetSketchCreator::onSelectionChanged()
+bool PartSet_WidgetSketchCreator::processSelection()
{
QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
bool isDone = setSelection(aSelected, true/*false*/);
+
+ return isDone;
}
//********************************************************************
/// sketch should not started by object(face) selected as global. If Local face is selected,
/// sketch is started
if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
- ResultConstructionPtr aConstruction =
+ ResultConstructionPtr aConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
if (!aConstruction.get() || !aConstruction->isInfinite())
return aSketchStarted;
}
aSketchStarted = true;
-
+ // Set View size if a plane is selected
+ if (myPreviewPlanes->isPreviewDisplayed() &&
+ myPreviewPlanes->isPreviewShape(aValue->shape())) {
+ // set default plane size
+ bool isSetSizeOfView = false;
+ double aSizeOfView = 0;
+ QString aSizeOfViewStr = mySizeOfView->text();
+ if (!aSizeOfViewStr.isEmpty()) {
+ aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
+ if (isSetSizeOfView && aSizeOfView <= 0) {
+ isSetSizeOfView = false;
+ }
+ }
+ if (isSetSizeOfView)
+ myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
+ }
// manually deactivation because the widget was not activated as has no focus acceptin controls
deactivate();
bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
myPreviewPlanes->erasePreviewPlanes(myWorkshop);
- // Launch Sketch operation
- CompositeFeaturePtr aCompFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
-
// start edit operation for the sketch
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myModule->createOperation("Sketch"));
return true;
}
else
- connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)),
+ connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)),
SLOT(onResumed(ModuleBase_Operation*)));
return true;
// Validate the created sketch. If it is valid, it is set into the composite feature selection
// list, otherwise it is removed
- CompositeFeaturePtr aCompFeature =
+ CompositeFeaturePtr aCompFeature =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
if (aCompFeature->numberOfSubs() > 0) {
aMgr->startOperation("Delete invalid Sketch feature", false);
// delete invalid sketch
- CompositeFeaturePtr aSketchFeature =
+ CompositeFeaturePtr aSketchFeature =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
QObjectPtrList anObjects;
anObjects.append(aSketchFeature);
}
// Hide sketcher result
- CompositeFeaturePtr aSketchFeature =
+ CompositeFeaturePtr aSketchFeature =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
std::list<ResultPtr> aResults = aSketchFeature->results();
std::list<ResultPtr>::const_iterator aIt;
}
ResultPtr aSketchRes = aSketchFeature->results().front();
- ResultConstructionPtr aConstruction =
+ ResultConstructionPtr aConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
if(!aConstruction.get()) {
return;