Skip to content

Add shield color #19

@Bernard13090

Description

@Bernard13090

I propose to add color to differentiate shields.

i try a rapid improvement on model.py (no very smart).

it will be better to add in model.add_shield()

Best Regards

def _trimBlocks(self, pl, bounds):
        """
        Adds shields to a Plotter instance after trimming any
        infinite shields to a predefined bounding box.
        """
        **shieldColor1 = 'blue'
        shieldColor2 = 'green'**
        sourceColor = 'red'
        **i = 0**
        for thisShield in self.shield_list:
            **i = i + 1**
            if thisShield.is_infinite():
                clipped = thisShield.draw()
                clipped = clipped.clip_closed_surface(
                    normal='x', origin=[bounds[0], 0, 0])
                clipped = clipped.clip_closed_surface(
                    normal='y', origin=[0, bounds[2], 0])
                clipped = clipped.clip_closed_surface(
                    normal='z', origin=[0, 0, bounds[4]])
                clipped = clipped.clip_closed_surface(
                    normal='-x', origin=[bounds[1], 0, 0])
                clipped = clipped.clip_closed_surface(
                    normal='-y', origin=[0, bounds[3], 0])
                clipped = clipped.clip_closed_surface(
                    normal='-z', origin=[0, 0, bounds[5]])
                **if i % 2 :
                  pl.add_mesh(clipped, color=shieldColor1)
                else:
                  pl.add_mesh(clipped, color=shieldColor2)**
                
            else:
                if isinstance(thisShield, source.Source):
                    # point sources are handled later
                    if len(self.source._get_source_points()) != 1:
                        pl.add_mesh(thisShield.draw(), 
                                    sourceColor, label='source', line_width=3)
                else:
                    **if i % 2:
                        pl.add_mesh(thisShield.draw(), shieldColor1)
                    else:
                        pl.add_mesh(thisShield.draw(), shieldColor2)**
                        
        # now add the "bounds" as a transparent block to for a display size

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions