Example #1
0
 def bind_model(self, model):
     self.model_manager = ModelManager(model)
     pois_str = session.get('pois')
     if pois_str:
         pois_obj = util.parse_pois_str(pois_str)
         self.model_manager.bind_pois(pois_obj)
     self.vsf.bind_model(self.model_manager)
     self.vcf.bind_model(self.model_manager)
Example #2
0
    def add_units(self, units):
        ModelManager.empty_model_list(ModelManager.MODEL_UNIT)

        for unit_object in units:
            unit = Models.Clip()
            unit.unit_name = unit_object['unit_name']
            unit.type = unit_object['type']
            unit.online = unit_object['online']
            ModelManager.register_model(unit, ModelManager.MODEL_UNIT)
Example #3
0
	def add_units(self, units):
		ModelManager.empty_model_list(ModelManager.MODEL_UNIT)

		for unit_object in units:
			unit = Models.Clip()
			unit.unit_name = unit_object['unit_name']
			unit.type = unit_object['type']
			unit.online = unit_object['online']
			ModelManager.register_model(unit, ModelManager.MODEL_UNIT)
Example #4
0
    def add_units(self, units):
        unit_list = []
        for unit_object in units:
            unit = Models.Unit()
            unit.unit_name = unit_object['unit_name']
            unit.type = unit_object['type']
            unit.online = unit_object['online']
            unit_list.append(unit)
            ModelManager.register_model(unit, ModelManager.MODEL_UNIT)
            self.get_eof_from_unit(unit.unit_name)

        self.find_all_existing_clips(unit_list)
Example #5
0
	def add_units(self, units):
		unit_list = []
		for unit_object in units:
			unit = Models.Unit()
			unit.unit_name = unit_object['unit_name']
			unit.type = unit_object['type']
			unit.online = unit_object['online']
			unit_list.append(unit)
			ModelManager.register_model(unit, ModelManager.MODEL_UNIT)
			self.get_eof_from_unit(unit.unit_name)

		self.find_all_existing_clips(unit_list)
	def on_view_added(self, view):
		self.view.window.set_title(Smelted_Settings.program_title)
		self.playlist_list_store = self.view.builder.get_object("playlist_list_store")
		self.unit_list_store = self.view.builder.get_object("unit_list_store")
		self.unit_tree_view = self.view.builder.get_object("unit_tree_view")
		self.playlist_tree_view = self.view.builder.get_object("playlist_tree_view")
		self.progress_label = self.view.builder.get_object("progress_label")

		self.in_slider_view = self.view.builder.get_object("in_slider")
		self.out_slider_view = self.view.builder.get_object("out_slider")

		self.in_slider_label_view = self.view.builder.get_object("in_slider_label")
		self.out_slider_label_view = self.view.builder.get_object("out_slider_label")

		# create combo box column on playlist tree view, should be moved to view if time allows
		end_event_list_store = Gtk.ListStore(str)
		self.end_event_list_items = ["Stop", "Loop", "Continue", "Pause"]
		for item in self.end_event_list_items:
			end_event_list_store.append([item])

		renderer_combo = Gtk.CellRendererCombo()
		renderer_combo.set_property("editable", True)
		renderer_combo.set_property("model", end_event_list_store)
		renderer_combo.set_property("text-column", 0)
		renderer_combo.set_property("has-entry", False)
		renderer_combo.connect("edited", self.on_combo_changed)

		column_combo = Gtk.TreeViewColumn("Unit Ended Event", renderer_combo, text=1)
		self.unit_tree_view.append_column(column_combo)

		ModelManager.register_on_model_added_callback(self.refresh_clips, ModelManager.MODEL_CLIP)
		ModelManager.register_on_model_added_callback(self.add_unit, ModelManager.MODEL_UNIT)
		ModelManager.register_on_model_list_emptied_callback(self.remove_units, ModelManager.MODEL_UNIT)

		ModelManager.register_on_attribute_changed_callback(self.update_seek_progress, Models.Clip.CLIP_PROGRESS)
