コード例 #1
0
    def linkMarkers(self, context, bmarkerobjects):
        if(len(bmarkerobjects) > 1):
            adam = getMeshForBlenderMarker(bmarkerobjects[0]);
            eve = getMeshForBlenderMarker(bmarkerobjects[1]);
            
            if(adam.name != eve.name):                
                ahmarker = getGenericLandmark(adam, bmarkerobjects[0]);
                ehmarker = getGenericLandmark(eve, bmarkerobjects[1]);
                
                if(ahmarker.is_linked or ehmarker.is_linked):
                    message = "You cannot link markers that are already linked";
                    bpy.ops.genericlandmarks.messagebox('INVOKE_DEFAULT',messagetype='ERROR',message=message,messagelinesize=60);
                    return;
                
                ahmarker.is_linked = True;
                ehmarker.is_linked = True;
                ahmarker.linked_id = ehmarker.id;
                ehmarker.linked_id = ahmarker.id;
                    
                changeMarkerColor(adam, bmarkerobjects[0]);
                changeMarkerColor(eve, bmarkerobjects[1]);
                
                
                slinkedmarkers = [m for m in adam.generic_landmarks if m.is_linked];
                tlinkedmarkers = [m for m in eve.generic_landmarks if m.is_linked];

                smarkersnum = len(adam.generic_landmarks);
                tmarkersnum = len(eve.generic_landmarks);

                slinkednum = len(slinkedmarkers);
                tlinkednum = len(tlinkedmarkers);

                sunlinkednum = smarkersnum - slinkednum;
                tunlinkednum = tmarkersnum - tlinkednum;
                
                print(sunlinkednum, tunlinkednum, slinkednum, tlinkednum, smarkersnum, tmarkersnum);
                bpy.ops.object.select_all(action="DESELECT");
                if(not self.silence):
                    if((sunlinkednum + tunlinkednum) == 0):
                        message = "All the landmarks in Source and Target are Linked \n";
                    else:
                        message = "Landmark "+str(ahmarker.id)+" in "+adam.name;
                        message += "\n is now linked to Landmark"+str(ehmarker.id)+" in "+eve.name;
                
                    bpy.ops.genericlandmarks.messagebox('INVOKE_DEFAULT',messagetype='INFO',message=message,messagelinesize=60);
            
            else:
                if(not self.silence):
                    message = "You cannot link markers in the same mesh";
                    bpy.ops.genericlandmarks.messagebox('INVOKE_DEFAULT',messagetype='ERROR',message=message,messagelinesize=60);
コード例 #2
0
def updateLandmarkName(self, context):
    #     print('WHO AM I : ', self);
    mesh, isM, isN = getMarkerOwner(self)
    if (mesh):
        data_landmark = getGenericLandmark(mesh, self)
        if (data_landmark):
            data_landmark.landmark_name = self.edit_landmark_name
コード例 #3
0
    def update(self, context):
        # Get the currently selected objects
        sel = context.selected_objects

        if (len(sel) < 1):
            return

        marker = sel[0]

        if (marker.is_visual_landmark):
            M, N = detectMN(marker)
        else:
            return

        belongsto = getMeshForBlenderMarker(marker)

        bpy.ops.object.select_all(action='DESELECT')  #deselect all object

        hmarker = getGenericLandmark(belongsto, marker)

        if (belongsto == M):
            sourcemarker = marker
            targetmarker = self.getPairMarker(context, hmarker, M, N)

        elif (belongsto == N):
            targetmarker = marker
            sourcemarker = self.getPairMarker(context, hmarker, N, M)

        if (sourcemarker is not None and targetmarker is not None):
            sourcemarker.select = True
            targetmarker.select = True
コード例 #4
0
    def unLinkMarkers(self, context, bmarkerobjects):
        if (len(bmarkerobjects) > 0):
            source, target = detectMN(bmarkerobjects[0])
            if (not source and not target):
                message = "Linking or Unlinking of landmarks is a concept applied only to mesh pairs with a bijective landmarks correspondence"
                bpy.ops.genericlandmarks.messagebox('INVOKE_DEFAULT',
                                                    messagetype='ERROR',
                                                    message=message,
                                                    messagelinesize=60)
                return
            for m in bmarkerobjects:
                info = m.name.split("_marker_")
                belongsto = bpy.data.objects[info[0]]
                hmarker = getGenericLandmark(belongsto, m)

                if (hmarker.is_linked):
                    hmarker.is_linked = False
                    hmarker.linked_id = -1
                else:
                    if (len(bmarkerobjects) < 2):
                        message = "You cannot unlink a marker that is not linked to any markers"
                        bpy.ops.genericlandmarks.messagebox(
                            'INVOKE_DEFAULT',
                            messagetype='ERROR',
                            message=message,
                            messagelinesize=60)

            for m in source.generic_landmarks:
                if (m.is_linked):
                    tm = [
                        tm for tm in target.generic_landmarks
                        if tm.id == m.linked_id
                    ][0]
                    if (not tm.is_linked):
                        m.is_linked = False
                        m.linked_id = -1
                        changeUnlinkedMarkerColor(source,
                                                  getBlenderMarker(source, m))
                        changeUnlinkedMarkerColor(target,
                                                  getBlenderMarker(target, tm))
                else:
                    changeUnlinkedMarkerColor(source,
                                              getBlenderMarker(source, m))

            for m in target.generic_landmarks:
                if (m.is_linked):
                    sm = [
                        sm for sm in source.generic_landmarks
                        if sm.id == m.linked_id
                    ][0]
                    if (not sm.is_linked):
                        m.is_linked = False
                        m.linked_id = -1
                        changeUnlinkedMarkerColor(target,
                                                  getBlenderMarker(target, m))
                        changeUnlinkedMarkerColor(source,
                                                  getBlenderMarker(source, sm))
                else:
                    changeUnlinkedMarkerColor(target,
                                              getBlenderMarker(target, m))
コード例 #5
0
def setLandmarkName(self, value):
    mesh, isM, isN = getMarkerOwner(self)
    if (mesh):
        data_landmark = getGenericLandmark(mesh, self)
        if (data_landmark):
            data_landmark.landmark_name = value

    self['edit_landmark_name'] = value
コード例 #6
0
def getLandmarkName(self):
    #     print('WHO AM I : ', self);
    mesh, isM, isN = getMarkerOwner(self)
    if (mesh):
        data_landmark = getGenericLandmark(mesh, self)
        if (data_landmark):
            return data_landmark.landmark_name

    return "No Name"