Ejemplo n.º 1
0
    def populate_result_tree(self, src_idx_selection_ls):
        self.result_tree.clear()

        # -- Populate Selection TreeWidget ---
        trim_items = dict()
        for model_code in self.wizard.session.data.fakom_selection.keys():
            trim = [t for t in self.wizard.session.data.import_data.models if t.model == model_code][0]
            trim_item_name = f'{trim.model_text} {model_code}'
            trim_item = QTreeWidgetItem([trim_item_name])
            trim_item.setIcon(0, IconRsc.get_icon('car'))
            trim_items[trim_item_name] = trim_item

        for src_index in src_idx_selection_ls:
            trim_idx = self.get_index_group_parent(src_index)
            model = trim_idx.siblingAtColumn(Kg.VALUE).data(Qt.DisplayRole)
            trim_item_name = f'{trim_idx.siblingAtColumn(Kg.NAME).data(Qt.DisplayRole)} {model}'

            trim_item = trim_items.get(trim_item_name)
            trim_item.setData(0, Qt.UserRole, trim_idx)

            name = src_index.siblingAtColumn(Kg.NAME).data(Qt.DisplayRole)
            icon = src_index.siblingAtColumn(Kg.style_column).data(Qt.DecorationRole) or QIcon()
            item = QTreeWidgetItem(trim_item, [name])
            item.setData(0, Qt.UserRole, src_index)
            item.setIcon(0, icon)

        # -- Expand DeltaGenResult Tree --
        for trim_item in trim_items.values():
            self.result_tree.addTopLevelItem(trim_item)
            self.result_tree.expandItem(trim_item)
Ejemplo n.º 2
0
 def onAddOptionGroup(self):
     text, ok = QInputDialog.getText(self.backtest, "请输入期权组名称", "名称",
                                     QLineEdit.Normal)
     current_item = self.backtest_tree.currentItem()
     # parent_item = current_item.parent()
     current_item_text = current_item.text(0)
     # parent_item_text = parent_item.text(0)
     if ok and text:
         node = QTreeWidgetItem(current_item)
         node.setText(0, text)
         node.setCheckState(0, Qt.Unchecked)
         node.setWhatsThis(0, "option_group")
         node.setIcon(0, QtGui.QIcon("../icon/group.png"))
         self.backtest_tree.expandItem(self.backtest_tree.currentItem())
         group_dict = {
             "name": text,
             "enable": 1,
             "contracts": [],
             "signal": {
                 "type": "list",
                 "value": 0,
                 "list": []
             },
             "ratio": {
                 "type": "float",
                 "value": 0,
             },
         }
         for underlying in self.config["options"]["underlyings"]:
             if underlying.get("name") == current_item_text:
                 underlying["groups"].append(group_dict)
Ejemplo n.º 3
0
 def update_node_data(self,
                      child_node: QTreeWidgetItem,
                      item: Union[JenkinsJob, JenkinsFolder]):
     icon = "job.png" if isinstance(item, JenkinsJob) else "folder.png"
     child_node.setText(0, item.name)
     child_node.setIcon(0, get_icon(icon))
     child_node.setCheckState(0, as_qt_selection(item.selected))
Ejemplo n.º 4
0
 def add_dir(self, dir_path, parent):
     sorted_list = sorted(self.list_dir(dir_path),
                          key=lambda x:
                          (x[0] not in self.dirs, x[0].lower()))
     for path, mtime in sorted_list:
         basename = os.path.basename(path)
         if len(basename) == 0:
             continue
         item = QTreeWidgetItem()
         item.setText(0, basename)
         self.index[item] = path
         parent.setFlags(parent.flags() | Qt.ItemIsTristate
                         | Qt.ItemIsUserCheckable)
         item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
         item.setCheckState(
             0, Qt.Checked
             if parent.checkState(0) == Qt.Checked else Qt.Unchecked)
         parent.addChild(item)
         item.setText(
             1, time.strftime("%b %d %Y %I:%M:%S %p",
                              time.localtime(mtime)))
         if path in self.dirs and len(self.list_dir(path)) != 0:
             sub_item = QTreeWidgetItem()
             self.hidden[item] = sub_item
             item.addChild(sub_item)
             item.setIcon(0, QIcon(get_resource_path("images/folder.png")))
Ejemplo n.º 5
0
 def add_root_path(self, path):
     root = QTreeWidgetItem()
     root.setText(0, path)
     root.setCheckState(0, Qt.Unchecked)
     root.setIcon(0, QIcon(get_resource_path("images/folder.png")))
     self.index[root] = path
     self.expanded.add(path)
     self.snapshot_tree_widget.addTopLevelItem(root)
     self.add_dir(path, root)
 def changeItemIconFun(self, item: QtWidgets.QTreeWidgetItem, index: int,
                       icon: str):
     path = getPath(icon)
     if icon in self.cachedIcons:
         item.setIcon(index, self.cachedIcons[icon])
     else:
         icn = QtGui.QIcon(
             QtGui.QPixmap(path).scaledToHeight(
                 16, QtCore.Qt.SmoothTransformation))
         self.cachedIcons[icon] = icn
         item.setIcon(index, icn)
Ejemplo n.º 7
0
    def __init__(self):
        super().__init__()
        self.setHeaderHidden(True)

        self.addTopLevelItem(QTreeWidgetItem(["Library"]))

        for i in range(10):
            group = QTreeWidgetItem()
            group.setText(0, "Group" + str(1))
            group.setIcon(0, QIcon("images/count.png"))
            self.addTopLevelItem(group)

            content = QTreeWidgetItem()
            group.addChild(content)
            self.setItemWidget(content, 0, ExpandedList(self))
Ejemplo n.º 8
0
    def addIndex(self, index):
        indexTree = self.applicationWindow.mainWindow.indexes

        if index.type == 'PRIMARY':
            name = 'PRIMARY KEY'
        else:
            name = index.name

        indexItem = QTreeWidgetItem()
        indexItem.setIcon(0, QIcon('../resources/icons/key.png'))
        indexItem.setText(0, name)
        indexItem.setText(1, index.type)

        for column in index.columns:
            columnItem = QTreeWidgetItem()
            columnItem.setIcon(0, QIcon('../resources/icons/bullet_black.png'))
            columnItem.setText(0, column.name)
            indexItem.addChild(columnItem)

        indexTree.addTopLevelItem(indexItem)
