<commit_before>#include "v3dViewMeshInteractor.h"

#include <dtkCore/dtkAbstractData.h>
#include <dtkCore/dtkAbstractDataFactory.h>
#include <dtkCore/dtkAbstractView.h>
#include <dtkCore/dtkAbstractViewFactory.h>
#include <dtkCore/dtkLog.h>
#include <vtkCamera.h>
#include <vtkActor.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkImageView.h>
#include <vtkImageView2D.h>
#include <vtkImageView3D.h>
#include <vtkPointSet.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkBoundingBox.h>
#include <vtkPolyDataManager.h>
#include "v3dView.h"
#include <vtkDatasetToImageGenerator.h>
#include <vtkImageData.h>
#include <QInputDialog>
#include <QColorDialog>
#include <vtkImageActor.h>
#include <vtkLookupTableManager.h>
#include <vtkLookupTable.h>
#include <vtkMetaDataSetSequence.h>
#include <vtkDataArrayCollection.h>

class v3dViewMeshInteractorPrivate
{
public:
    typedef vtkSmartPointer <vtkActor>  ActorSmartPointer;
    typedef vtkSmartPointer <vtkProperty>  PropertySmartPointer;

    QList<dtkAbstractData*> dataList;
    v3dView          *view;
    QList<ActorSmartPointer> actor2dList;
    QList<ActorSmartPointer> actor3dList;
    QList<PropertySmartPointer> actorPropertyList;
    QList<double> opacityList;
    QList<bool> visibilityList;
    QList<bool> edgeVisibilityList;
    QList<QString> colorList;
    QList<QString> renderingList;
    QList<QString> attributeList;
    QList<QString> lutList;
    int currentLayer;
    bool isMeshOnly;
};

v3dViewMeshInteractor::v3dViewMeshInteractor(): medMeshAbstractViewInteractor(), d(new v3dViewMeshInteractorPrivate)
{
    //d->data = NULL;
    d->view = NULL;
    d->currentLayer = 0;
    d->isMeshOnly = false;
    // addProperty here
    this->addProperty("Visibility", QStringList() << "true" << "false");
    this->addProperty("ShowEdges", QStringList() << "true" << "false");
    this->addProperty("RenderingMode", QStringList() << "surface" << "wireframe" << "points" );
    this->addProperty("OpacityMode", QStringList() << "");
    this->addProperty("LUTMode", QStringList() << "Default" << "Black & White" << "Black & White Inversed" << "Spectrum" << "Hot Metal" << "Hot Green"
                      << "Hot Iron" << "GE" << "Flow" << "Loni" << "Loni 2" << "Asymmetry" << "P-Value" << "Red Black Alpha"
                      << "Green Black Alpha" << "Blue Black Alpha" << "Muscles & Bones" << "Bones" << "Red Vessels"
                      << "Cardiac" << "Gray Rainbow" << "Stern" << "Black Body");
    this->addProperty("ColorMode", QStringList() << "#FFFFFF");
}

v3dViewMeshInteractor::~v3dViewMeshInteractor()
{
    this->disable();

    delete d;
    d = 0;
}

QString v3dViewMeshInteractor::description(void) const
{
    return tr("Interactor displaying Meshes");
}

QString v3dViewMeshInteractor::identifier() const
{
    return "v3dViewMeshInteractor";
}

QStringList v3dViewMeshInteractor::handled(void) const
{
    return QStringList () << "v3dView";
}

bool v3dViewMeshInteractor::registered(void)
{
    return dtkAbstractViewFactory::instance()->registerViewInteractorType("v3dViewMeshInteractor", QStringList() << "v3dView", createV3dViewMeshInteractor);
}

