Beispiel #1
0
void HelpIndexView::linksActivated(const QMap<QString,QUrl>& links, const QString& keyword)
{
  HelpTopicChooser tc(m_IndexWidget, keyword, links);
  if (tc.exec() == QDialog::Accepted)
  {
    IWorkbenchPage::Pointer page = this->GetSite()->GetPage();
    HelpPluginActivator::linkActivated(page, tc.link());
  }
}
std::vector<UnwrappedTileID> tileCover(const Geometry<double>& geometry, int32_t z) {
    std::vector<UnwrappedTileID> result;
    TileCover tc(geometry, z, true);
    while (tc.hasNext()) {
        result.push_back(*tc.next());
    };

    return result;
}
Beispiel #3
0
DistQuery::TransactionContextPtr
DistQuery::allocTransaction(TransactionContext::Type t)
{
    TransactionContextPtr tc(new TransactionContext(*this));
    tc->m_type = t;
    tc->m_tid = m_tid++;
    tc->m_stopWatch.start();
    return tc;
}
Beispiel #4
0
void
QvisText2DInterface::textOpacityChanged(int opacity)
{
    ColorAttribute tc(annot->GetTextColor());
    tc.SetAlpha(opacity);
    annot->SetTextColor(tc);
    SetUpdate(false);
    Apply();
}
void
QvisLine3DInterface::opacityChanged(int opacity)
{
    ColorAttribute tc(annot->GetColor1());
    tc.SetAlpha(opacity);
    annot->SetColor1(tc);
    SetUpdate(false);
    Apply();
}
uint64_t tileCount(const Geometry<double>& geometry, uint8_t z) {
    uint64_t tileCount = 0;

    TileCover tc(geometry, z, true);
    while (tc.next()) {
        tileCount++;
    };
    return tileCount;
}
Beispiel #7
0
void Foam::combustionModels::PaSR<Type>::correct()
{
    if (this->active())
    {
        const scalar t = this->mesh().time().value();
        const scalar dt = this->mesh().time().deltaTValue();

        if (!useReactionRate_)
        {
            this->chemistryPtr_->solve(t - dt, dt);
        }
        else
        {
            this->chemistryPtr_->calculate();
        }

        if (turbulentReaction_)
        {
            tmp<volScalarField> trho(this->rho());
            const volScalarField& rho = trho();
            tmp<volScalarField> tepsilon(this->turbulence().epsilon());
            const volScalarField& epsilon = tepsilon();
            tmp<volScalarField> tmuEff(this->turbulence().muEff());
            const volScalarField& muEff = tmuEff();

            tmp<volScalarField> ttc(tc());
            const volScalarField& tc = ttc();

            forAll(epsilon, i)
            {
                if (epsilon[i] > 0)
                {
                    scalar tk =
                        Cmix_*Foam::sqrt(muEff[i]/rho[i]/(epsilon[i] + SMALL));

                    // Chalmers PaSR model
                    if (!useReactionRate_)
                    {
                        kappa_[i] = (dt + tc[i])/(dt + tc[i] + tk);
                    }
                    else
                    {
                        kappa_[i] = tc[i]/(tc[i] + tk);
                    }
                }
                else
                {
                    // Return to laminar combustion
                    kappa_[i] = 1.0;
                }
            }
        }
        else
        {
            kappa_ = 1.0;
        }
    }
Beispiel #8
0
bool LabelDialog::TransferDataToWindow()
{
   int cnt = mData.size();
   int i;

   // Set the editor parameters.  Do this each time since they may change
   // due to NEW tracks and change in NumericTextCtrl format.  Rate won't
   // change but might as well leave it here.
   mChoiceEditor->SetChoices(mTrackNames);
   mTimeEditor->SetFormat(mFormat);
   mTimeEditor->SetRate(mRate);

   // Disable redrawing until we're done
   mGrid->BeginBatch();

   // Delete all rows
   if (mGrid->GetNumberRows()) {
      mGrid->DeleteRows(0, mGrid->GetNumberRows());
   }

   // Add the exact number that we'll need
   mGrid->InsertRows(0, cnt);

   // Populate the rows
   for (i = 0; i < cnt; i++) {
      RowData &rd = mData[i];

      // Set the cell contents
      mGrid->SetCellValue(i, Col_Track, TrackName(rd.index));
      mGrid->SetCellValue(i, Col_Label, rd.title);
      mGrid->SetCellValue(i, Col_Stime,
         wxString::Format(wxT("%g"), rd.selectedRegion.t0()));
      mGrid->SetCellValue(i, Col_Etime,
         wxString::Format(wxT("%g"), rd.selectedRegion.t1()));

      // PRL: to do: -- populate future additional selection fields
      // and write event code to update them from controls
   }

   // Autosize all the rows
   mGrid->AutoSizeRows(true);

   // Resize the track name column.  Use a wxChoice to determine the maximum
   // width needed.
   wxChoice tc(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, mTrackNames);
   mGrid->SetColSize(Col_Track, tc.GetSize().x);
   mGrid->SetColMinimalWidth(Col_Track, tc.GetSize().x);

   // Autosize the time columns and set their minimal widths
   mGrid->AutoSizeColumn(Col_Stime);
   mGrid->AutoSizeColumn(Col_Etime);

   // We're done, so allow the grid to redraw
   mGrid->EndBatch();

   return true;
}
Beispiel #9
0
bool PlayerServer::judgeResult(JudgeType type, std::unique_ptr<Card> &card)
{
	unique_ptr<Card> tc(new Card(*card));
	TRIEV(t_JudgeResult, &tc);
	bool b = Player::judgeResult(type, tc);
	TRIEV(t_JudgeResultEnd, &card);
	GAME->addToDeadwood(card);
	return b;
}
void SanitiseTool::parseSpacers(xercesc::DOMElement * parentNode, 
                                crispr::xml::writer& xmlParser)
{
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {

        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Spacer())) {
            char * c_spid = tc(currentElement->getAttribute(xmlParser.attr_Spid()));
            std::string spid = c_spid;
            ST_SpacerMap[spid] = getNextSpacerS();
            xr(&c_spid);
            XMLCh * x_next_spacer_num = tc(getNextSpacerS().c_str());
            currentElement->setAttribute(xmlParser.attr_Spid(), x_next_spacer_num);
            xr(&x_next_spacer_num);
            incrementSpacer();
        }
    }
}
bool KeywordsCompletionAssistProcessor::isInComment() const
{
    QTextCursor tc(m_interface->textDocument());
    tc.setPosition(m_interface->position());
    tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
    const QString &lineBeginning = tc.selectedText();
    if (lineBeginning.contains(startOfCommentChar()))
        return true;
    return false;
}
Beispiel #12
0
void NameCompiler::visitTemplateArgument(TemplateArgumentAST *node)
{
    TypeCompiler tc(m_session);
    tc.run(node->type_id->type_specifier);
    if (tc.isIntegral())
        m_templateArgs << tc.qualifiedName().join(" ");
    else
        m_templateArgs << tc.qualifiedName().join("::");
//   m_currentIdentifier.appendTemplateIdentifier( typeIdentifierFromTemplateArgument(m_session, node) );
}
Beispiel #13
0
vguard<set<Ontology::TermIndex> > Ontology::transitiveClosure() const {
  vguard<set<TermIndex> > tc (terms());
  auto L = toposortTermIndex();
  for (TermIndex n : L) {
    tc[n].insert (n);
    for (TermIndex p : parents[n])
      tc[n].insert (tc[p].begin(), tc[p].end());
  }
  return tc;
}
bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
{
    if (obj == m_searchLineEdit && e->type() == QEvent::KeyPress) {
        QKeyEvent *ke = static_cast<QKeyEvent*>(e);
        QModelIndex idx = m_indexWidget->currentIndex();
        switch (ke->key()) {
        case Qt::Key_Up:
            idx = m_indexWidget->model()->index(idx.row()-1,
                idx.column(), idx.parent());
            if (idx.isValid())
                m_indexWidget->setCurrentIndex(idx);
            break;
        case Qt::Key_Down:
            idx = m_indexWidget->model()->index(idx.row()+1,
                idx.column(), idx.parent());
            if (idx.isValid())
                m_indexWidget->setCurrentIndex(idx);
            break;
        case Qt::Key_Escape:
            MainWindow::activateCurrentCentralWidgetTab();
            break;
        default:
            ;
        }
    } else if (obj == m_indexWidget && e->type() == QEvent::ContextMenu) {
        QContextMenuEvent *ctxtEvent = static_cast<QContextMenuEvent*>(e);
        QModelIndex idx = m_indexWidget->indexAt(ctxtEvent->pos());
        if (idx.isValid()) {
            QMenu menu;
            QAction *curTab = menu.addAction(tr("Open Link"));
            QAction *newTab = menu.addAction(tr("Open Link in New Tab"));
            menu.move(m_indexWidget->mapToGlobal(ctxtEvent->pos()));

            QAction *action = menu.exec();
            if (curTab == action)
                m_indexWidget->activateCurrentItem();
            else if (newTab == action) {
                QHelpIndexModel *model = qobject_cast<QHelpIndexModel*>(m_indexWidget->model());
                QString keyword = model->data(idx, Qt::DisplayRole).toString();
                if (model) {
                    QMap<QString, QUrl> links = model->linksForKeyword(keyword);
                    if (links.count() == 1) {
                        CentralWidget::instance()->setSourceInNewTab(links.constBegin().value());
                    } else {
                        TopicChooser tc(this, keyword, links);
                        if (tc.exec() == QDialog::Accepted) {
                            CentralWidget::instance()->setSourceInNewTab(tc.link());
                        }
                    }
                }
            }
        }
    }
    return QWidget::eventFilter(obj, e);
}
TabId
ContentProcessManager::AllocateTabId(const TabId& aOpenerTabId,
                                     const IPCTabContext& aContext,
                                     const ContentParentId& aChildCpId)
{
  MOZ_ASSERT(NS_IsMainThread());

  auto iter = mContentParentMap.find(aChildCpId);
  if (NS_WARN_IF(iter == mContentParentMap.end())) {
    ASSERT_UNLESS_FUZZING();
    return TabId(0);
  }

  struct RemoteFrameInfo info;

  const IPCTabContextUnion& contextUnion = aContext.contextUnion();
  // If it's a PopupIPCTabContext, it's the case that a TabChild want to
  // open a new tab. aOpenerTabId has to be it's parent frame's opener id.
  if (contextUnion.type() == IPCTabContextUnion::TPopupIPCTabContext) {
    auto remoteFrameIter = iter->second.mRemoteFrames.find(aOpenerTabId);
    if (remoteFrameIter == iter->second.mRemoteFrames.end()) {
      ASSERT_UNLESS_FUZZING("Failed to find parent frame's opener id.");
      return TabId(0);
    }

    info.mOpenerTabId = remoteFrameIter->second.mOpenerTabId;

    const PopupIPCTabContext &ipcContext = contextUnion.get_PopupIPCTabContext();
    MOZ_ASSERT(ipcContext.opener().type() == PBrowserOrId::TTabId);

    remoteFrameIter = iter->second.mRemoteFrames.find(ipcContext.opener().get_TabId());
    if (remoteFrameIter == iter->second.mRemoteFrames.end()) {
      ASSERT_UNLESS_FUZZING("Failed to find tab id.");
      return TabId(0);
    }

    info.mContext = remoteFrameIter->second.mContext;
  }
  else {
    MaybeInvalidTabContext tc(aContext);
    if (!tc.IsValid()) {
      NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
                               "the child process. (%s)",
                               tc.GetInvalidReason()).get());
      return TabId(0);
    }
    info.mOpenerTabId = aOpenerTabId;
    info.mContext = tc.GetTabContext();
  }

  mUniqueId = ++gTabId;
  iter->second.mRemoteFrames[mUniqueId] = info;

  return mUniqueId;
}
Beispiel #16
0
void DivRep::computeExactFlags() {
  if (!first->flagsComputed())
    first->computeExactFlags();
  if (!second->flagsComputed())
    second->computeExactFlags();

  if (!second->sign())
    core_error("zero divisor.", __FILE__, __LINE__, true);

  if (!first->sign()) {// value must be exactly zero.
    reduceToZero();
    return;
  }

  // rational node
  if (rationalReduceFlag) {
    if (first->ratFlag() > 0 && second->ratFlag() > 0) {
      BigRat val = (*(first->ratValue()))/(*(second->ratValue()));
      reduceToBigRat(val);
      ratFlag() = first->ratFlag() + second->ratFlag();
      return;
    } else
      ratFlag() = -1;
  }

  // value is irrational.
  uMSB() = first->uMSB() - second->lMSB();
  lMSB() = first->lMSB() - second->uMSB() - EXTLONG_ONE;
  sign() = first->sign() * second->sign();

  extLong df = first->d_e();
  extLong ds = second->d_e();
  // extLong lf = first->length();
  // extLong ls = second->length();

  // length() = df * ls + ds * lf;
  measure() = (first->measure())*ds + (second->measure())*df;

  // BFMSS[2,5] bound.
  v2p() = first->v2p() + second->v2m();
  v2m() = first->v2m() + second->v2p();
  v5p() = first->v5p() + second->v5m();
  v5m() = first->v5m() + second->v5p();
  u25() = first->u25() + second->l25();
  l25() = first->l25() + second->u25();

  high() = first->high() + second->low();
  low() = first->low() + second->high();

  lc() = ds * first->lc() + df * second->tc();
  tc() = core_min(ds * first->tc() + df * second->lc(), measure());

  flagsComputed() = true;
}
void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e)
{
    QTextEdit::keyReleaseEvent(e);

    if(mMaximumLength && toPlainText().length()>mMaximumLength){
        setPlainText(toPlainText().left(mMaximumLength));
        QTextCursor tc(document());
        tc.setPosition(mMaximumLength);
        setTextCursor(tc);
    }
}
Beispiel #18
0
void TypeCompiler::visitParameterDeclaration(ParameterDeclarationAST* node)
{
    TypeCompiler tc(m_session, m_visitor);
    tc.run(node->type_specifier, node->declarator);
    NameCompiler name_cc(m_session, m_visitor);
    if (tc.type().isFunctionPointer() && node->declarator && node->declarator->sub_declarator)
        name_cc.run(node->declarator->sub_declarator->id);
    else if (node->declarator)
        name_cc.run(node->declarator->id);
    m_realType.appendParameter(Parameter(name_cc.name(), Type::registerType(tc.type())));
}
Beispiel #19
0
void Bomb::DoDraw() const {
  if (!IsAlive())
    return;

  const double tile_width_in_px = 16.0;
  const double tile_height_in_px = 16.0;
  TexCoords tc((470.0+tile_width_in_px*m_anim_frame_num), 16.0, tile_width_in_px, tile_height_in_px);
  Engine::Get().Renderer()->DrawSprite(tc, GetPosition());
  if (g_render_aabbs)
    Engine::Get().Renderer()->DrawAABB(GetAABB());
}
Beispiel #20
0
void DrawTool::parseGroup(xercesc::DOMElement * parentNode, crispr::xml::parser& xmlParser)
{

    
    // create a new graph object
    char * c_gid = tc(parentNode->getAttribute(xmlParser.attr_Gid()));
    crispr::graph * current_graph = new crispr::graph(c_gid);
    xr(&c_gid);
    // change the max and min coverages back to their original values
    resetInitialLimits();
    
    DT_Graphs.push_back(current_graph);
    for (xercesc::DOMElement * currentElement = parentNode->getFirstElementChild(); 
         currentElement != NULL; 
         currentElement = currentElement->getNextElementSibling()) {
        
        if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Data())) {
            parseData(currentElement, xmlParser, current_graph);
            setColours();
        } else if (xercesc::XMLString::equals(currentElement->getTagName(), xmlParser.tag_Assembly())) {
            parseAssembly(currentElement, xmlParser, current_graph);
        }
        
    }
    
    char * c_file_prefix = tc(parentNode->getAttribute(xmlParser.attr_Gid()));
    std::string file_prefix = c_file_prefix;
    std::string file_name = file_prefix + "." + DT_OutputFormat;
    xr(&c_file_prefix);
    char * file_name_c = strdup(file_name.c_str());

    layoutGraph(current_graph->getGraph(), DT_RenderingAlgorithm);
    renderGraphToFile(current_graph->getGraph(), DT_OutputFormat, file_name_c);
    freeLayout(current_graph->getGraph());
    // free the duplicated string
    try {
        delete file_name_c;
    } catch (std::exception& e) {
        std::cerr<<e.what()<<std::endl;
    }
}
Beispiel #21
0
void KisMacroTest::testCreation()
{
    QList<KisRecordedAction*> actions;
    TestAction tc("bla", "bla", KisNodeQueryPath::fromString("/"));
    actions << &tc;

    const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
    KisImageSP image = new KisImage(0, 512, 512, cs, "test");

    KisMacro a();
    KisMacro b(actions);
}
int3 whereToExplore(HeroPtr h)
{
	//TODO it's stupid and ineffective, write sth better
	cb->setSelection(*h);
	int radius = h->getSightRadious();
	int3 hpos = h->visitablePos();

	//look for nearby objs -> visit them if they're close enouh
	const int DIST_LIMIT = 3;
	std::vector<const CGObjectInstance *> nearbyVisitableObjs;
	for(const CGObjectInstance *obj : ai->getPossibleDestinations(h))
	{
		int3 op = obj->visitablePos();
		CGPath p;
		cb->getPath2(op, p);
		if(p.nodes.size() && p.endPos() == op && p.nodes.size() <= DIST_LIMIT)
			nearbyVisitableObjs.push_back(obj);
	}
	boost::sort(nearbyVisitableObjs, isCloser);
	if(nearbyVisitableObjs.size())
		return nearbyVisitableObjs.back()->visitablePos();

	try
	{
		return ai->explorationBestNeighbour(hpos, radius, h);
	}
	catch(cannotFulfillGoalException &e)
	{
		std::vector<std::vector<int3> > tiles; //tiles[distance_to_fow]
		try
		{
			return ai->explorationNewPoint(radius, h, tiles);
		}
		catch(cannotFulfillGoalException &e)
		{
			std::map<int, std::vector<int3> > profits;
			{
				TimeCheck tc("Evaluating exploration possibilities");
				tiles[0].clear(); //we can't reach FoW anyway
				for(auto &vt : tiles)
					for(auto &tile : vt)
						profits[howManyTilesWillBeDiscovered(tile, radius)].push_back(tile);
			}

			if(profits.empty())
				return int3 (-1,-1,-1);

			auto bestDest = profits.end();
			bestDest--;
			return bestDest->second.front(); //TODO which is the real best tile?
		}
	}
}
Beispiel #23
0
static qint64 getCorrection() {
    GCounter totalCounter("timer correction", "ticks", 1);

    TimeCounter tc(&totalCounter, false);
    tc.start(); tc.stop();
    tc.start(); tc.stop();
    tc.start(); tc.stop();
    tc.start(); tc.stop();

    qint64 correction = totalCounter.totalCount / 4;
    return correction;
}
Beispiel #24
0
eFlag Tree::parse(Sit S, DataLine *d)
{
    Log1(S, L1_PARSING, getURI());
    double time_was = getMillisecs();
    TreeConstructer tc(S);
    eFlag retval = tc.parseDataLineUsingExpat(S, this, d);
    if (!retval)
    {
        Log1(S, L1_PARSE_DONE, getMillisecsDiff(time_was));
    }
    return retval;
}
Beispiel #25
0
void Entity::render(const Map &map, const Camera &camera) const
{
    m_program->bind();

    m_program->setUniformValue(m_matrixUniform, camera.viewProjectionMatrix());

    QVector3D up(0, 0.65 * m_scale, 0);

    QVector3D va = m_a;
    QVector3D vb = m_a + up;
    QVector3D vc = m_b + up;
    QVector3D vd = m_b;

    qreal dx = 1. / m_textureSize.width();
    qreal dy = 1. / m_textureSize.height();

    int index = m_angleIndex;
    if (m_walking)
        index += 8 + 8 * (m_animationIndex % 4);

    qreal tx1 = (m_tileWidth * (index % m_tileMod) + 1) * dx;
    qreal tx2 = tx1 + (m_tileWidth - 2) * dx;
    qreal ty1 = (m_tileHeight * (index / m_tileMod) + 1) * dy;
    qreal ty2 = ty1 + (m_tileHeight - 2) * dy;

    QVector2D ta(tx2, ty2);
    QVector2D tb(tx2, ty1);
    QVector2D tc(tx1, ty1);
    QVector2D td(tx1, ty2);

    QVector<QVector3D> vertexBuffer;
    vertexBuffer << va << vb << vd << vd << vb << vc;
    QVector<QVector3D> texBuffer;
    texBuffer << ta << tb << td << td << tb << tc;

    m_program->enableAttributeArray(m_vertexAttr);
    m_program->setAttributeArray(m_vertexAttr, vertexBuffer.constData());
    m_program->enableAttributeArray(m_texAttr);
    m_program->setAttributeArray(m_texAttr, texBuffer.constData());

    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, m_texture);

    glDrawArrays(GL_TRIANGLES, 0, 6);

    glDisable(GL_BLEND);

    m_program->disableAttributeArray(m_texAttr);
    m_program->disableAttributeArray(m_vertexAttr);
}
void
FltExportVisitor::writeUVList( int numVerts, const osg::Geometry& geom, const std::vector<unsigned int>& indices )
{
    unsigned int numLayers( 0 );
    uint32 flags( 0 );
    unsigned int idx;
    for( idx=1; idx<8; idx++)
    {
        if( isTextured( idx, geom ) )
        {
            flags |= LAYER_1 >> (idx-1);
            numLayers++;
        }
    }
    if( numLayers == 0 )
        return;

    uint16 length( 8 + (8*numLayers*numVerts) );

    _records->writeInt16( (int16) UV_LIST_OP );
    _records->writeUInt16( length );
    _records->writeInt32( flags );

    osg::Vec2 defaultCoord( 0., 0. );
    // const osg::StateSet* ss = getCurrentStateSet();
    for( int vertexIdx=0; vertexIdx<numVerts; vertexIdx++)
    {
        for( idx=1; idx<8; idx++)
        {
            if( isTextured( idx, geom ) )
            {
                osg::Array* t = const_cast<osg::Array*>( geom.getTexCoordArray( idx ) );
                osg::ref_ptr<osg::Vec2Array> t2 = dynamic_cast<osg::Vec2Array*>( t );
                if (!t2.valid())
                {
                    std::ostringstream warning;
                    warning << "fltexp: No Texture2D for unit " << idx;
                    OSG_WARN << warning.str() << std::endl;
                    _fltOpt->getWriteResult().warn( warning.str() );
                    t2 = new osg::Vec2Array;
                }

                const int size = t2->getNumElements();
                int vIdx = indices[ vertexIdx ];
                osg::Vec2& tc( defaultCoord );
                if (vIdx < size)
                    tc = ( *t2 )[ vIdx ];
                _records->writeFloat32( tc[ 0 ] );
                _records->writeFloat32( tc[ 1 ] );
            }
        }
    }
}
Beispiel #27
0
/*!
SLMesh::preShade calculates the rest of the intersection information 
after the final hit point is determined. Should be called just before the 
shading when the final intersection point of the closest triangle was found.
*/
void SLMesh::preShade(SLRay* ray)
{
   SLFace* hit = ray->hitTriangle;
   
   // calculate the hit point in world space
   ray->hitPoint.set(ray->origin + ray->length * ray->dir);
      
   // calculate the interpolated normal with vertex normals in object space
   ray->hitNormal.set(N[hit->iA] * (1-(ray->hitU+ray->hitV)) + 
                      N[hit->iB] * ray->hitU + 
                      N[hit->iC] * ray->hitV);
                      
   // transform normal back to world space
   ray->hitNormal.set(ray->hitShape->wmN() * ray->hitNormal);
                 
   // invert normal if the ray is inside a shape
   if (!ray->isOutside) ray->hitNormal *= -1;
   
   // for shading the normal is expected to be unit length
   ray->hitNormal.normalize();
   
   // calculate interpolated texture coordinates
   SLVGLTexture& textures = ray->hitMat->textures();
   if (textures.size() > 0)
   {  SLVec2f Tu(Tc[hit->iB] - Tc[hit->iA]);
      SLVec2f Tv(Tc[hit->iC] - Tc[hit->iA]);
      SLVec2f tc(Tc[hit->iA] + ray->hitU*Tu + ray->hitV*Tv);
      ray->hitTexCol.set(textures[0]->getTexelf(tc.x,tc.y));
      
      // bumpmapping
      if (textures.size() > 1)
      {  if (T)
         {  
            // calculate the interpolated tangent with vertex tangent in object space
            SLVec4f hitT(T[hit->iA] * (1-(ray->hitU+ray->hitV)) + 
                         T[hit->iB] * ray->hitU + 
                         T[hit->iC] * ray->hitV);
                         
            SLVec3f T3(hitT.x,hitT.y,hitT.z);         // tangent with 3 components
            T3.set(ray->hitShape->wmN() * T3);        // transform tangent back to world space
            SLVec2f d = textures[1]->dsdt(tc.x,tc.y);  // slope of bumpmap at tc
            SLVec3f N = ray->hitNormal;               // unperturbated normal
            SLVec3f B(N^T3);                          // binormal tangent B
            B *= T[hit->iA].w;                        // correct handedness
            SLVec3f D(d.x*T3 + d.y*B);                // perturbation vector D
            N+=D;
            N.normalize();
            ray->hitNormal.set(N);
         }
      }
   }
}
Beispiel #28
0
TEST(BaseCluster, Read)
{
    std::stringstream input;
    tawara::UIntElement tc(tawara::ids::Timecode, 42);
    tawara::UIntElement st1(tawara::ids::SilentTrackNumber, 1);
    tawara::UIntElement st2(tawara::ids::SilentTrackNumber, 2);
    tawara::UIntElement ps(tawara::ids::PrevSize, 0x1234);

    FakeCluster e;
    std::streamsize body_size(tc.size());
    tawara::vint::write(body_size, input);
    tc.write(input);
    EXPECT_EQ(tawara::vint::size(body_size) + body_size,
            e.read(input));
    EXPECT_EQ(42, e.timecode());
    EXPECT_TRUE(e.silent_tracks().empty());
    EXPECT_EQ(0, e.previous_size());

    body_size += tawara::ids::size(tawara::ids::SilentTracks) +
        tawara::vint::size(st1.size() + st2.size()) +
        st1.size() + st2.size() + ps.size();
    tawara::vint::write(body_size, input);
    tc.write(input);
    tawara::ids::write(tawara::ids::SilentTracks, input);
    tawara::vint::write(st1.size() + st2.size(), input);
    st1.write(input);
    st2.write(input);
    ps.write(input);
    EXPECT_EQ(tawara::vint::size(body_size) + body_size,
            e.read(input));
    EXPECT_EQ(42, e.timecode());
    EXPECT_FALSE(e.silent_tracks().empty());
    EXPECT_EQ(0x1234, e.previous_size());

    // Body size value wrong (too small)
    input.str(std::string());
    tawara::vint::write(2, input);
    tc.write(input);
    ps.write(input);
    EXPECT_THROW(e.read(input), tawara::BadBodySize);
    // Invalid child
    input.str(std::string());
    tawara::UIntElement ue(tawara::ids::EBML, 0xFFFF);
    tawara::vint::write(ue.size(), input);
    ue.write(input);
    EXPECT_THROW(e.read(input), tawara::InvalidChildID);
    // Missing timecode
    input.str(std::string());
    tawara::vint::write(ps.size(), input);
    ps.write(input);
    EXPECT_THROW(e.read(input), tawara::MissingChild);
}
Beispiel #29
0
void MainWindow::on_time(){
    QTime time=QTime(0,0,0,0);
    time=time.addMSecs(videoPlayer->currentTime());
    if(sub!=NULL){
        QString replic("");
        TimeConteiner tc(time,time);
        replic=sub->value(tc,replic).trimmed();
        if(replic!=subtitles->toPlainText().trimmed()){
            subtitles->setText(replic);
        }
    }
    ui->label->setText(time.toString("hh:mm:ss"));
}
Beispiel #30
0
void info_manager::get_info_record(environment const & env, options const & o, io_state const & ios, pos_info pos,
                                   json & record, std::function<bool (info_data const &)> pred) const {
    type_context_old tc(env, o);
    io_state_stream out = regular(env, ios, tc).update_options(o);
    get_line_info_set(pos.first).for_each([&](unsigned c, list<info_data> const & ds) {
        if (c == pos.second) {
            for (auto const & d : ds) {
                if (!pred || pred(d))
                    d.report(out, record);
            }
        }
    });
}