Example #7
0
	def check_unit_exists(self, unit_name):
		units = ModelManager.get_models(ModelManager.MODEL_UNIT)
		for unit in units:
			if unit.unit_name == unit_name:
				return True
				break
		return False
Example #8
0
    def playlist_tree_view_cursor_changed(self, index):
        clip = None

        clip_list = ModelManager.get_models(ModelManager.MODEL_CLIP)
        for clip_candidate in clip_list:
            if str(
                    index
            ) == clip_candidate.index and Smelted_Settings.current_unit == clip_candidate.unit:
                clip = clip_candidate
                break

        if clip:
            total_seconds_in = math.floor(
                float(clip.clip_in) / float(clip.fps))
            total_seconds_out = math.floor(
                float(clip.clip_out) / float(clip.fps))

            label_text_in = self.convert_total_seconds_to_time(
                total_seconds_in)
            label_text_out = self.convert_total_seconds_to_time(
                total_seconds_out)

            GObject.idle_add(self.update_label_text,
                             self.out_slider_label_view, label_text_out)
            GObject.idle_add(self.update_label_text, self.in_slider_label_view,
                             label_text_in)

            GObject.idle_add(self.update_slider, self.out_slider_view,
                             int(clip.calculated_length), int(clip.clip_out))
            GObject.idle_add(self.update_slider, self.in_slider_view,
                             int(clip.calculated_length), int(clip.clip_in))
Example #9
0
 def check_unit_exists(self, unit_name):
     units = ModelManager.get_models(ModelManager.MODEL_UNIT)
     for unit in units:
         if unit.unit_name == unit_name:
             return True
             break
     return False
Example #10
0
 def update_gui(self, result, data):
     clip_list = ModelManager.get_models(ModelManager.MODEL_CLIP)
     for clip in clip_list:
         if result["clip_index"] == clip.index and "U" + result[
                 "unit"] == clip.unit:
             clip.set_clip_progress(result["current_position"])
             break
	def import_playlist(self, file):
		units_controller = self.main_controller.get_units_controller()

		tree = etree.parse(file)
		playlist_root = tree.getroot()
		if playlist_root.tag == 'playlist':
			# cleaning old units
			old_units = ModelManager.get_models(ModelManager.MODEL_UNIT)
			for unit in old_units:
				self.melted_telnet_controller.clean_unit(unit.unit_name)
				units_controller.find_clips_on_unit(unit.unit_name)

			for unit in playlist_root:
				# a bit reliant on unit names
				unit_name = unit.attrib.get('name')
				if not units_controller.check_unit_exists(unit_name):
					self.melted_telnet_controller.create_melted_unit()
					units_controller.find_existing_units()

				if unit.attrib.get('eof'):
					self.melted_telnet_controller.clip_end_event(unit_name, unit.attrib.get('eof'))
					self.main_controller.get_units_controller().get_eof_from_unit(unit_name)

				self.melted_telnet_controller.set_unit_points(unit_name, "ignore")

				for clip in unit:
					self.melted_telnet_controller.append_clip_to_queue(unit_name, clip.find("path").text)
					# if unit_name == Smelted_Settings.current_unit:
						# self.melted_telnet_controller.set_clip_in_point(unit.attrib.get('name'), clip.find("in").text, clip.get('index'))
						# self.melted_telnet_controller.set_clip_out_point(unit.attrib.get('name'), clip.find("out").text, clip.get('index'))
				self.melted_telnet_controller.set_unit_points(unit_name, "use")
				units_controller.find_clips_on_unit(unit_name)
		else:
			self.file_error()
	def refresh_clips(self, clip=None):
		GObject.idle_add(self.clear_list_model, self.playlist_list_store)
		clips = ModelManager.get_models(ModelManager.MODEL_CLIP)
		clip_index = 0
		for clip in clips:
			if clip.unit == Smelted_Settings.current_unit:
				GObject.idle_add(self.update_list_model, self.playlist_list_store, [os.path.basename(clip.path), int(clip.index), "#FFFFFF"])
				clip_index += 1
	def get_clip_by_playlist_cursor(self):
		model, list_iter = self.playlist_tree_view.get_selection().get_selected()
		if list_iter is not None:
			index = model.get_path(list_iter)[0]

			clip_list = ModelManager.get_models(ModelManager.MODEL_CLIP)
			for clip_candidate in clip_list:
				if str(index) == clip_candidate.index and Smelted_Settings.current_unit == clip_candidate.unit:
					return clip_candidate
					break
		return None
