Exemple #1
0
int main(){

		int n;
			while(scanf("%d",&n) == 1&&n){

						double x[109], y[109];
								double sum = 0;
										for(int i = 1; i<= n; i++){

														scanf("%lf%lf",&x[i],&y[i]);
																}
												
												for(int i = 2;i < n; i++){

																sum += area(x[1],y[1],x[i],y[i],x[i+1],y[i+1]);
																		}
													
														printf("%.1lf\n",sum);
															}
				return 0;
}
cell AMX_NATIVE_CALL Natives::CreateDynamicCircle(AMX *amx, cell *params)
{
	CHECK_PARAMS(6, "CreateDynamicCircle");
	if (core->getData()->getGlobalMaxItems(STREAMER_TYPE_AREA) == core->getData()->areas.size())
	{
		return 0;
	}
	int areaID = Item::Area::identifier.get();
	Item::SharedArea area(new Item::Area);
	area->amx = amx;
	area->areaID = areaID;
	area->type = STREAMER_AREA_TYPE_CIRCLE;
	area->position = Eigen::Vector2f(amx_ctof(params[1]), amx_ctof(params[2]));
	area->size = amx_ctof(params[3]) * amx_ctof(params[3]);
	Utility::addToContainer(area->worlds, static_cast<int>(params[4]));
	Utility::addToContainer(area->interiors, static_cast<int>(params[5]));
	Utility::addToContainer(area->players, static_cast<int>(params[6]));
	core->getGrid()->addArea(area);
	core->getData()->areas.insert(std::make_pair(areaID, area));
	return static_cast<cell>(areaID);
}
Exemple #3
0
void
pcl::EarClipping::triangulate (const Vertices& vertices, PolygonMesh& output)
{
  const int n_vertices = vertices.vertices.size ();

  if (n_vertices <= 3)
    return;

  std::vector<uint32_t> remaining_vertices (n_vertices);
  if (area (vertices.vertices) > 0) // clockwise?
    remaining_vertices = vertices.vertices;
  else
    for (int v = 0; v < n_vertices; v++)
      remaining_vertices[v] = vertices.vertices[n_vertices - 1 - v];

  // Avoid closed loops.
  if (remaining_vertices.front () == remaining_vertices.back ())
    remaining_vertices.erase (remaining_vertices.end () - 1);

  // null_iterations avoids infinite loops if the polygon is not simple.
  for (int u = remaining_vertices.size () - 1, null_iterations = 0;
      remaining_vertices.size () > 2 && null_iterations < (int)(remaining_vertices.size()*2);
      ++null_iterations, u = (u+1) % remaining_vertices.size ())
  {
    int v = (u + 1) % remaining_vertices.size ();
    int w = (u + 2) % remaining_vertices.size ();

    if (isEar (u, v, w, remaining_vertices))
    {
      Vertices triangle;
      triangle.vertices.resize (3);
      triangle.vertices[0] = remaining_vertices[u];
      triangle.vertices[1] = remaining_vertices[v];
      triangle.vertices[2] = remaining_vertices[w];
      output.polygons.push_back (triangle);
      remaining_vertices.erase (remaining_vertices.begin () + v);
      null_iterations = 0;
    }
  }
}
Exemple #4
0
void VolumeSlider::paintEvent(QPaintEvent *event)
{
	QWidget::paintEvent(event);

	QPainter painter(this);

	// Draw the background for the slider
	painter.drawImage(QPoint(margin(), margin()), mBackgroundSlider);

	float sliderValue = mActiveSlider.width() * ( value() - minimum() ) / ( maximum() - minimum() );

	// Calculate from the slider value how much of the slider to draw
	QRectF area(0, 0, sliderValue, mActiveSlider.height());

	// Only draw the value bar if we have over 0 width (otherwise it will draw the whole bar)
	if( (int)sliderValue > 0 )
	{
		// Draw the active or inactive slider depending on if the window is active
		if( !isEnabled() )
		{
			painter.drawImage(QPoint(margin(), margin()), mDisabledSlider, area);
		}
		else if( isActiveWindow() )
		{
			painter.drawImage(QPoint(margin(), margin()), mActiveSlider, area);
		}
		else
		{
			painter.drawImage(QPoint(margin(), margin()), mInactiveSlider, area);
		}
	}

	// Draw the border for the slider
	painter.drawImage(QPoint(margin(), margin()), mBorderSlider);

	// Draw the text
	painter.setFont(mSliderFont);
	painter.setBrush( palette().brush(QPalette::WindowText) );
	painter.drawText( margin(), margin() + mSliderFont.pixelSize(), tr("%1%").arg( (int)(100 * ( value() - minimum() ) / ( maximum() - minimum() )) ) );
};
autoLPC VocalTractTier_to_LPC (VocalTractTier me, double timeStep) {
	try {
		if (my d_vocalTracts -> size == 0) {
			Melder_throw (U"Empty VocalTractTier");
		}
		long numberOfFrames = (long) floor ((my xmax - my xmin) / timeStep);
		VocalTractPoint vtp = (VocalTractPoint) my d_vocalTracts -> item[1];
		long numberOfSections = vtp -> d_vocalTract -> nx;
		double samplingPeriod = 1.0 / (1000.0 * numberOfSections);
		autoNUMmatrix<double> area (1, numberOfFrames, 1, numberOfSections + 1);
		autoNUMvector<double> areavec (1, numberOfSections + 1);
		autoLPC thee = LPC_create (my xmin, my xmax, numberOfFrames, timeStep, timeStep / 2, numberOfSections, samplingPeriod);
		// interpolate each section
		for (long isection = 1; isection <= numberOfSections; isection++) {
			autoRealTier sectioni = RealTier_create (my xmin, my xmax);
			for (long i = 1; i <= my d_vocalTracts -> size; i++) {
				VocalTractPoint vtpi = (VocalTractPoint) my d_vocalTracts -> item[i];
				double areai = vtpi -> d_vocalTract -> z[1][isection];
				RealTier_addPoint (sectioni.peek(), vtpi -> number, areai);
			}
			for (long iframe = 1; iframe <= numberOfFrames; iframe++) {
				double time = thy x1 + (iframe - 1) * thy dx;
				area[iframe][isection] = RealTier_getValueAtTime (sectioni.peek(), time);
				area[iframe][numberOfSections + 1] = 0.0001; // normalisation is area[n+1] = 0.0001
			}
		}
		for (long iframe = 1; iframe <= numberOfFrames; iframe++) {
			LPC_Frame frame = &thy d_frames[iframe];
			LPC_Frame_init (frame, numberOfSections);
			for (long i = 1; i <= numberOfSections + 1; i++) {
				areavec[i] = area[iframe][numberOfSections + 1 - i];
			}
			NUMlpc_area_to_lpc (areavec.peek(), numberOfSections + 1, frame -> a);
			frame -> gain = 1e-6; // something
		}
		return thee;
	} catch (MelderError) {
		Melder_throw (U": not converted to LPC.");
	}
}
Exemple #6
0
void 
QuadtreeNode::build_quadtree(OctreeNode* o, double regularity)
{
   const double THRED_RATIO = 0.3;
   const double THRED_EDGE = THRED_RATIO * o->dim().length();
   /*
   if (!(o->contains(_v1) && o->contains(_v2))
       && o->contains(_v3)) {
       */

   //I've replaced that conditional with this one:
   // -Karol

 if (!(o->contains(_v1) && o->contains(_v2)
       && o->contains(_v3))) {

      if (max(max(_v1.dist(_v2), _v2.dist(_v3)), _v3.dist(_v1))
          < THRED_EDGE || !o->overlaps(bface_bbox(this))) {
         _leaf = true;
         _in_cell = false;
         return;
      }
   }

   if (area() < o->get_area()/20) {
      _leaf = true;
      return;
   }

   //Wpt nearest = nearest_pt(o->center());
   //Wpt farthest = farthest_pt(o->center());
   //double smallest = distr_func(regularity, farthest.dist(o->center()));
   //double largest = distr_func(regularity, nearest.dist(o->center()));
   //double ratio = (largest - smallest) / smallest;
   //if (ratio < THRED_RATIO) {
   //   _leaf = true;
   //   return;
   //}
   subdivide(o, regularity);
}
//------------------------------------------------------------------------------//
void InventoryItem::onMoved(ElementEventArgs& e)
{
    invalidate();

    DragContainer::onMoved(e);

    InventoryReceiver* receiver = dynamic_cast<InventoryReceiver*>(d_dropTarget);

    if (receiver)
    {
        const Sizef square_size(receiver->squarePixelSize());
        Rectf area(getUnclippedOuterRect().get());
        area.offset(0.5f * glm::vec2(square_size.d_width, square_size.d_height));
        const int x = receiver->gridXLocationFromPixelPosition(area.left());
        const int y = receiver->gridYLocationFromPixelPosition(area.top());

        d_validDropTarget = receiver->itemWillFitAtLocation(*this, x, y);
        return;
    }

    d_validDropTarget = false;
}
//==============================================================================
void MainContentComponent::resized()
{
#if DEBUG_FLAG
    test.setBounds(500, 500, 600, 200);
#endif
    //> menu bar
    Rectangle<int> area(getBounds());
    mMenuBar->setBounds(area.removeFromTop(LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight()));

    //> make a list of our child components that we want to reposition
    Component *comps[] = { &mFileTree, &mResizerBar, &mImgViewer };

    //> this will position the components to fit
    //> horizontally into the rectangle provided.
    const int pxShift = 4;
    Rectangle<int> r(getBounds().reduced(pxShift));
    
    mStretchableManager.layOutComponents(comps, numElementsInArray(comps),
        r.getX(), r.getY() + LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight(),
        r.getWidth(), r.getHeight() - LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight(),
        false, true);
}
Exemple #9
0
void BpdeMainWindow::loadSource()
{
    Bpde::BArea area(sourceFileEdit->text().toStdString());
    delete solver;
    if (openMPEnabled->isChecked()){
        solver = Bpde::BSolverBuilder::getInstance()->getSolver(
                sourceFileEdit->text().toStdString(), Bpde::ParallelizationMethod::OPENMP,
                threadsLineEdit->text().toInt());
    }
    else {
        std::vector<cl::Device> dev;
        dev.push_back(devices[deviceComboBox->currentIndex()]);
        solver = Bpde::BSolverBuilder::getInstance()->getSolver(
                    sourceFileEdit->text().toStdString(), Bpde::ParallelizationMethod::OPENCL,
                    dev);
    }
    solver->setTimeStep(0);
    solver->addExtraIterations(-area.T);

    assignAreaToR(area);
    plot();
}
Exemple #10
0
	// creates the buffer from the specified area.
	// old data is cleared.
	// Note : data values are not initialized, use the fill() function if necessary.
	void create(u32 psizeX, u32 psizeY)
	{
		// Delete old data
		if(m_data != nullptr)
		{
			delete[] m_data;
		}

		m_sizeX = psizeX;
		m_sizeY = psizeY;

		if(m_sizeX == 0 || m_sizeY == 0)
		{
			// Empty array
			m_data = nullptr;
		}
		else
		{
			// Allocate memory
			m_data = new T[area()];
		}
	}
