Beispiel #1
0
 def display(self, writer=None):
     debug("shape Display")
     if self.shape != None:
         if (writer != None):
             writer.Transfer(self.shape)
         else:
             debug("Line style is %s" % (self.style, ))
             ais_context = Singleton.sd.display.GetContext()
             if (self.style == 'hidden'):
                 ais_shp = AIS_Shape(self.shape)
                 ais_shp.SetWidth(0.1)
                 ais_shp.SetTransparency(0.10)
                 ais_shp.SetColor(rgb_color(0, 0, 0))
                 aspect = ais_shp.Attributes().WireAspect()
                 aspect.SetColor(rgb_color(0, 0, 0))
                 aspect.SetTypeOfLine(1)
                 ais_context.Display(ais_shp, True)
             elif (self.style == 'main_projection'):
                 ais_shp = AIS_Shape(self.shape)
                 ais_shp.SetWidth(5)
                 #ais_shp.SetTransparency(0)
                 #ais_shp.SetColor(rgb_color(0,0,0))
                 aspect = ais_shp.Attributes().WireAspect()
                 aspect.SetColor(rgb_color(0, 0, 0))
                 aspect.SetTypeOfLine(0)
                 ais_context.Display(ais_shp, True)
             else:
                 ais_context = Singleton.sd.display.GetContext()
                 ais_shp = AIS_Shape(self.shape)
                 ais_shp.SetWidth(2.0)
                 ais_shp.SetTypeOfHLR(2)
                 if (is_var_set(self.shape_color)):
                     ais_shp.SetColor(self.shape_color)
                 else:
                     ais_shp.SetColor(Quantity_Color(Quantity_NOC_PERU))
                 if (self.display_mode == DISP_MODE_WIREFRAME):
                     ais_context.SetDisplayMode(ais_shp, AIS_WireFrame,
                                                True)
                 else:
                     ais_context.SetDisplayMode(ais_shp, AIS_Shaded, True)
                 ais_context.Display(ais_shp, True)
     else:
         warning("Empty shape")
Beispiel #2
0
##
##You should have received a copy of the GNU Lesser General Public License
##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.


from OCC.Core.AIS import AIS_Shape
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()

#
# Create a box
#
s = BRepPrimAPI_MakeBox(200, 100, 50).Shape()
#
# Create an AIS_Shape from the previous shape
#
ais_shp = AIS_Shape(s)
ais_shp.SetWidth(4)
ais_shp.SetTransparency(0.10)

#
# Get context and display shape
#
# Get Context
ais_context = display.GetContext()
ais_context.Display(ais_shp)

display.View_Iso()
display.FitAll()
start_display()