Example #14
0
	def add_clips(self, clips, unit_name):
		unit = self.pending_unit_processing.pop(0)

		for clip_object in clips:
			clip = Models.Clip()
			clip.unit = unit.unit_name
			clip.index = clip_object['index']
			clip.path = clip_object['path']
			clip.clip_in = clip_object['clip_in']
			clip.clip_out = clip_object['clip_out']
			clip.length = clip_object['length']
			clip.calculated_length = clip_object['calculated_length']
			clip.fps = clip_object['fps']

			ModelManager.register_model(clip, ModelManager.MODEL_CLIP)

		if len(self.pending_unit_processing) > 0:
			self.melted_telnet_controller.get_unit_clips(self.pending_unit_processing[0].unit_name, self.add_clips)
		else:
			self.loaded_callback()
Example #15
0
 def refresh_clips(self, clip=None):
     GObject.idle_add(self.clear_list_model, self.playlist_list_store)
     clips = ModelManager.get_models(ModelManager.MODEL_CLIP)
     clip_index = 0
     for clip in clips:
         if clip.unit == Smelted_Settings.current_unit:
             GObject.idle_add(
                 self.update_list_model, self.playlist_list_store,
                 [os.path.basename(clip.path),
                  int(clip.index), "#FFFFFF"])
             clip_index += 1
Example #16
0
    def add_clips(self, clips, unit_name):
        unit = self.pending_unit_processing.pop(0)

        for clip_object in clips:
            clip = Models.Clip()
            clip.unit = unit.unit_name
            clip.index = clip_object['index']
            clip.path = clip_object['path']
            clip.clip_in = clip_object['clip_in']
            clip.clip_out = clip_object['clip_out']
            clip.length = clip_object['length']
            clip.calculated_length = clip_object['calculated_length']
            clip.fps = clip_object['fps']

            ModelManager.register_model(clip, ModelManager.MODEL_CLIP)

        if len(self.pending_unit_processing) > 0:
            self.melted_telnet_controller.get_unit_clips(
                self.pending_unit_processing[0].unit_name, self.add_clips)
        else:
            self.loaded_callback()
Example #17
0
	def add_clips(self, clips, unit_name):

		clip_models = ModelManager.get_models(ModelManager.MODEL_CLIP)
		for clip in clip_models:
			if clip.unit == unit_name:
				ModelManager.remove_model(clip, ModelManager.MODEL_CLIP)

		for clip_object in clips:
			clip = Models.Clip()
			clip.unit = unit_name
			clip.index = clip_object['index']
			clip.path = clip_object['path']
			clip.clip_in = clip_object['clip_in']
			clip.clip_out = clip_object['clip_out']
			clip.length = clip_object['length']
			clip.calculated_length = clip_object['calculated_length']
			clip.fps = clip_object['fps']

			ModelManager.register_model(clip, ModelManager.MODEL_CLIP)

		if len(clips) == 0:
			self.main_controller.get_main_interface_controller().refresh_clips()