Ejemplo n.º 9
0
    def _populate(self):
        """Populates the window with available folder paths and texture
        file names
        """

        # get all the available textures
        allTextures = self.__app.getAllTextures()

        # show info label if textures not found
        if not allTextures:
            self._showInfoLabel("No textures found in the scene")

        for texClassName in allTextures:  # loop through all texture types
            texClassNameItem = QTreeWidgetItem(self.treeWidget)
            texClassNameItem.setText(0, texClassName)
            # loop through all folder paths
            for texPath in allTextures[texClassName]:
                texPathItem = QTreeWidgetItem(texClassNameItem)
                texPathItem.setText(0, texPath)
                texPathItem.setIcon(
                    0, QIcon(os.path.join(_iconPath, 'folder.png')))
                self._folderItems.append(texPathItem)
                # loop through all the texture files in this path
                for texFile in allTextures[texClassName][texPath]:
                    texFileItem = QTreeWidgetItem(texPathItem)
                    texFileItem.setText(0, texFile.getFilename())
                    if texFile.exists():
                        texFileItem.setIcon(
                            0, QIcon(os.path.join(_iconPath, "check.png")))
                    else:
                        texFileItem.setIcon(
                            0, QIcon(os.path.join(_iconPath, "cross.png")))
                    self._fileItems.append(texFileItem)
            self.treeWidget.addTopLevelItem(texClassNameItem)
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        super(ToolTree, self).__init__(parent)
        group_names = []
        tool_names = []
        tool_infos = []
        tool_progress = [
        ]  # 0 = da fare, 1 = iniziato, 2 = funzionante, 3 = completo

        # [0]
        group_names.append(self.tr('[General]'))
        tool_names.append([
            self.tr('Original Image'),
            self.tr('File Digest'),
            self.tr('Hex Editor'),
            self.tr('Similar Search')
        ])
        tool_infos.append([
            self.tr(
                'Display the unaltered reference image for visual inspection'),
            self.
            tr('Retrieve physical file information, crypto and perceptual hashes'
               ),
            self.
            tr('Open an external hexadecimal editor to show and edit raw bytes'
               ),
            self.
            tr('Browse online search services to find visually similar images')
        ])
        tool_progress.extend([3, 3, 2, 2])

        # [1]
        group_names.append(self.tr('[Metadata]'))
        tool_names.append([
            self.tr('Header Structure'),
            self.tr('EXIF Full Dump'),
            self.tr('Thumbnail Analysis'),
            self.tr('Geolocation data')
        ])
        tool_infos.append([
            self.
            tr('Dump the file header structure and display an interactive view'
               ),
            self.
            tr('Scan through file metadata and gather all available information'
               ),
            self.tr(
                'Extract optional embedded thumbnail and compare with original'
            ),
            self.
            tr('Retrieve optional geolocation data and show it on a world map')
        ])
        tool_progress.extend([3, 3, 3, 2])

        # [2]
        group_names.append(self.tr('[Inspection]'))
        tool_names.append([
            self.tr('Enhancing Magnifier'),
            self.tr('Channel Histogram'),
            self.tr('Global Adjustments'),
            self.tr('Reference Comparison')
        ])
        tool_infos.append([
            self.
            tr('Magnifying glass with enhancements for better identifying forgeries'
               ),
            self.
            tr('Display single color channels or RGB composite interactive histogram'
               ),
            self.
            tr('Apply standard image adjustments (brightness, hue, saturation, ...)'
               ),
            self.
            tr('Open a synchronized double view for comparison with another picture'
               )
        ])
        tool_progress.extend([3, 3, 3, 3])

        # [3]
        group_names.append(self.tr('[Detail]'))
        tool_names.append([
            self.tr('Luminance Gradient'),
            self.tr('Echo Edge Filter'),
            self.tr('Wavelet Threshold'),
            self.tr('Correlation Plot')
        ])
        tool_infos.append([
            self.
            tr('Analyze horizontal/vertical brightness variations across the image'
               ),
            self.
            tr('Use derivative filters to reveal artificial out-of-focus regions'
               ),
            self.
            tr('Reconstruct image with different wavelet coefficient thresholds'
               ),
            self.
            tr('Exploit spatial correlation patterns among neighboring pixels')
        ])
        tool_progress.extend([3, 3, 3, 0])

        # [4]
        group_names.append(self.tr('[Colors]'))
        tool_names.append([
            self.tr('RGB/HSV Plots'),
            self.tr('Space Conversion'),
            self.tr('PCA Projection'),
            self.tr('Pixel Statistics')
        ])
        tool_infos.append([
            self.
            tr('Display interactive 2D and 3D plots of RGB and HSV pixel values'
               ),
            self.
            tr('Convert RGB channels into HSV/YCbCr/Lab/Luv/CMYK/Gray spaces'),
            self.tr(
                'Use color PCA to project pixel onto most salient components'),
            self.tr(
                'Compute minimum/maximum/average RGB values for every pixel')
        ])
        tool_progress.extend([3, 3, 3, 3])

        # [5]
        group_names.append(self.tr('[Noise]'))
        tool_names.append([
            self.tr('Noise Estimation'),
            self.tr('Min/Max Deviation'),
            self.tr('Frequency Split'),
            self.tr('Bit Plane Values')
        ])
        tool_infos.append([
            self.tr(
                'Estimate different kind of noise components of the image'),
            self.
            tr('Highlight pixels deviating from block-based min/max statistics'
               ),
            self.
            tr('Split image luminance into high and low frequency components'),
            self.
            tr('Show individual bit planes to find inconsistent noise patterns'
               )
        ])
        tool_progress.extend([3, 3, 3, 3])

        # [6]
        group_names.append(self.tr('[JPEG]'))
        tool_names.append([
            self.tr('Error Level Analysis'),
            self.tr('Quality Estimation'),
            self.tr('Multiple Compression'),
            self.tr('DCT Dimples Map')
        ])
        tool_infos.append([
            self.
            tr('Show pixel-level difference against fixed compression levels'),
            self.
            tr('Extract quantization tables and estimate last saved JPEG quality'
               ),
            self.
            tr('Use residuals to detect multiple compressions at different levels'
               ),
            self.
            tr('Analyze periodic quantization artifacts introduced by devices')
        ])
        tool_progress.extend([3, 3, 1, 0])

        # [7]
        group_names.append(self.tr('[Tampering]'))
        tool_names.append([
            self.tr('Contrast Enhancement'),
            self.tr('Copy-Move Forgery'),
            self.tr('Image Resampling'),
            self.tr('Composite Splicing')
        ])
        tool_infos.append([
            self.tr(
                'Analyze color distributions to detect contrast enhancements'),
            self.tr(
                'Use invariant feature descriptors to detect cloned regions'),
            self.
            tr('Estimate 2D pixel interpolation for detecting resampling traces'
               ),
            self.tr(
                'Exploit DCT statistics for automatic splicing zone detection')
        ])
        tool_progress.extend([3, 3, 0, 0])

        # [8]
        group_names.append(self.tr('[Various]'))
        tool_names.append([
            self.tr('Median Filtering'),
            self.tr('Illuminant Map'),
            self.tr('PRNU Identification'),
            self.tr('Stereogram Decoder')
        ])
        tool_infos.append([
            self.tr(
                'Detect processing traces left by nonlinear median filtering'),
            self.tr(
                'Estimate scene local light direction on estimated 3D surfaces'
            ),
            self.
            tr('Exploit sensor pattern noise introduced by different cameras'),
            self.
            tr('Decode 3D images concealed inside crossed-eye autostereograms')
        ])
        tool_progress.extend([0, 0, 0, 3])

        count = 0
        for i, group in enumerate(group_names):
            group_item = QTreeWidgetItem()
            group_item.setText(0, group)
            font = group_item.font(0)
            font.setBold(True)
            group_item.setFont(0, font)
            group_item.setData(0, Qt.UserRole, False)
            group_item.setIcon(0, QIcon('icons/{}.svg'.format(i)))
            for j, tool in enumerate(tool_names[i]):
                tool_item = QTreeWidgetItem(group_item)
                tool_item.setText(0, tool)
                tool_item.setData(0, Qt.UserRole, True)
                tool_item.setData(0, Qt.UserRole + 1, i)
                tool_item.setData(0, Qt.UserRole + 2, j)
                tool_item.setToolTip(0, tool_infos[i][j])
                if tool_progress[count] == 0:
                    modify_font(tool_item, italic=True)
                count += 1
            self.addTopLevelItem(group_item)
        self.expandAll()
        self.setColumnCount(1)
        self.header().setVisible(False)
        self.setMaximumWidth(300)
        self.version = '{:.2f}a'.format(sum(tool_progress) / (count * 3))
