Пример #1
0
def __TextInput(X,Y,W,Na,Tx=''):
    global Widgets,HitDefs,pw,ph
    global AllowHitUpdates

    #positioning precalculations
    pwW = pw*W
    
    ph20 = ph*20

    #Widget init info
    if Na not in Widgets.keys(): Widgets[Na]=__Widget(); Widgets[Na].info=[Tx,False]
    if AllowHitUpdates: HitDefs.update({Na:[X,Y,X+pwW,Y+ph20]})

    #Widget logic
    if Widgets[Na].event.releaseL: Widgets[Na].info[1]=True #isActive = True

    State = Widgets[Na].info

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(1.0,1.0,1.0,0.25)
    __GL.glVertex2f(X,Y)
    __GL.glVertex2f(X+pwW,Y)
    __GL.glVertex2f(X+pwW,Y+ph20)
    __GL.glVertex2f(X,Y+ph20)
    __GL.glEnd()
Пример #2
0
def __TButton(X,Y,Na,St=False,Text=''):
    global Widgets,HitDefs,pw,ph
    global AllowHitUpdates

    #positioning precalculations
    pw20 = pw*20
    
    ph20 = ph*20


    #Widget init info
    if Na not in Widgets.keys():
        Widgets[Na]=__Widget()
        Widgets[Na].info=St #toggle state
    if AllowHitUpdates: HitDefs.update({Na:[X,Y,X+pw20,Y+ph20]})

    #Widget logic
    if Widgets[Na].event.releaseL: Widgets[Na].info=(False if Widgets[Na].info else True)

    State = Widgets[Na].info

    if State: __GL.glColor4f(0.0,0.0,0.0,0.25)
    else:  __GL.glColor4f(0.0,0.0,0.0,0.1)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glVertex2f(X,Y)
    __GL.glVertex2f(X+pw20,Y)
    __GL.glVertex2f(X+pw20,Y+ph20)
    __GL.glVertex2f(X,Y+ph20)
    __GL.glEnd()

    __font(X+(pw*25),Y+(ph*2),12,Text,(0,0,0,100))

    return State
Пример #3
0
def __TButton(X, Y, Na, St=False, Text=""):
    global pw, ph

    try:
        State = W_States[Na]
    except KeyError:
        State = St
        W_States.update({Na: St})
        W_Types.update({Na: "toggle"})

    W_HitDefs.update({Na: [X, Y, X + (pw * 20), Y + (ph * 20)]})

    if State:
        __GL.glColor4f(0.0, 0.0, 0.0, 0.25)
    else:
        __GL.glColor4f(0.0, 0.0, 0.0, 0.1)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glVertex2f(X, Y)
    __GL.glVertex2f(X + (pw * 20), Y)
    __GL.glVertex2f(X + (pw * 20), Y + (ph * 20))
    __GL.glVertex2f(X, Y + (ph * 20))
    __GL.glEnd()

    return State
Пример #4
0
def __TButton(X,Y,Na,St=False,Text=''):
    global W_States,W_Info,W_HitDefs,__UpdateHits
    global pw,ph

    #Widget init info
    try: W_States[Na]
    except KeyError:
        W_States.update({Na:[0,0,0,False]})
        W_Info.update({Na:St})
    if __UpdateHits: W_HitDefs.update({Na:[X,Y,X+(pw*20),Y+(ph*20)]})

    #Widget logic
    L,M,R,O = W_States[Na]
    if L==2:
        W_Info[Na]=(False if W_Info[Na] else True)
        W_States[Na][0]=0
    State = W_Info[Na]

    if State: __GL.glColor4f(0.0,0.0,0.0,0.25)
    else:  __GL.glColor4f(0.0,0.0,0.0,0.1)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glVertex2f(X,Y)
    __GL.glVertex2f(X+(pw*20),Y)
    __GL.glVertex2f(X+(pw*20),Y+(ph*20))
    __GL.glVertex2f(X,Y+(ph*20))
    __GL.glEnd()

    __font(X+(25*pw),Y+(2*ph),12,Text,(0,0,0,100))

    return State
Пример #5
0
def __Button(X1,Y1,X2,Y2,Na,Text='',fontcolor=(0,0,0,255),St=False):
    global Widgets,HitDefs,pw,ph
    global AllowHitUpdates

    #Widget init info
    if Na not in Widgets.keys(): Widgets[Na]=__Widget(); Widgets[Na].info=['button',St]
    if AllowHitUpdates: HitDefs.update({Na:[X1,Y1,X2,Y2]})

    #Widget logic
    if Widgets[Na].event.releaseL: Widgets[Na].info[1]=True

    if Widgets[Na].event.clickL or Widgets[Na].event.holdL: __GL.glColor4f(0.0,0.0,0.0,0.1)
    else:  __GL.glColor4f(0.0,0.0,0.0,0.175)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glVertex2f(X1,Y1)
    __GL.glVertex2f(X2,Y1)
    __GL.glVertex2f(X2,Y2)
    __GL.glVertex2f(X1,Y2)
    __GL.glEnd()

    __font(X1,Y1,12,Text,fontcolor,X2,Y2)

    return Widgets[Na].info[1]
