<commit_before>
// Qt includes
#include <QLayout>
#include <QDebug>

// Visomics includes
#include "voTreeGraphView.h"
#include "voDataObject.h"

// VTK includes
#include <QVTKWidget.h>
#include <vtkTreeLayoutStrategy.h>
#include <vtkGraph.h>
#include <vtkTree.h>
#include <vtkGraphLayoutView.h>
#include <vtkLookupTable.h>
#include <vtkRenderedGraphRepresentation.h>
#include <vtkSmartPointer.h>
#include <vtkTextProperty.h>
#include <vtkViewTheme.h>

// --------------------------------------------------------------------------
class voTreeGraphViewPrivate
{
public:
  voTreeGraphViewPrivate();
  vtkSmartPointer<vtkGraphLayoutView> GraphView;
  QVTKWidget*                         Widget;
};

// --------------------------------------------------------------------------
// voTreeGraphViewPrivate methods

// --------------------------------------------------------------------------
voTreeGraphViewPrivate::voTreeGraphViewPrivate()
{
  this->GraphView = 0;
  this->Widget = 0;
}

// --------------------------------------------------------------------------
// voTreeGraphView methods

// --------------------------------------------------------------------------
voTreeGraphView::voTreeGraphView(QWidget * newParent):
    Superclass(newParent), d_ptr(new voTreeGraphViewPrivate)
{
}

// --------------------------------------------------------------------------
voTreeGraphView::~voTreeGraphView()
{
}

// --------------------------------------------------------------------------
void voTreeGraphView::setupUi(QLayout *layout)
{
  Q_D(voTreeGraphView);

  d->GraphView = vtkSmartPointer<vtkGraphLayoutView>::New();
  d->Widget = new QVTKWidget();
  d->GraphView->SetInteractor(d->Widget->GetInteractor());
  d->Widget->SetRenderWindow(d->GraphView->GetRenderWindow());
  d->GraphView->DisplayHoverTextOn();

  vtkSmartPointer<vtkTreeLayoutStrategy> treeLayout = vtkSmartPointer<vtkTreeLayoutStrategy>::New();

  d->GraphView->SetLayoutStrategy( treeLayout );
  d->GraphView->VertexLabelVisibilityOn();
  d->GraphView->ColorVerticesOn();
  d->GraphView->SetVertexLabelArrayName("id");

  layout->addWidget(d->Widget);
}

// --------------------------------------------------------------------------
void voTreeGraphView::setDataObject(voDataObject* dataObject)
{
  Q_D(voTreeGraphView);

  if (!dataObject)
    {
    qCritical() << "voTreeGraphView - Failed to setDataObject - dataObject is NULL";
    return;
    }

  vtkTree * tree = vtkTree::SafeDownCast(dataObject->data());
  if (!tree)
    {
    qCritical() << "voTreeGraphView - Failed to setDataObject - vtkTree data is expected !";
    return;
    }

  d->GraphView->SetRepresentationFromInputConnection(tree->GetProducerPort());
  d->GraphView->Render();
}
<commit_msg>Set camera to optimal position when displaying voTreeGraphView<commit_after>
// Qt includes
#include <QLayout>
#include <QDebug>

// Visomics includes
#include "voTreeGraphView.h"
#include "voDataObject.h"

// VTK includes
#include <QVTKWidget.h>
#include <vtkTreeLayoutStrategy.h>
#include <vtkGraph.h>
#include <vtkTree.h>
#include <vtkGraphLayoutView.h>
#include <vtkLookupTable.h>
#include <vtkRenderedGraphRepresentation.h>
#include <vtkSmartPointer.h>
#include <vtkTextProperty.h>
#include <vtkViewTheme.h>

// --------------------------------------------------------------------------
class voTreeGraphViewPrivate
{
public:
  voTreeGraphViewPrivate();
  vtkSmartPointer<vtkGraphLayoutView> GraphView;
  QVTKWidget*                         Widget;
};

// --------------------------------------------------------------------------
// voTreeGraphViewPrivate methods

// --------------------------------------------------------------------------
voTreeGraphViewPrivate::voTreeGraphViewPrivate()
{
  this->GraphView = 0;
  this->Widget = 0;
}

// --------------------------------------------------------------------------
// voTreeGraphView methods

// --------------------------------------------------------------------------
voTreeGraphView::voTreeGraphView(QWidget * newParent):
    Superclass(newParent), d_ptr(new voTreeGraphViewPrivate)
{
}

// --------------------------------------------------------------------------
voTreeGraphView::~voTreeGraphView()
{
}

// --------------------------------------------------------------------------
void voTreeGraphView::setupUi(QLayout *layout)
{
  Q_D(voTreeGraphView);

  d->GraphView = vtkSmartPointer<vtkGraphLayoutView>::New();
  d->Widget = new QVTKWidget();
  d->GraphView->SetInteractor(d->Widget->GetInteractor());
  d->Widget->SetRenderWindow(d->GraphView->GetRenderWindow());
  d->GraphView->DisplayHoverTextOn();

  vtkSmartPointer<vtkTreeLayoutStrategy> treeLayout = vtkSmartPointer<vtkTreeLayoutStrategy>::New();

  d->GraphView->SetLayoutStrategy( treeLayout );
  d->GraphView->VertexLabelVisibilityOn();
  d->GraphView->ColorVerticesOn();
  d->GraphView->SetVertexLabelArrayName("id");

  layout->addWidget(d->Widget);
}

// --------------------------------------------------------------------------
void voTreeGraphView::setDataObject(voDataObject* dataObject)
{
  Q_D(voTreeGraphView);

  if (!dataObject)
    {
    qCritical() << "voTreeGraphView - Failed to setDataObject - dataObject is NULL";
    return;
    }

  vtkTree * tree = vtkTree::SafeDownCast(dataObject->data());
  if (!tree)
    {
    qCritical() << "voTreeGraphView - Failed to setDataObject - vtkTree data is expected !";
    return;
    }

  d->GraphView->SetRepresentationFromInputConnection(tree->GetProducerPort());
  d->GraphView->ResetCamera();
  d->GraphView->Render();
}
{'fraction_non_alphanumeric': 0.3245629843214994, 'fraction_numerical': 0.0007208506037123806, 'mean_word_length': 1.8996865203761755, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6175847', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1481, 'n_words': 230}