Example #1
0
int BrowserApi::GetVolume(void)
{
    m_gotAnswer = false;

    MythEvent me(QString("MUSIC_COMMAND %1 GET_VOLUME")
                 .arg(gCoreContext->GetHostName()));
    gCoreContext->dispatch(me);

    QTime timer;
    timer.start();

    while (timer.elapsed() < 2000  && !m_gotAnswer)
    {
        qApp->processEvents();
        usleep(10000);
    }

    if (m_gotAnswer)
        return m_answer.toInt();

    return -1;
}
Example #2
0
complex AmpDB2::AmpBd(orders order) {
    if (mySM.getMyFlavour()->getHDF2().getCoeffBd().getOrder() < order % 3)
        throw std::runtime_error("DmBd::computeThValue(): requires cofficient of order not computed"); 

    vector<complex> ** allcoeff = mySM.getMyFlavour()->ComputeCoeffBd( 
            mySM.getBBd().getMu(),
        mySM.getBBd().getScheme());
    
    vector<double> me(mySM.getBBd().getBpars());
    double MBd = mySM.getMesons(QCD::B_D).getMass();
    double Mb = mySM.Mrun(mySM.getBBd().getMu(),
                mySM.getQuarks(QCD::BOTTOM).getMass_scale(),
                mySM.getQuarks(QCD::BOTTOM).getMass(), FULLNNLO);
    double Md = mySM.Mrun(mySM.getBBd().getMu(),
                mySM.getQuarks(QCD::DOWN).getMass_scale(),
                mySM.getQuarks(QCD::DOWN).getMass(), FULLNNLO);
    double KBd = MBd/(Mb+Md)*MBd/(Mb+Md);
    double Fb = mySM.getMesons(QCD::B_D).getDecayconst();
    me(0) *= 1./3.*MBd*Fb*Fb;
    me(1) *= -5./24.*KBd*MBd*Fb*Fb;
    me(2) *= 1./24.*KBd*MBd*Fb*Fb;
    me(3) *= 1./4.*KBd*MBd*Fb*Fb;
    me(4) *= 1./12.*KBd*MBd*Fb*Fb;
    
#if SUSYFIT_DEBUG & 1
    std::cout << "Bd: me(0) = " << me(0)  << std::endl;
#endif
#if SUSYFIT_DEBUG & 2
    std::cout << "M: " << me << std::endl;
    std::cout << "M.U: " << myFlavour.getHDF2().getUDF2().Df2Evol(4.2,1.e6,LO).transpose()*me << std::endl;
#endif

    switch(order) {
        case FULLNLO:
            return((*(allcoeff[LO]) + *(allcoeff[NLO])) * me / HCUT);
        case LO:
            return((*(allcoeff[LO])) * me / HCUT);
        default:
            throw std::runtime_error("AmpDB2::AmpBd(): order not implemented"); 
    }
}
bool SybCTnewDAImpl::Finis()
{
	StartTrace(SybCTnewDAImpl.Finis);
	if ( fgpPeriodicAction ) {
		fgpPeriodicAction->Terminate();
		delete fgpPeriodicAction;
		fgpPeriodicAction = NULL;
	}
	bool bInitialized;
	{
		LockUnlockEntry me(fgStructureMutex);
		bInitialized = fgInitialized;
		// force pending/upcoming Exec calls to fail
		fgInitialized = false;
	}
	if ( bInitialized ) {
		for (long lCount = 0L; lCount < fgListOfSybCT["Size"].AsLong(0L) && fgpResourcesSema->Acquire(); ++lCount) {
			SybCTnewDA *pSyb = NULL;
			bool bIsOpen = false;
			String strServer, strUser;
			if ( DoGetConnection(pSyb, bIsOpen, strServer, strUser) ) {
				if ( bIsOpen ) {
					pSyb->Close(true);
				}
				delete pSyb;
			}
		}
		delete fgpResourcesSema;
		fgpResourcesSema = NULL;
		SybCTnewDA::Finis(fg_cs_context);
		// trace messages which occurred without a connection
		while ( fgContextMessages.GetSize() ) {
			SystemLog::Warning(fgContextMessages[0L].AsString());
			fgContextMessages.Remove(0L);
		}
	}
	return !fgInitialized;
}
Example #4
0
bool CursorWindow::handleMouseEvent(QEvent *ev)
{
    bool handledEvent = false;
    static int inhere=0;
    if ( !inhere ) {
	inhere++;
	if ( m_view ) {
	    if ( ev->type() >= QEvent::MouseButtonPress && ev->type() <= QEvent::MouseMove ) {
		QMouseEvent *e = (QMouseEvent*)ev;
		QPoint gp = e->globalPos();
		QPoint vp = m_view->mapFromGlobal(gp);
		QPoint sp = skin->mapFromGlobal(gp);
		if ( e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick ) {
		    if ( m_view->rect().contains(vp) )
			mouseRecipient = m_view;
		    else if ( skin->parentWidget()->geometry().contains(gp) )
			mouseRecipient = skin;
		    else
			mouseRecipient = 0;
		}
		if ( mouseRecipient ) {
		    setPos(gp);
		    QMouseEvent me(e->type(),mouseRecipient==skin ? sp : vp,gp,e->button(),e->buttons(),e->modifiers());
		    QApplication::sendEvent(mouseRecipient, &me);
		} else if ( !skin->parentWidget()->geometry().contains(gp) ) {
		    hide();
		} else {
		    setPos(gp);
		}
		if ( e->type() == QEvent::MouseButtonRelease )
		    mouseRecipient = 0;
		handledEvent = true;
	    }
	}
	inhere--;
    }
    return handledEvent;
}
Example #5
0
/////////////////////////////////////////////////////////////////////////////
// test threads
/////////////////////////////////////////////////////////////////////////////
static void ThreadsTest()
{
 CPLog1D problem;
 CResults results(problem.GetDimensions());

// CSPUniform sp(problem.GetDimensions());

#if 0
 CPFQuadratic pf(problem.GetDimensions());
 CRegression reg(results, pf);
 reg.SetRefreshRate(0.1);
 reg.SetLocalizationHeight(2.0);
 CMERegressionMAPMax me(reg);

 CDFVarianceSamples var(reg, 1);
 var.SetMinSamples(problem.GetDimensions());
 CSPVOptimal sp(reg, var, 0);
 CArtificialExperiment artexp(problem, sp, me, results);
#else
 //CCrossEntropy alt(results, 0.9);
 //CSPSA alt(results);
 CRSPSA alt(results);
 CArtificialExperiment artexp(problem, alt, alt, results);
#endif

 CCPLConsole cplc;
 CRepeatThreads rts(79, 100000, &cplc);
 rts.AddThread(artexp);

 CPLog1D problemBis;
 CResults resultsBis(problemBis.GetDimensions());
 CRSPSA altBis(resultsBis);
 CArtificialExperiment artexpBis(problemBis, altBis, altBis, resultsBis);
 rts.AddThread(artexpBis);

 rts.Start();
 rts.WaitForTermination();
}
void DragClientQt::startDrag(DragImageRef dragImage, const IntPoint&, const IntPoint&, Clipboard* clipboard, Frame* frame, bool)
{
#ifndef QT_NO_DRAGANDDROP
    QMimeData* clipboardData = clipboard->pasteboard().clipboardData();
    clipboard->pasteboard().invalidateWritableData();
    QObject* view = m_chromeClient->platformPageClient()->ownerWidget();
    if (view) {
        QDrag* drag = new QDrag(view);
        if (dragImage)
            drag->setPixmap(*dragImage);
        else if (clipboardData && clipboardData->hasImage())
            drag->setPixmap(qvariant_cast<QPixmap>(clipboardData->imageData()));
        DragOperation dragOperationMask = clipboard->sourceOperation();
        drag->setMimeData(clipboardData);
        Qt::DropAction actualDropAction = drag->exec(dragOperationsToDropActions(dragOperationMask));

        // Send dragEnd event
        PlatformMouseEvent me(m_chromeClient->screenToRootView(QCursor::pos()), QCursor::pos(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, 0);
        frame->eventHandler()->dragSourceEndedAt(me, dropActionToDragOperation(actualDropAction));
    }
    frame->page()->dragController()->dragEnded();
#endif
}
Example #7
0
void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e )
{
  mCanvasProperties->mouseLastXY = e->pos();

  if ( mCanvasProperties->panSelectorDown )
  {
    panAction( e );
  }
  else
  {
    // call handler of current map tool
    if ( mMapTool )
    {
      QScopedPointer<QgsMapMouseEvent> me( new QgsMapMouseEvent( this, e ) );
      mMapTool->canvasMoveEvent( me.data() );
    }
  }

  // show x y on status bar
  QPoint xy = e->pos();
  QgsPoint coord = getCoordinateTransform()->toMapCoordinates( xy );
  emit xyCoordinates( coord );
} // mouseMoveEvent
Example #8
0
bool KexiBlobTableEdit::handleKeyPress( QKeyEvent* ke, bool editorActive )
{
	Q_UNUSED(editorActive);

	const int k = ke->key();
	KKey kkey(ke);
	if (!d->readOnly) {
		if ((ke->state()==Qt::NoButton && k==Qt::Key_F4)
			|| (ke->state()==Qt::AltButton && k==Qt::Key_Down)) {
			d->button->animateClick();
			QMouseEvent me( QEvent::MouseButtonPress, QPoint(2,2), Qt::LeftButton, Qt::NoButton );
			QApplication::sendEvent( d->button, &me );
		}
		else if ((ke->state()==NoButton && (k==Qt::Key_F2 || k==Qt::Key_Space || k==Qt::Key_Enter || k==Qt::Key_Return))) {
			d->popup->insertFromFile();
		}
		else
			return false;
	}
	else
		return false;
	return true;
}
Example #9
0
  /**
   * Signals the successful receipt of an RPC response.
   *
   * @param response RPC response
   * @param msg Channel-specific lower-layer message
   */
  void done(const Protocol::RpcResponse &response, const typename Channel::message_type &msg)
  {
    RpcCallWeakPtr<Channel> me(this->shared_from_this());

    // Response must be copied as a reference will go away after the method completes
    m_strand.post([me, response, msg]() {
      if (RpcCallPtr<Channel> self = me.lock()) {
        if (self->m_finished)
          return;

        self->m_timer.cancel();
        self->cancel();
        if (response.error()) {
          if (self->m_failure) {
            Protocol::RpcError error = message_cast<Protocol::RpcError>(response.data());
            self->m_failure(static_cast<RpcErrorCode>(error.code()), error.message());
          }
        } else if (self->m_success) {
          self->m_success(response, msg);
        }
      }
    });
  }