Пример #6
0
def __ExPanel(X1,Y1,X2,Y2,EB,Na,MX=0,MY=0,St=True): #returns current state for other panels
    global Widgets,HitDefs,pw,ph
    global AllowHitUpdates
    
    #positioning precalculations
    pw35 = pw*35
    pw30 = pw*30
    pw25 = pw*25
    pw15 = pw*15
    pw10 = pw*10
    pw5 = pw*5
    
    ph35 = ph*35
    ph30 = ph*30
    ph25 = ph*25
    ph15 = ph*15
    ph10 = ph*10
    ph5 = ph*5

    sx=X2-X1
    sy=Y2-Y1
    hsx=sx/2
    hsy=sy/2


    #Widget init info
    if Na not in Widgets.keys():
        Widgets[Na]=__Widget()
        Widgets[Na].info=St #toggle state

    #Widget logic
    if Widgets[Na].event.releaseL: Widgets[Na].info=(False if Widgets[Na].info else True)

    State = Widgets[Na].info


    #60x15px rectangle
    if   EB==0: #top
        EBX1,EBY1,EBX2,EBY2=(X1+hsx-pw30),Y1,(X1+hsx+pw30),Y1+ph15
        TPX1,TPY1 = EBX1+pw25,EBY1+ph5; TPX2,TPY2 = EBX1+pw30,EBY1+ph10; TPX3,TPY3 = EBX1+pw35,EBY1+ph5
    elif EB==1: #right
        EBX1,EBY1,EBX2,EBY2=X2-pw15,hsy-ph30,X2,hsy+ph30
        TPX1,TPY1 = EBX1+pw10,EBY1+ph25; TPX2,TPY2 = EBX1+pw5,EBY1+ph30; TPX3,TPY3 = EBX1+pw10,EBY1+ph35
    elif EB==2: #bottom
        EBX1,EBY1,EBX2,EBY2=(X1+hsx-pw30),Y2-ph15,(X1+hsx+pw30),Y2
        TPX1,TPY1 = EBX1+pw25,EBY1+ph10; TPX2,TPY2 = EBX1+pw30,EBY1+ph5; TPX3,TPY3 = EBX1+pw35,EBY1+ph10
    elif EB==3: #left
        EBX1,EBY1,EBX2,EBY2=X1,hsy-ph30,X1+pw15,hsy+ph30
        TPX1,TPY1 = EBX1+pw5,EBY1+ph25; TPX2,TPY2 = EBX1+pw10,EBY1+ph30; TPX3,TPY3 = EBX1+pw5,EBY1+ph35

    #is the panel expanded?
    if not State:
        if   EB==0: #top
            Eq=sy-ph15; EBY1,EBY2=EBY1+Eq,EBY2+Eq
            TPY1,TPY2,TPY3=TPY1+(Eq+ph5),TPY2+(Eq-ph5),TPY3+(Eq+ph5)
        elif EB==1: #right
            Eq=sx-pw15; EBX1,EBX2=EBX1-Eq,EBX2-Eq
            TPX1,TPX2,TPX3=TPX1-(Eq+pw5),TPX2-(Eq-pw5),TPX3-(Eq+pw5)
        elif EB==2: #bottom
            Eq=sy-ph15; EBY1,EBY2=EBY1-Eq,EBY2-Eq
            TPY1,TPY2,TPY3=TPY1-(Eq+ph5),TPY2-(Eq-ph5),TPY3-(Eq+ph5)
        elif EB==3: #left
            Eq=sx-pw15; EBX1,EBX2=EBX1+Eq,EBX2+Eq
            TPX1,TPX2,TPX3=TPX1+(Eq+pw5),TPX2+(Eq-pw5),TPX3+(Eq+pw5)

        '''
        __GL.glColor4f(0.5,0.5,0.5,0.8)
        __GL.glBegin(__GL.GL_QUADS) #(just the BG color behind the toggle button)
        __GL.glVertex2f(EBX1+MX,EBY1+MY)
        __GL.glVertex2f(EBX1+MX,EBY2+MY)
        __GL.glVertex2f(EBX2+MX,EBY2+MY)
        __GL.glVertex2f(EBX2+MX,EBY1+MY)
        __GL.glEnd()
        '''
    if AllowHitUpdates: HitDefs.update({Na:[EBX1+MX,EBY1+MY,EBX2+MX,EBY2+MY]})

    __GL.glColor4f(0.0,0.0,0.0,0.175)
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex3f(TPX1+MX,TPY1+MY,0.01)
    __GL.glVertex3f(TPX2+MX,TPY2+MY,0.01)
    __GL.glVertex3f(TPX3+MX,TPY3+MY,0.01)
    __GL.glEnd()
    __GL.glBegin(__GL.GL_QUADS)
    __GL.glVertex3f(EBX1+MX,EBY1+MY,0.01)
    __GL.glVertex3f(EBX1+MX,EBY2+MY,0.01)
    __GL.glVertex3f(EBX2+MX,EBY2+MY,0.01)
    __GL.glVertex3f(EBX2+MX,EBY1+MY,0.01)
    __GL.glEnd()

    if State:
        __GL.glBegin(__GL.GL_QUADS)
        __GL.glColor4f(0.5,0.5,0.5,0.8) #model (left) panel
        __GL.glVertex3f(X1,Y1,0.0)
        __GL.glVertex3f(X1,Y2,0.0)
        __GL.glVertex3f(X2,Y2,0.0)
        __GL.glVertex3f(X2,Y1,0.0)
        __GL.glEnd()

    return State
Пример #7
0
def __OprionsUpdatePanel(w,h):
    global pw,ph,OptionsUpdatePanelExpensionState,OptionsUpdatePanelButton
    PES=OptionsUpdatePanelExpensionState #short local name from long global name

    #positioning precalculations
    pw21 = pw*21
    pw20 = pw*20
    pw13 = pw*13
    pw10 = pw*10
    pw7 = pw*7

    ph20 = ph*20
    ph14 = ph*14
    ph13 = ph*13
    ph7 = ph*7
    ph6 = ph*6


    if PES: 
        X1,Y1,X2,Y2=0.0,0.0,1.0,1.0-ph20
        TX1,TY1,TX2,TY2=0.5-pw10,1.0-ph6,0.5+pw10,1.0-ph14
    else: 
        X1,Y1,X2,Y2=0.0,0.0,1.0,0.0
        TX1,TY1,TX2,TY2=0.5-pw10,ph6,0.5+pw10,ph14
    
    
    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(0.5,0.5,0.5,0.8) #options toggle
    __GL.glVertex2f(X1,Y1); __GL.glVertex2f(X2,Y1); __GL.glVertex2f(X2,Y2); __GL.glVertex2f(X1,Y2)
    __GL.glVertex2f(X1,Y2); __GL.glVertex2f(X2-pw21,Y2); __GL.glVertex2f(X2-pw21,Y2+ph20); __GL.glVertex2f(X1,Y2+ph20)
    __GL.glVertex2f(X2-pw20,Y2); __GL.glVertex2f(X2,Y2); __GL.glVertex2f(X2,Y2+ph20); __GL.glVertex2f(X2-pw20,Y2+ph20)

    __GL.glEnd()
    __GL.glColor4f(0.0,0.0,0.0,0.2)
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex2f(TX1,TY1); __GL.glVertex2f(TX2,TY1); __GL.glVertex2f(0.5,TY2)
    __GL.glEnd()

    
    if PES: 
        if OptionsUpdatePanelButton==0: #options drawing:
            pass

        if OptionsUpdatePanelButton==1: #update drawing:
            __font(X1,Y1,12,"The Update system is still in development.",(0,0,0,255),X2,Y2)


    if __Button(X1,Y2,X2-pw21,Y2+ph20,"OptionsPanelToggleButton",""):
        if not OptionsUpdatePanelExpensionState: #open panel
            OptionsUpdatePanelExpensionState=True
            OptionsUpdatePanelButton=0
        elif OptionsUpdatePanelButton==0: OptionsUpdatePanelExpensionState=False #close panel
        else: OptionsUpdatePanelButton=0 #switch to options
        __EndButton("OptionsPanelToggleButton")
    
    if __Button(X2-pw20,Y2,X2,Y2+ph20,"UpdatePanelToggleButton",""):
        if not OptionsUpdatePanelExpensionState: #open panel
            OptionsUpdatePanelExpensionState=True
            OptionsUpdatePanelButton=1
        elif OptionsUpdatePanelButton==1: OptionsUpdatePanelExpensionState=False #close panel
        else: OptionsUpdatePanelButton=1 #switch to update
        __EndButton("UpdatePanelToggleButton")
    
    
    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(1.0,0.25,0.25,0.65) #options toggle
    __GL.glVertex2f(X2-pw13,Y2+ph7); __GL.glVertex2f(X2-pw7,Y2+ph7); __GL.glVertex2f(X2-pw7,Y2+ph13); __GL.glVertex2f(X2-pw13,Y2+ph13)
    __GL.glEnd()

    return PES
