[vtkusers] Giving names to vtk objects

N Smethurst nick.smethurst at free.fr
Sun May 25 16:30:19 EDT 2003


Hello VTK users and developers.

I have been developing an application with a combination of the QT and VTK 
libraries. I have found the ability to give names to QT objects very 
useful, and would like to be able to do the same with VTK objects.

My question is: is there any chance of including a name attribute in the 
vtkObject base class, i.e. something simple like:

// in header:
public:
  void SetObjectName(const char* name);
  const char* GetObjectName() { return (const char*)this->ObjectName; }
private:
  char* ObjectName;

// in vtkObject constructor:
  this->ObjectName = 0;

// in vtkObject destructor:
  if (this->ObjectName)
    {
    delete [] this->ObjectName;
    }

// in vtkObject.cxx:
void vtkObject::SetObjectName(const char* name)
{
  if (this->ObjectName)
    {
    delete [] this->ObjectName;
    }
  this->ObjectName  = new char[strlen(name) + 1];
  strcpy(this->ObjectName, name);
}


Something like this would provide the same naming functionality that is so 
useful in QT.

Any thoughts and comments on this?

Regards

Nick




More information about the vtkusers mailing list