cell AMX_NATIVE_CALL Natives::CreateDynamicCuboid(AMX *amx, cell *params)
{
	CHECK_PARAMS(9, "CreateDynamicCuboid");
	if (core->getData()->getGlobalMaxItems(STREAMER_TYPE_AREA) == core->getData()->areas.size())
	{
		return 0;
	}
	int areaID = Item::Area::identifier.get();
	Item::SharedArea area(new Item::Area);
	area->amx = amx;
	area->areaID = areaID;
	area->type = STREAMER_AREA_TYPE_CUBOID;
	area->position = Box3D(Eigen::Vector3f(amx_ctof(params[1]), amx_ctof(params[2]), amx_ctof(params[3])), Eigen::Vector3f(amx_ctof(params[4]), amx_ctof(params[5]), amx_ctof(params[6])));
	boost::geometry::correct(boost::get<Box3D>(area->position));
	area->size = static_cast<float>(boost::geometry::comparable_distance(Eigen::Vector2f(boost::get<Box3D>(area->position).min_corner()[0], boost::get<Box3D>(area->position).min_corner()[1]), Eigen::Vector2f(boost::get<Box3D>(area->position).max_corner()[0], boost::get<Box3D>(area->position).max_corner()[1])));
	Utility::addToContainer(area->worlds, static_cast<int>(params[7]));
	Utility::addToContainer(area->interiors, static_cast<int>(params[8]));
	Utility::addToContainer(area->players, static_cast<int>(params[9]));
	core->getGrid()->addArea(area);
	core->getData()->areas.insert(std::make_pair(areaID, area));
	return static_cast<cell>(areaID);
}
void
QuadLight::renderGL() {
    Vector3 center = (A() + C()) / 2;
    glColor3f(1, 1, 1);
    glPushMatrix();
    //glTranslatef(center[0], center[1], center[2]);
    float s = 1.0 / 4.0;
    Vector3 n = m_mesh->normal(m_mesh->quadNormalIndex(m_index).m_a)*sqrt(area())*s;

    glBegin(GL_LINES);
    glVertex3f(center[0], center[1], center[2]);
    glVertex3f(center[0] + n[0], center[1] + n[1], center[2] + n[2]);
    glEnd();

    glBegin(GL_QUADS);
    glVertex3f(A()[0], A()[1], A()[2]);
    glVertex3f(B()[0], B()[1], B()[2]);
    glVertex3f(C()[0], C()[1], C()[2]);
    glVertex3f(D()[0], D()[1], D()[2]);
    glEnd();
    glPopMatrix();
}
Exemple #13
0
    void FalagardSlider::updateThumb(void)
    {
        // get area the thumb is supposed to use as it's area.
        const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName);
        Rect area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*this));
        // get accesss to the thumb
        Thumb* theThumb = static_cast<Thumb*>(WindowManager::getSingleton().getWindow(getName() + "__auto_thumb__"));

        // get base location for thumb widget
        Point thumbPosition(area.d_left, area.d_top);

        // Is this a vertical slider
        if (d_vertical)
        {
            // pixel extent of total available area the thumb moves in
            float slideExtent = area.getHeight() - theThumb->getAbsoluteHeight();
            // Set range of motion for the thumb widget
            theThumb->setVertRange(absoluteToRelativeY_impl(this, area.d_top), absoluteToRelativeY_impl(this, area.d_top + slideExtent));

            // calculate vertical positon for thumb
            float thumbOffset = d_value * (slideExtent / d_maxValue);
            thumbPosition.d_y += d_reversed ? thumbOffset : slideExtent - thumbOffset;
        }
        // Horizontal slider
        else
        {
            // pixel extent of total available area the thumb moves in
            float slideExtent = area.getWidth() - theThumb->getAbsoluteWidth();
            // Set range of motion for the thumb widget
            theThumb->setHorzRange(absoluteToRelativeX_impl(this, area.d_left), absoluteToRelativeX_impl(this, area.d_left + slideExtent));

            // calculate horizontal positon for thumb
            float thumbOffset = d_value * (slideExtent / d_maxValue);
            thumbPosition.d_x += d_reversed ? slideExtent - thumbOffset : thumbOffset;
        }

        // set new position for thumb.
        theThumb->setPosition(absoluteToRelative_impl(this, thumbPosition));
    }
