#include "VISU_PlanesWidget.hxx"
#include "VISU_SphereWidget.hxx"
//
+#include <algorithm>
+//
#include <vtkObject.h>
#include <vtkImplicitFunction.h>
#include <vtkImplicitSum.h>
// purpose :
//==================================================================
VISU_WidgetCtrl::VISU_WidgetCtrl()
-:
- vtkObject()
{
myDummyWidget=NULL;
myDisableAll=0;
myWidgets[i]->SetEnabled(0);
}
}
+
+ Modified();
}
//==================================================================
// function: ProcessEvents
if (theIndex>=0 && theIndex<myNbWidgets){
myActiveIndex=theIndex;
}
+
+ Modified();
}
//==================================================================
// function: GetActiveIndex
for (int i=0; i<myNbWidgets; ++i) {
myWidgets[i]->SetInteractor(theRWI);
}
+
+ Modified();
}
//==================================================================
// function: GetInteractor
for (int i=0; i<myNbWidgets; ++i) {
myWidgets[i]->SetPlaceFactor(theFactor);
}
+
+ Modified();
}
//==================================================================
// function: GetPlaceFactor
}
myImplicitSum->SetFunctionWeight(pIF, aWeight);
}
- return myImplicitSum;
+ //return myImplicitSum;
+ return this;
+}
+
+//==================================================================
+float
+VISU_WidgetCtrl
+::EvaluateFunction(float theX[3])
+{
+ if(VISU_ImplicitFunctionWidget* aWidget = GetActiveWidget()){
+ if(vtkImplicitFunction* aFunction = aWidget->ImplicitFunction())
+ return aFunction->EvaluateFunction(theX[0],theX[1],theX[2]);
+ }
+ return 1.0;
+}
+
+//==================================================================
+void
+VISU_WidgetCtrl
+::EvaluateGradient(float theX[3], float theG[3])
+{
+ theG[0] = theG[1] = theG[2] = 0.0;
+ if(VISU_ImplicitFunctionWidget* aWidget = GetActiveWidget()){
+ if(vtkImplicitFunction* aFunction = aWidget->ImplicitFunction())
+ aFunction->EvaluateGradient(theX,theG);
+ }
+}
+
+//==================================================================
+unsigned long
+VISU_WidgetCtrl
+::GetMTime()
+{
+ unsigned long aTime = Superclass::GetMTime();
+
+ if(vtkImplicitFunction* aFunction = myPlanesWidget->ImplicitFunction())
+ aTime = std::max(aTime,aFunction->GetMTime());
+
+ if(vtkImplicitFunction* aFunction = mySphereWidget->ImplicitFunction())
+ aTime = std::max(aTime,aFunction->GetMTime());
+
+ return aTime;
}
#define __VISU_WidgetCtrl_hxx
-#include <vtkObject.h>
+#include <vtkImplicitFunction.h>
class vtkImplicitFunction;
class vtkObject;
class VISU_SphereWidget;
class VISU_ImplicitFunctionWidget;
-class VISU_WidgetCtrl : public vtkObject
+class VISU_WidgetCtrl : public vtkImplicitFunction
{
public:
static VISU_WidgetCtrl *New();
vtkTypeRevisionMacro(VISU_WidgetCtrl,vtkObject);
vtkImplicitFunction* ImplicitFunction();
- //
+
+ virtual
+ float
+ EvaluateFunction(float theX[3]);
+
+ virtual
+ void
+ EvaluateGradient(float theX[3], float theG[3]);
+
+ virtual
+ unsigned long
+ GetMTime();
+
void PlaceWidget(float theBounds[6]);
void SetEnabled(int theFlag);
int GetEnabled();