JBoolean
CBSearchTextDialog::BuildSearchFileList
	(
	JPtrArray<JString>* fileList,
	JPtrArray<JString>* nameList
	)
	const
{
	(JXGetApplication())->DisplayBusyCursor();

	fileList->SetCleanUpAction(JPtrArrayT::kDeleteAll);
	fileList->SetCompareFunction(JCompareStringsCaseSensitive);

	nameList->SetCleanUpAction(JPtrArrayT::kDeleteAll);
	nameList->SetCompareFunction(JCompareStringsCaseSensitive);

	if (itsMultifileCB->IsChecked())
		{
		const JPtrArray<JString>& fullNameList = itsFileList->GetFullNameList();

		const JSize count = fullNameList.GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			SaveFileForSearch(*(fullNameList.NthElement(i)), fileList, nameList);
			}
		}

	JBoolean ok = kJTrue;

	JString path, fileFilter, pathFilter;
	if (GetSearchDirectory(&path, &fileFilter, &pathFilter))
		{
		JRegex* fileRegex = NULL;
		JString regexStr;
		if (JDirInfo::BuildRegexFromWildcardFilter(fileFilter, &regexStr))
			{
			fileRegex = jnew JRegex(regexStr);
			assert( fileRegex != NULL );
			fileRegex->SetCaseSensitive(kJFalse);
			}

		JRegex* pathRegex = NULL;
		if (JDirInfo::BuildRegexFromWildcardFilter(pathFilter, &regexStr))
			{
			pathRegex = jnew JRegex(regexStr);
			assert( pathRegex != NULL );
			pathRegex->SetCaseSensitive(kJFalse);
			}

		JLatentPG pg(100);
		pg.VariableLengthProcessBeginning("Collecting files...", kJTrue, kJFalse);
		ok = SearchDirectory(path, fileRegex, pathRegex, fileList, nameList, pg);
		pg.ProcessFinished();

		jdelete fileRegex;
		jdelete pathRegex;
		}

	return JI2B( ok && !fileList->IsEmpty() );
}
Example #2
0
	cVillage(
		int a_Seed,
		int a_GridX, int a_GridZ,
		int a_OriginX, int a_OriginZ,
		int a_MaxRoadDepth,
		int a_MaxSize,
		int a_Density,
		cVillagePiecePool & a_Prefabs,
		cTerrainHeightGenPtr a_HeightGen
	) :
		super(a_GridX, a_GridZ, a_OriginX, a_OriginZ),
		m_Seed(a_Seed),
		m_Noise(a_Seed),
		m_MaxSize(a_MaxSize),
		m_Density(a_Density),
		m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, cChunkDef::Height - 1, a_OriginZ + a_MaxSize),
		m_Prefabs(a_Prefabs),
		m_HeightGen(a_HeightGen)
	{
		// Generate the pieces for this village; don't care about the Y coord:
		cBFSPieceGenerator pg(*this, a_Seed);
		pg.PlacePieces(a_OriginX, a_OriginZ, a_MaxRoadDepth + 1, m_Pieces);
		if (m_Pieces.empty())
		{
			return;
		}
	}
