1616
1717update_paths ()
1818
19- from geos .mesh .utils .multiblockModifiers import mergeBlocks
2019import geos .pv .utils .paraviewTreatments as pvt
2120from geos .pv .utils .checkboxFunction import ( # type: ignore[attr-defined]
2221 createModifiedCallback , )
3534 GetActiveSource , GetActiveView , Render , Show , servermanager ,
3635)
3736from paraview .util .vtkAlgorithm import ( # type: ignore[import-not-found]
38- smdomain , smproperty ,
37+ VTKPythonAlgorithmBase , smdomain , smhint , smproperty , smproxy ,
3938)
4039from vtkmodules .vtkCommonCore import (
4140 vtkDataArraySelection ,
4241 vtkInformation ,
42+ vtkInformationVector ,
4343)
4444
45- from paraview .util .vtkAlgorithm import ( # type: ignore[import-not-found]
46- VTKPythonAlgorithmBase )
47-
48- from vtkmodules .vtkCommonDataModel import (
49- vtkDataObject ,
50- vtkMultiBlockDataSet ,
51- )
52- from geos .pv .utils .details import SISOFilter , FilterCategory
53-
5445__doc__ = """
5546PVPythonViewConfigurator is a Paraview plugin that allows to create cross-plots
5647from input data using the PythonView.
6859"""
6960
7061
71- @SISOFilter ( category = FilterCategory .GEOS_UTILS ,
72- decoratedLabel = "Python View Configurator" ,
73- decoratedType = "vtkDataObject" )
62+ @smproxy .filter ( name = "PVPythonViewConfigurator" , label = "Python View Configurator" )
63+ @smhint .xml ( '<ShowInMenu category="4- Geos Utils"/>' )
64+ @smproperty .input ( name = "Input" )
65+ @smdomain .datatype ( dataTypes = [ "vtkDataObject" ], composite_data_supported = True )
7466class PVPythonViewConfigurator ( VTKPythonAlgorithmBase ):
7567
7668 def __init__ ( self : Self ) -> None :
7769 """Paraview plugin to create cross-plots in a Python View.
7870
7971 Input is a vtkDataObject.
8072 """
81- # super().__init__( nInputPorts=1, nOutputPorts=1 )
73+ super ().__init__ ( nInputPorts = 1 , nOutputPorts = 1 )
8274 # Python view layout and object.
8375 self .m_layoutName : str = ""
8476 self .m_pythonView : Any
@@ -88,9 +80,6 @@ def __init__( self: Self ) -> None:
8880 # Input source and curve names.
8981 inputSource = GetActiveSource ()
9082 dataset = servermanager .Fetch ( inputSource )
91- # Handle vtkMultiBlockDataSet by merging blocks first
92- if isinstance ( dataset , vtkMultiBlockDataSet ):
93- dataset = mergeBlocks ( dataset , keepPartialAttributes = True )
9483 dataframe : pd .DataFrame = pvt .vtkToDataframe ( dataset )
9584 self .m_pathPythonViewScript : Path = geos_pv_path / "src/geos/pv/pythonViewUtils/mainPythonView.py"
9685
@@ -817,14 +806,47 @@ def FillInputPortInformation( self: Self, port: int, info: vtkInformation ) -> i
817806 info .Set ( self .INPUT_REQUIRED_DATA_TYPE (), "vtkDataObject" )
818807 return 1
819808
820- def Filter ( self , inputMesh : vtkDataObject , outputMesh : vtkDataObject ) -> None :
821- """Dummy interface for plugin to fit decorator reqs.
809+ def RequestDataObject (
810+ self : Self ,
811+ request : vtkInformation ,
812+ inInfoVec : list [ vtkInformationVector ],
813+ outInfoVec : vtkInformationVector ,
814+ ) -> int :
815+ """Inherited from VTKPythonAlgorithmBase::RequestDataObject.
816+
817+ Args:
818+ request (vtkInformation): Request.
819+ inInfoVec (list[vtkInformationVector]): Input objects.
820+ outInfoVec (vtkInformationVector): Output objects.
821+
822+ Returns:
823+ int: 1 if calculation successfully ended, 0 otherwise.
824+ """
825+ inData = self .GetInputData ( inInfoVec , 0 , 0 )
826+ outData = self .GetOutputData ( outInfoVec , 0 )
827+ assert inData is not None
828+ if outData is None or ( not outData .IsA ( inData .GetClassName () ) ):
829+ outData = inData .NewInstance ()
830+ outInfoVec .GetInformationObject ( 0 ).Set ( outData .DATA_OBJECT (), outData )
831+ return super ().RequestDataObject ( request , inInfoVec , outInfoVec ) # type: ignore[no-any-return]
832+
833+ def RequestData (
834+ self : Self ,
835+ request : vtkInformation , # noqa: F841
836+ inInfoVec : list [ vtkInformationVector ], # noqa: F841
837+ outInfoVec : vtkInformationVector , # noqa: F841
838+ ) -> int :
839+ """Inherited from VTKPythonAlgorithmBase::RequestData.
822840
823841 Args:
824- inputMesh : A dummy mesh to transform
825- outputMesh : A dummy mesh transformed
842+ request (vtkInformation): Request.
843+ inInfoVec (list[vtkInformationVector]): Input objects.
844+ outInfoVec (vtkInformationVector): Output objects.
826845
846+ Returns:
847+ int: 1 if calculation successfully ended, 0 otherwise.
827848 """
849+ # pythonViewGeneration
828850 assert self .m_pythonView is not None , "No Python View was found."
829851 viewSize = GetActiveView ().ViewSize
830852 self .m_userChoices [ "ratio" ] = viewSize [ 0 ] / viewSize [ 1 ]
@@ -833,4 +855,4 @@ def Filter( self, inputMesh: vtkDataObject, outputMesh: vtkDataObject ) -> None:
833855 self .defineCurvesAspect ()
834856 self .m_pythonView .Script = self .buildPythonViewScript ()
835857 Render ()
836- return
858+ return 1
0 commit comments