コード例 #1
0
ファイル: vista.py プロジェクト: wh19971014/gempy
    def call_back_plane_move_changes(self, indices):
        df_changes = self.model.orientations.df.loc[np.atleast_1d(indices)][[
            'X', 'Y', 'Z', 'G_x', 'G_y', 'G_z', 'id'
        ]]
        for index, new_values_df in df_changes.iterrows():
            new_center = new_values_df[['X', 'Y', 'Z']].values
            new_normal = new_values_df[['G_x', 'G_y', 'G_z']].values
            new_source = vtk.vtkPlaneSource()
            new_source.SetCenter(new_center)
            new_source.SetNormal(new_normal)
            new_source.Update()

            plane1 = self.p_widget.loc[index, 'val']
            #  plane1.SetInputData(new_source.GetOutput())
            plane1.SetNormal(new_normal)
            plane1.SetCenter(new_center[0], new_center[1], new_center[2])

            plane1.GetPlaneProperty().SetColor(
                parse_color(
                    self.model.surfaces.df.set_index('id')['color']
                    [new_values_df['id']]))  # self.C_LOT[new_values_df['id']])
            plane1.GetHandleProperty().SetColor(
                parse_color(
                    self.model.surfaces.df.set_index('id')['color'][
                        new_values_df['id']]))
        return True
コード例 #2
0
    def set_surfaces(self, surfaces=None, **kwargs):
        if surfaces is None:
            surfaces = self.model.surfaces
            for idx, val in surfaces.df[['vertices', 'edges',
                                         'color']].dropna().iterrows():

                surf = pv.PolyData(
                    val['vertices'],
                    np.insert(val['edges'], 0, 3, axis=1).ravel())
                self.surf_polydata.at[idx] = surf
                self.p.add_mesh(surf, parse_color(val['color']), **kwargs)

        return self.surf_polydata
コード例 #3
0
    def plot_surfaces(self,
                      surfaces: Union[str, Iterable[str]] = 'all',
                      surfaces_df: pd.DataFrame = None,
                      clear=True,
                      **kwargs):

        # TODO is this necessary for the updates?
        """
        Args:
            surfaces:
            surfaces_df (pd.DataFrame):
            clear:
            **kwargs:
        """
        cmap = mcolors.ListedColormap(
            list(self._get_color_lot(is_faults=True, is_basement=True)))
        if clear is True and self.plotter_type != 'notebook':
            try:
                [
                    self.p.remove_actor(actor)
                    for actor in self.surface_actors.items()
                ]
            except KeyError:
                pass

        if surfaces_df is None:
            surfaces_df = self._select_surfaces_data(self.model._surfaces.df,
                                                     surfaces)

        select_active = surfaces_df['isActive']
        for idx, val in surfaces_df[select_active][[
                'vertices', 'edges', 'color', 'surface', 'id'
        ]].dropna().iterrows():
            surf = pv.PolyData(val['vertices'],
                               np.insert(val['edges'], 0, 3, axis=1).ravel())
            # surf['id'] = val['id']
            self.surface_poly[val['surface']] = surf
            self.surface_actors[val['surface']] = self.p.add_mesh(
                surf,
                parse_color(val['color']),
                show_scalar_bar=True,
                cmap=cmap,
                **kwargs)
        self.set_bounds()

        # In order to set the scalar bar to only surfaces we would need to map
        # every vertex of each layer with the right id. So far I am going to avoid
        # the overhead since usually surfaces will be plotted either with data
        # or the regular grid.
        # self.set_scalar_bar()
        return self.surface_actors
コード例 #4
0
    def update_axes_label_color(axes_actor, color=None):
        """Set the axes label color (internale helper)."""
        if color is None:
            color = rcParams['font']['color']
        color = parse_color(color)
        if isinstance(axes_actor, vtk.vtkAxesActor):
            prop_x = axes_actor.GetXAxisCaptionActor2D(
            ).GetCaptionTextProperty()
            prop_y = axes_actor.GetYAxisCaptionActor2D(
            ).GetCaptionTextProperty()
            prop_z = axes_actor.GetZAxisCaptionActor2D(
            ).GetCaptionTextProperty()
            for prop in [prop_x, prop_y, prop_z]:
                prop.SetColor(color[0], color[1], color[2])
                prop.SetShadow(False)
        elif isinstance(axes_actor, vtk.vtkAnnotatedCubeActor):
            axes_actor.GetTextEdgesProperty().SetColor(color)

        return