void TowerDefence::Lecture()
{

   QByteArray recept=m_socket->read(m_socket->bytesAvailable());
   if(recept.at(0)=='#')
   {
        gest->ListeMonstre.clear();
        gest->EListeMonstre.clear();
        recept=recept.remove(0,1);
        QStringList Reception = QString(recept).split('#');
        QStringList coordmes=Reception.at(0).split('/');
        QStringList coordces=Reception.at(1).split('/');
        foreach(QString donne,coordmes)
        {
           QStringList coord=donne.split('.');
           int x,y;
           x=atoi(coord.at(0));
           y=atoi(coord.at(1));
           Monstre *monstre;
           QVector2D me(x,y);
           monstre=new Monstre(me,(float)0.10,(float)20,1,(float)20,QColor(Qt::green),&chemin);
           gest->ListeMonstre.append(monstre);
        }
Example #11
0
bool Dvr::DeleteRecording(int chanid, const QDateTime &recstarttsRaw,
                          bool forceDelete, bool allowRerecord)
{
    if (chanid <= 0 || !recstarttsRaw.isValid())
        throw QString("Channel ID or StartTime appears invalid.");

    ProgramInfo pi(chanid, recstarttsRaw.toUTC());

    if (pi.GetChanID() && pi.HasPathname())
    {
        QString cmd = QString("DELETE_RECORDING %1 %2 %3 %4")
            .arg(pi.GetChanID())
            .arg(pi.GetRecordingStartTime(MythDate::ISODate))
            .arg(forceDelete ? "FORCE" : "NO_FORCE")
            .arg(allowRerecord ? "FORGET" : "NO_FORGET");
        MythEvent me(cmd);

        gCoreContext->dispatch(me);
        return true;
    }

    return false;
}
Example #12
0
QString PropertyEditor::buildOptions()
{
    QString result;
    foreach (QMetaProperty mp, mMetaProperties) {
        if (qstrcmp(mp.name(), "objectName") == 0)
            continue;
        result += QString::fromLatin1("  * %1: ").arg(QString::fromLatin1(mp.name()));
        if (mp.isEnumType()) {
            if (mp.isFlagType())
                result += QString::fromLatin1("flag ");
            else
                result += QString::fromLatin1("enum ");
            QMetaEnum me(mp.enumerator());
            for (int i = 0; i < me.keyCount(); ++i) {
                result += QString::fromLatin1(me.key(i));
                result += QString::fromLatin1("=");
                result += QString::number(me.value(i));
                if (i < me.keyCount() - 1)
                    result += QString::fromLatin1(",");
            }
        } else if (mp.type() == QVariant::Int){
            result += QString::fromLatin1("int");
        } else if (mp.type() == QVariant::Double) {
            result += QString::fromLatin1("real");
        } else if (mp.type() == QVariant::String) {
            result += QString::fromLatin1("text");
        } else if (mp.type() == QVariant::Bool) {
            result += QString::fromLatin1("bool");
        }
        const QVariant detail =  mPropertyDetails.value(QString::fromLatin1(mp.name()));
        if (!detail.isNull())
            result += QString::fromLatin1("\n    > property detail: %1").arg(detail.toString());
        result += QString::fromLatin1("\n");
    }
    return result;
}
Example #13
0
void                        
bf_prefetch_thread_t::retire() 
{ 
    FUNC(bf_prefetch_thread_t::retire);
    {
        CRITICAL_SECTION(cs, _prefetch_mutex);
        _retire = true; 
    } // end critical section

    w_assert3( me() != this );

    w_rc_t e;
    for (;;) {
        /* keep hosing the thread until it dies */
            /* XXX This is bogus. telling it to shutdown and waiting
               should be enough. */
        DO_PTHREAD(pthread_cond_signal(&_activate));
        e = join(1000);
        if (!e.is_error())
            break;
        else if (e.err_num() != smthread_t::stTIMEOUT)
            W_COERCE(e);
    }        
}
Example #14
0
void CrystalButton::mouseReleaseEvent(QMouseEvent* e)
{
	lastmouse_ = e->button();
	int button;
	switch(e->button())
	{
	case LeftButton:
		button=LeftButton;
		break;
	case RightButton:
		if ((type_ == ButtonMax) || (type_ == ButtonMin) || (type_ == ButtonMenu) || (type_==ButtonClose))
			button=LeftButton; else button=NoButton;
		break;
	case MidButton:
		if ((type_ == ButtonMax) || (type_ == ButtonMin))
			button=LeftButton; else button=NoButton;
		break;
	
	default:button=NoButton;
		break;
	}
	QMouseEvent me(e->type(), e->pos(), e->globalPos(), button, e->state());
	QButton::mouseReleaseEvent(&me);
}
Example #15
0
void QgsLayoutView::mousePressEvent( QMouseEvent *event )
{
  if ( mTool )
  {
    std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event ) );
    mTool->layoutPressEvent( me.get() );
    event->setAccepted( me->isAccepted() );
  }

  if ( !mTool || !event->isAccepted() )
  {
    if ( event->button() == Qt::MidButton )
    {
      // Pan layout with middle mouse button
      setTool( mMidMouseButtonPanTool );
      event->accept();
    }
    else if ( event->button() == Qt::RightButton && mMenuProvider )
    {
      QMenu *menu = mMenuProvider->createContextMenu( this, currentLayout(), mapToScene( event->pos() ) );
      if ( menu )
      {
        menu->exec( event->globalPos() );
        delete menu;
      }
    }
    else
    {
      QGraphicsView::mousePressEvent( event );
    }
  }
  else
  {
    QGraphicsView::mousePressEvent( event );
  }
}
Example #16
0
 void Hub::setResultCapture( IResultCapture* resultCapture )
 {
     me().m_resultCapture = resultCapture;
 }