Example #18
0
    def get_clip_by_playlist_cursor(self):
        model, list_iter = self.playlist_tree_view.get_selection(
        ).get_selected()
        if list_iter is not None:
            index = model.get_path(list_iter)[0]

            clip_list = ModelManager.get_models(ModelManager.MODEL_CLIP)
            for clip_candidate in clip_list:
                if str(
                        index
                ) == clip_candidate.index and Smelted_Settings.current_unit == clip_candidate.unit:
                    return clip_candidate
                    break
        return None
Example #19
0
    def add_clips(self, clips, unit_name):

        clip_models = ModelManager.get_models(ModelManager.MODEL_CLIP)
        for clip in clip_models:
            if clip.unit == unit_name:
                ModelManager.remove_model(clip, ModelManager.MODEL_CLIP)

        for clip_object in clips:
            clip = Models.Clip()
            clip.unit = unit_name
            clip.index = clip_object['index']
            clip.path = clip_object['path']
            clip.clip_in = clip_object['clip_in']
            clip.clip_out = clip_object['clip_out']
            clip.length = clip_object['length']
            clip.calculated_length = clip_object['calculated_length']
            clip.fps = clip_object['fps']

            ModelManager.register_model(clip, ModelManager.MODEL_CLIP)

        if len(clips) == 0:
            self.main_controller.get_main_interface_controller().refresh_clips(
            )
Example #20
0
    def on_view_added(self, view):
        self.view.window.set_title(Smelted_Settings.program_title)
        self.playlist_list_store = self.view.builder.get_object(
            "playlist_list_store")
        self.unit_list_store = self.view.builder.get_object("unit_list_store")
        self.unit_tree_view = self.view.builder.get_object("unit_tree_view")
        self.playlist_tree_view = self.view.builder.get_object(
            "playlist_tree_view")
        self.progress_label = self.view.builder.get_object("progress_label")

        self.in_slider_view = self.view.builder.get_object("in_slider")
        self.out_slider_view = self.view.builder.get_object("out_slider")

        self.in_slider_label_view = self.view.builder.get_object(
            "in_slider_label")
        self.out_slider_label_view = self.view.builder.get_object(
            "out_slider_label")

        # create combo box column on playlist tree view, should be moved to view if time allows
        end_event_list_store = Gtk.ListStore(str)
        self.end_event_list_items = ["Stop", "Loop", "Continue", "Pause"]
        for item in self.end_event_list_items:
            end_event_list_store.append([item])

        renderer_combo = Gtk.CellRendererCombo()
        renderer_combo.set_property("editable", True)
        renderer_combo.set_property("model", end_event_list_store)
        renderer_combo.set_property("text-column", 0)
        renderer_combo.set_property("has-entry", False)
        renderer_combo.connect("edited", self.on_combo_changed)

        column_combo = Gtk.TreeViewColumn("Unit Ended Event",
                                          renderer_combo,
                                          text=1)
        self.unit_tree_view.append_column(column_combo)

        ModelManager.register_on_model_added_callback(self.refresh_clips,
                                                      ModelManager.MODEL_CLIP)
        ModelManager.register_on_model_added_callback(self.add_unit,
                                                      ModelManager.MODEL_UNIT)
        ModelManager.register_on_model_list_emptied_callback(
            self.remove_units, ModelManager.MODEL_UNIT)

        ModelManager.register_on_attribute_changed_callback(
            self.update_seek_progress, Models.Clip.CLIP_PROGRESS)
	def export_playlist(self, file):
		root = etree.Element('playlist')

		units = ModelManager.get_models(ModelManager.MODEL_UNIT)

		for unit in units:
			unit_element = etree.Element('unit', name=unit.unit_name, eof=str(unit.end_of_file))
			clips = self.get_unit_clips_as_xml(unit)
			for clip in clips:
				unit_element.append(clip)
			root.append(unit_element)

		xml_string = etree.tostring(root, pretty_print=True)
		file = open(file, 'w+')
		file.write('<?xml version="1.0" encoding="utf-8"?>\n' + xml_string)
		file.close()
