示例#1
0
    def createUI(self):
        self.load_button = QtGui.QPushButton("Load")
        self.revert_button = QtGui.QPushButton("Revert")
        self.clean_button = QtGui.QPushButton("Clean")
        self.save_button = QtGui.QPushButton("Save")
        self.clean_button.setEnabled(True)
        self.save_button.setEnabled(False)
        self.revert_button.setEnabled(False)

        self.file_name_label = QtGui.QLabel("File:")
        self.file_name_line_edit = QtGui.QLineEdit()
        self.file_name_line_edit.setReadOnly(True)

        self.start_label = QtGui.QLabel("Starting Coordinates:")
        self.start_x = QtGui.QSpinBox()
        self.start_y = QtGui.QSpinBox()

        self.end_label = QtGui.QLabel("Ending Coordinates:")
        self.end_x = QtGui.QSpinBox()
        self.end_y = QtGui.QSpinBox()

        self.strip_type_label = QtGui.QLabel("Algorithm:")
        self.strip_type_combo_box = QtGui.QComboBox()
        self.strip_type_combo_box.addItems(["Simple", "Row and Column Movement", "Canny's Edge Detection"])
        self.strip_threshold_label = QtGui.QLabel("Threshold")
        self.strip_threshold_spinbox = QtGui.QSpinBox()
        self.strip_threshold_spinbox.setPrefix(u"\u00B1")
        self.strip_threshold_spinbox.setRange(0, 255)
        self.strip_threshold_spinbox.setValue(10)
        self.slider_label = QtGui.QLabel("Zoom:")
        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.slider.setRange(0, 250)
        self.slider.setSingleStep(1)
        self.slider.setValue(100)
        self.slider_value_label = QtGui.QLabel("%d%%" % self.slider.value())
        self.slider.valueChanged.connect(self.zoomInOut)
        self.slider.setTickInterval(10)
        self.slider.setTickPosition(2)

        self.clearance_label = QtGui.QLabel("Pixel Clearance:")
        self.clearance = QtGui.QSpinBox()
        self.clearance.setRange(0, 10000)

        self.replaced_color_label = QtGui.QLabel("Replace Color With:")
        self.replacement_color_button = QColorButton()
        self.replacement_color_button.setColorFromRGB([255, 255, 255])
        self.alpha_label = QtGui.QLabel("Transparency (Alpha):")
        self.alpha_spinbox = QtGui.QSpinBox()
        self.alpha_spinbox.setRange(0, 255)
        self.alpha_spinbox.setValue(0)
        self.pixel_movement_behaviour_label = QtGui.QLabel("Pixel Movement:")
        self.pixel_movement_behaviour_combobox = QtGui.QComboBox()
        self.pixel_movement_behaviour_combobox.addItems(
            ["Forward, then Down", "Forward and Back, then Down", "Forward and Back, then Up and Down"]
        )
        settings = QtGui.QHBoxLayout()
        settings.addWidget(self.strip_type_label, 0)
        settings.addWidget(self.strip_type_combo_box, 0)
        settings.addWidget(self.strip_threshold_label, 0)
        settings.addWidget(self.strip_threshold_spinbox, 0)
        settings.addWidget(self.clearance_label, 0)
        settings.addWidget(self.clearance, 0)
        settings.addWidget(self.replaced_color_label, 0)
        settings.addWidget(self.replacement_color_button, 0)
        settings.addWidget(self.alpha_label, 0)
        settings.addWidget(self.alpha_spinbox, 0)
        settings.addWidget(self.pixel_movement_behaviour_label, 0)
        settings.addWidget(self.pixel_movement_behaviour_combobox, 0)

        slider_layout = QtGui.QHBoxLayout()
        slider_layout.addWidget(self.slider_label, 0)
        slider_layout.addWidget(self.slider, 5)
        slider_layout.addWidget(self.slider_value_label, 0)

        limit = 100000

        self.start_x.setRange(-limit, limit)
        self.start_y.setRange(-limit, limit)

        self.end_x.setRange(-limit, limit)
        self.end_y.setRange(-limit, limit)

        self.mona = MonaLisa(self.current_file)
        scrollable_widget = QtGui.QScrollArea()
        scrollable_widget.setWidget(self.mona)
        scrollable_widget.setWidgetResizable(True)
        scrollable_widget.setMinimumHeight(400)
        scrollable_widget.setMinimumWidth(400)
        # scrollable_widget.setFixedWidth(800)

        self.progress_bar = ProgressBar()
        self.status = QtGui.QLabel("Cowabunga!")
        self.chosen_color = QtGui.QPushButton()
        self.chosen_color.setEnabled(False)
        self.chosen_color.setFixedSize(15, 15)
        self.chosen_color.setToolTip("Color at the chosen pixel")

        status_bar = QtGui.QHBoxLayout()
        status_bar.addWidget(self.status, 10)
        status_bar.addWidget(self.chosen_color)

        buttons = QtGui.QHBoxLayout()
        buttons.addWidget(self.load_button)
        buttons.addWidget(self.revert_button)
        buttons.addWidget(self.clean_button)
        buttons.addWidget(self.save_button)

        file_name = QtGui.QHBoxLayout()
        file_name.addWidget(self.file_name_label, 0)
        file_name.addWidget(self.file_name_line_edit, 1)

        coords = QtGui.QHBoxLayout()
        coords.addWidget(self.start_label)
        coords.addWidget(self.start_x)
        coords.addWidget(self.start_y)
        coords.addWidget(self.end_label)
        coords.addWidget(self.end_x)
        coords.addWidget(self.end_y)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(buttons, 0)
        layout.addLayout(file_name, 0)
        layout.addLayout(coords, 0)
        layout.addLayout(settings, 0)
        layout.addWidget(scrollable_widget, 2)
        layout.addLayout(slider_layout, 0)
        layout.addWidget(self.progress_bar, 0)
        layout.addLayout(status_bar, 0)

        self.setLayout(layout)

        self.revert_button.clicked.connect(self.revertImage)
        self.load_button.clicked.connect(self.loadImage)
        self.clean_button.clicked.connect(self.cleanImage)

        self.mona.gotStart.connect(self.captureStart)
        self.mona.gotEnd.connect(self.captureEnd)

        self.setWindowTitle("Donatello")
        self.move(500, 70)
        self.show()