Ejemplo n.º 11
0
    def loadBacktestTree(self):
        options = self.config.get("options", {})
        underlyings = options.get("underlyings", [])

        for i in range(1):
            item = self.backtest_tree.topLevelItem(i)
            item.setExpanded(True)
            for j in range(item.childCount()):
                child_item = item.child(j)
                child_item.setExpanded(True)
                whatsthis = child_item.whatsThis(0)
                if whatsthis == "option":
                    for underlying in underlyings:
                        current_item = child_item
                        node = QTreeWidgetItem(current_item)
                        node.setText(0, underlying["name"])
                        node.setCheckState(0, Qt.Unchecked)
                        node.setWhatsThis(0, "option_underlying")
                        node.setExpanded(True)

                        data = underlying.get("id",
                                              {}).get("data", pd.DataFrame())
                        if not data.empty:
                            id_dict = underlying.get("id", {})
                            name = id_dict["list"][id_dict["value"]]
                            childSubWindow = {
                                "title": "%s的当日合约",
                                "type": "option_contract_table",
                                "table_name": "%date%",
                                "where": "",
                                "select": id,
                                "hidden_columns": [],
                                "index_column": [],
                                "childSubWindow": {},
                            }
                            hidden_columns = [
                                'total_turnover', 'limit_up', 'limit_down',
                                'settlement', 'prev_settlement',
                                'discount_rate', 'acc_net_value',
                                'unit_net_value', 'date', 'open_interest',
                                'iopv', 'num_trades'
                            ]

                            GridView(self.parent,
                                     name,
                                     data,
                                     id=name,
                                     hidden_columns=hidden_columns,
                                     index_column='date',
                                     childSubWindow=childSubWindow,
                                     type="option_underlying")
                        current_item = node

                        groups = underlying.get("groups", [])
                        for group in groups:
                            node = QTreeWidgetItem(current_item)
                            node.setText(0, group["name"])
                            node.setCheckState(0, Qt.Unchecked)
                            node.setIcon(0, QtGui.QIcon("../icon/group.png"))
                            node.setWhatsThis(0, "option_group")
                            node.setExpanded(True)
                            current_item = node
                            contracts = group.get("contracts")
                            for contract in contracts:
                                node = QTreeWidgetItem(current_item)
                                node.setText(0, contract["name"])
                                node.setCheckState(0, Qt.Unchecked)
                                node.setWhatsThis(0, "option_contract")
                                node.setExpanded(True)
                                current_item = node
