JNIEXPORT jobject JNICALL Java_org_ronhuang_vistroller_Vistroller_getMarker(JNIEnv *env, jobject) { //LOG("Java_org_ronhuang_vistroller_Vistroller_getMarker"); jobject result = NULL; QCAR::State state = QCAR::Renderer::getInstance().begin(); for (int i = 0; i < state.getNumActiveTrackables(); i++) { const QCAR::Trackable *trackable = state.getActiveTrackable(i); assert(trackable->getType() == QCAR::Trackable::MARKER); const QCAR::Marker *marker = static_cast<const QCAR::Marker*>(trackable); result = newMarker(env, marker->getMarkerId(), marker->getPose().data, marker->getSize().data); break; // FIXME: return only the first one for now. } if (NULL == result) { // Make sure always return an instance of Trackable. // Return invalid one. float pose[3 * 4] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; float size[2] = {0, 0}; result = newMarker(env, -1, pose, size); } QCAR::Renderer::getInstance().end(); return result; }
// Convert to XMarkerList ml::XMarkerList ColoredMarkerList::toXMarkerList() { ml::XMarkerList result; for(ml::ColoredMarkerList::iterator thisElement = this->begin(); thisElement != this->end(); ++thisElement) { ml::XMarker newMarker(Vector6(thisElement->x(),thisElement->y(),thisElement->z(),thisElement->c(),thisElement->t(),thisElement->u()), (int)thisElement->type); newMarker.setName(thisElement->name()); result.push_back(newMarker); } return result; }
// Convert from XMarkerList void ColoredMarkerList::fromXMarkerList(ml::XMarkerList importList, Vector4 rgbaColor) { this->clear(); for(ml::XMarkerList::iterator thisXMarker = importList.begin(); thisXMarker != importList.end(); ++thisXMarker) { ml::ColoredMarker newMarker(Vector3(thisXMarker->x(),thisXMarker->y(),thisXMarker->z()), thisXMarker->type); newMarker.c() = thisXMarker->c(); newMarker.t() = thisXMarker->t(); newMarker.u() = thisXMarker->u(); newMarker.rgba() = rgbaColor; newMarker.setName(thisXMarker->name()); this->push_back(newMarker); } }
void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { if (fCmdBuffer.empty()) { return; } GrGpu* gpu = iodb->getGpu(); // Loop over all batches and generate geometry CmdBuffer::Iter genIter(fCmdBuffer); while (genIter.next()) { if (Cmd::kDrawBatch_CmdType == genIter->type()) { DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get()); fBatchTarget.resetNumberOfDraws(); db->fBatch->generateGeometry(&fBatchTarget, db->fState->getPipeline()); db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); } } fBatchTarget.preFlush(); CmdBuffer::Iter iter(fCmdBuffer); while (iter.next()) { GrGpuTraceMarker newMarker("", -1); SkString traceString; if (iter->isTraced()) { traceString = iodb->getCmdString(iter->markerID()); newMarker.fMarker = traceString.c_str(); gpu->addGpuTraceMarker(&newMarker); } iter->execute(gpu); if (iter->isTraced()) { gpu->removeGpuTraceMarker(&newMarker); } } fBatchTarget.postFlush(); }
void KCColumnHeader::mousePressEvent(QMouseEvent * _ev) { if (!m_cellToolIsActive) return; if (!m_pView->koDocument()->isReadWrite()) return; if (_ev->button() == Qt::LeftButton) { m_bMousePressed = true; m_pView->enableAutoScroll(); } const register KCSheet * const sheet = m_pView->activeSheet(); if (!sheet) return; // We were editing a cell -> save value and get out of editing mode m_pView->selection()->emitCloseEditor(true); // save changes double ev_PosX; double dWidth = m_pView->zoomHandler()->unzoomItX(width()); if (sheet->layoutDirection() == Qt::RightToLeft) ev_PosX = dWidth - m_pView->zoomHandler()->unzoomItX(_ev->pos().x()) + m_pCanvas->xOffset(); else ev_PosX = m_pView->zoomHandler()->unzoomItX(_ev->pos().x()) + m_pCanvas->xOffset(); m_bResize = false; m_bSelection = false; // Find the first visible column and the x position of this column. double x; const double unzoomedPixel = m_pView->zoomHandler()->unzoomItX(1.0); if (sheet->layoutDirection() == Qt::RightToLeft) { int tmpCol = sheet->leftColumn(m_pCanvas->xOffset(), x); kDebug() << "evPos:" << ev_PosX << ", x:" << x << ", COL:" << tmpCol; while (ev_PosX > x && (!m_bResize) && tmpCol <= KS_colMax) { double w = sheet->columnFormat(tmpCol)->width(); kDebug() << "evPos:" << ev_PosX << ", x:" << x << ", w:" << w << ", COL:" << tmpCol; ++tmpCol; if (tmpCol > KS_colMax) tmpCol = KS_colMax; //if col is hide and it's the first column //you mustn't resize it. if (ev_PosX >= x + w - unzoomedPixel && ev_PosX <= x + w + unzoomedPixel && !(sheet->columnFormat(tmpCol)->isHiddenOrFiltered() && tmpCol == 1)) { m_bResize = true; } x += w; } //if col is hide and it's the first column //you mustn't resize it. double tmp2; tmpCol = sheet->leftColumn(dWidth - ev_PosX + 1, tmp2); if (sheet->columnFormat(tmpCol)->isHiddenOrFiltered() && tmpCol == 0) { kDebug() << "No resize:" << tmpCol << "," << sheet->columnFormat(tmpCol)->isHiddenOrFiltered(); m_bResize = false; } kDebug() << "Resize:" << m_bResize; } else { int col = sheet->leftColumn(m_pCanvas->xOffset(), x); // Did the user click between two columns? while (x < (dWidth + m_pCanvas->xOffset()) && (!m_bResize) && col <= KS_colMax) { double w = sheet->columnFormat(col)->width(); col++; if (col > KS_colMax) col = KS_colMax; if ((ev_PosX >= x + w - unzoomedPixel) && (ev_PosX <= x + w + unzoomedPixel) && !(sheet->columnFormat(col)->isHiddenOrFiltered() && col == 1)) m_bResize = true; x += w; } //if col is hide and it's the first column //you mustn't resize it. double tmp2; int tmpCol = sheet->leftColumn(ev_PosX - 1, tmp2); if (sheet->columnFormat(tmpCol)->isHiddenOrFiltered() && tmpCol == 1) m_bResize = false; } // So he clicked between two rows ? if (m_bResize) { // Determine the column to resize double tmp; if (sheet->layoutDirection() == Qt::RightToLeft) { m_iResizedColumn = sheet->leftColumn(ev_PosX - 1, tmp); // kDebug() <<"RColumn:" << m_iResizedColumn <<", PosX:" << ev_PosX; if (!sheet->isProtected()) paintSizeIndicator(_ev->pos().x()); } else { m_iResizedColumn = sheet->leftColumn(ev_PosX - 1, tmp); if (!sheet->isProtected()) paintSizeIndicator(_ev->pos().x()); } // kDebug() <<"Column:" << m_iResizedColumn; } else { if (_ev->button() != Qt::RightButton) { m_bSelection = true; } double tmp; int hit_col = sheet->leftColumn(ev_PosX, tmp); if (hit_col > KS_colMax) return; m_iSelectionAnchor = hit_col; if (!m_pView->selection()->contains(QPoint(hit_col, 1)) || !(_ev->button() == Qt::RightButton) || !m_pView->selection()->isColumnSelected()) { QPoint newMarker(hit_col, 1); QPoint newAnchor(hit_col, KS_rowMax); if (_ev->modifiers() == Qt::ControlModifier) { m_pView->selection()->extend(QRect(newAnchor, newMarker)); } else if (_ev->modifiers() == Qt::ShiftModifier) { m_pView->selection()->update(newMarker); } else { m_pView->selection()->initialize(QRect(newAnchor, newMarker)); } } if (_ev->button() == Qt::RightButton) { QApplication::sendEvent(m_pCanvas, _ev); } } }
void KCRowHeader::mousePressEvent(QMouseEvent * _ev) { if (!m_cellToolIsActive) return; if (!m_pView->koDocument()->isReadWrite()) return; register KCSheet * const sheet = m_pView->activeSheet(); if (!sheet) return; if (_ev->button() == Qt::LeftButton) { m_bMousePressed = true; m_pView->enableAutoScroll(); } double ev_PosY = m_pView->zoomHandler()->unzoomItY(_ev->pos().y()) + m_pCanvas->yOffset(); double dHeight = m_pView->zoomHandler()->unzoomItY(height()); m_bResize = false; m_bSelection = false; // We were editing a cell -> save value and get out of editing mode m_pView->selection()->emitCloseEditor(true); // save changes // Find the first visible row and the y position of this row. double y; int row = sheet->topRow(m_pCanvas->yOffset(), y); // Did the user click between two rows? while (y < (dHeight + m_pCanvas->yOffset()) && (!m_bResize) && row <= KS_rowMax) { double h = sheet->rowFormat(row)->height(); row++; if (row > KS_rowMax) row = KS_rowMax; if ((ev_PosY >= y + h - 2) && (ev_PosY <= y + h + 1) && !(sheet->rowFormat(row)->isHiddenOrFiltered() && row == 1)) m_bResize = true; y += h; } //if row is hide and it's the first row //you mustn't resize it. double tmp2; int tmpRow = sheet->topRow(ev_PosY - 1, tmp2); if (sheet->rowFormat(tmpRow)->isHiddenOrFiltered() && tmpRow == 1) m_bResize = false; // So he clicked between two rows ? if (m_bResize) { // Determine row to resize double tmp; m_iResizedRow = sheet->topRow(ev_PosY - 1, tmp); if (!sheet->isProtected()) paintSizeIndicator(_ev->pos().y()); } else { if (_ev->button() != Qt::RightButton) { m_bSelection = true; } double tmp; int hit_row = sheet->topRow(ev_PosY, tmp); if (hit_row > KS_rowMax) return; m_iSelectionAnchor = hit_row; if (!m_pView->selection()->contains(QPoint(1, hit_row)) || !(_ev->button() == Qt::RightButton) || !m_pView->selection()->isRowSelected()) { QPoint newMarker(1, hit_row); QPoint newAnchor(KS_colMax, hit_row); if (_ev->modifiers() == Qt::ControlModifier) { m_pView->selection()->extend(QRect(newAnchor, newMarker)); } else if (_ev->modifiers() == Qt::ShiftModifier) { m_pView->selection()->update(newMarker); } else { m_pView->selection()->initialize(QRect(newAnchor, newMarker)); } } if (_ev->button() == Qt::RightButton) { QApplication::sendEvent(m_pCanvas, _ev); } } }
void Plot::markerMenuSelected (QAction *a) { newMarker(a->data().toString()); }
int RSI::run (PluginData *pd) { if (! g_symbol) return 0; QVariant *input = pd->settings->get(QString("input")); if (! input) return 0; QVariant *period = pd->settings->get(QString("period")); if (! period) return 0; QVariant *label = pd->settings->get(QString("label")); if (! label) return 0; if (! getRSI(input->toString(), period->toInt(), label->toString())) return 0; // rsi QVariant *show = pd->settings->get(QString("rsiShow")); if (! show) return 0; if (show->toBool()) { QVariant *style = pd->settings->get(QString("style")); if (! style) return 0; QVariant *width = pd->settings->get(QString("width")); if (! width) return 0; QVariant *var = pd->settings->get(QString("color")); if (! var) return 0; QColor color(var->toString()); CurveLineType clt; Curve *rsi = new Curve(QString("CurveLine")); rsi->setColor(color); rsi->setLabel(label->toString()); rsi->setStyle(clt.stringToIndex(style->toString())); rsi->fill(label->toString(), QString(), QString(), QString(), color); rsi->setPen(width->toInt()); pd->curves << rsi; } // ma show = pd->settings->get(QString("maShow")); if (! show) return 0; if (show->toBool()) { Curve *ma = getMA(pd->settings); if (ma) pd->curves << ma; } // buy marker show = pd->settings->get(QString("buyMarkerShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("buyMarkerColor")); if (! var) return 0; QColor color(var->toString()); QVariant *price = pd->settings->get(QString("buyMarkerPrice")); if (! price) return 0; Marker *m = newMarker(color, price->toDouble()); if (! m) return 0; pd->markers << m; } // sell marker show = pd->settings->get(QString("sellMarkerShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("sellMarkerColor")); if (! var) return 0; QColor color(var->toString()); QVariant *price = pd->settings->get(QString("sellMarkerPrice")); if (! price) return 0; Marker *m = newMarker(color, price->toDouble()); if (! m) return 0; pd->markers << m; } return 1; }
void GrInOrderDrawBuffer::flush() { if (fFlushing) { return; } SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc); SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc); int numCmds = fCmds.count(); if (0 == numCmds) { return; } GrAutoTRestore<bool> flushRestore(&fFlushing); fFlushing = true; fVertexPool.unmap(); fIndexPool.unmap(); GrDrawTarget::AutoClipRestore acr(fDstGpu); AutoGeometryAndStatePush agasp(fDstGpu, kPreserve_ASRInit); GrDrawState playbackState; GrDrawState* prevDrawState = fDstGpu->drawState(); prevDrawState->ref(); fDstGpu->setDrawState(&playbackState); GrClipData clipData; int currState = 0; int currClip = 0; int currClear = 0; int currDraw = 0; int currStencilPath = 0; int currDrawPath = 0; int currDrawPaths = 0; int currCopySurface = 0; int currCmdMarker = 0; for (int c = 0; c < numCmds; ++c) { GrGpuTraceMarker newMarker("", -1); if (cmd_has_trace_marker(fCmds[c])) { SkString traceString = fGpuCmdMarkers[currCmdMarker].toString(); newMarker.fMarker = traceString.c_str(); fDstGpu->addGpuTraceMarker(&newMarker); ++currCmdMarker; } switch (strip_trace_bit(fCmds[c])) { case kDraw_Cmd: { const DrawRecord& draw = fDraws[currDraw]; fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer); if (draw.isIndexed()) { fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer); } fDstGpu->executeDraw(draw); ++currDraw; break; } case kStencilPath_Cmd: { const StencilPath& sp = fStencilPaths[currStencilPath]; fDstGpu->stencilPath(sp.fPath.get(), sp.fFill); ++currStencilPath; break; } case kDrawPath_Cmd: { const DrawPath& cp = fDrawPath[currDrawPath]; fDstGpu->executeDrawPath(cp.fPath.get(), cp.fFill, NULL != cp.fDstCopy.texture() ? &cp.fDstCopy : NULL); ++currDrawPath; break; } case kDrawPaths_Cmd: { DrawPaths& dp = fDrawPaths[currDrawPaths]; const GrDeviceCoordTexture* dstCopy = NULL != dp.fDstCopy.texture() ? &dp.fDstCopy : NULL; fDstGpu->executeDrawPaths(dp.fPathCount, dp.fPaths, dp.fTransforms, dp.fFill, dp.fStroke, dstCopy); ++currDrawPaths; break; } case kSetState_Cmd: fStates[currState].restoreTo(&playbackState); ++currState; break; case kSetClip_Cmd: clipData.fClipStack = &fClips[currClip]; clipData.fOrigin = fClipOrigins[currClip]; fDstGpu->setClip(&clipData); ++currClip; break; case kClear_Cmd: if (GrColor_ILLEGAL == fClears[currClear].fColor) { fDstGpu->discard(fClears[currClear].fRenderTarget); } else { fDstGpu->clear(&fClears[currClear].fRect, fClears[currClear].fColor, fClears[currClear].fCanIgnoreRect, fClears[currClear].fRenderTarget); } ++currClear; break; case kCopySurface_Cmd: fDstGpu->copySurface(fCopySurfaces[currCopySurface].fDst.get(), fCopySurfaces[currCopySurface].fSrc.get(), fCopySurfaces[currCopySurface].fSrcRect, fCopySurfaces[currCopySurface].fDstPoint); ++currCopySurface; break; } if (cmd_has_trace_marker(fCmds[c])) { fDstGpu->removeGpuTraceMarker(&newMarker); } } // we should have consumed all the states, clips, etc. SkASSERT(fStates.count() == currState); SkASSERT(fClips.count() == currClip); SkASSERT(fClipOrigins.count() == currClip); SkASSERT(fClears.count() == currClear); SkASSERT(fDraws.count() == currDraw); SkASSERT(fCopySurfaces.count() == currCopySurface); SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); fDstGpu->setDrawState(prevDrawState); prevDrawState->unref(); this->reset(); ++fDrawID; }
void GrInOrderDrawBuffer::flush() { if (fFlushing) { return; } this->getContext()->getFontCache()->updateTextures(); SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc); SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc); if (fCmdBuffer.empty()) { return; } GrAutoTRestore<bool> flushRestore(&fFlushing); fFlushing = true; fVertexPool.unmap(); fIndexPool.unmap(); GrDrawTarget::AutoClipRestore acr(fDstGpu); AutoGeometryAndStatePush agasp(fDstGpu, kPreserve_ASRInit); GrDrawState* prevDrawState = SkRef(fDstGpu->drawState()); CmdBuffer::Iter iter(fCmdBuffer); int currCmdMarker = 0; fDstGpu->saveActiveTraceMarkers(); while (iter.next()) { GrGpuTraceMarker newMarker("", -1); SkString traceString; if (cmd_has_trace_marker(iter->fType)) { traceString = fGpuCmdMarkers[currCmdMarker].toString(); newMarker.fMarker = traceString.c_str(); fDstGpu->addGpuTraceMarker(&newMarker); ++currCmdMarker; } SkDEBUGCODE(bool isDraw = kDraw_Cmd == strip_trace_bit(iter->fType) || kStencilPath_Cmd == strip_trace_bit(iter->fType) || kDrawPath_Cmd == strip_trace_bit(iter->fType) || kDrawPaths_Cmd == strip_trace_bit(iter->fType)); SkASSERT(!isDraw || fDstGpu->drawState() != prevDrawState); iter->execute(fDstGpu); if (cmd_has_trace_marker(iter->fType)) { fDstGpu->removeGpuTraceMarker(&newMarker); } } fDstGpu->restoreActiveTraceMarkers(); SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); fDstGpu->setDrawState(prevDrawState); prevDrawState->unref(); this->reset(); ++fDrawID; }