Example #17
0
 IResultCapture& Hub::getResultCapture
 ()
 {
     return *me().m_resultCapture;
 }
Example #18
0
 bool Hub::advanceGeneratorsForCurrentTest
 ()
 {
     GeneratorsForTest* generators = me().findGeneratorsForCurrentTest();
     return generators && generators->moveNext();
 }
Example #19
0
 void Hub::setRunner( IRunner* runner )
 {
     me().m_runner = runner;
 }
Example #20
0
bool Map::LoadV2(FILE *f) {
	uint32 data_size;
	if (fread(&data_size, sizeof(data_size), 1, f) != 1) {
		return false;
	}

	uint32 buffer_size;
	if (fread(&buffer_size, sizeof(buffer_size), 1, f) != 1) {
		return false;
	}

	std::vector<char> data;
	data.resize(data_size);
	if (fread(&data[0], data_size, 1, f) != 1) {
		return false;
	}

	std::vector<char> buffer;
	buffer.resize(buffer_size);
	uint32 v = InflateData(&data[0], data_size, &buffer[0], buffer_size);

	char *buf = &buffer[0];
	uint32 vert_count;
	uint32 ind_count;
	uint32 nc_vert_count;
	uint32 nc_ind_count;
	uint32 model_count;
	uint32 plac_count;
	uint32 plac_group_count;
	uint32 tile_count;
	uint32 quads_per_tile;
	float units_per_vertex;

	vert_count = *(uint32*)buf;
	buf += sizeof(uint32);

	ind_count = *(uint32*)buf;
	buf += sizeof(uint32);

	nc_vert_count = *(uint32*)buf;
	buf += sizeof(uint32);

	nc_ind_count = *(uint32*)buf;
	buf += sizeof(uint32);

	model_count = *(uint32*)buf;
	buf += sizeof(uint32);

	plac_count = *(uint32*)buf;
	buf += sizeof(uint32);

	plac_group_count = *(uint32*)buf;
	buf += sizeof(uint32);

	tile_count = *(uint32*)buf;
	buf += sizeof(uint32);

	quads_per_tile = *(uint32*)buf;
	buf += sizeof(uint32);

	units_per_vertex = *(float*)buf;
	buf += sizeof(float);

	std::vector<glm::vec3> verts;
	verts.reserve(vert_count);
	std::vector<uint32> indices;
	indices.reserve(ind_count);

	for (uint32 i = 0; i < vert_count; ++i) {
		float x;
		float y;
		float z;

		x = *(float*)buf;
		buf += sizeof(float);

		y = *(float*)buf;
		buf += sizeof(float);

		z = *(float*)buf;
		buf += sizeof(float);

		verts.emplace_back(x, y, z);
	}

	for (uint32 i = 0; i < ind_count; ++i) {
		indices.emplace_back(*(uint32 *)buf);
		buf += sizeof(uint32);
	}

	for (uint32 i = 0; i < nc_vert_count; ++i) {
		buf += sizeof(float) * 3;
	}

	for (uint32 i = 0; i < nc_ind_count; ++i) {
		buf += sizeof(uint32);
	}

	std::map<std::string, std::unique_ptr<ModelEntry>> models;
	for (uint32 i = 0; i < model_count; ++i) {
		std::unique_ptr<ModelEntry> me(new ModelEntry);
		std::string name = buf;
		buf += name.length() + 1;

		uint32 vert_count = *(uint32*)buf;
		buf += sizeof(uint32);

		uint32 poly_count = *(uint32*)buf;
		buf += sizeof(uint32);

		me->verts.reserve(vert_count);
		for (uint32 j = 0; j < vert_count; ++j) {
			float x = *(float*)buf;
			buf += sizeof(float);
			float y = *(float*)buf;
			buf += sizeof(float);
			float z = *(float*)buf;
			buf += sizeof(float);

			me->verts.emplace_back(x, y, z);
		}

		me->polys.reserve(poly_count);
		for (uint32 j = 0; j < poly_count; ++j) {
			uint32 v1 = *(uint32*)buf;
			buf += sizeof(uint32);
			uint32 v2 = *(uint32*)buf;
			buf += sizeof(uint32);
			uint32 v3 = *(uint32*)buf;
			buf += sizeof(uint32);
			uint8 vis = *(uint8*)buf;
			buf += sizeof(uint8);

			ModelEntry::Poly p;
			p.v1 = v1;
			p.v2 = v2;
			p.v3 = v3;
			p.vis = vis;
			me->polys.push_back(p);
		}

		models[name] = std::move(me);
	}

	for (uint32 i = 0; i < plac_count; ++i) {
		std::string name = buf;
		buf += name.length() + 1;

		float x = *(float*)buf;
		buf += sizeof(float);
		float y = *(float*)buf;
		buf += sizeof(float);
		float z = *(float*)buf;
		buf += sizeof(float);

		float x_rot = *(float*)buf;
		buf += sizeof(float);
		float y_rot = *(float*)buf;
		buf += sizeof(float);
		float z_rot = *(float*)buf;
		buf += sizeof(float);

		float x_scale = *(float*)buf;
		buf += sizeof(float);
		float y_scale = *(float*)buf;
		buf += sizeof(float);
		float z_scale = *(float*)buf;
		buf += sizeof(float);

		if (models.count(name) == 0)
			continue;

		auto &model = models[name];
		auto &mod_polys = model->polys;
		auto &mod_verts = model->verts;
		for (uint32 j = 0; j < mod_polys.size(); ++j) {
			auto &current_poly = mod_polys[j];
			if (current_poly.vis == 0)
				continue;
			auto v1 = mod_verts[current_poly.v1];
			auto v2 = mod_verts[current_poly.v2];
			auto v3 = mod_verts[current_poly.v3];

			RotateVertex(v1, x_rot, y_rot, z_rot);
			RotateVertex(v2, x_rot, y_rot, z_rot);
			RotateVertex(v3, x_rot, y_rot, z_rot);

			ScaleVertex(v1, x_scale, y_scale, z_scale);
			ScaleVertex(v2, x_scale, y_scale, z_scale);
			ScaleVertex(v3, x_scale, y_scale, z_scale);

			TranslateVertex(v1, x, y, z);
			TranslateVertex(v2, x, y, z);
			TranslateVertex(v3, x, y, z);

			verts.emplace_back(v1.y, v1.x, v1.z); // x/y swapped
			verts.emplace_back(v2.y, v2.x, v2.z);
			verts.emplace_back(v3.y, v3.x, v3.z);

			indices.emplace_back((uint32)verts.size() - 3);
			indices.emplace_back((uint32)verts.size() - 2);
			indices.emplace_back((uint32)verts.size() - 1);
		}
	}

	for (uint32 i = 0; i < plac_group_count; ++i) {
		float x = *(float*)buf;
		buf += sizeof(float);
		float y = *(float*)buf;
		buf += sizeof(float);
		float z = *(float*)buf;
		buf += sizeof(float);

		float x_rot = *(float*)buf;
		buf += sizeof(float);
		float y_rot = *(float*)buf;
		buf += sizeof(float);
		float z_rot = *(float*)buf;
		buf += sizeof(float);

		float x_scale = *(float*)buf;
		buf += sizeof(float);
		float y_scale = *(float*)buf;
		buf += sizeof(float);
		float z_scale = *(float*)buf;
		buf += sizeof(float);

		float x_tile = *(float*)buf;
		buf += sizeof(float);
		float y_tile = *(float*)buf;
		buf += sizeof(float);
		float z_tile = *(float*)buf;
		buf += sizeof(float);

		uint32 p_count = *(uint32*)buf;
		buf += sizeof(uint32);

		for (uint32 j = 0; j < p_count; ++j) {
			std::string name = buf;
			buf += name.length() + 1;

			float p_x = *(float*)buf;
			buf += sizeof(float);
			float p_y = *(float*)buf;
			buf += sizeof(float);
			float p_z = *(float*)buf;
			buf += sizeof(float);

			float p_x_rot = *(float*)buf * 3.14159f / 180;
			buf += sizeof(float);
			float p_y_rot = *(float*)buf * 3.14159f / 180;
			buf += sizeof(float);
			float p_z_rot = *(float*)buf * 3.14159f / 180;
			buf += sizeof(float);

			float p_x_scale = *(float*)buf;
			buf += sizeof(float);
			float p_y_scale = *(float*)buf;
			buf += sizeof(float);
			float p_z_scale = *(float*)buf;
			buf += sizeof(float);

			if (models.count(name) == 0)
				continue;

			auto &model = models[name];

			for (size_t k = 0; k < model->polys.size(); ++k) {
				auto &poly = model->polys[k];
				if (poly.vis == 0)
					continue;
				glm::vec3 v1, v2, v3;

				v1 = model->verts[poly.v1];
				v2 = model->verts[poly.v2];
				v3 = model->verts[poly.v3];

				ScaleVertex(v1, p_x_scale, p_y_scale, p_z_scale);
				ScaleVertex(v2, p_x_scale, p_y_scale, p_z_scale);
				ScaleVertex(v3, p_x_scale, p_y_scale, p_z_scale);

				TranslateVertex(v1, p_x, p_y, p_z);
				TranslateVertex(v2, p_x, p_y, p_z);
				TranslateVertex(v3, p_x, p_y, p_z);

				RotateVertex(v1, x_rot * 3.14159f / 180.0f, 0, 0);
				RotateVertex(v2, x_rot * 3.14159f / 180.0f, 0, 0);
				RotateVertex(v3, x_rot * 3.14159f / 180.0f, 0, 0);

				RotateVertex(v1, 0, y_rot * 3.14159f / 180.0f, 0);
				RotateVertex(v2, 0, y_rot * 3.14159f / 180.0f, 0);
				RotateVertex(v3, 0, y_rot * 3.14159f / 180.0f, 0);

				glm::vec3 correction(p_x, p_y, p_z);

				RotateVertex(correction, x_rot * 3.14159f / 180.0f, 0, 0);

				TranslateVertex(v1, -correction.x, -correction.y, -correction.z);
				TranslateVertex(v2, -correction.x, -correction.y, -correction.z);
				TranslateVertex(v3, -correction.x, -correction.y, -correction.z);

				RotateVertex(v1, p_x_rot, 0, 0);
				RotateVertex(v2, p_x_rot, 0, 0);
				RotateVertex(v3, p_x_rot, 0, 0);

				RotateVertex(v1, 0, -p_y_rot, 0);
				RotateVertex(v2, 0, -p_y_rot, 0);
				RotateVertex(v3, 0, -p_y_rot, 0);

				RotateVertex(v1, 0, 0, p_z_rot);
				RotateVertex(v2, 0, 0, p_z_rot);
				RotateVertex(v3, 0, 0, p_z_rot);

				TranslateVertex(v1, correction.x, correction.y, correction.z);
				TranslateVertex(v2, correction.x, correction.y, correction.z);
				TranslateVertex(v3, correction.x, correction.y, correction.z);

				RotateVertex(v1, 0, 0, z_rot * 3.14159f / 180.0f);
				RotateVertex(v2, 0, 0, z_rot * 3.14159f / 180.0f);
				RotateVertex(v3, 0, 0, z_rot * 3.14159f / 180.0f);

				ScaleVertex(v1, x_scale, y_scale, z_scale);
				ScaleVertex(v2, x_scale, y_scale, z_scale);
				ScaleVertex(v3, x_scale, y_scale, z_scale);

				TranslateVertex(v1, x_tile, y_tile, z_tile);
				TranslateVertex(v2, x_tile, y_tile, z_tile);
				TranslateVertex(v3, x_tile, y_tile, z_tile);

				TranslateVertex(v1, x, y, z);
				TranslateVertex(v2, x, y, z);
				TranslateVertex(v3, x, y, z);

				verts.emplace_back(v1.y, v1.x, v1.z); // x/y swapped
				verts.emplace_back(v2.y, v2.x, v2.z);
				verts.emplace_back(v3.y, v3.x, v3.z);

				indices.emplace_back((uint32)verts.size() - 3);
				indices.emplace_back((uint32)verts.size() - 2);
				indices.emplace_back((uint32)verts.size() - 1);
			}
		}
	}

	uint32 ter_quad_count = (quads_per_tile * quads_per_tile);
	uint32 ter_vert_count = ((quads_per_tile + 1) * (quads_per_tile + 1));
	std::vector<uint8> flags;
	std::vector<float> floats;
	flags.resize(ter_quad_count);
	floats.resize(ter_vert_count);
	for (uint32 i = 0; i < tile_count; ++i) {
		bool flat;
		flat = *(bool*)buf;
		buf += sizeof(bool);

		float x;
		x = *(float*)buf;
		buf += sizeof(float);

		float y;
		y = *(float*)buf;
		buf += sizeof(float);

		if (flat) {
			float z;
			z = *(float*)buf;
			buf += sizeof(float);

			float QuadVertex1X = x;
			float QuadVertex1Y = y;
			float QuadVertex1Z = z;

			float QuadVertex2X = QuadVertex1X + (quads_per_tile * units_per_vertex);
			float QuadVertex2Y = QuadVertex1Y;
			float QuadVertex2Z = QuadVertex1Z;

			float QuadVertex3X = QuadVertex2X;
			float QuadVertex3Y = QuadVertex1Y + (quads_per_tile * units_per_vertex);
			float QuadVertex3Z = QuadVertex1Z;

			float QuadVertex4X = QuadVertex1X;
			float QuadVertex4Y = QuadVertex3Y;
			float QuadVertex4Z = QuadVertex1Z;

			uint32 current_vert = (uint32)verts.size() + 3;
			verts.emplace_back(QuadVertex1X, QuadVertex1Y, QuadVertex1Z);
			verts.emplace_back(QuadVertex2X, QuadVertex2Y, QuadVertex2Z);
			verts.emplace_back(QuadVertex3X, QuadVertex3Y, QuadVertex3Z);
			verts.emplace_back(QuadVertex4X, QuadVertex4Y, QuadVertex4Z);

			indices.emplace_back(current_vert);
			indices.emplace_back(current_vert - 2);
			indices.emplace_back(current_vert - 1);

			indices.emplace_back(current_vert);
			indices.emplace_back(current_vert - 3);
			indices.emplace_back(current_vert - 2);
		}
		else {
			//read flags
			for (uint32 j = 0; j < ter_quad_count; ++j) {
				uint8 f;
				f = *(uint8*)buf;
				buf += sizeof(uint8);

				flags[j] = f;
			}

			//read floats
			for (uint32 j = 0; j < ter_vert_count; ++j) {
				float f;
				f = *(float*)buf;
				buf += sizeof(float);

				floats[j] = f;
			}

			int row_number = -1;
			std::map<std::tuple<float, float, float>, uint32> cur_verts;
			for (uint32 quad = 0; quad < ter_quad_count; ++quad) {
				if ((quad % quads_per_tile) == 0) {
					++row_number;
				}

				if (flags[quad] & 0x01)
					continue;

				float QuadVertex1X = x + (row_number * units_per_vertex);
				float QuadVertex1Y = y + (quad % quads_per_tile) * units_per_vertex;
				float QuadVertex1Z = floats[quad + row_number];

				float QuadVertex2X = QuadVertex1X + units_per_vertex;
				float QuadVertex2Y = QuadVertex1Y;
				float QuadVertex2Z = floats[quad + row_number + quads_per_tile + 1];

				float QuadVertex3X = QuadVertex1X + units_per_vertex;
				float QuadVertex3Y = QuadVertex1Y + units_per_vertex;
				float QuadVertex3Z = floats[quad + row_number + quads_per_tile + 2];

				float QuadVertex4X = QuadVertex1X;
				float QuadVertex4Y = QuadVertex1Y + units_per_vertex;
				float QuadVertex4Z = floats[quad + row_number + 1];

				uint32 i1, i2, i3, i4;
				std::tuple<float, float, float> t = std::make_tuple(QuadVertex1X, QuadVertex1Y, QuadVertex1Z);
				auto iter = cur_verts.find(t);
				if (iter != cur_verts.end()) {
					i1 = iter->second;
				}
				else {
					i1 = (uint32)verts.size();
					verts.emplace_back(QuadVertex1X, QuadVertex1Y, QuadVertex1Z);
					cur_verts[std::make_tuple(QuadVertex1X, QuadVertex1Y, QuadVertex1Z)] = i1;
				}

				t = std::make_tuple(QuadVertex2X, QuadVertex2Y, QuadVertex2Z);
				iter = cur_verts.find(t);
				if (iter != cur_verts.end()) {
					i2 = iter->second;
				}
				else {
					i2 = (uint32)verts.size();
					verts.emplace_back(QuadVertex2X, QuadVertex2Y, QuadVertex2Z);
					cur_verts[std::make_tuple(QuadVertex2X, QuadVertex2Y, QuadVertex2Z)] = i2;
				}

				t = std::make_tuple(QuadVertex3X, QuadVertex3Y, QuadVertex3Z);
				iter = cur_verts.find(t);
				if (iter != cur_verts.end()) {
					i3 = iter->second;
				}
				else {
					i3 = (uint32)verts.size();
					verts.emplace_back(QuadVertex3X, QuadVertex3Y, QuadVertex3Z);
					cur_verts[std::make_tuple(QuadVertex3X, QuadVertex3Y, QuadVertex3Z)] = i3;
				}

				t = std::make_tuple(QuadVertex4X, QuadVertex4Y, QuadVertex4Z);
				iter = cur_verts.find(t);
				if (iter != cur_verts.end()) {
					i4 = iter->second;
				}
				else {
					i4 = (uint32)verts.size();
					verts.emplace_back(QuadVertex4X, QuadVertex4Y, QuadVertex4Z);
					cur_verts[std::make_tuple(QuadVertex4X, QuadVertex4Y, QuadVertex4Z)] = i4;
				}

				indices.emplace_back(i4);
				indices.emplace_back(i2);
				indices.emplace_back(i3);

				indices.emplace_back(i4);
				indices.emplace_back(i1);
				indices.emplace_back(i2);
			}
		}
	}

	uint32 face_count = indices.size() / 3;

	if (imp) {
		imp->rm->release();
		imp->rm = nullptr;
	}
	else {
		imp = new impl;
	}

	imp->rm = createRaycastMesh((RmUint32)verts.size(), (const RmReal*)&verts[0], face_count, &indices[0]);

	if (!imp->rm) {
		delete imp;
		imp = nullptr;
		return false;
	}

	return true;
}
Example #21
0
/*!
 * \param command A command to parse, for example "/join #channel key"
 *
 * \return true when command was found, false otherwise.\n Note that, even if a command fails to execute, true is still returned.
 */