Ejemplo n.º 12
0
    def __init__(self, parent=None):
        super(ToolTree, self).__init__(parent)
        group_names = []
        tool_names = []
        tool_infos = []
        tool_progress = [
        ]  # 0 = da fare, 1 = debug, 2 = funzionante, 3 = completo

        # [0]
        group_names.append(self.tr("[General]"))
        tool_names.append([
            self.tr("Original Image"),
            self.tr("File Digest"),
            self.tr("Hex Editor"),
            self.tr("Similar Search")
        ])
        tool_infos.append([
            self.tr(
                "Display the unaltered reference image for visual inspection"),
            self.
            tr("Retrieve physical file information, crypto and perceptual hashes"
               ),
            self.
            tr("Open an external hexadecimal editor to show and edit raw bytes"
               ),
            self.tr(
                "Browse online search services to find visually similar images"
            ),
        ])
        tool_progress.extend([3, 3, 2, 2])

        # [1]
        group_names.append(self.tr("[Metadata]"))
        tool_names.append([
            self.tr("Header Structure"),
            self.tr("EXIF Full Dump"),
            self.tr("Thumbnail Analysis"),
            self.tr("Geolocation data"),
        ])
        tool_infos.append([
            self.
            tr("Dump the file header structure and display an interactive view"
               ),
            self.
            tr("Scan through file metadata and gather all available information"
               ),
            self.tr(
                "Extract optional embedded thumbnail and compare with original"
            ),
            self.tr(
                "Retrieve optional geolocation data and show it on a world map"
            ),
        ])
        tool_progress.extend([3, 3, 3, 2])

        # [2]
        group_names.append(self.tr("[Inspection]"))
        tool_names.append([
            self.tr("Enhancing Magnifier"),
            self.tr("Channel Histogram"),
            self.tr("Global Adjustments"),
            self.tr("Reference Comparison"),
        ])
        tool_infos.append([
            self.
            tr("Magnifying glass with enhancements for better identifying forgeries"
               ),
            self.
            tr("Display single color channels or RGB composite interactive histogram"
               ),
            self.
            tr("Apply standard image adjustments (brightness, hue, saturation, ...)"
               ),
            self.
            tr("Open a synchronized double view for comparison with another picture"
               ),
        ])
        tool_progress.extend([3, 3, 3, 3])

        # [3]
        group_names.append(self.tr("[Detail]"))
        tool_names.append([
            self.tr("Luminance Gradient"),
            self.tr("Echo Edge Filter"),
            self.tr("Wavelet Threshold"),
            self.tr("Frequency Split"),
        ])
        tool_infos.append([
            self.
            tr("Analyze horizontal/vertical brightness variations across the image"
               ),
            self.
            tr("Use derivative filters to reveal artificial out-of-focus regions"
               ),
            self.
            tr("Reconstruct image with different wavelet coefficient thresholds"
               ),
            self.tr(
                "Divide image luminance into high and low frequency components"
            ),
        ])
        tool_progress.extend([3, 3, 3, 3])

        # [4]
        group_names.append(self.tr("[Colors]"))
        tool_names.append([
            self.tr("RGB/HSV Plots"),
            self.tr("Space Conversion"),
            self.tr("PCA Projection"),
            self.tr("Pixel Statistics"),
        ])
        tool_infos.append([
            self.
            tr("Display interactive 2D and 3D plots of RGB and HSV pixel values"
               ),
            self.
            tr("Convert RGB channels into HSV/YCbCr/Lab/Luv/CMYK/Gray spaces"),
            self.tr(
                "Use color PCA to project pixel onto most salient components"),
            self.tr(
                "Compute minimum/maximum/average RGB values for every pixel"),
        ])
        tool_progress.extend([3, 3, 3, 3])

        # [5]
        group_names.append(self.tr("[Noise]"))
        tool_names.append([
            self.tr("Noise Separation"),
            self.tr("Min/Max Deviation"),
            self.tr("Bit Plane Values"),
            self.tr("PRNU Identification"),
        ])
        tool_infos.append([
            self.tr(
                "Estimate and extract different kind of image noise components"
            ),
            self.
            tr("Highlight pixels deviating from block-based min/max statistics"
               ),
            self.
            tr("Show individual bit planes to find inconsistent noise patterns"
               ),
            self.
            tr("Exploit sensor pattern noise introduced by different cameras"),
        ])
        tool_progress.extend([3, 3, 3, 0])

        # [6]
        group_names.append(self.tr("[JPEG]"))
        tool_names.append([
            self.tr("Quality Estimation"),
            self.tr("Error Level Analysis"),
            self.tr("Multiple Compression"),
            self.tr("JPEG Ghost Maps"),
        ])
        tool_infos.append([
            self.
            tr("Extract quantization tables and estimate last saved JPEG quality"
               ),
            self.tr(
                "Show pixel-wise differences against a fixed compression level"
            ),
            self.tr(
                "Use a machine learning model to detect multiple compression"),
            self.
            tr("Highlight traces of different compressions in difference images"
               ),
        ])
        tool_progress.extend([3, 3, 0, 0])

        # [7]
        group_names.append(self.tr("[Tampering]"))
        tool_names.append([
            self.tr("Contrast Enhancement"),
            self.tr("Copy-Move Forgery"),
            self.tr("Composite Splicing"),
            self.tr("Image Resampling"),
        ])
        tool_infos.append([
            self.tr(
                "Analyze color distributions to detect contrast enhancements"),
            self.tr(
                "Use invariant feature descriptors to detect cloned regions"),
            self.
            tr("Exploit DCT statistics for automatic splicing zone detection"),
            self.
            tr("Estimate 2D pixel interpolation for detecting resampling traces"
               ),
        ])
        tool_progress.extend([3, 2, 3, 0])

        # [8]
        group_names.append(self.tr("[Various]"))
        tool_names.append([
            self.tr("Median Filtering"),
            self.tr("Illuminant Map"),
            self.tr("Dead/Hot Pixels"),
            self.tr("Stereogram Decoder"),
        ])
        tool_infos.append([
            self.tr(
                "Detect nonlinear processing traces left by median filtering"),
            self.tr(
                "Estimate scene local light direction on estimated 3D surfaces"
            ),
            self.tr(
                "Detect and fix dead/hot pixels caused by sensor imperfections"
            ),
            self.tr(
                "Decode 3D images concealed inside crossed-eye autostereograms"
            ),
        ])
        tool_progress.extend([2, 0, 0, 3])

        count = 0
        for i, group in enumerate(group_names):
            group_item = QTreeWidgetItem()
            group_item.setText(0, group)
            font = group_item.font(0)
            font.setBold(True)
            group_item.setFont(0, font)
            group_item.setData(0, Qt.UserRole, False)
            group_item.setIcon(0, QIcon(f"icons/{i}.svg"))
            for j, tool in enumerate(tool_names[i]):
                tool_item = QTreeWidgetItem(group_item)
                tool_item.setText(0, tool)
                tool_item.setData(0, Qt.UserRole, True)
                tool_item.setData(0, Qt.UserRole + 1, i)
                tool_item.setData(0, Qt.UserRole + 2, j)
                tool_item.setToolTip(0, tool_infos[i][j])
                if tool_progress[count] == 0:
                    modify_font(tool_item, italic=True)
                count += 1
            self.addTopLevelItem(group_item)
        self.expandAll()
        self.setColumnCount(1)
        self.header().setVisible(False)
        self.setMaximumWidth(300)
        self.version = f"{sum(tool_progress) / 100:.2f}a"