Пример #8
0
def __DropBox(X,Y,W,Na,Items,Def=0,Text=''):
    global Widgets,HitDefs,pw,ph
    global AllowHitUpdates

    #convert pixel values to screen ranges
    X2,Y2 = X+(pw*W),Y+(ph*20)
    #EG: XPosition = (1.0/ScreenWidth)*XPixelPos

    #positioning precalculations
    pw15 = pw*15
    pw5 = pw*5

    ph2 = ph*2

    sy = Y2-Y

    #Widget init info
    if Na not in Widgets.keys():
        Widgets[Na]=__Widget()
        Widgets[Na].info=[Def,False] #[selectionID,isOpen]
    if AllowHitUpdates: HitDefs.update({Na:[X,Y,X2+pw15,Y2]})

    #Widget logic
    if Widgets[Na].event.releaseL: Widgets[Na].info[1]=True #isOpen = True

    State = Widgets[Na].info

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(1.0,1.0,1.0,0.25)
    __GL.glVertex2f(X,Y)
    __GL.glVertex2f(X2,Y)
    __GL.glVertex2f(X2,Y2)
    __GL.glVertex2f(X,Y2)

    __GL.glColor4f(0.0,0.0,0.0,0.1)
    __GL.glVertex2f(X2,Y)
    __GL.glVertex2f(X2+pw15,Y)
    __GL.glVertex2f(X2+pw15,Y2)
    __GL.glVertex2f(X2,Y2)
    __GL.glEnd()

    __font(X+pw5,Y+ph2,12,Na,(0,0,0,100))

    if State[1]: #the box has been clicked
        HitDefs.clear()
        AllowHitUpdates=False #prevent hit updates from other widgets
        #(once we've made our selection, we can then allow hit updates)

        remove=False

        for i,v in enumerate(Items):
            #generate a custom widget name using the main name, the item's text, and the enumerant value
            N = '%s_%s_Sel%i'%(Na,v,i)
            x1,y1,x2,y2=X,Y+(sy*(i+1)),X2,Y2+(sy*(i+1))

            #we have to create a new widget for each entry here
            if N not in Widgets.keys(): Widgets[N]=__Widget() #test the loop run (doesn't re-create widgets)
            HitDefs.update({N:[x1,y1,x2,y2]})

            if Widgets[N].event.hasFocus: __GL.glColor4f(0.375,0.375,0.375,0.75)
            elif Widgets[N].event.holdL: __GL.glColor4f(0.5,0.5,0.5,0.75)
            else: __GL.glColor4f(0.0,0.0,0.0,0.5)
            
            __GL.glBegin(__GL.GL_QUADS)
            __GL.glVertex2f(x1,y1)
            __GL.glVertex2f(x2,y1)
            __GL.glVertex2f(x2,y2)
            __GL.glVertex2f(x1,y2)
            __GL.glEnd()

            __font(x1+pw5,y1+ph2,12,v,(200,200,200,100))

            #apply the selection and set to remove these widgets when LMB is released
            if Widgets[N].event.releaseL: Widgets[Na].info=[i,False]; remove=True

        #add a few widgets to define the click-off area
        #(anywhere on the screen that's not in this widget's range)
        # ^clicking will close the widget and keep it at it's current selection
        _DAN=['%s_DeActivator%i'%(Na,i) for i in range(4)] #custom deactivator names
        if _DAN[0] not in Widgets.keys():
            Widgets[_DAN[0]]=__Widget()
            Widgets[_DAN[1]]=__Widget()
            Widgets[_DAN[2]]=__Widget()
            Widgets[_DAN[3]]=__Widget()
        HitDefs.update({_DAN[0]:[0.0,0.0,X,1.0]}) #left
        HitDefs.update({_DAN[1]:[X2,0.0,1.0,1.0]}) #right
        HitDefs.update({_DAN[2]:[X,0.0,X2,Y2]}) #top (Y2 because the main widget has no control here)
        HitDefs.update({_DAN[3]:[X,y2,X2,1.0]}) #bottom
        
        #the logic to test for and execute a click-off
        if any([Widgets[_DAN[0]].event.clickL,Widgets[_DAN[0]].event.clickM,Widgets[_DAN[0]].event.clickR,
                Widgets[_DAN[1]].event.clickL,Widgets[_DAN[1]].event.clickM,Widgets[_DAN[1]].event.clickR,
                Widgets[_DAN[2]].event.clickL,Widgets[_DAN[2]].event.clickM,Widgets[_DAN[2]].event.clickR,
                Widgets[_DAN[3]].event.clickL,Widgets[_DAN[3]].event.clickM,Widgets[_DAN[3]].event.clickR]):
            Widgets[Na].info[1]=False #isOpen = False
            remove=True

        if remove: #remove the selection widgets and click-off widgets
            for i,v in enumerate(Items): Widgets.pop('%s_%s_Sel%i'%(Na,v,i)); 
            Widgets.pop(_DAN[0]) #left
            Widgets.pop(_DAN[1]) #right
            Widgets.pop(_DAN[2]) #top (Y2 because the widget has no control here)
            Widgets.pop(_DAN[3]) #bottom
            HitDefs.clear()
            AllowHitUpdates=True


    return State[0]