示例#2
0
    def createUI(self):
        self.filter_label = QtGui.QLabel("Label:")
        self.filter_legend = QtGui.QLineEdit()
        self.filter_legend.setToolTip(
            "Type a meaningful name for this data set here.\nTry avoiding special characters as they could result in errors."
        )

        self.writer_label = QtGui.QLabel("Writer(s):")
        self.writer_combobox = CheckableComboBox("Writers")
        self.editor_label = QtGui.QLabel("Editor(s):")
        self.editor_combobox = CheckableComboBox("Editors")

        self.writer_all_button = QtGui.QPushButton("All")
        self.writer_all_button.setToolTip("Select all writers")
        self.writer_clear_button = QtGui.QPushButton("Clear")
        self.writer_clear_button.setToolTip("Clear writer selection")

        self.editor_all_button = QtGui.QPushButton("All")
        self.editor_all_button.setToolTip("Select all editors")
        self.editor_clear_button = QtGui.QPushButton("Clear")
        self.editor_clear_button.setToolTip("Clear editor selection")

        self.pd_button = QtGui.QPushButton("PD")
        self.rpd_button = QtGui.QPushButton("RPD")
        self.seo_button = QtGui.QPushButton("SEO")
        self.all_button = QtGui.QPushButton("All")

        self.all_button.setFixedWidth(30)
        self.rpd_button.setFixedWidth(30)
        self.pd_button.setFixedWidth(30)
        self.seo_button.setFixedWidth(30)

        self.all_button.setCheckable(True)
        self.rpd_button.setCheckable(True)
        self.pd_button.setCheckable(True)
        self.seo_button.setCheckable(True)

        self.date_field_label = QtGui.QLabel("Date Range:")
        self.date_field_start = QtGui.QDateEdit()
        self.date_field_end = QtGui.QDateEdit()
        self.date_field_start.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_start.setMaximumDate(datetime.date.today())
        self.date_field_start.setDate(datetime.date.today())
        self.date_field_start.setCalendarPopup(True)
        self.date_field_end.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_end.setMaximumDate(datetime.date.today())
        self.date_field_end.setDate(datetime.date.today())
        self.date_field_end.setCalendarPopup(True)
        self.select_all_data = QtGui.QCheckBox("Select all audits")
        self.graph_color_label = QtGui.QLabel("Graph Color")
        self.graph_color_button = QColorButton()
        self.category_selector = CategorySelector(self.category_tree)

        row_0_layout = QtGui.QHBoxLayout()
        row_0_layout.addWidget(self.filter_label, 0)
        row_0_layout.addWidget(self.filter_legend, 1)

        row_1_layout = QtGui.QHBoxLayout()
        row_1_layout.addWidget(self.writer_label, 0)
        row_1_layout.addWidget(self.writer_combobox, 1)
        row_1_layout.addWidget(self.writer_all_button, 0)
        row_1_layout.addWidget(self.writer_clear_button, 0)
        row_1_layout.addStretch(1)

        row_2_layout = QtGui.QHBoxLayout()
        row_2_layout.addWidget(self.editor_label, 0)
        row_2_layout.addWidget(self.editor_combobox, 1)
        row_2_layout.addWidget(self.editor_all_button, 0)
        row_2_layout.addWidget(self.editor_clear_button, 0)
        row_2_layout.addWidget(self.graph_color_label, 0)
        row_2_layout.addWidget(self.graph_color_button, 0)
        row_2_layout.addStretch(1)

        row_3_layout = QtGui.QHBoxLayout()
        row_3_layout.addWidget(self.date_field_label, 0)
        row_3_layout.addWidget(self.date_field_start, 0)
        row_3_layout.addWidget(self.date_field_end, 0)
        row_3_layout.addWidget(self.select_all_data, 0)
        row_3_layout.addWidget(self.pd_button, 0)
        row_3_layout.addWidget(self.rpd_button, 0)
        row_3_layout.addWidget(self.seo_button, 0)
        row_3_layout.addWidget(self.all_button, 0)
        row_3_layout.addStretch(1)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_0_layout, 1)
        layout.addLayout(row_1_layout, 1)
        layout.addLayout(row_2_layout, 1)
        layout.addLayout(row_3_layout, 1)
        layout.addLayout(self.category_selector, 2)
        self.setLayout(layout)