Ejemplo n.º 13
0
    def __init__(self, parent=None):
        super(ToolTree, self).__init__(parent)
        group_names = []
        tool_names = []
        tool_infos = []
        tool_progress = [
        ]  # 0 = da fare, 1 = iniziato, 2 = funzionante, 3 = completo

        # [0]
        group_names.append(self.tr('[General]'))
        tool_names.append([
            self.tr('Original Image'),
            self.tr('File Digest'),
            self.tr('Hex Editor'),
            self.tr('Reverse Search')
        ])
        tool_infos.append([
            self.tr(
                'Display the unaltered reference image for visual inspection'),
            self.
            tr('Retrieve file information and compute many hashes and ballistics'
               ),
            self.
            tr('Open an external hexadecimal editor to show and edit raw bytes'
               ),
            self.tr(
                'Use online search services to find visually similar images')
        ])
        tool_progress.extend([3, 3, 2, 2])

        # [1]
        group_names.append(self.tr('[Metadata]'))
        tool_names.append([
            self.tr('Header Structure'),
            self.tr('Metadata Extraction'),
            self.tr('Thumbnail Analysis'),
            self.tr('Geolocation data')
        ])
        tool_infos.append([
            self.
            tr('Dump the physical EXIF structure and display an interactive view'
               ),
            self.
            tr('Scan through file metadata and gather all available information'
               ),
            self.tr(
                'Extract optional embedded thumbnail and compare with original'
            ),
            self.
            tr('Retrieve optional geo-location data and show it on a world map'
               )
        ])
        tool_progress.extend([3, 3, 3, 2])

        # [2]
        group_names.append(self.tr('[Inspection]'))
        tool_names.append([
            self.tr('Enhancing Magnifier'),
            self.tr('Reference Comparison'),
            self.tr('Global Adjustments'),
            self.tr('Fourier Transform')
        ])
        tool_infos.append([
            self.
            tr('Use a loupe with visual enhancement for better identifying forgeries'
               ),
            self.
            tr('Open a synchronized double view to compare two different pictures'
               ),
            self.
            tr('Apply standard adjustments (contrast, brightness, hue, saturation)'
               ),
            self.
            tr('Compute amplitude and phase components of the 2D Fourier Transform'
               )
        ])
        tool_progress.extend([2, 2, 2, 3])

        # [3]
        group_names.append(self.tr('[JPEG]'))
        tool_names.append([
            self.tr('Quality Estimation'),
            self.tr('Error Level Analysis'),
            self.tr('Multiple Compression'),
            self.tr('DCT Dimples Map')
        ])
        tool_infos.append([
            self.
            tr('Extract quantization tables and estimate last saved JPEG quality'
               ),
            self.
            tr('Show pixel-level difference against different compression levels'
               ),
            self.
            tr('Use residuals to detect multiple compressions at different levels'
               ),
            self.
            tr('Analyze periodic quantization artifacts to detect manipulations'
               )
        ])
        tool_progress.extend([2, 3, 1, 0])

        # [4]
        group_names.append(self.tr('[Colors]'))
        tool_names.append([
            self.tr('RGB/HSV Plots'),
            self.tr('PCA Projection'),
            self.tr('Pixel Statistics'),
            self.tr('Space Conversion')
        ])
        tool_infos.append([
            self.tr(
                'Display interactive 2D and 3D plots of RGB and HSV pixel data'
            ),
            self.
            tr('Use color PCA to project RGB values onto reduced vector spaces'
               ),
            self.tr(
                'Compute minimum/maximum/average RGB values for every pixel'),
            self.
            tr('Convert color channels into RGB/HSV/YCbCr/Lab/Luv/CMYK spaces')
        ])
        tool_progress.extend([0, 2, 3, 2])

        # [5]
        group_names.append(self.tr('[Tonality]'))
        tool_names.append([
            self.tr('Luminance Gradient'),
            self.tr('Echo Edge Filter'),
            self.tr('Correlation Plot'),
            self.tr('Wavelet Threshold')
        ])
        tool_infos.append([
            self.
            tr('Analyze horizontal/vertical brightness variations across the image'
               ),
            self.
            tr('Use derivative filters to reveal artificial out-of-focus zones'
               ),
            self.tr(
                'Exploit spatial correlation patterns among neighboring pixels'
            ),
            self.
            tr('Reconstruct image with different wavelet coefficient thresholds'
               )
        ])
        tool_progress.extend([2, 3, 0, 0])

        # [6]
        group_names.append(self.tr('[Noise]'))
        tool_names.append([
            self.tr('Noise Estimation'),
            self.tr('Min/Max Deviation'),
            self.tr('Image Bit Planes'),
            self.tr('Frequency Separation')
        ])
        tool_infos.append([
            self.tr(
                'Estimate and visualize gaussian noise components of the image'
            ),
            self.
            tr('Highlight pixels deviating from block-based min/max statistics'
               ),
            self.
            tr('Visualize bit planes values to find different noise patterns'),
            self.
            tr('Estimate high/low frequency components of the luminance channel'
               )
        ])
        tool_progress.extend([3, 2, 3, 0])

        # [7]
        group_names.append(self.tr('[Tampering]'))
        tool_names.append([
            self.tr('Contrast Enhancement'),
            self.tr('Region Cloning'),
            self.tr('Image Resampling'),
            self.tr('Composite Splicing')
        ])
        tool_infos.append([
            self.tr(
                'Analyze color distribuions to detect contrast enhancements'),
            self.
            tr('Use feature descriptors for copy/rotate clone area detection'),
            self.
            tr('Analyze 2D pixel interpolation for detecting resampling traces'
               ),
            self.tr(
                'Exploit DCT statistics for automatic splicing zone detection')
        ])
        tool_progress.extend([0, 0, 0, 0])

        count = 0
        for i, group in enumerate(group_names):
            group_item = QTreeWidgetItem()
            group_item.setText(0, group)
            font = group_item.font(0)
            font.setBold(True)
            group_item.setFont(0, font)
            group_item.setData(0, Qt.UserRole, False)
            group_item.setIcon(0, QIcon('icons/{}.svg'.format(i)))
            for j, tool in enumerate(tool_names[i]):
                tool_item = QTreeWidgetItem(group_item)
                tool_item.setText(0, tool)
                tool_item.setData(0, Qt.UserRole, True)
                tool_item.setData(0, Qt.UserRole + 1, i)
                tool_item.setData(0, Qt.UserRole + 2, j)
                tool_item.setToolTip(0, tool_infos[i][j])
                if tool_progress[count] == 0:
                    modify_font(tool_item, italic=True)
                count += 1
            self.addTopLevelItem(group_item)
        self.expandAll()
        self.setColumnCount(1)
        self.header().setVisible(False)
        self.setMaximumWidth(300)
        self.version = '{:.2f}a'.format(sum(tool_progress) / (count * 3))