Example #22
0
    def export_playlist(self, file):
        root = etree.Element('playlist')

        units = ModelManager.get_models(ModelManager.MODEL_UNIT)

        for unit in units:
            unit_element = etree.Element('unit',
                                         name=unit.unit_name,
                                         eof=str(unit.end_of_file))
            clips = self.get_unit_clips_as_xml(unit)
            for clip in clips:
                unit_element.append(clip)
            root.append(unit_element)

        xml_string = etree.tostring(root, pretty_print=True)
        file = open(file, 'w+')
        file.write('<?xml version="1.0" encoding="utf-8"?>\n' + xml_string)
        file.close()
	def playlist_tree_view_cursor_changed(self, index):
		clip = None

		clip_list = ModelManager.get_models(ModelManager.MODEL_CLIP)
		for clip_candidate in clip_list:
			if str(index) == clip_candidate.index and Smelted_Settings.current_unit == clip_candidate.unit:
				clip = clip_candidate
				break

		if clip:
			total_seconds_in = math.floor(float(clip.clip_in) / float(clip.fps))
			total_seconds_out = math.floor(float(clip.clip_out) / float(clip.fps))

			label_text_in = self.convert_total_seconds_to_time(total_seconds_in)
			label_text_out = self.convert_total_seconds_to_time(total_seconds_out)

			GObject.idle_add(self.update_label_text, self.out_slider_label_view, label_text_out)
			GObject.idle_add(self.update_label_text, self.in_slider_label_view, label_text_in)

			GObject.idle_add(self.update_slider, self.out_slider_view, int(clip.calculated_length), int(clip.clip_out))
			GObject.idle_add(self.update_slider, self.in_slider_view, int(clip.calculated_length), int(clip.clip_in))
Example #24
0
    def import_playlist(self, file):
        units_controller = self.main_controller.get_units_controller()

        tree = etree.parse(file)
        playlist_root = tree.getroot()
        if playlist_root.tag == 'playlist':
            # cleaning old units
            old_units = ModelManager.get_models(ModelManager.MODEL_UNIT)
            for unit in old_units:
                self.melted_telnet_controller.clean_unit(unit.unit_name)
                units_controller.find_clips_on_unit(unit.unit_name)

            for unit in playlist_root:
                # a bit reliant on unit names
                unit_name = unit.attrib.get('name')
                if not units_controller.check_unit_exists(unit_name):
                    self.melted_telnet_controller.create_melted_unit()
                    units_controller.find_existing_units()

                if unit.attrib.get('eof'):
                    self.melted_telnet_controller.clip_end_event(
                        unit_name, unit.attrib.get('eof'))
                    self.main_controller.get_units_controller(
                    ).get_eof_from_unit(unit_name)

                self.melted_telnet_controller.set_unit_points(
                    unit_name, "ignore")

                for clip in unit:
                    self.melted_telnet_controller.append_clip_to_queue(
                        unit_name,
                        clip.find("path").text)
                    # if unit_name == Smelted_Settings.current_unit:
                    # self.melted_telnet_controller.set_clip_in_point(unit.attrib.get('name'), clip.find("in").text, clip.get('index'))
                    # self.melted_telnet_controller.set_clip_out_point(unit.attrib.get('name'), clip.find("out").text, clip.get('index'))
                self.melted_telnet_controller.set_unit_points(unit_name, "use")
                units_controller.find_clips_on_unit(unit_name)
        else:
            self.file_error()