示例#3
0
class Donatello(QtGui.QWidget):
    def __init__(self):
        super(Donatello, self).__init__()
        self.current_file = os.path.join("essentials", "tmnt_cover.jpg")
        self.images_record = [self.current_file]
        self.createUI()

    def createUI(self):
        self.load_button = QtGui.QPushButton("Load")
        self.revert_button = QtGui.QPushButton("Revert")
        self.clean_button = QtGui.QPushButton("Clean")
        self.save_button = QtGui.QPushButton("Save")
        self.clean_button.setEnabled(True)
        self.save_button.setEnabled(False)
        self.revert_button.setEnabled(False)

        self.file_name_label = QtGui.QLabel("File:")
        self.file_name_line_edit = QtGui.QLineEdit()
        self.file_name_line_edit.setReadOnly(True)

        self.start_label = QtGui.QLabel("Starting Coordinates:")
        self.start_x = QtGui.QSpinBox()
        self.start_y = QtGui.QSpinBox()

        self.end_label = QtGui.QLabel("Ending Coordinates:")
        self.end_x = QtGui.QSpinBox()
        self.end_y = QtGui.QSpinBox()

        self.strip_type_label = QtGui.QLabel("Algorithm:")
        self.strip_type_combo_box = QtGui.QComboBox()
        self.strip_type_combo_box.addItems(["Simple", "Row and Column Movement", "Canny's Edge Detection"])
        self.strip_threshold_label = QtGui.QLabel("Threshold")
        self.strip_threshold_spinbox = QtGui.QSpinBox()
        self.strip_threshold_spinbox.setPrefix(u"\u00B1")
        self.strip_threshold_spinbox.setRange(0, 255)
        self.strip_threshold_spinbox.setValue(10)
        self.slider_label = QtGui.QLabel("Zoom:")
        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.slider.setRange(0, 250)
        self.slider.setSingleStep(1)
        self.slider.setValue(100)
        self.slider_value_label = QtGui.QLabel("%d%%" % self.slider.value())
        self.slider.valueChanged.connect(self.zoomInOut)
        self.slider.setTickInterval(10)
        self.slider.setTickPosition(2)

        self.clearance_label = QtGui.QLabel("Pixel Clearance:")
        self.clearance = QtGui.QSpinBox()
        self.clearance.setRange(0, 10000)

        self.replaced_color_label = QtGui.QLabel("Replace Color With:")
        self.replacement_color_button = QColorButton()
        self.replacement_color_button.setColorFromRGB([255, 255, 255])
        self.alpha_label = QtGui.QLabel("Transparency (Alpha):")
        self.alpha_spinbox = QtGui.QSpinBox()
        self.alpha_spinbox.setRange(0, 255)
        self.alpha_spinbox.setValue(0)
        self.pixel_movement_behaviour_label = QtGui.QLabel("Pixel Movement:")
        self.pixel_movement_behaviour_combobox = QtGui.QComboBox()
        self.pixel_movement_behaviour_combobox.addItems(
            ["Forward, then Down", "Forward and Back, then Down", "Forward and Back, then Up and Down"]
        )
        settings = QtGui.QHBoxLayout()
        settings.addWidget(self.strip_type_label, 0)
        settings.addWidget(self.strip_type_combo_box, 0)
        settings.addWidget(self.strip_threshold_label, 0)
        settings.addWidget(self.strip_threshold_spinbox, 0)
        settings.addWidget(self.clearance_label, 0)
        settings.addWidget(self.clearance, 0)
        settings.addWidget(self.replaced_color_label, 0)
        settings.addWidget(self.replacement_color_button, 0)
        settings.addWidget(self.alpha_label, 0)
        settings.addWidget(self.alpha_spinbox, 0)
        settings.addWidget(self.pixel_movement_behaviour_label, 0)
        settings.addWidget(self.pixel_movement_behaviour_combobox, 0)

        slider_layout = QtGui.QHBoxLayout()
        slider_layout.addWidget(self.slider_label, 0)
        slider_layout.addWidget(self.slider, 5)
        slider_layout.addWidget(self.slider_value_label, 0)

        limit = 100000

        self.start_x.setRange(-limit, limit)
        self.start_y.setRange(-limit, limit)

        self.end_x.setRange(-limit, limit)
        self.end_y.setRange(-limit, limit)

        self.mona = MonaLisa(self.current_file)
        scrollable_widget = QtGui.QScrollArea()
        scrollable_widget.setWidget(self.mona)
        scrollable_widget.setWidgetResizable(True)
        scrollable_widget.setMinimumHeight(400)
        scrollable_widget.setMinimumWidth(400)
        # scrollable_widget.setFixedWidth(800)

        self.progress_bar = ProgressBar()
        self.status = QtGui.QLabel("Cowabunga!")
        self.chosen_color = QtGui.QPushButton()
        self.chosen_color.setEnabled(False)
        self.chosen_color.setFixedSize(15, 15)
        self.chosen_color.setToolTip("Color at the chosen pixel")

        status_bar = QtGui.QHBoxLayout()
        status_bar.addWidget(self.status, 10)
        status_bar.addWidget(self.chosen_color)

        buttons = QtGui.QHBoxLayout()
        buttons.addWidget(self.load_button)
        buttons.addWidget(self.revert_button)
        buttons.addWidget(self.clean_button)
        buttons.addWidget(self.save_button)

        file_name = QtGui.QHBoxLayout()
        file_name.addWidget(self.file_name_label, 0)
        file_name.addWidget(self.file_name_line_edit, 1)

        coords = QtGui.QHBoxLayout()
        coords.addWidget(self.start_label)
        coords.addWidget(self.start_x)
        coords.addWidget(self.start_y)
        coords.addWidget(self.end_label)
        coords.addWidget(self.end_x)
        coords.addWidget(self.end_y)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(buttons, 0)
        layout.addLayout(file_name, 0)
        layout.addLayout(coords, 0)
        layout.addLayout(settings, 0)
        layout.addWidget(scrollable_widget, 2)
        layout.addLayout(slider_layout, 0)
        layout.addWidget(self.progress_bar, 0)
        layout.addLayout(status_bar, 0)

        self.setLayout(layout)

        self.revert_button.clicked.connect(self.revertImage)
        self.load_button.clicked.connect(self.loadImage)
        self.clean_button.clicked.connect(self.cleanImage)

        self.mona.gotStart.connect(self.captureStart)
        self.mona.gotEnd.connect(self.captureEnd)

        self.setWindowTitle("Donatello")
        self.move(500, 70)
        self.show()

    def captureStart(self, coords):
        self.start_x.setValue(coords[0])
        self.start_y.setValue(coords[1])
        image_object = Image.open(self.current_file).convert("RGBA")
        start_x, start_y = coords
        image_array = np.array(image_object)
        # Remember: x is columns, y is rows in an array.
        r, g, b, a = image_array[start_y][start_x]
        self.chosen_color.setStyleSheet("background-color: rgb(%d,%d,%d);" % (r, g, b))

    def captureEnd(self, coords):
        self.end_x.setValue(coords[0])
        self.end_y.setValue(coords[1])

    def revertImage(self):
        # print "Reverting to original."
        self.current_file = self.images_record[-1]
        self.mona.setImage(self.current_file)

    def loadImage(self):
        open_path = os.getcwd() if self.current_file is None else os.path.dirname(self.current_file)
        open_file_name = QtGui.QFileDialog.getOpenFileName(
            self, "Load an Image", open_path, ("Image files (*.jpeg *.jpg *.png)")
        )
        if open_file_name is not None:
            self.file_name_line_edit.setText(os.path.splitext(os.path.basename(str(open_file_name)))[0])
            self.mona.setImage(open_file_name)
            self.current_file = str(open_file_name)
            self.images_record = [self.current_file]
            self.revert_button.setEnabled(False)
            self.clean_button.setEnabled(True)
        else:
            self.clean_button.setEnabled(False)
            self.save_button.setEnabled(False)

    def zoomInOut(self):
        self.slider_value_label.setText("%d%%" % int(self.slider.value()))
        self.mona.zoomInOut(int(self.slider.value()))

    def cleanImage(self):
        start, end = self.mona.getCoords()
        image_path = self.current_file
        threshold = self.strip_threshold_spinbox.value()
        clearance_pixels = self.clearance.value()
        replacement_color = self.replacement_color_button.getColor()
        replacement_alpha = int(self.alpha_spinbox.value())
        self.cleanImageRectangle(
            image_path, start, end, threshold, clearance_pixels, replacement_color, replacement_alpha
        )

    def cleanImageRectangle(
        self, image_path, start, end, threshold, clearance_pixels, replacement_color, replacement_alpha
    ):
        image_object = Image.open(image_path).convert("RGBA")
        start_x, start_y = start
        end_x, end_y = end
        image_array = np.array(image_object)
        # print image_object.size, image_array.shape

        # Remember: x is columns, y is rows in an array.
        try:
            chosen_color = image_array[start_y][start_x]
        except:
            print start, end
            raise Exception("Error getting coordinates from the canvas.")

        # print "Received a request for cleaning %s in an image between "%chosen_color, start, end
        r, g, b, a = chosen_color
        min_r = r - threshold
        max_r = r + threshold

        min_g = g - threshold
        max_g = g + threshold

        min_b = b - threshold
        max_b = b + threshold

        replacement_color_rgba = list(replacement_color) + [replacement_alpha]
        self.chosen_color.setStyleSheet("background-color: rgb(%d,%d,%d);" % (r, g, b))
        # print chosen_color
        clean_down = True
        # Along one row, proceed forward in the column
        min_row = min(start_y, end_y)
        min_col = min(start_x, end_x)
        max_row = max(start_y, end_y)
        max_col = max(start_x, end_x)
        rows, columns, rgba = image_array.shape
        if max_row >= rows:
            max_row = rows - 1
        if max_col >= columns:
            max_col = columns - 1
        current_row = min_row
        while current_row <= (max_row + clearance_pixels):
            current_col = min_col
            while current_col <= (max_col + clearance_pixels):
                current_r, current_g, current_b, current_a = image_array[current_row][current_col]
                if min_r <= current_r <= max_r:
                    if min_g <= current_g <= max_g:
                        if min_b <= current_b <= max_b:
                            image_array[current_row][current_col] = replacement_color_rgba
                current_col += 1
            current_row += 1
        # print "*"*10
        # print start, end
        self.rememberImage(self.current_file)
        self.revert_button.setEnabled(True)
        self.current_file = os.path.join("cache", "test.png")
        # print max_row, max_col
        # print current_row, current_col
        # print "*"*10
        new_image = Image.fromarray(image_array, mode="RGBA")
        new_image.save(self.current_file)

        self.mona.setImage(self.current_file)
        # os.startfile("test.png","open")

        # while clean_down:

    def rememberImage(self, image_path):
        self.images_record.append(image_path)
