+++ /dev/null
-@ECHO OFF
-
-REM Find absolute path to ROOT_DIR
-@SET PARENT_DIR=%~dp0..
-@SET ROOT_DIR=
-pushd %PARENT_DIR%
-@SET ROOT_DIR=%CD%
-popd
-
-@SET SRC_DIR=%ROOT_DIR%\sources
-@SET OCC_LIB_PREFIX=d
-
-call %SRC_DIR%\msvc9_env_Salome.bat d
-mkdir %ROOT_DIR%\build
-cd %ROOT_DIR%\build
-
-cmake %SRC_DIR% -G "Visual Studio 9 2008" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
-
-start "" %MSVC_EXE% NewGEOM.sln
+++ /dev/null
-@ECHO OFF
-
-REM Find absolute path to ROOT_DIR
-@SET PARENT_DIR=%~dp0..
-@SET ROOT_DIR=
-pushd %PARENT_DIR%
-@SET ROOT_DIR=%CD%
-popd
-
-@SET SRC_DIR=%ROOT_DIR%\sources
-
-call %SRC_DIR%\msvc9_env_Salome.bat
-mkdir %ROOT_DIR%\build
-cd %ROOT_DIR%\build
-
-cmake %SRC_DIR% -G "Visual Studio 9 2008" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
-
-start "" %MSVC_EXE% NewGEOM.sln
+++ /dev/null
-@echo off
-
-IF NOT EXIST "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" GOTO ERROR1
-
-@REM Load local settings from file localenv.bat that should be located in the root directory
-if "%ROOT_DIR%" == "" (
- set ROOT_DIR=%~dp0..
-)
-
-if exist "%ROOT_DIR%\localenv.bat" (
- echo Setting local environment from %ROOT_DIR%\localenv.bat
- call "%ROOT_DIR%\localenv.bat"
-) else (
- echo Warning: file %ROOT_DIR%\localenv.bat does not exist; using default environment
-)
-
-if "%SALOME_ROOT_DIR%" == "" (
- set SALOME_ROOT_DIR=%ROOT_DIR%\SALOME
-)
-
-if "%SOLVESPACE_ROOT_DIR%" == "" (
- @SET SOLVESPACE_ROOT_DIR=%ROOT_DIR%\products\solvespace-2.0
-)
-
-call %SALOME_ROOT_DIR%\WORK\set_env.bat %1
-call "%PDIR%\env_compile.bat"
-
-
-@REM -------------------------
-@REM Python
-@SET PYTHON_LIB_DIR=%PYTHON_ROOT_DIR%\libs
-@SET PYTHON_INC_DIR=%PYTHON_ROOT_DIR%\include
-@REM -------------------------
-
-@REM -------------------------
-@REM CASCADE
-@SET PATH=%CASROOT%;%CASROOT%\win32\bin%OCC_LIB_PREFIX%;%PATH%
-@SET LIB=%CASROOT%\win32\lib%OCC_LIB_PREFIX%;%LIB%
-@set CSF_MDTVFontDirectory=%CASROOT%\src\FontMFT
-@set CSF_LANGUAGE=us
-@set MMGT_CLEAR=1
-@set CSF_EXCEPTION_PROMPT=1
-@set CSF_SHMessage=%CASROOT%\src\SHMessage
-@set CSF_MDTVTexturesDirectory=%CASROOT%\src\Textures
-@set CSF_XSMessage=%CASROOT%\src\XSMessage
-@set CSF_StandardDefaults=%CASROOT%\src\StdResource
-@set CSF_PluginDefaults=%CASROOT%\src\StdResource
-@set CSF_XCAFDefaults=%CASROOT%\src\StdResource
-@set CSF_StandardLiteDefaults=%CASROOT%\src\StdResource
-@set CSF_UnitsLexicon=%CASROOT%\src\UnitsAPI\Lexi_Expr.dat
-@set CSF_UnitsDefinition=%CASROOT%\src\UnitsAPI\Units.dat
-@set CSF_IGESDefaults=%CASROOT%\src\XSTEPResource
-@set CSF_STEPDefaults=%CASROOT%\src\XSTEPResource
-@set CSF_XmlOcafResource=%CASROOT%\src\XmlOcafResource
-@REM -------------------------
-
-@REM -------------------------
-@REM Create launch path
-@SET PATH=%LIBXML2_ROOT_DIR%\bin;%PATH%
-@SET PATH=%PDIR%\tbb\bin;%PATH%
-@SET PATH=%PDIR%\freeimage-3.15.4\bin;%PATH%
-@SET PATH=%PDIR%\ftgl-2.1.3\bin;%PATH%
-@SET PATH=%PDIR%\freetype-2.4.11\bin;%PATH%
-@SET PATH=%PDIR%\gl2ps-1.3.8\bin;%PATH%
-@SET PATH=%PDIR%\qwt-5.2.1\lib;%PATH%
-@SET PATH=%SOLVESPACE_ROOT_DIR%\lib;%PATH%
-@REM -------------------------
-
-
-
-IF "%ARCH%" == "Win64" (
- call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" x64
-) ELSE (
- IF "%ARCH%" == "Win32" (
- call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" x86
- ) ELSE (
- echo Wrong architecture is used. Win32 or Win64 architecture is allowed only.
- echo Refer to the set_env.bat script.
- )
-)
-
-@SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins
-@SET PATH=%PATH%;%ROOT_DIR%\install\bin;%ROOT_DIR%\install\plugins
-
-@SET LightAppConfig=%ROOT_DIR%\install\share\salome\resources\newgeom;%GUI_ROOT_DIR%\share\salome\resources\gui
void Events_Loop::flush(const Events_ID& theID)
{
+ if (!myFlushActive)
+ return;
std::map<char*, Events_MessageGroup*>::iterator aMyGroup = myGroups.find(theID.eventText());
if (aMyGroup != myGroups.end()) { // really sends
Events_MessageGroup* aGroup = aMyGroup->second;
delete aGroup;
}
}
+
+void Events_Loop::activateFlushes(const bool theActivate)
+{
+ myFlushActive = theActivate;
+}
/// map from event ID to groupped messages (accumulated on flush)
std::map<char*, Events_MessageGroup*> myGroups;
+ /// to process flushes or not
+ bool myFlushActive;
+
//! The empty constructor, will be called at startup of the application, only once
- Events_Loop()
- {
- }
- ;
+ Events_Loop() : myFlushActive(true) {}
+
public:
///! Returns the main object of the loop, one per application.
EVENTS_EXPORT static Events_Loop* loop();
//! Initializes sending of a group-message by the given ID
EVENTS_EXPORT void flush(const Events_ID& theID);
+
+ //! Allows to disable flushes: needed in synchronization of document mechanism
+ //! (to synchronize all and only then flush create, update, etc in correct order)
+ EVENTS_EXPORT void activateFlushes(const bool theActivate);
};
#endif
ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
if (!aFaceRef)
return;
+ boost::shared_ptr<GeomAPI_Shape> aFace;
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
ModelAPI_ResultConstruction>(aFaceRef->value());
- if (!aConstr)
- return;
- boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
- if (!aFace)
+ if (aConstr) {
+ aFace = aConstr->shape();
+ }
+ if (!aFace) {
+ // Check for body
+ boost::shared_ptr<ModelAPI_ResultBody> aBody = boost::dynamic_pointer_cast<
+ ModelAPI_ResultBody>(aFaceRef->value());
+ if (aBody)
+ aFace = aBody->shape();
+ }
+ if (!aFace)
return;
double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
void Model_AttributeDocRef::setValue(boost::shared_ptr<ModelAPI_Document> theDoc)
{
+ myDoc = theDoc;
TCollection_ExtendedString aNewID(theDoc->id().c_str());
if (!myIsInitialized || myComment->Get() != aNewID) {
myComment->Set(TCollection_ExtendedString(theDoc->id().c_str()));
boost::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
{
- if (myComment->Get().Length())
- return Model_Application::getApplication()->getDocument(
- TCollection_AsciiString(myComment->Get()).ToCString());
- // not initialized
- return boost::shared_ptr<ModelAPI_Document>();
+ return myDoc;
}
Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
class Model_AttributeDocRef : public ModelAPI_AttributeDocRef
{
Handle_TDataStd_Comment myComment; ///< reference to document is identified as string-id
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document referenced by this attribute (if already loaded)
public:
/// Defines the document referenced from this attribute
MODEL_EXPORT virtual void setValue(boost::shared_ptr<ModelAPI_Document> theDoc);
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
+#include <TDataStd_UAttribute.hxx>
#include <TDF_ChildIDIterator.hxx>
#include <TDataStd_ReferenceArray.hxx>
#include <TDataStd_HLabelArray1.hxx>
if (isError) {
switch (aStatus) {
case PCDM_RS_UnknownDocument:
- Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownDocument"));
+ Events_Error::send(std::string("Can not open document: unknown format"));
break;
case PCDM_RS_AlreadyRetrieved:
- Events_Error::send(std::string("Can not open document: PCDM_RS_AlreadyRetrieved"));
+ Events_Error::send(std::string("Can not open document: already opened"));
break;
case PCDM_RS_AlreadyRetrievedAndModified:
Events_Error::send(
- std::string("Can not open document: PCDM_RS_AlreadyRetrievedAndModified"));
+ std::string("Can not open document: already opened and modified"));
break;
case PCDM_RS_NoDriver:
- Events_Error::send(std::string("Can not open document: PCDM_RS_NoDriver"));
+ Events_Error::send(std::string("Can not open document: driver library is not found"));
break;
case PCDM_RS_UnknownFileDriver:
- Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownFileDriver"));
+ Events_Error::send(std::string("Can not open document: unknown driver for opening"));
break;
case PCDM_RS_OpenError:
- Events_Error::send(std::string("Can not open document: PCDM_RS_OpenError"));
+ Events_Error::send(std::string("Can not open document: file open error"));
break;
case PCDM_RS_NoVersion:
- Events_Error::send(std::string("Can not open document: PCDM_RS_NoVersion"));
+ Events_Error::send(std::string("Can not open document: invalid version"));
break;
case PCDM_RS_NoModel:
- Events_Error::send(std::string("Can not open document: PCDM_RS_NoModel"));
+ Events_Error::send(std::string("Can not open document: no data model"));
break;
case PCDM_RS_NoDocument:
- Events_Error::send(std::string("Can not open document: PCDM_RS_NoDocument"));
+ Events_Error::send(std::string("Can not open document: no document inside"));
break;
case PCDM_RS_FormatFailure:
- Events_Error::send(std::string("Can not open document: PCDM_RS_FormatFailure"));
+ Events_Error::send(std::string("Can not open document: format failure"));
break;
case PCDM_RS_TypeNotFoundInSchema:
- Events_Error::send(std::string("Can not open document: PCDM_RS_TypeNotFoundInSchema"));
+ Events_Error::send(std::string("Can not open document: invalid object"));
break;
case PCDM_RS_UnrecognizedFileFormat:
- Events_Error::send(std::string("Can not open document: PCDM_RS_UnrecognizedFileFormat"));
+ Events_Error::send(std::string("Can not open document: unrecognized file format"));
break;
case PCDM_RS_MakeFailure:
- Events_Error::send(std::string("Can not open document: PCDM_RS_MakeFailure"));
+ Events_Error::send(std::string("Can not open document: make failure"));
break;
case PCDM_RS_PermissionDenied:
- Events_Error::send(std::string("Can not open document: PCDM_RS_PermissionDenied"));
+ Events_Error::send(std::string("Can not open document: permission denied"));
break;
case PCDM_RS_DriverFailure:
- Events_Error::send(std::string("Can not open document: PCDM_RS_DriverFailure"));
+ Events_Error::send(std::string("Can not open document: driver failure"));
break;
default:
Events_Error::send(std::string("Can not open document: unknown error"));
if (!isDone) {
switch (aStatus) {
case PCDM_SS_DriverFailure:
- Events_Error::send(std::string("Can not save document: PCDM_SS_DriverFailure"));
+ Events_Error::send(std::string("Can not save document: save driver-library failure"));
break;
case PCDM_SS_WriteFailure:
- Events_Error::send(std::string("Can not save document: PCDM_SS_WriteFailure"));
+ Events_Error::send(std::string("Can not save document: file writing failure"));
break;
case PCDM_SS_Failure:
default:
- Events_Error::send(std::string("Can not save document: PCDM_SS_Failure"));
+ Events_Error::send(std::string("Can not save document"));
break;
}
}
if (!myDoc->HasOpenCommand() && myNestedNum != -1)
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(false); // for nested transaction commit
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
if (!myDoc->HasOpenCommand() && myNestedNum != -1)
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(true); // for nested transaction commit
// after all updates, sends a message that groups of features were created or updated
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(false);
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->activateFlushes(false);
+
// update all objects by checking are they of labels or not
std::set<FeaturePtr> aNewFeatures, aKeptFeatures;
TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
ModelAPI_EventCreator::get()->sendDeleted(aThis, ModelAPI_Feature::group());
}
// results of this feature must be redisplayed (hided)
- static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
for (; aRIter != aResults.cend(); aRIter++) {
}
myExecuteFeatures = false;
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- if (theMarkUpdated)
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aLoop->activateFlushes(true);
+
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ if (theMarkUpdated) {
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ }
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(true);
myExecuteFeatures = true;
}
}
+static const Standard_GUID ID_CONSTRUCTION("b59fa408-8ab1-42b8-980c-af5adeebe7e4");
+static const Standard_GUID ID_BODY("c1148e9a-9b17-4e9c-9160-18e918fd0013");
+static const Standard_GUID ID_PART("1b3319b9-3e0a-4298-a1dc-3fb5aaf9be59");
+
boost::shared_ptr<ModelAPI_ResultConstruction> Model_Document::createConstruction(
const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
- ObjectPtr anOldObject = object(resultLabel(theFeatureData, theIndex));
+ TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+ TDataStd_UAttribute::Set(aLab, ID_CONSTRUCTION);
+ ObjectPtr anOldObject = object(aLab);
boost::shared_ptr<ModelAPI_ResultConstruction> aResult;
if (anOldObject) {
aResult = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anOldObject);
boost::shared_ptr<ModelAPI_ResultBody> Model_Document::createBody(
const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
- ObjectPtr anOldObject = object(resultLabel(theFeatureData, theIndex));
+ TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+ TDataStd_UAttribute::Set(aLab, ID_BODY);
+ ObjectPtr anOldObject = object(aLab);
boost::shared_ptr<ModelAPI_ResultBody> aResult;
if (anOldObject) {
aResult = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(anOldObject);
boost::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
- ObjectPtr anOldObject = object(resultLabel(theFeatureData, theIndex));
+ TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+ TDataStd_UAttribute::Set(aLab, ID_PART);
+ ObjectPtr anOldObject = object(aLab);
boost::shared_ptr<ModelAPI_ResultPart> aResult;
if (anOldObject) {
aResult = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(anOldObject);
int aResSize = theFeature->results().size();
TDF_ChildIterator aLabIter(resultLabel(theFeature->data(), 0).Father());
for(; aLabIter.More(); aLabIter.Next()) {
- // here must be at least Name
+ // here must be GUID of the feature
int aResIndex = aLabIter.Value().Tag() - 1;
- if (aLabIter.Value().FindChild(TAG_FEATURE_ARGUMENTS).HasAttribute() &&
- aResSize <= aResIndex)
- {
- ResultBodyPtr aNewBody = createBody(theFeature->data(), aResIndex);
- theFeature->setResult(aNewBody, aResIndex);
+ ResultPtr aNewBody;
+ if (aResSize <= aResIndex) {
+ TDF_Label anArgLab = aLabIter.Value();
+ if (anArgLab.IsAttribute(ID_BODY)) {
+ aNewBody = createBody(theFeature->data(), aResIndex);
+ } else if (anArgLab.IsAttribute(ID_PART)) {
+ aNewBody = createPart(theFeature->data(), aResIndex);
+ } else if (!anArgLab.IsAttribute(ID_CONSTRUCTION)) {
+ Events_Error::send("Unknown type of result if found in the document");
+ }
+ if (aNewBody) {
+ theFeature->setResult(aNewBody, aResIndex);
+ }
}
}
}
#include <Model_ResultPart.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_PluginManager.h>
boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
{
data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
}
}
+
+void Model_ResultPart::activate()
+{
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(DOC_REF());
+
+ if (!aDocRef->value()) { // create (or open) a document if it is not yet created
+ boost::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
+ if (aDoc) {
+ aDocRef->setValue(aDoc);
+ }
+ }
+ if (aDocRef->value())
+ ModelAPI_PluginManager::get()->setCurrentDocument(aDocRef->value());
+}
/// Part has no stored feature: this method returns NULL
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
- protected:
+ /// Sets this document as current and if it is not loaded yet, loads it
+ MODEL_EXPORT virtual void activate();
+
+protected:
/// makes a result on a temporary feature (an action)
Model_ResultPart();
#include <ModelAPI_Validator.h>
#include <Events_Loop.h>
#include <Events_LongOp.h>
+#include <Events_Error.h>
using namespace std;
!theFeature->isPersistentResult()) {
ModelAPI_ValidatorsFactory* aFactory = ModelAPI_PluginManager::get()->validators();
if (aFactory->validate(theFeature)) {
- theFeature->execute();
+ try {
+ theFeature->execute();
+ } catch(...) {
+ Events_Error::send(
+ "Feature " + theFeature->getKind() + " has failed during the execution");
+ theFeature->eraseResults();
+ }
} else {
theFeature->eraseResults();
}
class ModelAPI_Object
{
boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
- boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this object belongs to
public:
/// By default object is displayed in the object browser.
virtual bool isInHistory()
/// Returns the part-document of this result
virtual boost::shared_ptr<ModelAPI_Document> partDoc() = 0;
+
+ /// Sets this document as current and if it is not loaded yet, loads it
+ virtual void activate() = 0;
};
//! Pointer on feature object
ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
- double aX = myXSpin->value();
- double aY = myYSpin->value();
aPoint->setValue(myXSpin->value(), myYSpin->value());
updateObject(myFeature);
that->blockSignals(isBlocked);
aResult = document()->createPart(data());
setResult(aResult);
}
+ /*
boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aResult->data()->docRef(
ModelAPI_ResultPart::DOC_REF());
-
+
if (!aDocRef->value()) { // create a document if not yet created
boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
ModelAPI_PluginManager::get()->rootDocument();
aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
}
+ */
}
boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd()
AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
aData->attribute(SketchPlugin_Constraint::VALUE()));
- if (!anAttr_Value->isInitialized()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
- aData, SketchPlugin_Constraint::ENTITY_A());
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
- aData, SketchPlugin_Constraint::ENTITY_B());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_B());
- if (aPoint_A && aPoint_B) { // both points
- anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
- } else {
- if (!aPoint_A && aPoint_B) { //Line and point
- boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine)
- anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
- } else if (aPoint_A && !aPoint_B) { // Point and line
- boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine)
- anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
- }
+ if (aPoint_A && aPoint_B) { // both points
+ anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
+ } else {
+ if (!aPoint_A && aPoint_B) { //Line and point
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ if (aLine)
+ anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
+ } else if (aPoint_A && !aPoint_B) { // Point and line
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_B());
+ if (aLine)
+ anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
}
}
}
void SketchPlugin_ConstraintLength::execute()
{
- if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
- && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
- if (aFeature) {
- // set length value
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
-
- double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- aValueAttr->setValue(aLenght);
- }
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ // set length value
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+
+ double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ aValueAttr->setValue(aLenght);
}
}
void SketchPlugin_ConstraintRadius::execute()
{
- if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
- && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
- if (aFeature) {
- double aRadius = 0;
- boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
- if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
- AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
- if (anAttribute)
- aRadius = anAttribute->value();
- } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
- if (aCenterAttr && aStartAttr)
- aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
- }
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- aValueAttr->setValue(aRadius);
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ double aRadius = 0;
+ boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+ if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+ AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ if (anAttribute)
+ aRadius = anAttribute->value();
+ } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ if (aCenterAttr && aStartAttr)
+ aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
}
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ aValueAttr->setValue(aRadius);
}
}
// If the object is not a line then it is accepted
const ModelAPI_ResultValidator* aLineValidator =
- dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("Model_ResultLineValidator"));
+ dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultLineValidator"));
if (!aLineValidator->isValid(theObject))
return true;
<feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points" internal="1"/>
<feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object">
- <label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
- <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select an point in the viewer">
+ <label title="Select objects for distance difinition. Following objects can be accepted: point, line end point, line, center of circle or arc."/>
+ <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select point, line end point, line, center of circle or arc.">
<validator id="SketchPlugin_ResultPointValidator"/>
<validator id="SketchPlugin_ResultLineValidator"/>
</feature_or_attribute_selector>
- <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select an point in the viewer">
+ <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select point, line end point, line, center of circle or arc.">
<validator id="SketchPlugin_ResultPointValidator"/>
<validator id="SketchPlugin_ResultLineValidator"/>
<validator id="SketchPlugin_DistanceAttrValidator" parameters="ConstraintEntityA"/>
aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this);
addAction("SHOW_CMD", aAction);
+ aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), this);
+ addAction("SHOW_ONLY_CMD", aAction);
+
aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this);
addAction("HIDE_CMD", aAction);
}
} else {
if (aDisplayer->isVisible(aObject))
aMenu->addAction(action("HIDE_CMD"));
- else
+ else {
aMenu->addAction(action("SHOW_CMD"));
+ }
+ aMenu->addAction(action("SHOW_ONLY_CMD"));
}
} else { // If feature is 0 the it means that selected root object (document)
if (aMgr->currentDocument() != aMgr->rootDocument())
if (hasResult) {
aMenu->addAction(action("SHOW_CMD"));
aMenu->addAction(action("HIDE_CMD"));
+ aMenu->addAction(action("SHOW_ONLY_CMD"));
}
if (hasFeature)
aMenu->addAction(action("DELETE_CMD"));
updateViewer();
}
-/*void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
+void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
{
- Handle(AIS_InteractiveContext) ic = AISContext();
-
- AIS_ListOfInteractive aList;
- ic->DisplayedObjects(aList);
- AIS_ListIteratorOfListOfInteractive anIter(aList);
- for (; anIter.More(); anIter.Next()) {
- if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron)))
- continue;
-
- // erase an object
- Handle(AIS_InteractiveObject) anIO = anIter.Value();
- ic->Erase(anIO, false);
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ ResultToAISMap::iterator aIt;
+ for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+ // erase an object
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = (*aIt).second;
+ Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anIO.IsNull())
+ ic->Remove(anIO, false);
+ }
+ myResult2AISObjectMap.clear();
+ if (isUpdateViewer)
+ updateViewer();
}
- myResult2AISObjectMap.clear();
- if (isUpdateViewer)
- updateViewer();
- }*/
void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
{
/// Erase all presentations
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
- //void EraseAll(const bool isUpdateViewer = true);
+ void eraseAll(const bool isUpdateViewer = true);
/// Erase AIS interactive objects, which has an empty feature in the internal map
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void XGUI_OperationMgr::onCommitOperation()
{
ModuleBase_Operation* anOperation = currentOperation();
+ anOperation->onWidgetActivated(NULL);
if (anOperation)
anOperation->commit();
}
/**\class XGUI_OperationMgr
* \ingroup GUI
- * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
- * of started operations. In simple case, if only one operration is started, the stack contains
+ * \brief Operation manager. Servers to manipulate to the workshop operations. Contains a stack
+ * of started operations. In simple case, if only one operation is started, the stack contains
* one operation. It is possible for some kind of operations to start them above already
- * started one. In that case, the previous active operation becames suspended, a new one - active.
+ * started one. In that case, the previous active operation becomes suspended, a new one - active.
* The new operation is added to the top of the stack. Then it is finished, it is removed from
* the stack and the previous operation is activated.
*/
}
switch (parent.internalId()) {
case MyRoot:
- return 3 + partDocument()->size(ModelAPI_Feature::group());
+ {
+ DocumentPtr aDoc = partDocument();
+ if (aDoc)
+ return 3 + aDoc->size(ModelAPI_Feature::group());
+ else
+ return 0;
+ }
case ParamsFolder:
return partDocument()->size(ModelAPI_ResultParameters::group());
case ConstructFolder:
showObjects(aObjects, true);
else if (theId == "HIDE_CMD")
showObjects(aObjects, false);
+ else if (theId == "SHOW_ONLY_CMD")
+ showOnlyObjects(aObjects);
}
//**************************************************************
//**************************************************************
void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
{
+ if (theFeature)
+ theFeature->activate();
changeCurrentDocument(theFeature);
myObjectBrowser->activatePart(theFeature);
}
myDisplayer->updateViewer();
}
+//**************************************************************
+void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
+{
+ myDisplayer->eraseAll(false);
+ showObjects(theList, true);
+}
+
+
//**************************************************************
void XGUI_Workshop::updateCommandsOnViewSelection()
{
//**************************************************************
void XGUI_Workshop::displayDocumentResults(DocumentPtr theDoc)
{
+ if (!theDoc)
+ return;
displayGroupResults(theDoc, ModelAPI_ResultConstruction::group());
displayGroupResults(theDoc, ModelAPI_ResultBody::group());
}
//! Show the given features in 3d Viewer
void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
+ //! Show the given features in 3d Viewer
+ void showOnlyObjects(const QList<ObjectPtr>& theList);
+
ModuleBase_IModule* module() const
{
return myModule;