Example #25
0
    def get_unit_clips_as_xml(self, unit):
        clip_elements = []
        clips = ModelManager.get_models(ModelManager.MODEL_CLIP)
        for clip in clips:
            if clip.unit == unit.unit_name:
                clip_element = etree.Element('clip', index=clip.index)

                path_element = etree.Element('path')
                path_element.text = clip.path

                in_element = etree.Element('in')
                in_element.text = clip.clip_in

                out_element = etree.Element('out')
                out_element.text = clip.clip_out

                clip_element.append(path_element)
                clip_element.append(in_element)
                clip_element.append(out_element)

                clip_elements.append(clip_element)

        return clip_elements
	def get_unit_clips_as_xml(self, unit):
		clip_elements = []
		clips = ModelManager.get_models(ModelManager.MODEL_CLIP)
		for clip in clips:
			if clip.unit == unit.unit_name:
				clip_element = etree.Element('clip', index=clip.index)

				path_element = etree.Element('path')
				path_element.text = clip.path

				in_element = etree.Element('in')
				in_element.text = clip.clip_in

				out_element = etree.Element('out')
				out_element.text = clip.clip_out

				clip_element.append(path_element)
				clip_element.append(in_element)
				clip_element.append(out_element)

				clip_elements.append(clip_element)

		return clip_elements
Example #27
0
	def get_unit_by_name(self, unit_name):
		units = ModelManager.get_models(ModelManager.MODEL_UNIT)
		for unit in units:
			if unit.unit_name == unit_name:
				return unit
		return None
Example #28
0
	def update_gui(self, result, data):
		clip_list = ModelManager.get_models(ModelManager.MODEL_CLIP)
		for clip in clip_list:
			if result["clip_index"] == clip.index and "U" + result["unit"] == clip.unit:
				clip.set_clip_progress(result["current_position"])
				break
Example #29
0
import os
import tornado.ioloop
import tornado.web
import tornado.template
from model import ModelManager
from handlers import ShowListHandler, EpisodeHandler, UpdateStateHandler, AddedEpisodesHandler, NextEpisodesHandler, StartedEpisodesHandler, RefreshHandler 
from core import configurator


