Exemplo n.º 1
0
HistoryModel::HistoryModel(History* history)
    : QAbstractItemModel(history)
    , m_rootItem(new HistoryItem(0))
    , m_todayItem(0)
    , m_history(history)
{
    init();

    connect(m_history, SIGNAL(resetHistory()), this, SLOT(resetHistory()));
    connect(m_history, SIGNAL(historyEntryAdded(const HistoryEntry &)), this, SLOT(historyEntryAdded(const HistoryEntry &)));
    connect(m_history, SIGNAL(historyEntryDeleted(const HistoryEntry &)), this, SLOT(historyEntryDeleted(const HistoryEntry &)));
    connect(m_history, SIGNAL(historyEntryEdited(const HistoryEntry &, const HistoryEntry &)), this, SLOT(historyEntryEdited(const HistoryEntry &, const HistoryEntry &)));
}
Exemplo n.º 2
0
bool MapManager::load( QString newFileName )
{
    if( newFileName.isEmpty() ) {
        newFileName = m_fileName;
        if( newFileName.isEmpty() ) {
            return false;
        }
    }

    QMessageBox msgBox;
    msgBox.setText("This document does not seem to be a valid UV-map.");
    msgBox.setIcon(QMessageBox::Critical);

    cv::Mat loadedMat = cv::imread( newFileName.toStdString(), CV_LOAD_IMAGE_UNCHANGED );
    if( !loadedMat.data ) {
        msgBox.setInformativeText("The document is not an image or could not be read.");
        msgBox.exec();
        return false;
    }

    if( loadedMat.depth() != CV_16U ) {
        msgBox.setInformativeText("UV-map documents should be 16 bit per color channel.");
        msgBox.exec();
        return false;
    }

    resetHistory();
    m_map = loadedMat;

    addHistoryState();
    updateTexture();

    m_fileName = newFileName;
    return true;
}
Exemplo n.º 3
0
void MapManager::addHistoryState()
{
    if( m_historyIndex < (m_history.count()-1) )
        resetHistory( m_historyIndex );

    m_history.push_back( m_map );
    m_historyIndex = m_history.count()-1;
}
Exemplo n.º 4
0
void MapManager::createFromTexture( GLuint texture )
{
    GLint width, height, glFormat;
    int depth=0, channels=0, type;

    glBindTexture(GL_TEXTURE_2D, texture);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
    glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &glFormat);

    switch(glFormat) {
    case GL_RGB8:
        depth = CV_8U;
        channels = 3;
        break;
    case GL_RGBA8:
        depth = CV_8U;
        channels = 4;
        break;
    case GL_RGB16:
        depth = CV_16U;
        channels = 3;
        break;
    case GL_RGBA16:
        depth = CV_16U;
        channels = 4;
        break;
    default:
        qDebug() << "Unsupported texture format";
        return;
        break;
    }

    type = (depth == CV_8U)?
           ((channels == 3)?CV_8UC3:CV_8UC4):
           ((channels == 3)?CV_16UC3:CV_16UC4);
    cv::Mat newMat(height, width, type);

    glGetTexImage(GL_TEXTURE_2D,0,
                  (channels == 3)?GL_BGR_EXT:GL_BGRA_EXT,
                  (depth == CV_8U)?GL_UNSIGNED_BYTE:GL_UNSIGNED_SHORT,
                  newMat.data);

    m_fileName.clear();
    resetHistory();

    setMat(newMat);
}
Exemplo n.º 5
0
	bool insertIntoTree(Edge *edge) {
		Witness *newWitness = new Witness(edge, edge);
		auto nearest = witnessInterface.nearestWithin(newWitness, radius);

		bool didAddNewEdge = false;

		if(nearest.elements.size() == 0 || nearest.distances[0] > radius) {
			witnessInterface.insertIntoTree(newWitness);
			insertionInterface.insertIntoTree(edge);
			didAddNewEdge = true;
		} else {
			Witness *witnessNode = nearest.elements[0];
			Edge *prevBest = witnessNode->edge;

			//make sure the previous best is still in the tree
			if(prevBest->getPointIndex() != 0 && edge->gCost() < prevBest->gCost()) {
				tree[prevBest->parent].erase(prevBest);
				removeSubtree(prevBest);

				witnessNode->edge = edge;
				insertionInterface.insertIntoTree(edge);
				didAddNewEdge = true;
			}
		}

		if(didAddNewEdge) {
			if(tree.find(edge->parent) == tree.end()) {
				tree[edge->parent] = std::unordered_set<Edge*>();
			}
			
			tree[edge->parent].insert(edge);
		}


		double failureRate = updateHistory(didAddNewEdge);
		
		if(historyFilled && failureRate >= resizeThreshold) {
			radius *= 0.5;
			resetHistory();
		}

		return didAddNewEdge;
	}
