void KisFilterStrokeStrategy::doStrokeCallback(KisStrokeJobData *data)
{
    Data *d = dynamic_cast<Data*>(data);
    CancelSilentlyMarker *cancelJob =
        dynamic_cast<CancelSilentlyMarker*>(data);

    if (d) {
        QRect rc = d->processRect;

        KisProcessingVisitor::ProgressHelper helper(m_d->node);

        m_d->filter->processImpl(m_d->filterDevice, rc,
                                 m_d->filterConfig.data(), helper.updater());

        if (m_d->secondaryTransaction) {
            KisPainter p(targetDevice());
            p.setCompositeOp(COMPOSITE_COPY);
            p.setSelection(activeSelection());
            p.bitBlt(rc.topLeft(), m_d->filterDevice, rc);

            // Free memory
            m_d->filterDevice->clear(rc);
        }

        m_d->node->setDirty(rc);
    } else if (cancelJob) {
        m_d->cancelSilently = true;
    } else {
        qFatal("KisFilterStrokeStrategy: job type is not known");
    }
}
示例#2
0
void KisFilterStrokeStrategy::initStrokeCallback()
{
    KisPainterBasedStrokeStrategy::initStrokeCallback();

    KisPaintDeviceSP dev = targetDevice();
    m_d->filterDeviceBounds = dev->extent();


    if (activeSelection() ||
        (dev->colorSpace() != dev->compositionSourceColorSpace() &&
         !(dev->colorSpace() == dev->compositionSourceColorSpace()))) {

        m_d->filterDevice = dev->createCompositionSourceDevice(dev);
        m_d->secondaryTransaction = new KisTransaction(m_d->filterDevice);

        if (activeSelection()) {
            m_d->filterDeviceBounds &= activeSelection()->selectedRect();
        }
    } else {
        m_d->filterDevice = dev;
    }
}
示例#3
0
void BookmarkView::onTreeSelect( wxTreeEvent& event ) {

    if (skipEvents()) {
        return;
    }

    wxTreeItemId itm = event.GetItem();
    TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(itm));

    if (!tvi) {
        
        if (itm == bookmarkBranch) {
            bookmarkBranchSelection();
        } else if (itm == activeBranch) {
            activeBranchSelection();
        } else if (itm == recentBranch) {
            recentBranchSelection();
        } else if (itm == rangeBranch) {
            rangeBranchSelection();
        } else {
            hideProps();
            this->Layout();
        }
        
        return;
    }
                                                    
    if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
        activeSelection(tvi->demod);
        if (tvi->demod->isActive()) {
            wxGetApp().getDemodMgr().setActiveDemodulator(nullptr, true);
            wxGetApp().getDemodMgr().setActiveDemodulator(tvi->demod, false);
            tvi->demod->setTracking(true);
        }
    } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
        recentSelection(tvi->bookmarkEnt);
    } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
        bookmarkSelection(tvi->bookmarkEnt);
    } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
        groupSelection(tvi->groupName);
    } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {
        rangeSelection(tvi->rangeEnt);
    } else {
        hideProps();
        this->Layout();
    }
}
示例#4
0
void BookmarkView::doUpdateActiveList() {

    auto demods = wxGetApp().getDemodMgr().getDemodulators();
    auto lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();

    //capture the previously selected item info BY COPY (because the original will be destroyed together with the destroyed tree items) to restore it again after 
    //having rebuilding the whole tree.
    TreeViewItem* prevSel = itemToTVI(m_treeView->GetSelection());
    TreeViewItem* prevSelCopy = nullptr;
   
    if (prevSel != NULL) {
        prevSelCopy = new TreeViewItem(*prevSel);
    }

    // Actives
    m_treeView->DeleteChildren(activeBranch);
    
    bool activeExpandState = expandState["active"];
    bool searchState = (searchKeywords.size() != 0);
    
    wxTreeItemId selItem = nullptr;
    for (auto demod_i : demods) {
        wxString activeLabel = BookmarkMgr::getActiveDisplayName(demod_i);
        
        if (searchState) {
            std::string freqStr = frequencyToStr(demod_i->getFrequency());
            std::string bwStr = frequencyToStr(demod_i->getBandwidth());
            std::string mtype = demod_i->getDemodulatorType();
            
            std::wstring fullText = activeLabel.ToStdWstring() +
            L" " + demod_i->getDemodulatorUserLabel() +
            L" " + std::to_wstring(demod_i->getFrequency()) +
            L" " + wxString(freqStr).ToStdWstring() +
            L" " + wxString(bwStr).ToStdWstring() +
            L" " + wxString(mtype).ToStdWstring();
            
            if (!isKeywordMatch(fullText, searchKeywords)) {
                continue;
            }
        }

        TreeViewItem* tvi = new TreeViewItem();
        tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE;
        tvi->demod = demod_i;

        wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel);
        SetTreeItemData(itm, tvi);
        
        if (nextDemod != nullptr && nextDemod == demod_i) {
            selItem = itm;
            wxGetApp().getDemodMgr().setActiveDemodulator(nextDemod, false);
            nextDemod = nullptr;
        } else if (!selItem && activeExpandState && lastActiveDemodulator && lastActiveDemodulator == demod_i) {
            selItem = itm;
        }
    }

    bool rangeExpandState = searchState?false:expandState["range"];
    
	//Ranges
    BookmarkRangeList bmRanges = wxGetApp().getBookmarkMgr().getRanges();

    m_treeView->DeleteChildren(rangeBranch);
    
    for (auto &re_i: bmRanges) {
        TreeViewItem* tvi = new TreeViewItem();
        tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE;
        tvi->rangeEnt = re_i;
        
        std::wstring labelVal = re_i->label;
        
        if (labelVal == L"") {
            std::string wstr = frequencyToStr(re_i->startFreq) + " - " + frequencyToStr(re_i->endFreq);

            labelVal = wxString(wstr).ToStdWstring();
        }
        
        wxTreeItemId itm = m_treeView->AppendItem(rangeBranch, labelVal);
        SetTreeItemData(itm, tvi);
        
        if (nextRange == re_i) {
            selItem = itm;
            nextRange = nullptr;
        } else if (!selItem && rangeExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE && prevSelCopy->rangeEnt == re_i) {
            selItem = itm;
        }
    }
     
    bool recentExpandState = searchState || expandState["recent"];
    
    // Recents
    BookmarkList bmRecents = wxGetApp().getBookmarkMgr().getRecents();
    
	m_treeView->DeleteChildren(recentBranch);
    
    for (auto &bmr_i: bmRecents) {
        TreeViewItem* tvi = new TreeViewItem();
        tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT;
        tvi->bookmarkEnt = bmr_i;

        std::wstring labelVal;
        bmr_i->node->child("user_label")->element()->get(labelVal);

        if (labelVal == L"") {
            std::string str = frequencyToStr(bmr_i->frequency) + " " + bmr_i->type;

            labelVal = wxString(str).ToStdWstring();
        }
        
        if (searchKeywords.size()) {
            
            std::string freqStr = frequencyToStr(bmr_i->frequency);
            std::string bwStr = frequencyToStr(bmr_i->bandwidth);
            
            std::wstring fullText = labelVal +
                L" " + std::to_wstring(bmr_i->frequency) +

                L" " + wxString(freqStr).ToStdWstring() +
                L" " + wxString(bwStr).ToStdWstring() +
                L" " + wxString(bmr_i->type).ToStdWstring();
            
            if (!isKeywordMatch(fullText, searchKeywords)) {
                continue;
            }
        }
        
        wxTreeItemId itm = m_treeView->AppendItem(recentBranch, labelVal);
        SetTreeItemData(itm, tvi);

        if (nextEnt == bmr_i) {
            selItem = itm;
            nextEnt = nullptr;
        } else if (!selItem && recentExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT && prevSelCopy->bookmarkEnt == bmr_i) {
            selItem = itm;
        }
    }
    
    if (activeExpandState) {
        m_treeView->Expand(activeBranch);
    } else {
        m_treeView->Collapse(activeBranch);
    }
    if (recentExpandState) {
        m_treeView->Expand(recentBranch);
    } else {
        m_treeView->Collapse(recentBranch);
    }
    if (rangeExpandState) {
        m_treeView->Expand(rangeBranch);
    } else {
        m_treeView->Collapse(rangeBranch);
    }

    //select the item having the same meaning as the previously selected item
    if (selItem != nullptr) {
        m_treeView->SelectItem(selItem);
    }

    // Add an extra refresh, that rebuilds the buttons from sratch.
    activeSelection(lastActiveDemodulator);

    delete prevSelCopy;
}