コード例 #5
0
ファイル: vista.py プロジェクト: rccmodena/gempy
    def plot_surfaces(self, surfaces=None, delete_surfaces=True, **kwargs):
        self.update_colot_lot()
        if delete_surfaces is True:
            for actor in self.vista_surf_actor.values():
                self.delete_surface(actor)

        if surfaces is None:
            surfaces = self.model.surfaces.df
        for idx, val in surfaces[['vertices', 'edges',
                                  'color']].dropna().iterrows():

            surf = pv.PolyData(val['vertices'],
                               np.insert(val['edges'], 0, 3, axis=1).ravel())
            self.surf_polydata.at[idx] = surf
            self.vista_surf_actor[idx] = self.p.add_mesh(
                surf, parse_color(val['color']), **kwargs)

        self.set_bounds()
        return self.surf_polydata
コード例 #6
0
    def create_axes_marker2(label_color=None,
                            x_color=None,
                            y_color=None,
                            z_color=None,
                            xlabel='a',
                            ylabel='b',
                            zlabel='c',
                            labels_off=False,
                            line_width=50):
        """Return an axis actor to add in the scene."""
        if x_color is None:
            x_color = rcParams['axes']['x_color']
        if y_color is None:
            y_color = rcParams['axes']['y_color']
        if z_color is None:
            z_color = rcParams['axes']['z_color']
        axes_actor = vtk.vtkAxesActor()

        axes_actor.GetXAxisShaftProperty().SetColor(parse_color(x_color))
        axes_actor.GetXAxisTipProperty().SetColor(parse_color(x_color))
        axes_actor.GetYAxisShaftProperty().SetColor(parse_color(y_color))
        axes_actor.GetYAxisTipProperty().SetColor(parse_color(y_color))
        axes_actor.GetZAxisShaftProperty().SetColor(parse_color(z_color))
        axes_actor.GetZAxisTipProperty().SetColor(parse_color(z_color))

        transform = vtk.vtkTransform()
        mat = transform.GetMatrix()
        latt_or = np.array(latt)
        latt_or[:, 0] = 2 * latt_or[:, 0] / np.linalg.norm(latt_or[:, 0])
        latt_or[:, 1] = 2 * latt_or[:, 1] / np.linalg.norm(latt_or[:, 1])
        latt_or[:, 2] = 2 * latt_or[:, 2] / np.linalg.norm(latt_or[:, 2])
        for i in range(len(latt)):
            for j in range(len(latt)):
                mat.SetElement(i, j, 2 * latt_or[i, j])

        axes_actor.SetUserTransform(transform)

        text = vtk.vtkTextProperty()
        text.SetFontSize(100)
        text.SetBold(True)
        text.SetFontFamilyAsString("Times")

        # Set labels
        axes_actor.SetXAxisLabelText(xlabel)
        axes_actor.SetYAxisLabelText(ylabel)
        axes_actor.SetZAxisLabelText(zlabel)
        axes_actor.SetNormalizedLabelPosition((1.3, 1.3, 1.3))
        axes_actor.GetXAxisCaptionActor2D().SetCaptionTextProperty(text)
        axes_actor.GetYAxisCaptionActor2D().SetCaptionTextProperty(text)
        axes_actor.GetZAxisCaptionActor2D().SetCaptionTextProperty(text)

        if labels_off:
            axes_actor.AxisLabelsOff()
        # Set Line width
        axes_actor.GetXAxisShaftProperty().SetLineWidth(line_width)
        axes_actor.GetYAxisShaftProperty().SetLineWidth(line_width)
        axes_actor.GetZAxisShaftProperty().SetLineWidth(line_width)
        #axes_actor.SetNormalizedTipLength(1,1,1)
        #axes_actor.SetNormalizedShaftLength(2,2,2)

        update_axes_label_color(axes_actor, label_color)

        #axes_actor.SetNormalizedShaftLength(1.6,1.6,1.6)
        #axes_actor.SetNormalizedTipLength(0.4,0.4,0.4)
        #axes_actor.SetTotalLength(2,2,2)
        return axes_actor