void v3dViewMeshInteractor::setData(dtkAbstractData *data)
{

    if (d->dataList.contains (data))
    {
        return;
    }

    if(data->identifier() == "vtkDataMesh4D")
    {
        d->isMeshOnly = true; //        d->isMeshOnly = false;

        vtkMetaDataSetSequence *sequence = dynamic_cast<vtkMetaDataSetSequence *>((vtkDataObject *)(data->data()));
        vtkPointSet *pointSet = vtkPointSet::SafeDownCast (sequence->GetDataSet());
        vtkDatasetToImageGenerator* imagegenerator = vtkDatasetToImageGenerator::New();
        imagegenerator->SetInput (pointSet);
        vtkImageData * image = imagegenerator->GetOutput();
        d->view->view2d()->SetInput(image, 0);

        d->dataList.append(data);
        d->opacityList.append(1.0);
        d->visibilityList.append(true);
        d->edgeVisibilityList.append(false);
        d->colorList.append(QString("#FFFFFF"));
        d->renderingList.append("Surface");
        d->attributeList.append("Solid");
        d->lutList.append("Default");
        updatePipeline(d->dataList.size()-1);
    }
    else if (vtkPointSet *pointSet = dynamic_cast<vtkPointSet *>((vtkDataObject *)(data->data()))) {
        if(!d->view->dataInList(0))
        {
            d->isMeshOnly = true;
            vtkDatasetToImageGenerator* imagegenerator = vtkDatasetToImageGenerator::New();
            imagegenerator->SetInput (pointSet);
            vtkImageData * image = imagegenerator->GetOutput();
            d->view->view2d()->SetInput(image, 0);
            //d->view->view3d()->SetInput(image, 0);
            vtkImageActor *actor = d->view->view2d()->GetImageActor(0);
            actor->SetOpacity(0.0);
        }
        else
            d->isMeshOnly = false;
        Q_UNUSED( pointSet );
        d->dataList.append(data);
        d->opacityList.append(1.0);
        d->visibilityList.append(true);
        d->edgeVisibilityList.append(false);
        d->colorList.append(QString("#FFFFFF"));
        d->renderingList.append("Surface");
        d->attributeList.append("Solid");
        d->lutList.append("Default");
        updatePipeline(d->dataList.size()-1);
    }
}