Пример #9
0
def __DrawGUI(w, h, RotMatrix):  # called directly by the display function after drawing the scene
    global pw, ph
    # the GUI is drawn over the scene by clearing the depth buffer
    pw, ph = 1.0 / w, 1.0 / h

    global W_HitDefs
    W_HitDefs = {}  # clear the hitdefs to avoid improper activation

    __GL.glMatrixMode(__GL.GL_PROJECTION)
    __GL.glLoadIdentity()
    # glOrtho(-2*P, 2*P, -2, 2, -100, 100)
    __GLU.gluOrtho2D(0.0, 1.0, 1.0, 0.0)

    __GL.glMatrixMode(__GL.GL_MODELVIEW)

    __GL.glClear(__GL.GL_DEPTH_BUFFER_BIT)
    __GL.glPolygonMode(__GL.GL_FRONT_AND_BACK, __GL.GL_FILL)

    __GL.glLoadIdentity()

    __GL.glEnable(__GL.GL_BLEND)
    __GL.glDisable(__GL.GL_DEPTH_TEST)
    __GL.glDisable(__GL.GL_LIGHTING)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(0.4, 0.4, 0.4, 0.8)  # options toggle
    __GL.glVertex2f(pw * 0, ph * 0)
    __GL.glVertex2f(pw * w, ph * 0)
    __GL.glVertex2f(pw * w, ph * 20)
    __GL.glVertex2f(pw * 0, ph * 20)
    __GL.glEnd()
    __GL.glColor4f(0.0, 0.0, 0.0, 0.2)
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex2f(pw * ((w / 2) - 10), ph * 6)
    __GL.glVertex2f(pw * ((w / 2) + 10), ph * 6)
    __GL.glVertex2f(pw * (w / 2), ph * 15)
    __GL.glEnd()

    M = __ExPanel(pw * 0, ph * 21, pw * 210, ph * h, 1, "MODEL")
    if M:
        __BrowseBar(pw * 10, ph * 40, 180)

    A = __ExPanel(pw * (w - 210), ph * 21, pw * w, ph * h, 3, "ANIM")
    D = __ExPanel(
        pw * (211 if M else 1),
        ph * 21,
        pw * (w - (211 if A else 1)),
        ph * 150,
        2,
        "DSPL",
        (0 if M else pw * 105) + (0 if A else pw * -105),
    )
    if D:
        VIEWER.TOGGLE_LIGHTING = __TButton(pw * (221 if M else 11), ph * 31, "EnLight", True, "Lighting")
        VIEWER.TOGGLE_WIREFRAME = __TButton(pw * (221 if M else 11), ph * 56, "EnWire", False, "Wireframe")
        VIEWER.TOGGLE_BONES = __TButton(pw * (221 if M else 11), ph * 81, "EnBone", True, "Bones")

        global ORTHO
        if VIEWER.TOGGLE_ORTHO != ORTHO:
            W_States["EnOrtho"] = VIEWER.TOGGLE_ORTHO
            ORTHO = VIEWER.TOGGLE_ORTHO  # HACK
        ORTHO = __TButton(pw * (321 if M else 111), ph * 31, "EnOrtho", True, "Ortho")
        VIEWER.TOGGLE_ORTHO = ORTHO

        VIEWER.TOGGLE_3D = __TButton(pw * (321 if M else 111), ph * 56, "En3D", False, "3D Analglyph")
        VIEWER.TOGGLE_NORMALS = __TButton(pw * (321 if M else 111), ph * 81, "EnNrm", False, "Normals")

    C = __ExPanel(
        pw * (211 if M else 1),
        ph * (h - 150),
        pw * (w - (211 if A else 1)),
        ph * h,
        0,
        "CTRL",
        (0 if M else pw * 105) + (0 if A else pw * -105),
    )

    __GL.glDisable(__GL.GL_BLEND)
    __GL.glEnable(__GL.GL_DEPTH_TEST)

    # axis
    __GL.glLineWidth(1.0)
    __GL.glPushMatrix()
    __GL.glTranslatef(pw * (228 if M else 17), ph * (h - (167 if C else 17)), 0)
    __GL.glScalef(pw * 600, ph * 600, 1)
    __GL.glMultMatrixf(RotMatrix)

    __GL.glColor3f(1.0, 0.0, 0.0)
    __GL.glBegin(__GL.GL_LINES)
    __GL.glVertex3f(0.0, 0.0, 0.0)
    __GL.glVertex3f(0.02, 0.0, 0.0)
    __GL.glEnd()  # X
    __GL.glTranslatef(0.0145, 0.0, 0.0)
    __GL.glRotatef(90, 0.0, 1.0, 0.0)
    # __GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 0.0, 1.0, 0.0)
    __GL.glTranslatef(-0.0145, 0.0, 0.0)
    __GL.glColor3f(0.0, 1.0, 0.0)
    __GL.glBegin(__GL.GL_LINES)
    __GL.glVertex3f(0.0, 0.0, 0.0)
    __GL.glVertex3f(0.0, -0.02, 0.0)
    __GL.glEnd()  # Y
    __GL.glTranslatef(0.0, -0.0145, 0.0)
    __GL.glRotatef(90, 1.0, 0.0, 0.0)
    # __GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 1.0, 0.0, 0.0)
    __GL.glTranslatef(0.0, 0.0145, 0.0)
    __GL.glColor3f(0.0, 0.0, 1.0)
    __GL.glBegin(__GL.GL_LINES)
    __GL.glVertex3f(0.0, 0.0, 0.0)
    __GL.glVertex3f(0.0, 0.0, 0.02)
    __GL.glEnd()  # Z
    __GL.glTranslatef(0.0, 0.0, 0.0145)
    # __GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glTranslatef(0.0, 0.0, -0.0145)
    __GL.glColor3f(0.5, 0.5, 0.5)
    # __GLUT.glutSolidSphere(0.003, 8, 4)
    __GL.glPopMatrix()