Exemplo n.º 6
0
bool State::load(unsigned slot) {
  if(!allowed()) return false;

  file fp;
  bool result = false;
  if(fp.open(name(slot), file::mode_read)) {
    unsigned size = fp.size();
    uint8_t *data = new uint8_t[size];
    fp.read(data, size);
    fp.close();
    serializer state(data, size);
    delete[] data;
    result = SNES::system.unserialize(state);
  }

  if(result) {
    utility.showMessage(string() << "State " << (slot + 1) << " loaded.");
    resetHistory();
  } else {
    utility.showMessage(string() << "Failed to load state " << (slot + 1) << ".");
  }
  return result;
}
Exemplo n.º 7
0
bool TrackerThread::work()
{
    if ((m_HistoryDelay + m_StartTime) < TimeSource::get()->getCurrentMillisecs() 
            && m_HistoryDelay != -1) 
    {   
        resetHistory();
        m_HistoryDelay = -1;
    }
    
    BitmapPtr pCamBmp;
    {
        ScopeTimer timer(ProfilingZoneCapture);
        pCamBmp = m_pCamera->getImage(true);
        BitmapPtr pTempBmp1;
        while ((pTempBmp1 = m_pCamera->getImage(false))) {
            m_NumCamFramesDiscarded++;
            m_NumFrames++;
            pCamBmp = pTempBmp1;
        }
    }
    long long time = TimeSource::get()->getCurrentMillisecs(); 
    if (pCamBmp) {
        m_NumFrames++;
        ScopeTimer timer(ProfilingZoneTracker);
        if (m_pCameraMaskBmp) {
            ScopeTimer timer(ProfilingZoneMask);
            FilterMask(m_pCameraMaskBmp).applyInPlace(pCamBmp);
        }
        if (m_bCreateDebugImages) {
            boost::mutex::scoped_lock lock(*m_pMutex);
            *(m_pBitmaps[TRACKER_IMG_CAMERA]) = *pCamBmp;
            ScopeTimer timer(ProfilingZoneHistogram);
            drawHistogram(m_pBitmaps[TRACKER_IMG_HISTOGRAM], pCamBmp);
        }
        {
            if (m_Prescale != 1) {
                ScopeTimer timer(ProfilingZoneDownscale);
                FilterFastDownscale(m_Prescale).applyInPlace(pCamBmp);
            }
        }
        BitmapPtr pDistortedBmp;
        {
            ScopeTimer timer(ProfilingZoneDistort);
            pDistortedBmp = m_pDistorter->apply(pCamBmp);
        }
        BitmapPtr pCroppedBmp(new Bitmap(*pDistortedBmp, m_ROI));
        if (m_bCreateDebugImages) {
            boost::mutex::scoped_lock lock(*m_pMutex);
            m_pBitmaps[TRACKER_IMG_DISTORTED]->copyPixels(*pCroppedBmp);
        }
        if (m_pHistoryPreProcessor) {
            ScopeTimer timer(ProfilingZoneHistory);
            m_pHistoryPreProcessor->applyInPlace(pCroppedBmp);
        }
        if (m_bCreateDebugImages) {
            boost::mutex::scoped_lock lock(*m_pMutex);
            m_pBitmaps[TRACKER_IMG_NOHISTORY]->copyPixels(*pCroppedBmp);
            FilterNormalize(2).applyInPlace(m_pBitmaps[TRACKER_IMG_NOHISTORY]);
        }
        {
            BitmapPtr pBmpBandpass;
            if (m_TouchThreshold != 0) {
                {
                    ScopeTimer timer(ProfilingZoneBandpass);
                    pBmpBandpass = m_pBandpassFilter->apply(pCroppedBmp);
                }
                if (m_bCreateDebugImages) {
                    boost::mutex::scoped_lock lock(*m_pMutex);
                    *(m_pBitmaps[TRACKER_IMG_HIGHPASS]) = *pBmpBandpass;
                }
            }
            calcBlobs(pCroppedBmp, pBmpBandpass, time);
        }
        ThreadProfiler::get()->reset();
    }
    return true;
}
Exemplo n.º 8
0
void CMyPaintDoc::init() {
  resetHistory();
  SetTitle(s_defaultName);
  CHECKINVARIANT;
}
Exemplo n.º 9
0
void CMyPaintDoc::clear() {
  resetHistory();
  setImage(NULL);
  setFileImage();
}