void VoicePrint::scopeEvent(float *data, int bands)
{
	// save cpu
	if(isHidden()) return;

	QPainter paint(&mBuffer);
	// each square has a width of mSegmentWidth
	float brightness = float(bands * mSegmentWidth);
	for (int i=0; i<bands ; i++)
	{
		float b=data[bands-i-1]+1.0;
		// the more bands there are, the dimmer each becomes
		b=log10(b)/log(2) * 16 * brightness;
		int band=int(b);
		if (band>255) band=255;
		else if (band<0) band=0;
		
		QColor area(averageByIntensity(mLowColor, mHighColor, band));

		int bandTop=i*height()/bands, bandBottom=(i+1)*height()/bands;
		paint.fillRect(mOffset, bandTop, mSegmentWidth,bandBottom-bandTop,area);
	}
	
	int newOffset = mOffset+mSegmentWidth;
	if (newOffset>QWidget::width()) newOffset=0;
	paint.fillRect(newOffset, 0, mSegmentWidth, height(), mProgress);

	// redraw changes with the minimum amount of work
	if(newOffset != 0)
	{
		repaint(mOffset,0,mSegmentWidth*2,height(),false);
	}
	else
	{
		repaint(mOffset,0,mSegmentWidth,height(),false);
		repaint(newOffset,0,mSegmentWidth,height(),false);
	}
	mOffset = newOffset;
}
Exemple #15
0
void button::draw_first(image *screen)
{
  if (pressed)
    draw(0,screen);
  else
  {

    int x1,y1,x2,y2;
    area(x1,y1,x2,y2);


    if (up)
    {
      screen->rectangle(x1,y1,x2,y2,wm->black());
//      screen->widget_bar(,wm->bright_color(),wm->medium_color(),wm->dark_color());
      screen->widget_bar(x1+1,y1+1,x2-1,y2-1,wm->bright_color(),wm->medium_color(),wm->dark_color());
      if (text)
      {
        wm->font()->put_string(screen,x+4,y+5,text,wm->black());
        wm->font()->put_string(screen,x+3,y+4,text);
      }
      else visual->put_image(screen,x+3,y+3,1);
    } else
    {
      screen->line(x1,y1,x2,y1,wm->dark_color());
      screen->line(x1,y1,x1,y2,wm->dark_color());
      screen->line(x2,y1+1,x2,y2,wm->bright_color());
      screen->line(x1+1,y2,x2,y2,wm->bright_color());
      screen->bar(x1+1,y1+1,x2-1,y2-1,wm->medium_color());
      if (visual)
        visual->put_image(screen,x1+3,y1+3,1);
      else
      {
        wm->font()->put_string(screen,x+4,y+5,text,wm->black());
        wm->font()->put_string(screen,x+3,y+4,text);
      }
    }
  }
}
void EFXPreviewArea_Test::draw()
{
    EFXPreviewArea area(NULL);
    area.show();

    QPolygon poly(5);
    poly.setPoint(0, QPoint(0, 0));
    poly.setPoint(1, QPoint(10, 10));
    poly.setPoint(2, QPoint(20, 20));
    poly.setPoint(3, QPoint(128, 128));
    poly.setPoint(4, QPoint(255, 255));
    area.setPoints(poly);

    area.draw();
    QCOMPARE(area.m_iter, 0);
    QCOMPARE(area.m_timer.isActive(), true);
    QCOMPARE(area.m_timer.interval(), 20);

    QTest::qWait(300);
    QVERIFY(area.m_iter >= 5);
    QCOMPARE(area.m_timer.isActive(), false);
}
Exemple #17
0
	UIEnterNumber::UIEnterNumber(std::string q, std::function<void(int32_t)> nh, int32_t mi, int32_t ma, int32_t de)
		: UINotice(q) {

		numhandler = nh;
		min = mi;
		max = ma;

		int16_t belowtext = UINotice::box2offset();

		nl::node src = nl::nx::ui["Basic.img"];

		buttons[OK] = std::make_unique<MapleButton>(src["BtOK4"], 90, belowtext + 21);
		buttons[CANCEL] = std::make_unique<MapleButton>(src["BtCancel4"], 132, belowtext + 21);

		Rectangle<int16_t> area(26, 232, belowtext, belowtext + 20);
		numfield = Textfield(Text::A11M, Text::LEFT, Text::LIGHTGREY, area, 9);
		numfield.set_state(Textfield::FOCUSED);
		numfield.change_text(std::to_string(de));
		numfield.set_enter_callback([&](std::string numstr){
			handlestring(numstr);
		});
	}