Example #3
0
void
MainWindow::on_actionInsertRandomPoints_triggered()
{
  QRectF rect = CGAL::Qt::viewportsBbox(&m_scene);
  CGAL::Qt::Converter<Kernel> convert;  
  Iso_rectangle_2 isor = convert(rect);
  CGAL::Random_points_in_iso_rectangle_2<Point_2> pg((isor.min)(), (isor.max)());
  bool ok = false;
  const int number_of_points = 
    QInputDialog::getInteger(this, 
                             tr("Number of random points"),
                             tr("Enter number of random points"),
			     100,
			     0,
			     (std::numeric_limits<int>::max)(),
			     1,
			     &ok);

  if(!ok) {
    return;
  }

  // wait cursor
  QApplication::setOverrideCursor(Qt::WaitCursor);
  for(int i = 0; i < number_of_points; ++i){
    m_sites.push_back(*pg++);
  }
  calculate_envelope();
  // default cursor
  QApplication::restoreOverrideCursor();
  emit(changed());
}
Example #4
0
void Test_PG_Output::testGet_JSON_vertex_ids_first() {
   ProductGraph pg(f,s);
    pg.setProductGraph(p);
    std::string result = PG_Output::get_JSON_vertex_ids_first(pg, clique);
    std::string check = "[\n\t10,\n\t20,\n\t30,\n\t40\n]";
    CPPUNIT_ASSERT(result == check);
}
Example #5
0
void Test_PG_Output::testGet_JSON_vertex_ids_second() {
   ProductGraph pg(f,s);
    pg.setProductGraph(p);
    std::string result = PG_Output::get_JSON_vertex_ids_second(pg, clique);
    std::string check = "[\n\t11,\n\t33,\n\t44,\n\t55\n]";
    CPPUNIT_ASSERT(result == check);
}
Example #6
0
void
MainWindow::on_actionInsertRandomPoints_triggered()
{
  QRectF rect = CGAL::Qt::viewportsBbox(&scene);
  CGAL::Qt::Converter<K> convert;
  Iso_rectangle_2 isor = convert(rect);
  CGAL::Random_points_in_iso_rectangle_2<Point_2> pg((isor.min)(), (isor.max)());
  CGAL::Random rnd(CGAL::get_default_random());

  const int number_of_points = 
    QInputDialog::getInt(this, 
                             tr("Number of random points"),
                             tr("Enter number of random points"), 100, 0);

  // wait cursor
  QApplication::setOverrideCursor(Qt::WaitCursor);
  std::vector<Weighted_point_2> points;
  points.reserve(number_of_points);
  for(int i = 0; i < number_of_points; ++i){
    Weighted_point_2 wp(*pg++, rnd.get_double(0, 500));
    points.push_back(wp);
  }
  dt.insert(points.begin(), points.end());
  // default cursor
  QApplication::setOverrideCursor(Qt::ArrowCursor);
  Q_EMIT( changed());
}
Example #7
0
Vector<Real, STATE_NF> State::scalar_y_flux(const _3Vec& X) const {
	Vector<Real, STATE_NF> flux = 0.0;
#ifdef USE_LZ
	flux[sx_index] = pg(X);
#endif
	return flux;
}
Example #8
0
DH::DH(RandomNumberGenerator &rng, unsigned int pbits)
{
	PrimeAndGenerator pg(1, rng, pbits);
	p = pg.Prime();
	g = pg.Generator();
	gpc.Precompute(p, g, ExponentBitLength(), 1);
}
Example #9
0
/* ----------------------------------------------------------------------------
 * When an Onion receives a mob, carried by Pikmin.
 */