bool ICommand::parse(QString command)
{
    /*
        This function must return true if the command was found, even if
        the command resulted in an error!
        ONLY return false if the command was not found.
    */

    if (command[0] == '/')
        command = command.mid(1);

    QStringList token = command.split(' ');
    QString t1 = token[0].toUpper();

    if (t1 == "JOIN") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Join"));
            return true;
        }
        if (token.count() == 1) {
            localMsg(InsufficientParameters("/Join"));
            return true;
        }
        if (token.count() == 2) {
            join(token.at(1));
            return true;
        }
        QString pass = command.mid(t1.length() + token.at(1).length() + 2);
        join(token.at(1), pass);
        return true;
    }

    if (t1 == "PART") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Part"));
            return true;
        }
        if (token.count() == 1) {
            localMsg(InsufficientParameters("/Part"));
            return true;
        }
        if (token.count() == 2) {
            part(token.at(1));
            return true;
        }
        QString reason = command.mid(t1.length() + token[1].length() + 2);
        part(token.at(1), reason);
        return true;
    }

    if (t1 == "QUIT") {
        QString reason;

        reason = command.mid(5);
        quit(reason);
    }

    if (t1 == "NOTICE") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Notice"));
            return true;
        }
        if (token.count() < 3) {
            localMsg(InsufficientParameters("/Notice"));
            return true;
        }
        QString text = command.mid(token[1].length()+8);
        notice(token[1], text);
        return true;
    }

    if (t1 == "MSG") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Msg"));
            return true;
        }
        if (token.count() < 3) {
            localMsg(InsufficientParameters("/Msg"));
            return true;
        }
        QString text = command.mid(token[1].length()+5);
        msg(token[1], text);
        return true;
    }

    if (t1 == "ME") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Me"));
            return true;
        }
        subwindow_t wt = winlist->value(activewin());
        if ((wt.type != WT_CHANNEL) && (wt.type != WT_PRIVMSG)) {
            localMsg(tr("You're not in a chat window!"));
            return true;
        }
        QString target = wt.widget->getTarget();
        me(target, command.mid(3));
        return true;
    }

    if (t1 == "CTCP") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Ctcp"));
            return true;
        }

        if (token.count() < 3) {
            localMsg(InsufficientParameters("/Ctcp"));
            return true;
        }

        // /ctcp target msg param param param ...

        int skip = 0;
        for (int i = 0; i <= 1; ++i)
            skip += token[i].length() + 1;
        QString msg = command.mid(skip).toUpper();

        if (msg == "PING") {
            QString ms = QString::number( QDateTime::currentMSecsSinceEpoch() );
            msg += ' ';
            msg += ms;
        }

        ctcp(token[1], msg);
        return true;
    }

    if (t1 == "KICK") {
        // kick #chan nick [reason]
        if (token.count() < 2) {
            localMsg(InsufficientParameters("/Kick"));
            return true;
        }
        QString channel = token[1];
        QString nickname;
        int l = 5;
        if (! connection->isValidChannel(channel)) {
            channel.clear();
            nickname = token[1];
            l += nickname.length() + 1;
        }
        else {
            nickname = token[2];
            l += nickname.length() + channel.length() + 2;
        }

        QString reason = command.mid(l);

        kick(channel, nickname, reason);

        return true;
    }

    if (t1 == "KILL") {
        if (token.count() < 2) {
            localMsg(InsufficientParameters("/Kill"));
            return true;
        }
        QString nickname = token[1];
        QString reason = command.mid(nickname.length() + 5);

        kill(nickname, reason);
        return true;
    }

    if (t1 == "BAN") {
        if (token.count() < 2) {
            localMsg(InsufficientParameters("/Ban"));
            return true;
        }

        QString channel = token[1];
        QString nickname;
        if (token.count() == 2) {
            channel.clear();
            nickname = token[1];
        }
        else
            nickname = token[2];

        ban(channel, nickname);
        return true;
    }

    if ((t1 == "RAW") || (t1 == "QUOTE")) {
        if (! connection->isOnline()) {
            localMsg( tr("/%1: Not connected to server.")
                     .arg(t1)
                  );
            return true;
        }
        if (token.count() < 2) {
            localMsg( tr("/%1: Insufficient parameters.")
                     .arg(t1)
                  );
            return true;
        }
        QString c = command.mid(t1.length()+1);
        raw(c);
        return true;
    }

    if (t1 == "CHARSET") {
        if (token.count() < 2) {
            localMsg( tr("/Charset: Current set is '%1'")
                     .arg(conf->charset));
            return true;
        }

        charset(token[1]);
        return true;
    }

    if (t1 == "CLEAR") {
        if (token.count() == 1) {
            // clear active window
        }

        subwindow_t sw = getCurrentSubwin();
        if (sw.type == WT_NOTHING)
            return true;
        sw.widget->clear();
        return true;
    }

    if (t1 == "PING") {
        if (! connection->isOnline()) {
            localMsg(NotConnectedToServer("/Ping"));
            return true;
        }
        ping();
        return true;
    }

    if (t1 == "QUERY") {
        if (token.count() < 2) {
            localMsg(InsufficientParameters("/Query"));
            return true;
        }

        query(token[1]);
        return true;
    }

    if (t1 == "CHANSETTINGS") {
        chansettings();
        return true;
    }

    return false; // Command wasn't found.
}
Example #22
0
void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    if (!d->enabled && !d->pressed) {
        QQuickItem::mouseMoveEvent(event);
        return;
    }

    d->saveEvent(event);

    // ### we should skip this if these signals aren't used
    // ### can GV handle this for us?
    setHovered(contains(d->lastPos));