/*************************************************************************
	move the window's top edge by 'delta'.  The rest of the window
	does not move, thus this changes the size of the Window.
*************************************************************************/
void FrameWindow::moveTopEdge(float delta)
{
    float orgHeight = d_pixelSize.d_height;
    URect area(d_area);

    // ensure that we only size to the set constraints.
    //
    // NB: We are required to do this here due to our virtually unique sizing nature; the
    // normal system for limiting the window size is unable to supply the information we
    // require for updating our internal state used to manage the dragging, etc.
    float maxHeight(d_maxSize.d_y.asAbsolute(System::getSingleton().getRenderer()->getHeight()));
    float minHeight(d_minSize.d_y.asAbsolute(System::getSingleton().getRenderer()->getHeight()));
    float newHeight = orgHeight - delta;

    if (newHeight > maxHeight)
        delta = orgHeight - maxHeight;
    else if (newHeight < minHeight)
        delta = orgHeight - minHeight;

    // ensure adjustment will be whole pixel
    float adjustment = PixelAligned(delta);

    if (d_vertAlign == VA_BOTTOM)
    {
        area.d_max.d_y.d_offset -= adjustment;
    }
    else if (d_vertAlign == VA_CENTRE)
    {
        area.d_max.d_y.d_offset -= adjustment * 0.5f;
        area.d_min.d_y.d_offset += adjustment * 0.5f;
    }
    else
    {
        area.d_min.d_y.d_offset += adjustment;
    }

    setArea_impl(area.d_min, area.getSize(), d_vertAlign == VA_TOP);
}
/*************************************************************************
	move the window's left edge by 'delta'.  The rest of the window
	does not move, thus this changes the size of the Window.	
*************************************************************************/
void FrameWindow::moveLeftEdge(float delta)
{
    float orgWidth = d_pixelSize.d_width;
    URect area(d_area);

    // ensure that we only size to the set constraints.
    //
    // NB: We are required to do this here due to our virtually unique sizing nature; the
    // normal system for limiting the window size is unable to supply the information we
    // require for updating our internal state used to manage the dragging, etc.
    float maxWidth(d_maxSize.d_x.asAbsolute(System::getSingleton().getRenderer()->getWidth()));
    float minWidth(d_minSize.d_x.asAbsolute(System::getSingleton().getRenderer()->getWidth()));
    float newWidth = orgWidth - delta;

    if (newWidth > maxWidth)
        delta = orgWidth - maxWidth;
    else if (newWidth < minWidth)
        delta = orgWidth - minWidth;

    // ensure adjustment will be whole pixel
    float adjustment = PixelAligned(delta);

    if (d_horzAlign == HA_RIGHT)
    {
        area.d_max.d_x.d_offset -= adjustment;
    }
    else if (d_horzAlign == HA_CENTRE)
    {
        area.d_max.d_x.d_offset -= adjustment * 0.5f;
        area.d_min.d_x.d_offset += adjustment * 0.5f;
    }
    else
    {
        area.d_min.d_x.d_offset += adjustment;
    }

    setArea_impl(area.d_min, area.getSize(), d_horzAlign == HA_LEFT);
}
void blur_channels_node_t::do_process( const render::context_t& context)
{
    Imath::Box2i area( ImathExt::intersect( input_as<image_node_t>()->defined(), defined()));

    if( area.isEmpty())
		return;

    int iters = get_value<float>( param( "iters"));

    Imath::V2f r_radius = get_value<Imath::V2f>( param( "r_radius")) / iters;
    Imath::V2f g_radius = get_value<Imath::V2f>( param( "g_radius")) / iters;
    Imath::V2f b_radius = get_value<Imath::V2f>( param( "b_radius")) / iters;
    Imath::V2f a_radius = get_value<Imath::V2f>( param( "a_radius")) / iters;

	r_radius = adjust_blur_size( r_radius, context.subsample);
	g_radius = adjust_blur_size( g_radius, context.subsample);
	b_radius = adjust_blur_size( b_radius, context.subsample);
	a_radius = adjust_blur_size( a_radius, context.subsample);

    boost::gil::copy_pixels( input_as<image_node_t>()->const_subimage_view( area), subimage_view( area));	
	
	image::buffer_t buffer( image_view().height(), image_view().width(), 1);
	image::gray_image_view_t tmp = buffer.gray_view();

    blur_border_mode bmode = ( blur_border_mode) get_value<int>( param( "border"));
	
	boost::gil::fill_pixels( tmp, 0.0f);
    blur_channel( 0, area, tmp, r_radius, iters, bmode);

	boost::gil::fill_pixels( tmp, 0.0f);
    blur_channel( 1, area, tmp, g_radius, iters, bmode);

	boost::gil::fill_pixels( tmp, 0.0f);
    blur_channel( 2, area, tmp, b_radius, iters, bmode);

	boost::gil::fill_pixels( tmp, 0.0f);
    blur_channel( 3, area, tmp, a_radius, iters, bmode);
}
Exemple #21
0
void c_video_screen::dispatch_render(c_time_cyclic& timer)
{
    // Acquire context
    if (!m_context->make_current(m_window)) {
        std::cout << boost::format("Screen (%1%): Failed to acquire OpenGL context!") % m_name << std::endl;
        return;
    }
    g_opengl_check();

    // Time pulses
    const float time_current = SDL_GetTicks() / 1000.f;
    const float time_elapsed = time_current - m_time;
    m_context->cegui_system().injectTimePulse(time_elapsed);
    m_cegui->context().injectTimePulse(time_elapsed);
    m_time = time_current;

    // Viewport drawing
    for (auto& view : m_view_list)
        view->dispatch(timer);
    g_opengl_check();

    // Init screen drawing
    gl_init();

    // CEGUI
    CEGUI::Rectf area(CEGUI::Vector2f(0.0f, 0.0f), CEGUI::Sizef(m_window_width, m_window_height));
    m_cegui->target().setArea(area);
    //m_cegui->target().activate();
    m_context->cegui_renderer().beginRendering();
    m_cegui->context().draw();
    m_context->cegui_renderer().endRendering();
    //m_cegui->target().deactivate();
    g_opengl_check();

    // Swap buffers
    SDL_GL_SwapWindow(m_window);
    g_opengl_check();
}
Exemple #22
0
  static LifeV::Real volume(std::string& filename,
                            const reffem_t& reffem,
                            const geomap_t& geomap,
                            comm_t comm)
  {  
    bool ilead = (comm->MyPID() == 0);

    baremesh_t baremesh;

    if (!LifeV::MeshIO::ReadGmshFile(filename, baremesh, 1, ilead))
      return false;

    // Convert the mesh
    boost::shared_ptr<mesh_t> mesh (new mesh_t(comm));
    LifeV::convertBareMesh (baremesh, *mesh, ilead);

    // The current finite element
    LifeV::CurrentFE curFE (reffem, geomap, LifeV::quadRuleQuad4pt);
    // List of all the elements
    elms_t& elms = mesh->elementList();

    LifeV::Real area(0.0);

    // For every element ...
    for (elms_citer it = elms.begin(); it != elms.end(); ++it)
    {
      // Need to update only the weighted determinant
      curFE.update(*it, LifeV::UPDATE_WDET);

      const LifeV::UInt nbQuadPt(curFE.nbQuadPt());
      // Loop on the quadrature nodes
      for (LifeV::UInt iQuadPt(0); iQuadPt < nbQuadPt; ++iQuadPt)
      {
        area += curFE.wDetJacobian(iQuadPt);
      }
    }
    return area;
  }