if __name__ == '__main__':
    sys.path.insert(0, os.path.join(os.path.dirname(__file__)))

    configurator.init('settings.json')

    ModelManager.refresh()

    class Application(tornado.web.Application):

        def __init__(self):
            root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
            handlers = [
                # GET
                (r"/shows", ShowListHandler),
                (r"/episodes/([^/]*)", EpisodeHandler),
                (r"/started", StartedEpisodesHandler),
                (r"/added", AddedEpisodesHandler),
                (r"/next", NextEpisodesHandler),
                (r"/refresh", RefreshHandler),

                # PUT
Example #30
0
	def clean_units(self):
		old_units = ModelManager.get_models(ModelManager.MODEL_UNIT)
		for unit in old_units:
			self.melted_telnet_controller.clean_unit(unit.unit_name)
			self.find_clips_on_unit(unit.unit_name)
Example #31
0
from model import ModelManager
manager = ModelManager()


#TODO Add URLs
#TODO Add Edit
def usage(args):
    print("")
    print("Commands:")
    print("help: Prints this message")
    print("list: Prints what's inside the database")
    print("add:  Adds a Bot with a Network")
    print("del:  Deletes a Bot, Network, Channel, Server")
    print("edit: Edits a Bot")
    print("quit: quits the program")
    print("")


def list_database(args):
    if args == '?':
        print "Lists aspects of the database."
        print "list bot [name]: Lists the name of the bot or all the bots"
        print "list networks: lists all the networks."
        print "list servers: lists all the servers."
        print "list channels: lists all the channels."
        print "list users: lists all the users."
        print "list msg: lists all the messages."
        print "list: lists the whole database"
        return
    #find the occurence of the first space
    if args is None or len(args.strip()) == 0:
Example #32
0
 def get(self):
     ModelManager.refresh()
     self.write("ok")
Example #33
0
 def clean_units(self):
     old_units = ModelManager.get_models(ModelManager.MODEL_UNIT)
     for unit in old_units:
         self.melted_telnet_controller.clean_unit(unit.unit_name)
         self.find_clips_on_unit(unit.unit_name)
Example #34
0
 def get_unit_by_name(self, unit_name):
     units = ModelManager.get_models(ModelManager.MODEL_UNIT)
     for unit in units:
         if unit.unit_name == unit_name:
             return unit
     return None
Example #35
0
def load_model(args):
    mm = ModelManager(args) # ModelManager
    return mm
Example #36
0
from dataset import CaravanImageDataLoader, CaravanImageDataset


def train_model():
    #dataset = CaravanImageDataset("./caravan_images")
    #model = UNET()
    pass


def image_segmentation_accuracy(target, prediction):
    pass


if __name__ == "__main__":
    dev = "cuda" if torch.cuda.is_available() else "cpu"
    from pudb import set_trace as st
    st()
    trn_tf, val_tf = CaravanImageDataLoader.get_default_transforms(
        height=1280 // 4, width=1920 // 4)
    data = CaravanImageDataLoader("../caravan_images", 2, trn_tf, val_tf)
    model = UNET().to(device=dev)
    loss_fn = nn.BCEWithLogitsLoss()
    optimizer = torch.optim.Adam(model.parameters(), lr=0.001)

    mm = ModelManager(model, data, loss_fn, optimizer, 'WD')
    mm.train_epoch()
    # Size: batch_size, nFeatures, Heigh, Width
    #tt = torch.rand((2, 1, 572, 572))
    #model.forward(tt)

    pass
Example #37
0
class VelocityFrame(ttk.Frame):
    """Velocity frame"""
    def __init__(self, master):
        super().__init__(master)
        self.master = master
        self.logger = util.get_file_logger(name=type(self).__name__,
                                           file=os.path.join(
                                               cur_dir, 'log',
                                               'velocity_window.log'),
                                           level='debug')
        self.model_manager = None
        self.last_tab_id = None
        self.create_widgets()

    def create_widgets(self):
        # Set master window properties
        self.master.title('v.in editor - Velocity Plotting')
        self.master.geometry('1000x600+220+50')
        self.master.rowconfigure(0, weight=1)
        self.master.columnconfigure(0, weight=1)

        # Make frame resizable
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        # Create a Notebook widget to contain several panels
        self.notebook = ttk.Notebook(self)
        self.notebook.grid(row=0, column=0, sticky='nswe')
        self.vsf = VelocitySectionFrame(self)
        self.vcf = VelocityContourFrame(self)
        self.st = SettingsFrame(self)
        self.notebook.add(self.vsf, text=' Sections ', sticky='nswe')
        self.notebook.add(self.vcf, text=' Contours ', sticky='nswe')
        self.notebook.add(self.st, text=' Settings ', sticky='nswe')
        self.notebook.bind('<<NotebookTabChanged>>', self.tab_changed)

    def bind_model(self, model):
        self.model_manager = ModelManager(model)
        pois_str = session.get('pois')
        if pois_str:
            pois_obj = util.parse_pois_str(pois_str)
            self.model_manager.bind_pois(pois_obj)
        self.vsf.bind_model(self.model_manager)
        self.vcf.bind_model(self.model_manager)

    def tab_changed(self, event):
        if event.widget.index(event.widget.select()) == 1:
            pass

    def goto_settings(self):
        self.last_tab_id = self.notebook.select()
        self.notebook.select(2)

    def settings_work(self, flag_pois=False):
        """A flag will be set as True when related settings is changed"""
        if self.last_tab_id is not None:
            self.notebook.select(self.last_tab_id)
            self.last_tab_id = None
        if flag_pois:
            pois_str = session.get('pois')
            if pois_str is not '':
                pois_obj = util.parse_pois_str(pois_str)
                self.model_manager.bind_pois(pois_obj)
                self.vsf.pois_set()
                self.vcf.pois_set()
            else:
                self.model_manager.unbind_pois()
                self.vsf.pois_unset()
                self.vcf.pois_unset()