Пример #10
0
def __ExPanel(X1, Y1, X2, Y2, EB, Na, MX=0, MY=0, St=True):  # returns current state for other widgets
    global pw, ph

    try:
        State = W_States[Na]
    except KeyError:
        State = St
        W_States.update({Na: St})
        W_Types.update({Na: "toggle"})

    if State:
        __GL.glBegin(__GL.GL_QUADS)
        __GL.glColor4f(0.5, 0.5, 0.5, 0.8)  # model (left) panel
        __GL.glVertex2f(X1, Y1)
        __GL.glVertex2f(X1, Y2)
        __GL.glVertex2f(X2, Y2)
        __GL.glVertex2f(X2, Y1)
        __GL.glEnd()

        # 60x15px rectangle
    if EB == 0:  # top
        EBX1, EBY1, EBX2, EBY2 = (
            (X1 + ((X2 - X1) / 2) - (pw * 30)),
            Y1,
            (X1 + ((X2 - X1) / 2) + (pw * 30)),
            Y1 + (ph * 15),
        )
        TPX1, TPY1 = EBX1 + (pw * 25), EBY1 + (ph * 5)
        TPX2, TPY2 = EBX1 + (pw * 30), EBY1 + (ph * 10)
        TPX3, TPY3 = EBX1 + (pw * 35), EBY1 + (ph * 5)
    elif EB == 1:  # right
        EBX1, EBY1, EBX2, EBY2 = X2 - (pw * 15), ((Y2 - Y1) / 2) - (ph * 30), X2, ((Y2 - Y1) / 2) + (ph * 30)
        TPX1, TPY1 = EBX1 + (pw * 10), EBY1 + (ph * 25)
        TPX2, TPY2 = EBX1 + (pw * 5), EBY1 + (ph * 30)
        TPX3, TPY3 = EBX1 + (pw * 10), EBY1 + (ph * 35)
    elif EB == 2:  # bottom
        EBX1, EBY1, EBX2, EBY2 = (
            (X1 + ((X2 - X1) / 2) - (pw * 30)),
            Y2 - (ph * 15),
            (X1 + ((X2 - X1) / 2) + (pw * 30)),
            Y2,
        )
        TPX1, TPY1 = EBX1 + (pw * 25), EBY1 + (ph * 10)
        TPX2, TPY2 = EBX1 + (pw * 30), EBY1 + (ph * 5)
        TPX3, TPY3 = EBX1 + (pw * 35), EBY1 + (ph * 10)
    elif EB == 3:  # left
        EBX1, EBY1, EBX2, EBY2 = X1, ((Y2 - Y1) / 2) - (ph * 30), X1 + (pw * 15), ((Y2 - Y1) / 2) + (ph * 30)
        TPX1, TPY1 = EBX1 + (pw * 5), EBY1 + (ph * 25)
        TPX2, TPY2 = EBX1 + (pw * 10), EBY1 + (ph * 30)
        TPX3, TPY3 = EBX1 + (pw * 5), EBY1 + (ph * 35)

        # is the panel expanded?
    if not State:
        if EB == 0:  # top
            Eq = (Y2 - Y1) - (ph * 15)
            EBY1, EBY2 = EBY1 + Eq, EBY2 + Eq
            TPY1, TPY2, TPY3 = TPY1 + (Eq + (ph * 5)), TPY2 + (Eq - (ph * 5)), TPY3 + (Eq + (ph * 5))
        elif EB == 1:  # right
            Eq = (X2 - X1) - (pw * 15)
            EBX1, EBX2 = EBX1 - Eq, EBX2 - Eq
            TPX1, TPX2, TPX3 = TPX1 - (Eq + (pw * 5)), TPX2 - (Eq - (pw * 5)), TPX3 - (Eq + (pw * 5))
        elif EB == 2:  # bottom
            Eq = (Y2 - Y1) - (ph * 15)
            EBY1, EBY2 = EBY1 - Eq, EBY2 - Eq
            TPY1, TPY2, TPY3 = TPY1 - (Eq + (ph * 5)), TPY2 - (Eq - (ph * 5)), TPY3 - (Eq + (ph * 5))
        elif EB == 3:  # left
            Eq = (X2 - X1) - (pw * 15)
            EBX1, EBX2 = EBX1 + Eq, EBX2 + Eq
            TPX1, TPX2, TPX3 = TPX1 + (Eq + (pw * 5)), TPX2 + (Eq - (pw * 5)), TPX3 + (Eq + (pw * 5))

        __GL.glColor4f(0.5, 0.5, 0.5, 0.8)
        __GL.glBegin(__GL.GL_QUADS)  # (just the BG color behind the toggle button)
        __GL.glVertex2f(EBX1 + MX, EBY1 + MY)
        __GL.glVertex2f(EBX1 + MX, EBY2 + MY)
        __GL.glVertex2f(EBX2 + MX, EBY2 + MY)
        __GL.glVertex2f(EBX2 + MX, EBY1 + MY)
        __GL.glEnd()

    W_HitDefs.update({Na: [EBX1 + MX, EBY1 + MY, EBX2 + MX, EBY2 + MY]})

    __GL.glColor4f(0.0, 0.0, 0.0, 0.2)
    __GL.glBegin(__GL.GL_QUADS)
    __GL.glVertex2f(EBX1 + MX, EBY1 + MY)
    __GL.glVertex2f(EBX1 + MX, EBY2 + MY)
    __GL.glVertex2f(EBX2 + MX, EBY2 + MY)
    __GL.glVertex2f(EBX2 + MX, EBY1 + MY)
    __GL.glEnd()
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex2f(TPX1 + MX, TPY1 + MY)
    __GL.glVertex2f(TPX2 + MX, TPY2 + MY)
    __GL.glVertex2f(TPX3 + MX, TPY3 + MY)
    __GL.glEnd()

    return State