Ejemplo n.º 14
0
    def __init__(self):
        super(TreeWidget, self).__init__()
        self.setColumnCount(3)
        self.setColumnWidth(0, 80)
        self.setColumnWidth(1, 80)
        self.setColumnWidth(2, 80)
        self.setIndentation(0)
        self.setHeaderHidden(True)
        self.foreground_font = QFont()
        self.foreground_font.setBold(True)
        self.normal_font = QFont()
        self.normal_font.setBold(False)
        self.setExpandsOnDoubleClick(False)
        p = QTreeWidgetItem(self)
        font = QFont()
        font.setPointSize(10)
        font.setBold(True)
        p.setFont(0, font)
        p.setText(0, "父级1父级1父级1父级1父级1父级1")
        p.setIcon(0, QIcon("icons/arrow_right.png"))
        p.setFirstColumnSpanned(True)

        c = QTreeWidgetItem(p)

        c.setText(0, "子级1")
        c.setText(1, "子级2")
        c.setText(2, "子级3")
        c.setTextAlignment(0, Qt.AlignCenter)
        c.setTextAlignment(1, Qt.AlignCenter)
        c.setTextAlignment(2, Qt.AlignCenter)
        c.setData(0, Qt.UserRole, "c_00")
        c.setData(1, Qt.UserRole, "c_01")
        c.setData(2, Qt.UserRole, "c_02")

        c = QTreeWidgetItem(p)

        c.setText(0, "子级1")
        c.setText(1, "子级2")
        c.setTextAlignment(0, Qt.AlignCenter)
        c.setTextAlignment(1, Qt.AlignCenter)
        c.setData(0, Qt.UserRole, "c_03")
        c.setData(1, Qt.UserRole, "c_04")

        p.addChild(c)

        p = QTreeWidgetItem(self)
        p.setText(0, "父级2父级2父级2父级2父级2父级2")
        p.setIcon(0, QIcon("icons/arrow_right.png"))
        p.setFirstColumnSpanned(True)

        p.setFont(0, font)
        c = QTreeWidgetItem(p)

        c.setText(0, "子级2")
        c.setText(1, "子级22")
        c.setText(2, "子级23")
        c.setTextAlignment(0, Qt.AlignCenter)
        c.setTextAlignment(1, Qt.AlignCenter)
        c.setTextAlignment(2, Qt.AlignCenter)
        c.setData(0, Qt.UserRole, "c_10")
        c.setData(1, Qt.UserRole, "c_11")
        c.setData(2, Qt.UserRole, "c_12")

        p.addChild(c)
        self.itemClicked.connect(self.click)
        self.setFocusPolicy(Qt.NoFocus)
        self.setObjectName("tree")
        self.setStyleSheet(
            "#tree::item:selected{background-color:rgb(255,255,255);color:rgb(180,12,34);}"
            "#tree::item:hover{background-color:rgb(255,255,255);color:rgb(10,160,10)}"
        )
        self.setAnimated(True)
        self.setSelectionBehavior(QAbstractItemView.SelectItems)
        self.setSelectionMode(QAbstractItemView.SingleSelection)
Ejemplo n.º 15
0
 def onAddOptionContract(self):
     text, ok = QInputDialog.getText(self.backtest, "请输入期权合约名称", "名称",
                                     QLineEdit.Normal)
     current_item = self.backtest_tree.currentItem()
     current_item_whats_this = current_item.whatsThis(0)
     current_item_text = current_item.text(0)
     parent_item = current_item.parent()
     parent_whats_this = parent_item.whatsThis(0)
     parent_item_text = parent_item.text(0)
     if ok and text:
         node = QTreeWidgetItem(current_item)
         node.setText(0, text)
         node.setCheckState(0, Qt.Unchecked)
         node.setWhatsThis(0, "option_contract")
         node.setIcon(0, QtGui.QIcon("../icon/contract.png"))
         self.backtest_tree.expandItem(self.backtest_tree.currentItem())
         filter_dict = {
             "name": text,
             "enable": 1,
             "open_status": False,
             "ids": [],
             "option_type": {
                 "type": "list",
                 "value": 0,
                 "list": setting.OPTION_TYPE,
             },
             "option_side": {
                 "type": "list",
                 "value": 0,
                 "list": setting.OPTION_SIDE,
             },
             "close_method": {
                 "type": "list",
                 "value": 0,
                 "list": setting.OPTION_CLOSE_METHOD,
             },
             "change_feq": {
                 "type": "list",
                 "value": 0,
                 "list": setting.OPTION_CHANGE_FEQ,
             },
             "change_condition": {
                 "type": "list",
                 "value": 0,
                 "list": setting.OPTION_CHANGE_CONDITION,
             },
             "month_interval": {
                 "type":
                 "list",
                 "value":
                 0,
                 "list": [
                     setting.OPTION_INTERVAL[i]
                     for i in range(len(setting.OPTION_INTERVAL)) if i != 2
                 ],
             },
             "strike_interval": {
                 "type": "list",
                 "value": 0,
                 "list": setting.OPTION_STRIKE_INTERVAL,
             },
             "smart_selection": {
                 "type": "list",
                 "value": 1,
                 "list": setting.OPTION_SMART_SELECTION,
             },
             "type": "option",
             "volume": {
                 "type": "int",
                 "value": 0
             },
             "deposit_coefficient": {
                 "type": "int",
                 "value": 1,
             },
             "delta": {
                 "type": "int",
                 "value": 0,
             },
             "gamma": {
                 "type": "int",
                 "value": 0,
             },
             "theta": {
                 "type": "int",
                 "value": 0,
             },
             "vega": {
                 "type": "int",
                 "value": 0,
             },
             "rho": {
                 "type": "int",
                 "value": 0,
             },
             "ivix": {
                 "type": "float",
                 "value": 0
             }
         }
         for underlying in self.config["options"]["underlyings"]:
             underlying_name = underlying.get("name")
             if current_item_whats_this == "option_group":
                 if underlying_name == parent_item_text:
                     groups = underlying.get("groups")
                     for group in groups:
                         if group.get("name") == current_item_text:
                             group["contracts"].append(filter_dict)
             elif current_item_whats_this == "option_underlying":
                 if underlying_name == current_item_text:
                     underlying.get("contracts").append(filter_dict)
