Skip to content

Commit

Permalink
CPlot: opt. selection, mod. style mesh 4
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Sep 6, 2024
1 parent 52677c7 commit e9abf65
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
20 changes: 11 additions & 9 deletions Cassiopee/CPlot/CPlot/Display/meshStyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@
break;

case 4:
// Wires multicolor grb
getrgb(this, zone*1./_numberOfZones, &g, &r, &b);
//color1[0] = r; color1[1] = b; color1[2] = g;
complementColor(g,r,b, color1[0],color1[1],color1[2]);
if (color1[2] > 0.8 && color1[0] < 0.2 && color1[1] < 0.2)
{ r = color1[0]; g = color1[1]; b = color1[2];
color1[0] = b; color1[1] = r; color1[2] = g;}
color2[0] = 0.7; color2[1] = 0.88; color2[2] = 1.;
// Wires noirs
//getrgb(this, zone*1./_numberOfZones, &g, &r, &b);
//complementColor(g,r,b, color1[0],color1[1],color1[2]);
//if (color1[2] > 0.8 && color1[0] < 0.2 && color1[1] < 0.2)
//{ r = color1[0]; g = color1[1]; b = color1[2];
// color1[0] = b; color1[1] = r; color1[2] = g;}
//color2[0] = 0.7; color2[1] = 0.88; color2[2] = 1.;

color1[0] = 0.; color1[1] = 0.; color1[2] = 0.;
color2[0] = 0.7; color2[1] = 0.88; color2[2] = 1.;
// Ecrasement si render tag
if (zonep->colorR != -1.)
{ complementColor(zonep->colorR,zonep->colorG,zonep->colorB, color1[0],color1[1],color1[2]); }
glLineWidth(1.5*resf);
glLineWidth(0.4*resf);
break;

default:
Expand Down
26 changes: 26 additions & 0 deletions Cassiopee/CPlot/CPlot/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,32 @@ def updateCPlotNumbering(t):
nb += 1
return (Nb, Nz)

#==============================================================================
# Retourne le numero global nz de la basename/zonename dans CPlot
#==============================================================================
def updateCPlotGlobalNumbering(t):
dnz = {}
# count total struct zones
nstr = 0
for b in t[2]:
if b[3] == 'CGNSBase_t':
for z in b[2]:
if z[3] == 'Zone_t':
type = Internal.getZoneType(z)
if type == 1: nstr += 1

nzs = 0 # global cplot numbering
nzu = nstr
for b in t[2]:
if b[3] == 'CGNSBase_t':
dnz[b[0]] = {}
for z in b[2]:
if z[3] == 'Zone_t':
type = Internal.getZoneType(z)
if type == 1: dnz[b[0]][z[0]] = nzs; nzs += 1
else: dnz[b[0]][z[0]] = nzu; nzu += 1
return dnz

#==============================================================================
# Retourne la numerotation CPlot de la zone baseName/zoneName de t
# IN: t: un noeud pyTree (et pas autre chose)
Expand Down
29 changes: 21 additions & 8 deletions Cassiopee/CPlot/apps/tkTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,11 @@ def PVT_key(self, event):
zones = Internal.getNodesFromType1(pid, 'Zone_t')
bases = CTK.t[2][1:]
active = []
dnz = CPlot.updateCPlotGlobalNumbering(CTK.t)
for z in zones:
zoneName = pid[0]+Internal.SEP1+z[0]
i = CPlot.getCPlotNumber(CTK.t, pid[0], z[0])
#i = CPlot.getCPlotNumber(CTK.t, pid[0], z[0])
i = dnz[pid[0]][z[0]]
active.append((i, zoneName))
CPlot.setZoneNames(active)
(CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t)
Expand Down Expand Up @@ -602,13 +604,16 @@ def PVT_clickRight(self, event):
nodes = Internal.getNodesFromType1(pid, 'Zone_t')
activated = []
s = -1
dnz = CPlot.updateCPlotGlobalNumbering(CTK.t)
if nodes != []:
noz = CPlot.getCPlotNumber(CTK.t, baseName, nodes[0][0])
#noz = CPlot.getCPlotNumber(CTK.t, baseName, nodes[0][0])
noz = dnz[baseName][nodes[0][0]]
s = CPlot.getActiveStatus(noz)
if s == 0: s = 1
else: s = 0
for z in nodes:
noz = CPlot.getCPlotNumber(CTK.t, baseName, z[0])
#noz = CPlot.getCPlotNumber(CTK.t, baseName, z[0])
noz = dnz[baseName][z[0]]
activated.append( (noz, s) )
if s == 0:
CTK.TXT.insert('START', 'Base '+baseName+' deactivated.\n')
Expand All @@ -626,9 +631,11 @@ def PVT_clickRight(self, event):

activated = []
active = -2
dnz = CPlot.updateCPlotGlobalNumbering(CTK.t)
for z in zones:
base, c = Internal.getParentOfNode(CTK.t, z)
noz = CPlot.getCPlotNumber(CTK.t, base[0], z[0])
#noz = CPlot.getCPlotNumber(CTK.t, base[0], z[0])
noz = dnz[base[0]][z[0]]
if active == -2:
active = CPlot.getActiveStatus(noz)
if active == 1: activated.append( (noz, 0) )
Expand Down Expand Up @@ -696,15 +703,18 @@ def PVT_displayNode(self, clear=False):
baseName = pid[0]
nodes = Internal.getNodesFromType1(pid, 'Zone_t')
s = 1
dnz = CPlot.updateCPlotGlobalNumbering(CTK.t)
if nodes != []:
noz = CPlot.getCPlotNumber(CTK.t, baseName, nodes[0][0])
#noz = CPlot.getCPlotNumber(CTK.t, baseName, nodes[0][0])
noz = dnz[baseName][nodes[0][0]]
s = CPlot.getSelectedStatus(noz)
if s == 0: s = 1
else: s = 0
if clear: CPlot.unselectAllZones(); s = 1 # force select
selected = []
for z in nodes:
noz = CPlot.getCPlotNumber(CTK.t, baseName, z[0])
#noz = CPlot.getCPlotNumber(CTK.t, baseName, z[0])
noz = dnz[baseName][z[0]]
selected.append((noz, s))
CPlot.setSelectedZones(selected)
if s == 1:
Expand Down Expand Up @@ -881,17 +891,20 @@ def PVT_displayNode(self, clear=False):

selected = []
s = 1
dnz = CPlot.updateCPlotGlobalNumbering(CTK.t)
if zones != []:
z = zones[0]
base, c = Internal.getParentOfNode(CTK.t, z)
noz = CPlot.getCPlotNumber(CTK.t, base[0], z[0])
#noz = CPlot.getCPlotNumber(CTK.t, base[0], z[0])
noz = dnz[base[0]][z[0]]
s = CPlot.getSelectedStatus(noz)
if s == 0: s = 1
else: s = 0
if clear: s = 1 # force select
for z in zones:
base, c = Internal.getParentOfNode(CTK.t, z)
noz = CPlot.getCPlotNumber(CTK.t, base[0], z[0])
#noz = CPlot.getCPlotNumber(CTK.t, base[0], z[0])
noz = dnz[base[0], z[0]]
selected.append((noz, s))
if clear: CPlot.unselectAllZones()
CPlot.setSelectedZones(selected)
Expand Down

0 comments on commit e9abf65

Please sign in to comment.