Пример #11
0
def __DrawGUI(w,h,RotMatrix): #called directly by the display function after drawing the scene

    global pw,ph
    #the GUI is drawn over the scene by clearing the depth buffer
    pw,ph=1./w,1./h

    global W_HitDefs
    W_HitDefs = {} #clear the hitdefs to avoid improper activation

    __GL.glMatrixMode(__GL.GL_PROJECTION)
    __GL.glLoadIdentity()
    #glOrtho(-2*P, 2*P, -2, 2, -100, 100)
    __GLU.gluOrtho2D(0.0, 1.0, 1.0, 0.0) #TODO update the viewport with the pixel range instead of 1.0 (less GUI calculations will be needed)

    __GL.glMatrixMode(__GL.GL_MODELVIEW)

    __GL.glClear( __GL.GL_DEPTH_BUFFER_BIT )
    __GL.glPolygonMode(__GL.GL_FRONT_AND_BACK,__GL.GL_FILL)

    __GL.glLoadIdentity()

    __GL.glEnable(__GL.GL_BLEND)
    __GL.glDisable(__GL.GL_DEPTH_TEST)
    __GL.glDisable(__GL.GL_TEXTURE_2D)
    __GL.glDisable(__GL.GL_LIGHTING)

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(0.4,0.4,0.4,0.8) #options toggle
    __GL.glVertex2f(pw*0,ph*0)
    __GL.glVertex2f(pw*w,ph*0)
    __GL.glVertex2f(pw*w,ph*20)
    __GL.glVertex2f(pw*0,ph*20)
    __GL.glEnd()
    __GL.glColor4f(0.0,0.0,0.0,0.2)
    __GL.glBegin(__GL.GL_TRIANGLES)
    __GL.glVertex2f(pw*((w/2)-10),ph*6)
    __GL.glVertex2f(pw*((w/2)+10),ph*6)
    __GL.glVertex2f(pw*(w/2),ph*15)
    __GL.glEnd()

    M = __ExPanel(pw*0,ph*21,pw*210,ph*h,1,'MODEL')
    if M: __ModelPanel()

    A = __ExPanel(pw*(w-210),ph*21,pw*w,ph*h,3,'ANIM')
    if A: __AnimPanel()

    D = __ExPanel(pw*(211 if M else 1),ph*21,pw*(w-(211 if A else 1)),ph*150,2,'DSPL',(0 if M else pw*105)+(0 if A else pw*-105))
    if D: __DisplayPanel(210 if M else 0,-210 if A else 0)

    C = __ExPanel(pw*(211 if M else 1),ph*(h-150),pw*(w-(211 if A else 1)),ph*h,0,'CTRL',(0 if M else pw*105)+(0 if A else pw*-105))
    if C: __ControlPanel(210 if M else 0,-210 if A else 0)


    #__font(40,40,14,"testing",(128,0,0,100))


    __GL.glDisable(__GL.GL_BLEND)
    __GL.glEnable(__GL.GL_DEPTH_TEST)

    #axis
    __GL.glLineWidth(1.0)
    __GL.glPushMatrix()
    __GL.glTranslatef(pw*(228 if M else 17),ph*(h-(167 if C else 17)),0)
    __GL.glScalef(pw*600,ph*600,1)

    __GL.glMultMatrixf(RotMatrix)

    __GL.glColor3f(1.0,0.0,0.0)
    __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.02,0.0,0.0); __GL.glEnd() #X
    __GL.glTranslatef(0.0145,0.0,0.0); __GL.glRotatef(90, 0.0, 1.0, 0.0)
    #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 0.0, 1.0, 0.0); __GL.glTranslatef(-0.0145,0.0,0.0)

    __GL.glColor3f(0.0,1.0,0.0)
    __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.0,-0.02,0.0); __GL.glEnd() #Y
    __GL.glTranslatef(0.0,-0.0145,0.0); __GL.glRotatef(90, 1.0, 0.0, 0.0)
    #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glRotatef(-90, 1.0, 0.0, 0.0); __GL.glTranslatef(0.0,0.0145,0.0)

    __GL.glColor3f(0.0,0.0,1.0)
    __GL.glBegin(__GL.GL_LINES); __GL.glVertex3f(0.0,0.0,0.0); __GL.glVertex3f(0.0,0.0,0.02); __GL.glEnd() #Z
    __GL.glTranslatef(0.0,0.0,0.0145)
    #__GLUT.glutSolidCone(0.003, 0.011, 8, 1)
    __GL.glTranslatef(0.0,0.0,-0.0145)

    __GL.glColor3f(0.5,0.5,0.5) ; #__GLUT.glutSolidSphere(0.003, 8, 4)
    __GL.glPopMatrix()