Exemple #23
0
void HandleMessage_DrawText(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	uint16_t	x = message.ReadU16();
	uint16_t	y = message.ReadU16();
	uint16_t	w = message.ReadU16();
	uint16_t	h = message.ReadU16();
	uint16_t	font_id = message.ReadU16();
	::std::string	str = message.ReadString();
	_SysDebug("_DrawText: (%i (%i,%i) %ix%i Font%i \"%s\")", win_id, x, y, w, h, font_id, str.c_str());
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_DrawText: Bad window");
	}
	
	// 1. Get font from client structure
	IFontFace& fontface = client.GetFont(font_id);
	
	// 2. Render
	CRect	area(x, y, w, h);
	fontface.Render(win->m_surface, area, str, h);
}
Exemple #24
0
	bool MarkupBase::onSized(bool update)
	{
		if(update)
		{
			Rect area(m_area);
			area.m_left += m_margin.m_left;
			area.m_right -= m_margin.m_right;
			area.m_top += m_margin.m_top;
			area.m_bottom -= m_margin.m_bottom;
			if(area.m_right - area.m_left >= m_minWidth)
			{
				if(m_viewport != area)
				{
					clear();
					m_viewport = area;
					parseBBCodes();
				}
			}
			else
				clear();
		}
		return BaseWindow::onSized(false);
	}