示例#4
0
class FilterForm(QtGui.QGroupBox):
    changedStartDate = QtCore.pyqtSignal()
    changedFilter = QtCore.pyqtSignal()

    def __init__(self, user_id, password, color, category_tree, *args,
                 **kwargs):
        super(FilterForm, self).__init__(*args, **kwargs)
        self.user_id = user_id
        self.password = password
        self.category_tree = category_tree
        self.user_name = MOSES.getEmpName(self.user_id)
        self.lock_mode = None
        self.createUI()
        self.mapEvents()
        self.all_button.setChecked(True)
        label = str(args[0]) if args is not None else "Data Set"
        self.filter_legend.setText(label)

    def createUI(self):
        self.filter_label = QtGui.QLabel("Label:")
        self.filter_legend = QtGui.QLineEdit()
        self.filter_legend.setToolTip(
            "Type a meaningful name for this data set here.\nTry avoiding special characters as they could result in errors."
        )

        self.writer_label = QtGui.QLabel("Writer(s):")
        self.writer_combobox = CheckableComboBox("Writers")
        self.editor_label = QtGui.QLabel("Editor(s):")
        self.editor_combobox = CheckableComboBox("Editors")

        self.writer_all_button = QtGui.QPushButton("All")
        self.writer_all_button.setToolTip("Select all writers")
        self.writer_clear_button = QtGui.QPushButton("Clear")
        self.writer_clear_button.setToolTip("Clear writer selection")

        self.editor_all_button = QtGui.QPushButton("All")
        self.editor_all_button.setToolTip("Select all editors")
        self.editor_clear_button = QtGui.QPushButton("Clear")
        self.editor_clear_button.setToolTip("Clear editor selection")

        self.pd_button = QtGui.QPushButton("PD")
        self.rpd_button = QtGui.QPushButton("RPD")
        self.seo_button = QtGui.QPushButton("SEO")
        self.all_button = QtGui.QPushButton("All")

        self.all_button.setFixedWidth(30)
        self.rpd_button.setFixedWidth(30)
        self.pd_button.setFixedWidth(30)
        self.seo_button.setFixedWidth(30)

        self.all_button.setCheckable(True)
        self.rpd_button.setCheckable(True)
        self.pd_button.setCheckable(True)
        self.seo_button.setCheckable(True)

        self.date_field_label = QtGui.QLabel("Date Range:")
        self.date_field_start = QtGui.QDateEdit()
        self.date_field_end = QtGui.QDateEdit()
        self.date_field_start.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_start.setMaximumDate(datetime.date.today())
        self.date_field_start.setDate(datetime.date.today())
        self.date_field_start.setCalendarPopup(True)
        self.date_field_end.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_end.setMaximumDate(datetime.date.today())
        self.date_field_end.setDate(datetime.date.today())
        self.date_field_end.setCalendarPopup(True)
        self.select_all_data = QtGui.QCheckBox("Select all audits")
        self.graph_color_label = QtGui.QLabel("Graph Color")
        self.graph_color_button = QColorButton()
        self.category_selector = CategorySelector(self.category_tree)

        row_0_layout = QtGui.QHBoxLayout()
        row_0_layout.addWidget(self.filter_label, 0)
        row_0_layout.addWidget(self.filter_legend, 1)

        row_1_layout = QtGui.QHBoxLayout()
        row_1_layout.addWidget(self.writer_label, 0)
        row_1_layout.addWidget(self.writer_combobox, 1)
        row_1_layout.addWidget(self.writer_all_button, 0)
        row_1_layout.addWidget(self.writer_clear_button, 0)
        row_1_layout.addStretch(1)

        row_2_layout = QtGui.QHBoxLayout()
        row_2_layout.addWidget(self.editor_label, 0)
        row_2_layout.addWidget(self.editor_combobox, 1)
        row_2_layout.addWidget(self.editor_all_button, 0)
        row_2_layout.addWidget(self.editor_clear_button, 0)
        row_2_layout.addWidget(self.graph_color_label, 0)
        row_2_layout.addWidget(self.graph_color_button, 0)
        row_2_layout.addStretch(1)

        row_3_layout = QtGui.QHBoxLayout()
        row_3_layout.addWidget(self.date_field_label, 0)
        row_3_layout.addWidget(self.date_field_start, 0)
        row_3_layout.addWidget(self.date_field_end, 0)
        row_3_layout.addWidget(self.select_all_data, 0)
        row_3_layout.addWidget(self.pd_button, 0)
        row_3_layout.addWidget(self.rpd_button, 0)
        row_3_layout.addWidget(self.seo_button, 0)
        row_3_layout.addWidget(self.all_button, 0)
        row_3_layout.addStretch(1)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_0_layout, 1)
        layout.addLayout(row_1_layout, 1)
        layout.addLayout(row_2_layout, 1)
        layout.addLayout(row_3_layout, 1)
        layout.addLayout(self.category_selector, 2)
        self.setLayout(layout)

    def lock(self, lock_mode=None):
        if lock_mode is not None:
            self.lock_mode = lock_mode
        if self.lock_mode is not None:
            self.editor_combobox.clearSelection()
            self.editor_combobox.setEnabled(False)
            self.editor_all_button.setEnabled(False)
            self.editor_clear_button.setEnabled(False)
            if self.lock_mode == 1:
                self.writer_combobox.clearSelection()
                self.writer_combobox.select(self.user_name)
                self.writer_combobox.setEnabled(False)
                self.writer_all_button.setEnabled(False)
                self.writer_clear_button.setEnabled(False)
            elif self.lock_mode == 2:
                self.writer_combobox.clearSelection()
                self.writer_combobox.selectAll()
                self.writer_combobox.setEnabled(False)

    def mapEvents(self):
        self.all_button.toggled.connect(self.toggleAll)
        self.pd_button.toggled.connect(self.toggleTypes)
        self.rpd_button.toggled.connect(self.toggleTypes)
        self.seo_button.toggled.connect(self.toggleTypes)

        self.select_all_data.toggled.connect(self.changeDateType)
        self.writer_all_button.clicked.connect(self.selectAllWriters)
        self.writer_clear_button.clicked.connect(self.clearWriters)
        self.editor_all_button.clicked.connect(self.selectAllEditors)
        self.editor_clear_button.clicked.connect(self.clearEditors)

        self.date_field_start.dateChanged.connect(self.changedDate)

        #Any change in the filter form should result in emitting the changedFilter signal.
        self.date_field_start.dateChanged.connect(self.changedFilter)
        self.date_field_end.dateChanged.connect(self.changedFilter)
        self.all_button.toggled.connect(self.changedFilter)
        self.pd_button.toggled.connect(self.changedFilter)
        self.rpd_button.toggled.connect(self.changedFilter)
        self.seo_button.toggled.connect(self.changedFilter)
        self.select_all_data.toggled.connect(self.changedFilter)
        self.writer_combobox.changedSelection.connect(self.changedFilter)
        self.editor_combobox.changedSelection.connect(self.changedFilter)
        self.category_selector.changedCategorySelection.connect(
            self.changedFilter)

    def changedDate(self):
        self.changedStartDate.emit()

    def selectAllWriters(self):
        self.writer_combobox.selectAll()

    def selectAllEditors(self):
        self.editor_combobox.selectAll()

    def clearWriters(self):
        self.writer_combobox.clearSelection()
        if self.lock_mode is not None:
            if self.lock_mode == 2:
                self.writer_combobox.select(self.user_name)

    def clearEditors(self):
        self.editor_combobox.clearSelection()

    def changeDateType(self):
        if self.select_all_data.isChecked():
            self.date_field_start.setEnabled(False)
            self.date_field_end.setEnabled(False)
        else:
            self.date_field_start.setEnabled(True)
            self.date_field_end.setEnabled(True)

    def getLabel(self):
        return str(self.filter_legend.text()).strip()

    def toggleAll(self):
        if self.all_button.isChecked():
            self.pd_button.setChecked(True)
            self.rpd_button.setChecked(True)
            self.seo_button.setChecked(True)
            self.all_button.setEnabled(False)

    def toggleTypes(self):
        if self.pd_button.isChecked() and self.rpd_button.isChecked(
        ) and self.seo_button.isChecked():
            self.all_button.setChecked(True)
            self.all_button.setEnabled(False)
        else:
            self.all_button.setEnabled(True)
            self.all_button.setChecked(False)

    def getFilters(self):
        category_tree_filter = self.category_selector.getFilters()

        writer_filter = self.writer_combobox.getCheckedItems()
        editor_filter = self.editor_combobox.getCheckedItems()

        start_date = self.date_field_start.date().toPyDate()
        end_date = self.date_field_end.date().toPyDate()

        get_pd = False
        get_rpd = False
        get_seo = False

        if self.all_button.isChecked():
            get_pd = True
            get_rpd = True
            get_seo = True
        else:
            if self.pd_button.isChecked():
                get_pd = True
            if self.rpd_button.isChecked():
                get_rpd = True
            if self.seo_button.isChecked():
                get_seo = True

        description_type = []
        if get_pd:
            description_type.append("PD")
        if get_rpd:
            description_type.append("RPD")
        if get_seo:
            description_type.append("SEO")

        filter_settings = {
            "Category Tree":
            category_tree_filter
            if category_tree_filter.shape[0] > 0 else None,
            "Writers":
            writer_filter if len(writer_filter) > 0 else None,
            "Editors":
            editor_filter if len(editor_filter) > 0 else None,
            "Dates": [start_date, end_date]
            if not (self.select_all_data.isChecked()) else None,
            "Description Types":
            description_type if len(description_type) > 0 else None
        }
        return filter_settings

    def getGraphColor(self):
        return self.graph_color_button.getColor()

    def populateFilter(self):
        pass

    def populateEditorAndWritersList(self):
        comparison_date = self.date_field_end.date().toPyDate()
        self.writer_and_editor_dataframe = MOSES.getWriterAndEditorData(
            self.user_id, self.password, comparison_date)
        self.writers_list = list(
            set(self.writer_and_editor_dataframe["Writer Name"]))
        self.editors_list = list(
            set(self.writer_and_editor_dataframe["Editor Name"]))
        self.writers_list.sort()
        self.editors_list.sort()
        self.writer_combobox.clear()
        self.writer_combobox.addItems(self.writers_list)
        self.editor_combobox.clear()
        self.editor_combobox.addItems(self.editors_list)

    def getDates(self):
        if self.select_all_data.isChecked():
            return datetime.date(2015, 1, 1), datetime.date.today()
        else:
            return self.date_field_start.date().toPyDate(
            ), self.date_field_end.date().toPyDate()

    def getData(self):
        pass