Пример #12
0
def __DropBox(X,Y,W,Na,Items,Def=0,Text=''):
    global W_States,W_Info,W_HitDefs,__UpdateHits
    global pw,ph

    X2,Y2 = X+(pw*(W*10)),Y+(ph*20)

    #Widget init info
    try: W_States[Na]
    except KeyError:
        W_States.update({Na:[0,0,0,False]})
        W_Info.update({Na:[Def,False]})
    if __UpdateHits: W_HitDefs.update({Na:[X,Y,X2+(pw*15),Y2]})

    #Widget logic
    L,M,R,O = W_States[Na]
    if L==2:
        W_Info[Na][1]=True
        W_States[Na][0]=0
    State = W_Info[Na]

    __GL.glBegin(__GL.GL_QUADS)
    __GL.glColor4f(1.0,1.0,1.0,0.25)
    __GL.glVertex2f(X,Y)
    __GL.glVertex2f(X2,Y)
    __GL.glVertex2f(X2,Y2)
    __GL.glVertex2f(X,Y2)

    __GL.glColor4f(0.0,0.0,0.0,0.1)
    __GL.glVertex2f(X2,Y)
    __GL.glVertex2f(X2+(pw*15),Y)
    __GL.glVertex2f(X2+(pw*15),Y2)
    __GL.glVertex2f(X2,Y2)
    __GL.glEnd()

    __font(X+(5*pw),Y+(2*ph),12,Na,(0,0,0,100))

    if State[1]:
        W_HitDefs={}
        __UpdateHits=False #prevent hit updates from other widgets
        #once we've made our selection, we can then allow hit updates

        remove=False

        
        for i,v in enumerate(Items):
            #we have to create custom widget defs for each entry here
            N = '%s_%s_Sel%i'%(Na,v,i) #Na+v+'_Sel'+str(i)
            x1,y1,x2,y2=X,Y+((Y2-Y)*(i+1)),X2,Y2+((Y2-Y)*(i+1))
            try: W_States[N]
            except KeyError: W_States.update({N:[0,0,0,False]}) #mouse updates
            W_HitDefs.update({N:[x1,y1,x2,y2]})
            #these should be the only hits avaliable

            l,m,r,o = W_States[N]
            #all we need to worry about here, is the state, and the hit-def
            if o: __GL.glColor4f(0.375,0.375,0.375,0.75)
            else: __GL.glColor4f(0.0,0.0,0.0,0.5)
            
            __GL.glBegin(__GL.GL_QUADS)
            __GL.glVertex2f(x1,y1)
            __GL.glVertex2f(x2,y1)
            __GL.glVertex2f(x2,y2)
            __GL.glVertex2f(x1,y2)
            __GL.glEnd()

            __font(x1+(5*pw),y1+(2*ph),12,v,(200,200,200,100))

            if l==2:
                W_Info[Na]=[i,False] #State should not be an index
                remove=True


        if remove:
            for i,v in enumerate(Items): #clear the buffers of these widgets
                n = '%s_%s_Sel%i'%(Na,v,i)
                W_States.pop(n)
                W_HitDefs.pop(n)
            __UpdateHits=True


    return State[0]