AlanFord / ZapMeNot

Python library for simple point-kernel photon shielding analyses
GNU General Public License v3.0
10 stars 3 forks source link

Add shield color #19

Open Bernard13090 opened 1 year ago

Bernard13090 commented 1 year ago

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
AlanFord commented 1 year ago

That's a good idea. It's also been suggested that the shields would be better displayed in translucent colors - allowing all objects to be seen without needing to rotate the view.