#ifndef QT_NO_DRAGANDDROP
    if (d->drag && d->drag->target()) {
        if (!d->moved) {
            d->targetStartPos = d->drag->target()->parentItem()
                    ? d->drag->target()->parentItem()->mapToScene(d->drag->target()->position())
                    : d->drag->target()->position();
        }

        QPointF startLocalPos;
        QPointF curLocalPos;
        if (drag()->target()->parentItem()) {
            startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
            curLocalPos = drag()->target()->parentItem()->mapFromScene(event->windowPos());
        } else {
            startLocalPos = d->startScene;
            curLocalPos = event->windowPos();
        }

        if (keepMouseGrab() && d->stealMouse && !d->drag->active())
            d->drag->setActive(true);

        QPointF startPos = d->drag->target()->parentItem()
                ? d->drag->target()->parentItem()->mapFromScene(d->targetStartPos)
                : d->targetStartPos;

        bool dragX = drag()->axis() & QQuickDrag::XAxis;
        bool dragY = drag()->axis() & QQuickDrag::YAxis;

        QPointF dragPos = d->drag->target()->position();
        if (dragX) {
            dragPos.setX(qBound(
                    d->drag->xmin(),
                    startPos.x() + curLocalPos.x() - startLocalPos.x(),
                    d->drag->xmax()));
        }
        if (dragY) {
            dragPos.setY(qBound(
                    d->drag->ymin(),
                    startPos.y() + curLocalPos.y() - startLocalPos.y(),
                    d->drag->ymax()));
        }
        if (d->drag->active())
            d->drag->target()->setPosition(dragPos);

        if (!keepMouseGrab()
                && (QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event, d->drag->threshold())
                || QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event, d->drag->threshold()))) {
            setKeepMouseGrab(true);
            d->stealMouse = true;

            if (d->drag->smoothed())
                d->startScene = event->windowPos();
        }

        d->moved = true;
    }