bool v3dViewMeshInteractor::isMeshOnly()
{<commit_msg>set the size of the image used for 2D mesh visualization to match the default view toolbars slider size<commit_after>#include "v3dViewMeshInteractor.h"

#include <dtkCore/dtkAbstractData.h>
#include <dtkCore/dtkAbstractDataFactory.h>
#include <dtkCore/dtkAbstractView.h>
#include <dtkCore/dtkAbstractViewFactory.h>
#include <dtkCore/dtkLog.h>
#include <vtkCamera.h>
#include <vtkActor.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkImageView.h>
#include <vtkImageView2D.h>
#include <vtkImageView3D.h>
#include <vtkPointSet.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkBoundingBox.h>
#include <vtkPolyDataManager.h>
#include "v3dView.h"
#include <vtkDatasetToImageGenerator.h>
#include <vtkImageData.h>
#include <QInputDialog>
#include <QColorDialog>
#include <vtkImageActor.h>
#include <vtkLookupTableManager.h>
#include <vtkLookupTable.h>
#include <vtkMetaDataSetSequence.h>
#include <vtkDataArrayCollection.h>

class v3dViewMeshInteractorPrivate
{
public:
    typedef vtkSmartPointer <vtkActor>  ActorSmartPointer;
    typedef vtkSmartPointer <vtkProperty>  PropertySmartPointer;

    QList<dtkAbstractData*> dataList;
    v3dView          *view;
    QList<ActorSmartPointer> actor2dList;
    QList<ActorSmartPointer> actor3dList;
    QList<PropertySmartPointer> actorPropertyList;
    QList<double> opacityList;
    QList<bool> visibilityList;
    QList<bool> edgeVisibilityList;
    QList<QString> colorList;
    QList<QString> renderingList;
    QList<QString> attributeList;
    QList<QString> lutList;
    int currentLayer;
    bool isMeshOnly;
};

v3dViewMeshInteractor::v3dViewMeshInteractor(): medMeshAbstractViewInteractor(), d(new v3dViewMeshInteractorPrivate)
{
    //d->data = NULL;
    d->view = NULL;
    d->currentLayer = 0;
    d->isMeshOnly = false;
    // addProperty here
    this->addProperty("Visibility", QStringList() << "true" << "false");
    this->addProperty("ShowEdges", QStringList() << "true" << "false");
    this->addProperty("RenderingMode", QStringList() << "surface" << "wireframe" << "points" );
    this->addProperty("OpacityMode", QStringList() << "");
    this->addProperty("LUTMode", QStringList() << "Default" << "Black & White" << "Black & White Inversed" << "Spectrum" << "Hot Metal" << "Hot Green"
                      << "Hot Iron" << "GE" << "Flow" << "Loni" << "Loni 2" << "Asymmetry" << "P-Value" << "Red Black Alpha"
                      << "Green Black Alpha" << "Blue Black Alpha" << "Muscles & Bones" << "Bones" << "Red Vessels"
                      << "Cardiac" << "Gray Rainbow" << "Stern" << "Black Body");
    this->addProperty("ColorMode", QStringList() << "#FFFFFF");
}

v3dViewMeshInteractor::~v3dViewMeshInteractor()
{
    this->disable();

    delete d;
    d = 0;
}

QString v3dViewMeshInteractor::description(void) const
{
    return tr("Interactor displaying Meshes");
}

QString v3dViewMeshInteractor::identifier() const
{
    return "v3dViewMeshInteractor";
}

QStringList v3dViewMeshInteractor::handled(void) const
{
    return QStringList () << "v3dView";
}

bool v3dViewMeshInteractor::registered(void)
{
    return dtkAbstractViewFactory::instance()->registerViewInteractorType("v3dViewMeshInteractor", QStringList() << "v3dView", createV3dViewMeshInteractor);
}

void v3dViewMeshInteractor::setData(dtkAbstractData *data)
{

    if (d->dataList.contains (data))
    {
        return;
    }

    if(data->identifier() == "vtkDataMesh4D")
    {
        if(!d->view->dataInList(0))
        {
            d->isMeshOnly = true; //        d->isMeshOnly = false;
            vtkMetaDataSetSequence *sequence = dynamic_cast<vtkMetaDataSetSequence *>((vtkDataObject *)(data->data()));
            vtkPointSet *pointSet = vtkPointSet::SafeDownCast (sequence->GetDataSet());
            vtkDatasetToImageGenerator* imagegenerator = vtkDatasetToImageGenerator::New();
            unsigned int imSize [3]; imSize[0]=100; imSize[1]=100; imSize[2]=100;
            imagegenerator->SetOutputImageSize(imSize);
            imagegenerator->SetInput (pointSet);
            vtkImageData * image = imagegenerator->GetOutput();
            d->view->view2d()->SetInput(image, 0);
            vtkImageActor *actor = d->view->view2d()->GetImageActor(0);
            actor->SetOpacity(0.0);
        }
        else
            d->isMeshOnly = false;

        d->dataList.append(data);
        d->opacityList.append(1.0);
        d->visibilityList.append(true);
        d->edgeVisibilityList.append(false);
        d->colorList.append(QString("#FFFFFF"));
        d->renderingList.append("Surface");
        d->attributeList.append("Solid");
        d->lutList.append("Default");
        updatePipeline(d->dataList.size()-1);
    }
    else if (vtkPointSet *pointSet = dynamic_cast<vtkPointSet *>((vtkDataObject *)(data->data()))) {
        if(!d->view->dataInList(0))
        {
            d->isMeshOnly = true;
            vtkDatasetToImageGenerator* imagegenerator = vtkDatasetToImageGenerator::New();
            imagegenerator->SetInput (pointSet);
            vtkImageData * image = imagegenerator->GetOutput();
            unsigned int imSize [3]; imSize[0]=100; imSize[1]=100; imSize[2]=100;
            imagegenerator->SetOutputImageSize(imSize);
            d->view->view2d()->SetInput(image, 0);
            //d->view->view3d()->SetInput(image, 0);
            vtkImageActor *actor = d->view->view2d()->GetImageActor(0);
            actor->SetOpacity(0.0);
        }
        else
            d->isMeshOnly = false;

        Q_UNUSED( pointSet );
        d->dataList.append(data);
        d->opacityList.append(1.0);
        d->visibilityList.append(true);
        d->edgeVisibilityList.append(false);
        d->colorList.append(QString("#FFFFFF"));
        d->renderingList.append("Surface");
        d->attributeList.append("Solid");
        d->lutList.append("Default");
        updatePipeline(d->dataList.size()-1);
    }
}

bool v3dViewMeshInteractor::isMeshOnly()
{
{'fraction_non_alphanumeric': 0.14915019077349984, 'fraction_numerical': 0.01057925771765522, 'mean_word_length': 3.705426356589147, 'pattern_counts': {'":': 0, '<': 227, '<?xml version=': 0, '>': 216, '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': '3726190', 'n_tokens_mistral': 3806, 'n_tokens_neox': 3740, 'n_words': 620}