void onion_fsm::receive_mob(mob* m, void* info1, void* info2) {
    size_t seeds = (size_t) info1;
    onion* o_ptr = (onion*) m;
    
    if(o_ptr->spew_queue == 0) {
        o_ptr->full_spew_timer.start();
        o_ptr->next_spew_timer.time_left = 0.0f;
    }
    o_ptr->spew_queue += seeds;
    
    particle p(
        PARTICLE_TYPE_BITMAP, m->x, m->y,
        24, 1.5, PARTICLE_PRIORITY_MEDIUM
    );
    p.bitmap = bmp_smoke;
    particle_generator pg(0, p, 15);
    pg.number_deviation = 5;
    pg.angle = 0;
    pg.angle_deviation = M_PI;
    pg.speed = 70;
    pg.speed_deviation = 10;
    pg.duration_deviation = 0.5;
    pg.emit(particles);
    
}
void
MainWindow::on_actionInsertRandomPoints_triggered()
{
  QRectF rect = CGAL::Qt::viewportsBbox(&scene);
  CGAL::Qt::Converter<K> convert;  
  Iso_rectangle_2 isor = convert(rect);
  CGAL::Random_points_in_iso_rectangle_2<Point_2> pg(isor.min(), isor.max());
  bool ok = false;
  const int number_of_points = 
    QInputDialog::getInteger(this, 
                             tr("Number of random points"),
                             tr("Enter number of random points"),
			     100,
			     0,
			     std::numeric_limits<int>::max(),
			     1,
			     &ok);

  if(!ok) {
    return;
  }

  // wait cursor
  QApplication::setOverrideCursor(Qt::WaitCursor);
  std::vector<Point_2> points;
  points.reserve(number_of_points);
  for(int i = 0; i < number_of_points; ++i){
    points.push_back(*pg++);
  }
  dt.insert(points.begin(), points.end());
  // default cursor
  QApplication::restoreOverrideCursor();
  emit(changed());
}
void VirtualKeyboardContainer::showVirtualKeyboard(QWidget *w)
{
    if ( w )
    {       
        QPoint pg(w->mapToGlobal( QPoint( 0, 0 ) ) );
        QPoint pd(parent->mapFromGlobal( pg ) );

        int origin = pd.y();
        int keyboardWidth = parent->width() - 10;
        int keyboardHeight = std::min(vk.heightForWidth( keyboardWidth ), parent->height() - w->height() - 5);

        QRect kRect;
        if ( origin + w->height() + keyboardHeight <= parent->height() )
        {
            // keyboard can be placed below the widget
            kRect = QRect( 0, origin + w->height(), keyboardWidth, keyboardHeight );
        }
        else
        if ( origin - keyboardHeight >= 0 )
        {
            // keyboard can be placed above the widget
            kRect = QRect( 0, origin - keyboardHeight, keyboardWidth, keyboardHeight );
        }
        else
        {
            // we need to resize the dialog to place the keyboard below the widget
            int remainHeight = parent->height() - origin - w->height();
            extraSize = keyboardHeight - remainHeight;
            QPoint p(parent->pos());
            parent->move( p.x(), p.y() - extraSize );
            QSize s(parent->size());
            parent->resize( s.width(), s.height() + extraSize );
            kRect = QRect( 0, origin + w->height(), keyboardWidth, keyboardHeight );
        }

        if ( kRect.isValid() )
        {
            vk.setGeometry( kRect );
            vk.raise();
            vk.show();
        }
        else
        {
            vk.hide();
        }
    }
    else
    {
        if ( extraSize > 0 )
        {
            QPoint p(parent->pos());
            parent->move( p.x(), p.y() + extraSize );
            QSize s(parent->size());
            parent->resize( s.width(), s.height() - extraSize );
            extraSize = 0;
        }
        vk.hide();
    }
    vk.setBuddy(w);
}
Example #12
0
void Test_PG_Output::testGet_vertex_ids_first() {
    ProductGraph pg(f,s);
    pg.setProductGraph(p);
    std::list<int> result = PG_Output::get_vertex_ids_first(pg, clique);
    result.sort();
    std::list<int> check = {10,20,30,40};
    CPPUNIT_ASSERT(result == check);
}
Example #13
0
void Test_PG_Output::testGet_vertex_ids_second() {
    ProductGraph pg(f,s);
    pg.setProductGraph(p);
    std::list<int> result = PG_Output::get_vertex_ids_second(pg, clique);
    result.sort();
    std::list<int> check = {11,33,44,55};
    CPPUNIT_ASSERT(result == check);
}
Example #14
0
void Test_PG_Output::testGet_common_second() {
    ProductGraph pg(f,s);
    pg.setProductGraph(p);
    std::list<unsigned long> result = PG_Output::get_common_second(pg, clique);
    result.sort();
    std::list<unsigned long> check = {0,2,3,4};
    CPPUNIT_ASSERT(result == check);
}
Example #15
0
ompl::geometric::PathGeometric ompl::control::PathControl::asGeometric(void) const
{
    PathControl pc(*this);
    pc.interpolate();
    geometric::PathGeometric pg(si_);
    pg.getStates().swap(pc.states_);
    return pg;
}
Example #16
0
ElGamalDecryptor::ElGamalDecryptor(RandomNumberGenerator &rng, unsigned int pbits)
{
	PrimeAndGenerator pg(1, rng, pbits);
	m_p = pg.Prime();
	m_g = pg.Generator();
	m_x.Randomize(rng, ExponentBitLength());
	m_gpc.SetModulusAndBase(m_p, m_g);
	m_y = m_gpc.Exponentiate(m_x);
	m_ypc.SetModulusAndBase(m_p, m_y);
}
Example #17
0
marathon_group::ptr_t mesos_state_t::add_group(const Json::Value& group, marathon_group::ptr_t to_group, const std::string& framework_id)
{
	Json::Value group_id = group["id"];
	if(!group_id.isNull())
	{
		std::string id = group_id.asString();
		std::ostringstream os;
		os << "Adding Marathon group [" + id + ']';
		if(to_group)
		{
			os << " to group [" + to_group->get_id() << ']';
		}
		g_logger.log(os.str(), sinsp_logger::SEV_INFO);
		marathon_group::ptr_t pg(new marathon_group(id));
		marathon_group::ptr_t p_group = add_or_replace_group(pg, to_group);
		if(!framework_id.empty())
		{
			Json::Value apps = group["apps"];
			if(!apps.isNull())
			{
				for(const auto& app : apps)
				{
					Json::Value app_id = app["id"];
					if(!app_id.isNull())
					{
						marathon_app::ptr_t p_app = get_app(app_id.asString());
						if(!p_app)
						{
							p_app = add_app(app, framework_id);
						}
						if(p_app)
						{
							p_group->add_or_replace_app(p_app);
							for(const auto& task : get_tasks(framework_id))
							{
								if(task.second->get_marathon_app_id() == app_id.asString())
								{
									add_task_to_app(p_app, task.first);
								}
							}
						}
						else
						{
							g_logger.log("An error occured adding app [" + app_id.asString() +
										"] to group [" + id + ']', sinsp_logger::SEV_ERROR);
						}
					}
				}
			}
		}
		return p_group;
	}
	return 0;
}
Example #18
0
NRDigestSigner::NRDigestSigner(RandomNumberGenerator &rng, unsigned int pbits)
{
    PrimeAndGenerator pg(1, rng, pbits, 2*DiscreteLogWorkFactor(pbits));
    p = pg.Prime();
    q = pg.SubPrime();
    g = pg.Generator();
    x.Randomize(rng, 2, q-2, Integer::ANY);
    gpc.Precompute(p, g, ExponentBitLength(), 1);
    y = gpc.Exponentiate(x);
    ypc.Precompute(p, y, ExponentBitLength(), 1);
}
Example #19
0
NRDigestSigner::NRDigestSigner(RandomNumberGenerator &rng, unsigned int pbits)
{
	PrimeAndGenerator pg(1, rng, pbits, 2*DiscreteLogWorkFactor(pbits));
	m_p = pg.Prime();
	m_q = pg.SubPrime();
	m_g = pg.Generator();
	m_x.Randomize(rng, 1, m_q-1, Integer::ANY);
	m_gpc.SetModulusAndBase(m_p, m_g);
	m_y = m_gpc.Exponentiate(m_x);
	m_ypc.SetModulusAndBase(m_p, m_y);
}
Example #20
0
QImage DkPageExtractionPlugin::drawPoly(const QSize & imgSize, const QPolygonF & poly) const {

	QImage img(imgSize, QImage::Format_RGB888);
	img.fill(QColor(0, 0, 0));

	QPainter pg(&img);
	pg.setBrush(QColor(255, 255, 255));
	pg.drawPolygon(poly);

	return img;
}
Example #21
0
int KQtTester::testPathgradientFillRectPath()
{
	QPainterPath path;
	path.addRect(0, 0, 500, 500);
	QPathGradient pg(path);
	pg.setColorAt(0, Qt::red);
	pg.setColorAt(0.5, Qt::green);
	pg.setColorAt(1.0, Qt::blue);

	return testFillRectPath(QBrush(pg));
}
MultiNdbWakeupHandler::~MultiNdbWakeupHandler()
{
  if (localWakeupMutexPtr)
  {
    NdbMutex_Destroy(localWakeupMutexPtr);
    localWakeupMutexPtr = NULL;
  }
  PollGuard pg(* wakeNdb->theImpl);
  bool rc = wakeNdb->theImpl->m_transporter_facade->
    unregisterForWakeup(wakeNdb->theImpl);
  require(rc);
}
Example #23
0
int platform_cpu_get_interrupt( elua_int_id id, elua_int_resnum resnum )
{
  elua_int_p_get_status pg;

  if( id < ELUA_INT_FIRST_ID || id > INT_ELUA_LAST )
    return PLATFORM_INT_INVALID;
  if( ( pg = elua_int_table[ id - ELUA_INT_FIRST_ID ].int_get_status ) == NULL )
    return PLATFORM_INT_NOT_HANDLED;
  if( id == INT_TMR_MATCH )
    return cmn_tmr_int_get_status( resnum );
  return pg( resnum );
}
JError
JDirInfo::BuildInfo()
{
	if (!JDirectoryReadable(*itsCWD))
		{
		return JAccessDenied(*itsCWD);
		}

	const JString origDir = JGetCurrentDirectory();

	JError err = JChangeDirectory(*itsCWD);
	if (!err.OK())
		{
		return err;
		}

	// clear old information

	itsDirEntries->CleanOut();

	// update instance variables

	JStripTrailingDirSeparator(itsCWD);		// keep Windows happy

	ACE_stat stbuf;
	ACE_OS::stat(*itsCWD, &stbuf);
	itsIsValidFlag    = kJTrue;
	itsIsWritableFlag = JDirectoryWritable(*itsCWD);
	itsModTime        = stbuf.st_mtime;
	itsStatusTime     = stbuf.st_ctime;

	JAppendDirSeparator(itsCWD);

	// process files in the directory

	JLatentPG pg(itsContentRegex == NULL ? 100 : 10);
	if (itsPG != NULL)
		{
		pg.SetPG(itsPG, kJFalse);
		}
	pg.VariableLengthProcessBeginning("Scanning directory...", kJTrue, kJFalse);

	BuildInfo1(pg);

	pg.ProcessFinished();

	err = JChangeDirectory(origDir);
	assert_ok( err );

	ApplyFilters(kJFalse);
	return JNoError();
}
MultiNdbWakeupHandler::MultiNdbWakeupHandler(Ndb* _wakeNdb)
  : wakeNdb(_wakeNdb)
{
  localWakeupMutexPtr = NdbMutex_Create();
  assert(localWakeupMutexPtr);
  /* Register the waiter Ndb to receive wakeups for all Ndbs in the group */
  PollGuard pg(* wakeNdb->theImpl);
  woken = false;
  ignore_wakeups();
  bool rc = wakeNdb->theImpl->m_transporter_facade->registerForWakeup(wakeNdb->theImpl);
  require(rc);
  wakeNdb->theImpl->wakeHandler = this;
}
Example #26
0
QStringList ProfileManager::availableProfiles(QString profileType)
{
    KConfigGroup group(krConfig, "Private");
    QStringList profiles = group.readEntry(profileType, QStringList());
    QStringList profileNames;

    for (int i = 0; i != profiles.count() ; i++) {
        KConfigGroup pg(krConfig, profileType + " - " + profiles[ i ]);
        profileNames.append(pg.readEntry("Name"));
    }

    return profileNames;
}
Example #27
0
void PaletteGenerator_Test::initial()
{
    Doc doc(this, m_fixtureDefCache);
    QList <Fixture*> list;
    list << new Fixture(&doc);
    list << new Fixture(&doc);
    list << new Fixture(&doc);

    PaletteGenerator pg(&doc, list);
    QCOMPARE(pg.m_doc, &doc);
    QCOMPARE(pg.m_fixtures.size(), 3);
    QCOMPARE(pg.m_scenes.size(), 0);
}
Example #28
0
Vector<Real, STATE_NF> State::vector_z_flux(const _3Vec& X, const _3Vec& V) const {
	Vector<Real, STATE_NF> flux = 0.0;
	Real v, v0, p;
	v = vz(X);
	v0 = v - V[2];
	p = pg(X);
	for (int i = 0; i < STATE_NF; i++) {
		flux[i] = (*this)[i] * v0;
	}
	flux[sz_index] += p;
	flux[et_index] += v * p;
	return flux;
}
// create per-port, per-priority_group instance
static t_std_error create_port_priority_group(hal_ifindex_t port_id,
                                    uint8_t local_id,
                                    ndi_obj_id_t ndi_priority_group_id)
{
    interface_ctrl_t intf_ctrl;

    if (nas_qos_get_port_intf(port_id, &intf_ctrl) != true) {
        EV_LOG_TRACE(ev_log_t_QOS, ev_log_s_MAJOR, "QOS",
                     "Cannot find NPU id for ifIndex: %d",
                      port_id);
        return NAS_QOS_E_FAIL;
    }

    nas_qos_switch *switch_p = nas_qos_get_switch_by_npu(intf_ctrl.npu_id);
    if (switch_p == NULL) {
        EV_LOG_TRACE(ev_log_t_QOS, ev_log_s_MAJOR, "QOS",
                     "switch_id of ifindex: %u cannot be found/created",
                     port_id);
        return NAS_QOS_E_FAIL;
    }

    try {
        // create the priority_group and add the priority_group to switch
        nas_obj_id_t priority_group_id = switch_p->alloc_priority_group_id();
        nas_qos_priority_group_key_t key;
        key.port_id = intf_ctrl.if_index;
        key.local_id = local_id;
        nas_qos_priority_group pg (switch_p, key);

        pg.set_priority_group_id(priority_group_id);
        pg.add_npu(intf_ctrl.npu_id);
        pg.set_ndi_port_id(intf_ctrl.npu_id, intf_ctrl.port_id);
        pg.set_ndi_obj_id(ndi_priority_group_id);
        pg.mark_ndi_created();

        EV_LOG_TRACE(ev_log_t_QOS, ev_log_s_MAJOR, "QOS",
                     "NAS priority_group_id 0x%016lX is allocated for priority_group:"
                     "local_qid %u, ndi_priority_group_id 0x%016lX",
                     priority_group_id, local_id, ndi_priority_group_id);
       switch_p->add_priority_group(pg);
    }
    catch (...) {
        return NAS_QOS_E_FAIL;
    }

    return STD_ERR_OK;

}
Example #30
0
File: tpio.cpp Project: nyaxt/ptnk
page_id_t
TPIO::RebaseTPIOTxSession::rebaseForceVisit(page_id_t pgid)
{
	m_visited.insert(pgid);
	
#ifdef VERBOSE_REBASE
	std::cout << "rebase visit pgid: " << pgid << std::endl;
#endif

	Page pg(readPage(pgid));

	mod_info_t mod;
	pg.updateLinks(&mod, this);
	
	return mod.isValid() ? mod.idOvr : pgid;
}