void EFXPreviewArea_Test::setPoints()
{
    EFXPreviewArea area(NULL);
    area.show();

    QPolygon poly(5);
    poly.setPoint(0, QPoint(0, 0));
    poly.setPoint(1, QPoint(10, 10));
    poly.setPoint(2, QPoint(20, 20));
    poly.setPoint(3, QPoint(128, 128));
    poly.setPoint(4, QPoint(255, 255));

    area.setPoints(poly);

    QSize size = QSize(200, 200);
    area.resize(size);
    QCOMPARE(area.m_original, poly);
    QCOMPARE(area.m_points[0], QPoint(0, 0));
    QCOMPARE(area.m_points[1], QPoint(7, 7));
    QCOMPARE(area.m_points[2], QPoint(15, 15));
    QCOMPARE(area.m_points[3], QPoint(100, 100));
    QCOMPARE(area.m_points[4], QPoint(200, 200));
}
Exemple #26
0
void MetronomeBar::paintEvent(QPaintEvent*)
{
  QPainter painter(this);

  painter.setBrush(Qt::white);
  painter.drawRect(rect());

  // Avoid divide-by-zero when there is nothing to paint
  if (bpi == 0) {
    return;
  }

  qreal beatWidth = width() / (qreal)bpi;
  qreal beatHeight = height();
  qreal padding = 2.0;

  int i;
  for (i = 0; i < beat; i++) {
    QRectF area(i * beatWidth + padding, padding,
                beatWidth - 2 * padding, beatHeight - 2 * padding);
    painter.fillRect(area, Qt::darkBlue);
  }
}
Exemple #27
0
void dp()
{
	long u,i,j;
	long a[maxn],tmp,max=0;
	for (u=1;u<=n-2;u++)
	{
		memset(a,0,sizeof(a));
		for (i=u+1;i<=n-1;i++)
		for (j=i+1;j<=n;j++)
		if (out[u][i]+out[i][j]+out[j][u]==m) {
			tmp=area(vertex[u],vertex[i],vertex[j]);
			if (tmp>a[j]) a[j]=tmp;
			if (online[u][i]==0) {
				tmp+=a[i];
				if (tmp>a[j]) a[j]=tmp;
			}
		}
		for (j=u+2;j<=n;j++)
			if (a[j]>max) max=a[j];
	}
	if (max==0) printf("die\n");
		else printf("%.2lf\n",max/2.);
}
void FastGaussProcessor::processImage(QImage *image) const
{
  int width = 3;
  int *gaussMatrix = new int[width * width];
  ImageAlgorithm::gaussCore(1, 1, gaussMatrix);
  int divisor = 0;
  for (int i = 0;i < width * width;++i)
    divisor += gaussMatrix[i];
  int offset = 0;
  for (int i = 0;i < positions.size();++i)
  {
    ImageAlgorithm::ConvolutionFilter *filter =
        new ImageAlgorithm::ConvolutionFilter(gaussMatrix,
                                              width,
                                              width,
                                              divisor,
                                              offset);
    Area area(Ellipse(positions.at(i), _radius, _radius));
    ImageAlgorithm::filtImage<ImageAlgorithm::ConvolutionFilter>(image, area, filter);
    delete filter;
  }
  delete gaussMatrix;
}
Exemple #29
0
void button::draw(int active, image *screen)
{
  int x1,y1,x2,y2,color=(active ? wm->bright_color() : wm->medium_color());
  area(x1,y1,x2,y2);
  if (active!=act  && act_id!=-1 && active)
    wm->push_event(new event(act_id,NULL));

  if (pressed)
  {
    if (up)
    {
      if (!active)
        visual->put_image(screen,x,y);
      else
        pressed->put_image(screen,x,y);
    } else act_pict->put_image(screen,x,y);
  }
  else
  {
    screen->rectangle(x1+2,y1+2,x2-2,y2-2,color);
    act=active;
  }
}
Exemple #30
0
void CylMesh::matchCubeMeshEntries( const CubeMesh* other,
vector< VoxelJunction >& ret ) const
{
	const double EPSILON = 1e-18;
	Vec a( x1_ - x0_, y1_ - y0_, z1_ - z0_ );
	Vec u;
	Vec v;
	a.orthogonalAxes( u, v );

	double h = selectGridVolume( other->getDx() );

	unsigned int num = floor( 0.1 + diffLength_ / h );
	// March along axis of cylinder.
	// q is the location of the point along axis.
	for ( unsigned int i = 0; i < numEntries_; ++i ) {
		vector< double >area( other->getNumEntries(), 0.0 );
		for ( unsigned int j = 0; j < num; ++j ) {
			unsigned int m = i * num + j;
			double frac = ( m * h + h/2.0 ) / totLen_;
			double q0 = x0_ + a.a0() * frac;
			double q1 = y0_ + a.a1() * frac;
			double q2 = z0_ + a.a2() * frac;
			// get radius of cylinder at this point.
			double r = r0_ + ( m * h + h / 2.0 ) * rSlope_;
			fillPointsOnCircle( u, v, Vec( q0, q1, q2 ),
						h, r, area, other );
			}
		// Go through all cubeMesh entries and compute diffusion 
		// cross-section. Assume this is through a membrane, so the 
		// only factor relevant is area. Not the distance.
		for ( unsigned int k = 0; k < area.size(); ++k ) {
			if ( area[k] > EPSILON ) {
				ret.push_back( VoxelJunction( i, k, area[k] ) );
			}
		}
	}
}