Ejemplo n.º 16
0
def parse(context, xml):
    content = ET.fromstring(xml)

    for elem in content.findall('.//page_contents/'):
        # Add to element view
        elementview_item = QTreeWidgetItem()
        elementview_item.setText(0, elem.tag)

        if elem.tag == "heading":
            # Error Handling
            try:
                elem.attrib["bold"]
            except KeyError:
                elem.attrib["bold"] = False
            try:
                elem.attrib["size"]
            except KeyError:
                elem.attrib["size"] = "20"
            try:
                elem.attrib["alignment"]
            except KeyError:
                elem.attrib["alignment"] = "left"

            # Add heading
            add_heading(context,
                        text=elem.text,
                        size=elem.attrib["size"],
                        bold=elem.attrib["bold"],
                        alignment=elem.attrib["alignment"])

            # Add info to element list
            text_child = QTreeWidgetItem()
            text_child.setText(0, f'"{elem.text}"')
            text_child.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/type/text.png")))

            bold_child = QTreeWidgetItem()
            bold_child.setText(0, f"Bold: {str(elem.attrib['bold'])}")
            bold_child.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/type/bold.png")))

            size_child = QTreeWidgetItem()
            size_child.setText(0, f"Size: {str(elem.attrib['size'])}")
            size_child.setIcon(
                0,
                QIcon(
                    resource_path("./gui/assets/elements/type/font_size.png")))

            alignment_child = QTreeWidgetItem()
            alignment_child.setText(
                0, f"Alignment: {str(elem.attrib['alignment'])}")
            alignment_child.setIcon(
                0,
                QIcon(
                    resource_path("./gui/assets/elements/type/alignment.png")))

            elementview_item.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/heading.png")))
            elementview_item.addChildren(
                [text_child, bold_child, size_child, alignment_child])

        if elem.tag == "label":
            # Error Handling
            try:
                elem.attrib["bold"]
            except KeyError:
                elem.attrib["bold"] = False
            try:
                elem.attrib["size"]
            except KeyError:
                elem.attrib["size"] = "12"
            try:
                elem.attrib["alignment"]
            except KeyError:
                elem.attrib["alignment"] = "left"

            # Add Label
            add_label(context,
                      text=elem.text,
                      size=elem.attrib["size"],
                      bold=elem.attrib["bold"],
                      alignment=elem.attrib["alignment"])

            # Add info to element list
            text_child = QTreeWidgetItem()
            text_child.setText(0, f'"{elem.text}"')
            text_child.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/type/text.png")))

            bold_child = QTreeWidgetItem()
            bold_child.setText(0, f"Bold: {str(elem.attrib['bold'])}")
            bold_child.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/type/bold.png")))

            size_child = QTreeWidgetItem()
            size_child.setText(0, f"Size: {str(elem.attrib['size'])}")
            size_child.setIcon(
                0,
                QIcon(
                    resource_path("./gui/assets/elements/type/font_size.png")))

            alignment_child = QTreeWidgetItem()
            alignment_child.setText(
                0, f"Alignment: {str(elem.attrib['alignment'])}")
            alignment_child.setIcon(
                0,
                QIcon(
                    resource_path("./gui/assets/elements/type/alignment.png")))

            elementview_item.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/label.png")))
            elementview_item.addChildren(
                [text_child, bold_child, size_child, alignment_child])

        if elem.tag == "link":
            # Error Handling
            try:
                elem.attrib["href"]
            except KeyError:
                elem.attrib["href"] = ""
            try:
                elem.attrib["alignment"]
            except KeyError:
                elem.attrib["alignment"] = "left"

            # Add link
            add_link(context,
                     text=elem.text,
                     location=elem.attrib["href"],
                     alignment=elem.attrib["alignment"])

            # Add info to element list
            location_child = QTreeWidgetItem()
            location_child.setText(0, f"Location: {str(elem.attrib['href'])}")
            location_child.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/type/link.png")))

            alignment_child = QTreeWidgetItem()
            alignment_child.setText(
                0, f"Alignment: {str(elem.attrib['alignment'])}")
            alignment_child.setIcon(
                0,
                QIcon(
                    resource_path("./gui/assets/elements/type/alignment.png")))

            elementview_item.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/link.png")))
            elementview_item.addChildren([location_child, alignment_child])

        if elem.tag == "horizontal_line":
            # Add horizontal line
            add_horizontal_line(context)
            elementview_item.setIcon(
                0,
                QIcon(
                    resource_path(
                        "./gui/assets/elements/horizontal_line.png")))

        if elem.tag == "spacer":
            # Error Handling
            try:
                elem.attrib["height"]
            except KeyError:
                elem.attrib["height"] = "20"

            # Add Spacer
            add_spacer(context, height=elem.attrib["height"])

            # Add info to element view
            elementview_item.setIcon(
                0, QIcon(resource_path("./gui/assets/elements/spacer.png")))
            height_child = QTreeWidgetItem()
            height_child.setText(0, f"Height: {str(elem.attrib['height'])}")
            height_child.setIcon(
                0,
                QIcon(resource_path("./gui/assets/elements/type/height.png")))

            elementview_item.addChildren([height_child])

        context.ui.ElementList.addTopLevelItem(elementview_item)

    # print(elem)
    # print(content.find("page_header"))
    context.ui.statusbar.showMessage(f"Done!")
