def initPositionValues(self):
        """ init the position values with the position of the connected node """
        
        # flag modification
        if self.flag_name:
            # open the flag file
            flagFile = newFlagDialog.FLAG_DIR_NAME + os.sep + self.flag_name
            try:
                f = file(flagFile, 'r')
            except:
                displayError(self, "Can not open the file " + flagFile)
                return 0

            # read file and close
            line = f.read()
            f.close()
            try:
                name, posX, posY = line.split(';')
            except:
                displayError(self, 'The file %s has a bad format !' %self.flag_name)
                # close the dialog box
                self.Close(FALSE)
                return 0

            # set default parameters
            self.nameTextCtrl.SetValue(name)
            self.xposTextCtrl.SetValue(posX)
            self.yposTextCtrl.SetValue(posY)

         # new flag -> check if the navigator is connected to a node
        elif (self.navigator.getIsConnected() == 1):
            posX = self.navigator.getNodePosX()
            posY = self.navigator.getNodePosY()
            self.xposTextCtrl.SetValue(str(posX))
            self.yposTextCtrl.SetValue(str(posY))
    def OnFlagsGoto(self, event):
        """ Go to the flag selected in the menu """
        id = event.GetId()
        flag = self.menuFlags.GetLabel(id)

        # display a confirmation message
        message = 'Are you sure you want to go to this flag : ' + flag + ' ?'
        dlg = wxMessageDialog(self, message, 'Go to flag', wxOK|wxCANCEL|wxCENTRE|wxICON_QUESTION)
        dlg.Center(wxBOTH)
        if dlg.ShowModal() == wxID_OK:
            # open the flag file
            flagFile = "Flags" + os.sep + flag
            try:
                f = file(flagFile, 'r')
            except:
                displayError(self, 'Can not open the file %s' %flagFile)
                return 0

            # read file and close
            line = f.read()
            f.close()
            try:
                name, posX, posY = line.split(';')
            except:
                displayError(self, 'The file %s has a bad format !' %flagFile)
                return 0
            
            # get the node AR to generate noise near the selected point
            ar = self.controller.getNodeAr()
            debug.debug_info("getNodeAr() -> " + str(ar))
            deltaNoise = long(random.random()*ar/10)            
            posX = long(posX) + deltaNoise
            posY = long(posY) + deltaNoise
                
            # jump to the flag position
            self.controller.jumpMyNode(str(posX), str(posY))
    def OnOkButton(self, event):
        """ save the flag with the parameter filled by the user """

        # get the parameters filled by the user
        name = self.nameTextCtrl.GetValue()
        posX = self.xposTextCtrl.GetValue()
        posY = self.yposTextCtrl.GetValue()

        # errors control
        if name == "":
            displayError(self, "Your flag name is empty !")
        elif posX == "":
            displayError(self, "Your flag X coordinate is empty !")
            messageDialog.ShowModal()
        elif posY == "":
            displayError(self, "Your flag Y coordinate is empty !")
        else:
            try:
                x = long(posX)
            except:
                displayError(self, "Your flag X coordinate has a bad format. Please, enter an integer.")
                return 0
            try:
                y = long(posY)
            except:
                displayError(self, "Your flag Y coordinate has a bad format. Please, enter an integer.")
                return 0

            flagFile = newFlagDialog.FLAG_DIR_NAME + os.sep + name

            # control the doublon
            if os.path.isfile(flagFile):
                displayError(self, "This flag name already exists. Please, choose another name.")
                return 0

            # flag modification
            if self.flag_name:
                # rename the flag file
                flagFile_old = newFlagDialog.FLAG_DIR_NAME + os.sep + self.flag_name
                os.rename(flagFile_old, flagFile)

            # open the flag file
            try:
                f = file(flagFile, 'w')
            except:
                displayError(self, 'Can not open the file %s' %flagFile)
                return 0

            # save the parameters in the flag file
            line = name + ';' + posX + ';'+ posY
            f.write(line)
            f.close()

            # close the dialog box
            self.Close(FALSE)