// function : isValid
// purpose :
//=================================================================================
-bool BasicGUI_PointDlg::isValid( QString& /*msg*/ )
+bool BasicGUI_PointDlg::isValid( QString& msg )
{
const int id = getConstructorId();
- if ( id == 0 )
- return true;
- else if ( id == 1 )
- return !myRefPoint->_is_nil();
- else if ( id == 2 )
- return !myEdge->_is_nil();
+ if ( id == 0 ) {
+ bool ok = true;
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ return ok;
+ }
+ else if ( id == 1 ) {
+ bool ok = true;
+ ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+
+ return !myRefPoint->_is_nil() && ok;
+ }
+ else if ( id == 2 ) {
+ return !myEdge->_is_nil() && GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
+ }
else if ( id == 3 )
return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
- else if ( id == 4 )
- return !myFace->_is_nil();
+ else if ( id == 4 ) {
+ bool ok = true;
+ ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ return !myFace->_is_nil() && ok;
+
+ }
return false;
}
bool res = false;
GEOM::GEOM_Object_var anObj;
+ QStringList aParameters;
switch ( getConstructorId() ) {
case 0 :
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
double z = GroupXYZ->SpinBox_DZ->value();
+
+ aParameters << GroupXYZ->SpinBox_DX->text();
+ aParameters << GroupXYZ->SpinBox_DY->text();
+ aParameters << GroupXYZ->SpinBox_DZ->text();
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
res = true;
double dx = GroupRefPoint->SpinBox_DX->value();
double dy = GroupRefPoint->SpinBox_DY->value();
double dz = GroupRefPoint->SpinBox_DZ->value();
+
+ aParameters << GroupRefPoint->SpinBox_DX->text();
+ aParameters << GroupRefPoint->SpinBox_DY->text();
+ aParameters << GroupRefPoint->SpinBox_DZ->text();
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointWithReference( myRefPoint, dx, dy, dz );
case 2 :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointOnCurve( myEdge, getParameter() );
+ aParameters<<GroupOnCurve->SpinBox_DX->text();
res = true;
break;
case 3 :
case 4 :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointOnSurface( myFace, getUParameter(), getVParameter() );
+ aParameters<<GroupOnSurface->SpinBox_DX->text();
+ aParameters<<GroupOnSurface->SpinBox_DY->text();
res = true;
break;
}
+ if(!anObj->_is_nil() && (getConstructorId()==0 ||
+ getConstructorId() == 1 ||
+ getConstructorId() == 2 ||
+ getConstructorId() == 4) ) {
+ anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+ }
+
+
if ( getConstructorId() == 1 || getConstructorId() == 2 ||
getConstructorId() == 4 ) {
TopoDS_Shape aShape;
</widget>
</item>
<item row="1" column="1" colspan="2" >
- <widget class="QtxDoubleSpinBox" name="SpinBox_DX" />
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
</item>
</layout>
</widget>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
- <class>QtxDoubleSpinBox</class>
+ <class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
- <header location="global" >QtxDoubleSpinBox.h</header>
+ <header location="global" >SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<number>6</number>
</property>
<item row="2" column="1" colspan="2" >
- <widget class="QtxDoubleSpinBox" name="SpinBox_DY" />
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY" />
</item>
<item row="1" column="1" colspan="2" >
- <widget class="QtxDoubleSpinBox" name="SpinBox_DX" />
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="TextLabel2" >
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
- <class>QtxDoubleSpinBox</class>
+ <class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
- <header location="global" >QtxDoubleSpinBox.h</header>
+ <header location="global" >SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<number>6</number>
</property>
<item row="2" column="1" colspan="2" >
- <widget class="QtxDoubleSpinBox" name="SpinBox_DY" />
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY" />
</item>
<item row="3" column="1" colspan="2" >
- <widget class="QtxDoubleSpinBox" name="SpinBox_DZ" />
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DZ" />
</item>
<item row="1" column="1" colspan="2" >
- <widget class="QtxDoubleSpinBox" name="SpinBox_DX" />
+ <widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="TextLabel2" >
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
- <class>QtxDoubleSpinBox</class>
+ <class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
- <header location="global" >QtxDoubleSpinBox.h</header>
+ <header location="global" >SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
#include <map>
#include <string>
+#include <vector>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
static GEOM_Engine* TheEngine = NULL;
+using namespace std;
+
static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject)
{
TCollection_AsciiString anID(theObject->GetDocID()), anEntry;
void ProcessFunction(Handle(GEOM_Function)& theFunction,
TCollection_AsciiString& theScript,
- Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
- TColStd_HSequenceOfAsciiString& theStudyVariables,
+ TVariablesList theVariables,
TColStd_MapOfTransient& theProcessed);
void ReplaceVariables(TCollection_AsciiString& theCommand,
- Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
- TColStd_HSequenceOfAsciiString& theStudyVariables);
+ TVariablesList theVariables);
//=============================================================================
TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
- Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
- TColStd_HSequenceOfAsciiString& theStudyVariables,
+ TVariablesList theVariables,
bool isPublished,
bool& aValidScript)
{
MESSAGE ( "Null function !!!!" );
continue;
}
- ProcessFunction(aFunction, aScript, theVariableNames, theStudyVariables ,aMap);
+ ProcessFunction(aFunction, aScript, theVariables,aMap);
}
}
//===========================================================================
void ProcessFunction(Handle(GEOM_Function)& theFunction,
TCollection_AsciiString& theScript,
- Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
- TColStd_HSequenceOfAsciiString& theStudyVariables,
+ TVariablesList theVariables,
TColStd_MapOfTransient& theProcessed)
{
if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return;
if(aDescr == "None") return;
//Replace parameter by notebook variables
- ReplaceVariables(aDescr,theVariableNames,theStudyVariables);
+ ReplaceVariables(aDescr,theVariables);
theScript += "\n\t";
theScript += aDescr;
*/
//=============================================================================
void ReplaceVariables(TCollection_AsciiString& theCommand,
- Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
- TColStd_HSequenceOfAsciiString& theStudyVariables)
+ TVariablesList theVariables)
{
//Get Entry of the result object
TCollection_AsciiString anEntry = theCommand.Token("=",1);
+ if (MYDEBUG) {
+ cout<<"All Entries:"<<endl;
+ TVariablesList::const_iterator it = theVariables.begin();
+ for(;it != theVariables.end();it++)
+ cout<<"\t'"<<(*it).first<<"'"<<endl;
+ }
+
//Remove white spaces
anEntry.RightAdjust();
anEntry.LeftAdjust();
cout<<"Result entry : '" <<anEntry<<"'"<<endl;
//Find variables used for object construction
- TCollection_AsciiString aVariables;
- if(theVariableNames.IsBound(anEntry))
- aVariables = theVariableNames.Find(anEntry);
+ vector<TVariable> aVariables;
+ TVariablesList::const_iterator it = theVariables.find(anEntry);
+ if( it != theVariables.end() )
+ aVariables = (*it).second;
- if(aVariables.IsEmpty()) {
+ if(aVariables.empty()) {
if(MYDEBUG)
cout<<"Valiables list empty!!!"<<endl;
return;
}
-
- if(MYDEBUG)
- cout<<"Variables : '" <<aVariables<<"'"<<endl;
-
- //Calculate number of variables, that mast be replaced
- Standard_Integer aNbReplacedParams = 1,aPos;
- TColStd_HSequenceOfInteger aPositions;
- while(aPos = aVariables.Location(aNbReplacedParams,':',1,aVariables.Length())) {
- aPositions.Append(aPos);
- aNbReplacedParams++;
+
+ if(MYDEBUG) {
+ cout<<"Variables from SObject:"<<endl;
+ for (int i = 0; i < aVariables.size();i++)
+ cout<<"\t Variable["<<i<<"]"<<aVariables[i].myVariable<<endl;
}
- if(MYDEBUG)
- cout<<"Number of replaced variables : " <<aNbReplacedParams<<endl;
-
- if(MYDEBUG)
- {
- for(Standard_Integer i = 1;i<=aPositions.Length();i++)
- cout<<"Positions ["<<i<<"] = "<<aPositions.Value(i)<<endl;
- }
-
//Calculate total number of parameter
Standard_Integer aTotalNbParams = 1;
while(theCommand.Location(aTotalNbParams,COMMA,1,theCommand.Length()))
aTotalNbParams++;
-
-
- if(MYDEBUG)
- cout<<"Total Number of parameters : " <<aTotalNbParams<<endl;
-
- //Get Variables names
- TColStd_SequenceOfAsciiString aVarSeq;
- TCollection_AsciiString aVar;
- Standard_Integer i = 1;
- while(i <= aNbReplacedParams){
-
- if(i == 1)
- aVar = (aPositions.Value(i) == 1) ? TCollection_AsciiString() : aVariables.SubString(1, aPositions.Value(i)-1);
- else if(i == aNbReplacedParams) {
- Standard_Integer aLen = aVariables.Length();
- Standard_Integer aPos = aPositions.Value(i-1);
- aVar = (aPos == aLen) ? TCollection_AsciiString() : aVariables.SubString(aPos+1, aLen);
- }
- else {
- Standard_Integer aPrevPos = aPositions.Value(i-1);
- Standard_Integer aCurrentPos = aPositions.Value(i);
- aVar = (aCurrentPos - aPrevPos == 1) ? TCollection_AsciiString() : aVariables.SubString(aPrevPos+1, aCurrentPos-1);
- }
- if(MYDEBUG)
- cout<<"Variable ["<<i<<"] = '"<<aVar<<"'"<<endl;
-
- //Add current varibale
- aVarSeq.Append(aVar);
- i++;
- }
-
+
//Replace parameters by variables
Standard_Integer aStartPos = 0;
Standard_Integer aEndPos = 0;
- Standard_Integer iVar = 1;
+ int iVar = 0;
+ TCollection_AsciiString aReplasedVar, aVar;
for(Standard_Integer i=1;i <= aTotalNbParams;i++) {
//Replace first parameter (bettwen '(' character and first ',' character)
- if(i == 1)
+ if(i == 1)
{
aStartPos = theCommand.Location(O_BRACKET, 1, theCommand.Length()) + 1;
aEndPos = theCommand.Location(COMMA, 1, theCommand.Length());
}
//Replace last parameter (bettwen ',' character and ')' character)
- else if(i == aVarSeq.Length())
+ else if(i == aTotalNbParams)
{
aStartPos = theCommand.Location(i-1, COMMA, 1, theCommand.Length()) + 2;
aEndPos = theCommand.Location(C_BRACKET, 1, theCommand.Length());
}
//Replace other parameters (bettwen two ',' characters)
- else if(i != 1 && i != aVarSeq.Length())
+ else if(i != 1 && i != aTotalNbParams )
{
aStartPos = theCommand.Location(i-1, COMMA, 1, theCommand.Length()) + 2;
aEndPos = theCommand.Location(i, COMMA, 1, theCommand.Length());
}
-
- aVar = aVarSeq.Value(iVar);
-
+ aVar = theCommand.SubString(aStartPos, aEndPos-1);
+ if(MYDEBUG)
+ cout<<"Current variable 1: '"<< aVar <<"'"<<endl;
//If parameter is entry, skip it
aVar.RightAdjust();
aVar.LeftAdjust();
- if(theVariableNames.IsBound(aVar))
+
+ if(MYDEBUG)
+ cout<<"Current variable 2: '"<< aVar <<"'"<<endl;
+
+ if(theVariables.find(aVar) != theVariables.end())
continue;
+ aReplasedVar = aVariables[iVar].myVariable;
+
- if(aVar.IsEmpty()) {
+ if(aReplasedVar.IsEmpty()) {
iVar++;
continue;
}
- bool isVar = false;
- for(Standard_Integer i = 1; i <= theStudyVariables.Length();i++)
- if(theStudyVariables.Value(i).IsEqual(aVar)) {
- isVar = true;
- break;
- }
- if(isVar) {
- aVar.InsertBefore(1,"\"");
- aVar.InsertAfter(aVar.Length(),"\"");
+ if(aVariables[iVar].isVariable) {
+ aReplasedVar.InsertBefore(1,"\"");
+ aReplasedVar.InsertAfter(aReplasedVar.Length(),"\"");
}
theCommand.Remove(aStartPos, aEndPos - aStartPos);
- theCommand.Insert(aStartPos,aVar);
+ theCommand.Insert(aStartPos,aReplasedVar);
iVar++;
}
}
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <TDF_Label.hxx>
+#include <map>
+#include <vector>
+
+struct TVariable{
+ TCollection_AsciiString myVariable;
+ bool isVariable;
+
+ TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true):
+ myVariable(theVariable),
+ isVariable(theFlag){}
+};
+
+typedef std::map<TCollection_AsciiString, std::vector<TVariable> > TVariablesList;
+
class GEOM_Engine
{
public:
Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
- Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
- TColStd_HSequenceOfAsciiString& theStudyVariables,
+ TVariablesList theVariables,
bool isPublished,
bool& aValidScript);
return aDSStudy._retn();
}
+//=======================================================================
+// function : JoinObjectParameters
+// purpose :
+//=======================================================================
+char* GeometryGUI::JoinObjectParameters(const QStringList& theParametersList)
+{
+ return (char*)theParametersList.join(":").toLatin1().constData();
+}
//=======================================================================
// function : GeometryGUI::GeometryGUI()
// purpose : Constructor
static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
+ static char* JoinObjectParameters(const QStringList& theParametersList);
+
GEOM_Client& GetShapeReader() { return myShapeReader; }
Standard_CString& GetFatherior() { return myFatherior; }
//void SetState( const int state ) { myState = state; }
#include <Standard_Stream.hxx>
#include "GEOM_Gen_i.hh"
+
+//#include <GEOM_Engine.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
+#include <vector>
+#include <string>
+
//=======================================================================
//function : DumpPython
//purpose :
if(CORBA::is_nil(aSO))
return new Engines::TMPFile(0);
- Resource_DataMapOfAsciiStringAsciiString aMap, aVariableMap;
+ Resource_DataMapOfAsciiStringAsciiString aMap;
+
+ TVariablesList aVariableMap;
SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
//Find attribute with list of used notebook variables
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeString_var anAttrStr;
- TCollection_AsciiString aParameters;
+ vector<TVariable> aVariables;
if(aValue->FindAttribute(anAttr,"AttributeString")){
anAttrStr = SALOMEDS::AttributeString::_narrow(anAttr);
- aParameters = TCollection_AsciiString(anAttrStr->Value());
+ SALOMEDS::ListOfStrings_var aListOfVars = aStudy->ParseVariables(anAttrStr->Value());
+ for(int i = 0;i < aListOfVars->length();i++) {
+ bool isVar = aStudy->IsVariable(aListOfVars[i].in());
+ TVariable aVar = TVariable( (char*)aListOfVars[i].in(), isVar );
+ aVariables.push_back(aVar);
+ }
}
- aVariableMap.Bind((char*)anEntry.in(),aParameters);
+ aVariableMap.insert(pair<TCollection_AsciiString,vector<TVariable> >((char*)anEntry,aVariables));
}
}
}
-
- //Get Study variables
- SALOMEDS::ListOfStrings_var aListOfVars = aStudy->GetVariableNames();
- TColStd_HSequenceOfAsciiString aStudyVariables;
- for(int i = 0;i < aListOfVars->length();i++)
- {
- aStudyVariables.Append(aListOfVars[i].in());
- }
TCollection_AsciiString aScript =
"### This file is generated by SALOME automatically by dump python functionality\n"
"### of GEOM component\n\n";
- aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, aStudyVariables, isPublished, isValidScript);
+ aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, isPublished, isValidScript);
if (isPublished)
{
# @ref tui_creation_point "Example"
def MakeVertex(self,theX, theY, theZ):
# Example: see GEOM_TestAll.py
+ theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ)
anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ)
RaiseIfFailed("MakePointXYZ", self.BasicOp)
+ anObj.SetParameters(Parameters)
return anObj
## Create a point, distant from the referenced point
# @ref tui_creation_point "Example"
def MakeVertexWithRef(self,theReference, theX, theY, theZ):
# Example: see GEOM_TestAll.py
+ theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ)
anObj = self.BasicOp.MakePointWithReference(theReference, theX, theY, theZ)
RaiseIfFailed("MakePointWithReference", self.BasicOp)
+ anObj.SetParameters(Parameters)
return anObj
## Create a point, corresponding to the given parameter on the given curve.
# @ref tui_creation_point "Example"
def MakeVertexOnCurve(self,theRefCurve, theParameter):
# Example: see GEOM_TestAll.py
+ theParameter, Parameters = ParseParameters(theParameter)
anObj = self.BasicOp.MakePointOnCurve(theRefCurve, theParameter)
RaiseIfFailed("MakePointOnCurve", self.BasicOp)
+ anObj.SetParameters(Parameters)
return anObj
## Create a point, corresponding to the given parameters on the
#
# @ref swig_MakeVertexOnSurface "Example"
def MakeVertexOnSurface(self, theRefSurf, theUParameter, theVParameter):
+ theUParameter, theVParameter, Parameters = ParseParameters(theParameter)
# Example: see GEOM_TestAll.py
anObj = self.BasicOp.MakePointOnSurface(theRefSurf, theUParameter, theVParameter)
RaiseIfFailed("MakePointOnSurface", self.BasicOp)
+ anObj.SetParameters(Parameters);
return anObj
## Create a point on intersection of two lines.