Ejemplo n.º 17
0
    def __init__(self, *args, **kwargs):
        super(ExchangeLibTree, self).__init__(*args, **kwargs)
        self.itemClicked.connect(self.item_clicked)
        # self.setIndentation(0)  # 设置子项不缩进
        self.header().hide()
        # self.setRootIsDecorated(False)
        self.setFocusPolicy(Qt.NoFocus)
        # self.setLayoutDirection(Qt.RightToLeft)
        self.setColumnCount(1)
        # 添加交易所数据
        lib = [
            {
                "id": "cffex", "name": "中国金融期货交易所", "logo": "icons/cffex_logo.png",
                "children": [
                    {"id": "daily", "name": "日交易数据", "logo": "icons/daily.png"},
                    {"id": "rank", "name": "日交易排名", "logo": "icons/rank.png"},
                ]
            },
            {
                "id": "shfe", "name": "上海期货交易所", "logo": "icons/shfe_logo.png",
                "children": [
                    {"id": "daily", "name": "日交易数据", "logo": "icons/daily.png"},
                    {"id": "rank", "name": "日交易排名", "logo": "icons/rank.png"},
                ]
            },
            {
                "id": "czce", "name": "郑州商品交易所", "logo": "icons/czce_logo.png",
                "children": [
                        {"id": "daily", "name": "日交易数据", "logo": "icons/daily.png"},
                        {"id": "rank", "name": "日交易排名", "logo": "icons/rank.png"},
                        {"id": "receipt", "name": "每日仓单", "logo": "icons/receipt.png"},
                    ]
             },
            {
                "id": "dce", "name": "大连商品交易所", "logo": "icons/dce_logo.png",
                "children": [
                    {"id": "daily", "name": "日交易数据", "logo": "icons/daily.png"},
                    {"id": "rank", "name": "日交易排名", "logo": "icons/rank.png"},
                ]
             },
        ]

        for item in lib:
            tree_item = QTreeWidgetItem(self)
            tree_item.setText(0, item["name"])
            setattr(tree_item, "id", item["id"])
            # tree_item.setTextAlignment(0, Qt.AlignRight | Qt.AlignVCenter)
            tree_item.setIcon(0, QIcon(item["logo"]))
            for child_item in item["children"]:
                child = QTreeWidgetItem(tree_item)
                child.setText(0, child_item["name"])
                setattr(child, "id", child_item["id"])
                child.setIcon(0, QIcon(child_item["logo"]))
                # child.setTextAlignment(0, Qt.AlignRight | Qt.AlignVCenter)
                tree_item.addChild(child)
        self.setObjectName("exchangeTree")
        self.setStyleSheet("#exchangeTree{font-size:14px;border:none;border-right: 1px solid rgba(50,50,50,100)}"
                           "#exchangeTree::item:hover{background-color:rgba(0,255,0,50)}"
                           "#exchangeTree::item:selected{background-color:rgba(255,0,0,100)}"
                           "#exchangeTree::item{height:28px;}"
                           )
Ejemplo n.º 18
0
    def update_node_data_and_tree(self):
        """
        Updates the tree and assembles the node-data

        This data is obtained from scene.nodes and assumes that
        each of the nodes has a visual assigned to it.

        """

        self.items = dict()

        self.guiScene.sort_nodes_by_dependency()
        self.treeView.clear()

        for node in self.guiScene._nodes:

            # create a tree item
            text = node.name
            item = QTreeWidgetItem()
            item.setText(0,text)

            # if we have a parent, then put the items under the parent,
            # else put it under the root

            item.setIcon(0, QIcon(":/icons/redball.png"))
            if isinstance(node, ds.Axis):
                item.setIcon(0, QIcon(":/icons/axis.png"))
            if isinstance(node, ds.RigidBody):
                item.setIcon(0, QIcon(":/icons/cube.png"))
            if isinstance(node, ds.Poi):
                item.setIcon(0,QIcon(":/icons/poi.png"))
            if isinstance(node, ds.Cable):
                item.setIcon(0,QIcon(":/icons/cable.png"))
            if isinstance(node, ds.Visual):
                item.setIcon(0,QIcon(":/icons/visual.png"))
            if isinstance(node, ds.LC6d):
                item.setIcon(0,QIcon(":/icons/lincon6.png"))
            if isinstance(node, ds.Connector2d):
                item.setIcon(0,QIcon(":/icons/con2d.png"))
            if isinstance(node, ds.LinearBeam):
                item.setIcon(0,QIcon(":/icons/beam.png"))
            if isinstance(node, ds.HydSpring):
                item.setIcon(0,QIcon(":/icons/linhyd.png"))
            if isinstance(node, ds.Force):
                item.setIcon(0,QIcon(":/icons/force.png"))
            if isinstance(node, ds.Sheave):
                item.setIcon(0,QIcon(":/icons/sheave.png"))
            if isinstance(node, ds.Buoyancy):
                item.setIcon(0,QIcon(":/icons/trimesh.png"))
            if isinstance(node, ds.WaveInteraction1):
                item.setIcon(0,QIcon(":/icons/waveinteraction.png"))
            if isinstance(node, ds.ContactBall):
                item.setIcon(0,QIcon(":/icons/contactball.png"))
            if isinstance(node, ds.ContactMesh):
                item.setIcon(0,QIcon(":/icons/contactmesh.png"))

            try:
                parent = node.parent
            except:
                parent = None

            self.items[node.name] = item

            if parent is not None:
                try:
                    self.items[node.parent.name].addChild(item)
                except:
                    print('stop here')
            else:
                self.treeView.invisibleRootItem().addChild(item)

        # self.treeView.resizeColumnToContents(0)
        self.treeView.expandAll()