#endif

    QQuickMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
    emit mouseXChanged(&me);
    me.setPosition(d->lastPos);
    emit mouseYChanged(&me);
    me.setPosition(d->lastPos);
    emit positionChanged(&me);
}
Example #23
0
void me_SM(void (*me)(double,double ,double *, double *, int),
	  double s,double t, double *re, double*im, int exclude_loops){
  // This routine computes the complex SM amplitude
  // The first argument can be any of the helicity amplitudes Mpppp,Mppmm,Mpmpm,Mpmmp,Mpppm


  // SM fermion content: (e,mu,tau,u,c,t,d,s,b)
  // SM_weight equals (number of colors) * (el. charge)^4  
  // SM masses in GeV
  
  const double SM_weight [9] = {1, 1, 1, 16./27., 16./27., 16./27., 1./27.,  1./27., 1./27.};
  const double SM_masses [9] = {0.5e-3,0.105,1.77,0.0023,1.28,173.07,0.0048,0.095,4.18};

  double d_re;
  double d_im;
  

  *re=0;
  *im=0;

  for (int i=0;i<=8;i++){
    me(s/(4*SM_masses[i]*SM_masses[i]),t/(4*SM_masses[i]*SM_masses[i]), &d_re, &d_im, exclude_loops);
    *re += d_re * SM_weight[i];
    *im += d_im * SM_weight[i];
  };

  //  cout<<*re<<"  "<<*im<<endl;


  // Add also the W contribution

  const double mW=80.385;  // W mass in GeV
 
 
  if (me==Mpppp_fermion){
    Mpppp_vector(s/(4*mW*mW),t/(4*mW*mW), &d_re, &d_im, exclude_loops);
  }
  else if (me==Mppmm_fermion){
    Mppmm_vector(s/(4*mW*mW),t/(4*mW*mW), &d_re, &d_im, exclude_loops);
  }
  else if (me==Mpmpm_fermion){
    Mpmpm_vector(s/(4*mW*mW),t/(4*mW*mW), &d_re, &d_im, exclude_loops);
  }
  else if (me==Mpmmp_fermion){
    Mpmmp_vector(s/(4*mW*mW),t/(4*mW*mW), &d_re, &d_im, exclude_loops);
  }
  else if (me==Mpppm_fermion){
    Mpppm_vector(s/(4*mW*mW),t/(4*mW*mW), &d_re, &d_im, exclude_loops);  
  }
   
  *re += d_re; 
  *im += d_im;
    
  *re *= 8 * alpha_em*alpha_em;
  *im *= 8 * alpha_em*alpha_em;
   
  // the factor of 8 is needed because of the conventions in
  // Costantini, DeTollis, Pistoni

  
  return;
    
};
Example #24
0
void BrowserApi::PlayFile(QString filename)
{
    MythEvent me(QString("MUSIC_COMMAND %1 PLAY_FILE '%2'")
                .arg(gCoreContext->GetHostName()).arg(filename));
    gCoreContext->dispatch(me);
}
Example #25
0
 ITestCaseRegistry& Hub::getTestCaseRegistry
 ()
 {
     return *me().m_testCaseRegistry.get();
 }
Example #26
0
 IRunner& Hub::getRunner
 ()
 {
     return *me().m_runner;
 }
Example #27
0
 IReporterRegistry& Hub::getReporterRegistry
 ()
 {
     return *me().m_reporterRegistry.get();
 }
Example #28
0
void BrowserApi::PlayURL(QString url)
{
    MythEvent me(QString("MUSIC_COMMAND %1 PLAY_URL %2")
                .arg(gCoreContext->GetHostName()).arg(url));
    gCoreContext->dispatch(me);
}
Example #29
0
void BrowserApi::PlayTrack(int trackID)
{
    MythEvent me(QString("MUSIC_COMMAND %1 PLAY_TRACK %2")
                .arg(gCoreContext->GetHostName()).arg(trackID));
    gCoreContext->dispatch(me);
}
Example #30
0
void AGOSEngine_Elvira2::oe2_moveDirn() {
	// 54: move direction
	int16 d = getVarOrByte();
	moveDirn(me(), d);
}