Пример #1
0
PrefsWindow::PrefsWindow(void)
  : BWindow (BRect (88.0, 108.0, 0.0, 0.0),
      S_PREFSWIN_TITLE,
      B_TITLED_WINDOW,
      B_ASYNCHRONOUS_CONTROLS)
{
  GeneralPrefsView *generalView = new GeneralPrefsView(BRect(0.0, 0.0, 0.0, 0.0),
     "view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);

  ResizeTo(generalView->Bounds().Width(), generalView->Bounds().Height());

  BBox *box = new BBox (Bounds().InsetByCopy(-1,-1), "box", B_FOLLOW_ALL_SIDES);
  
  AddChild(box);

  box->AddChild(generalView);
  generalView->MoveTo ((box->Bounds().Width() - generalView->Bounds().Width()) / 2,
    (box->Bounds().Height() - generalView->Bounds().Height()) / 2);

  BRect prefsRect (vision_app->GetRect ("GenPrefWinRect"));
  if (prefsRect.Width() != 0.0 && prefsRect.Height() != 0.0)
  {
    ResizeTo (prefsRect.Width(), prefsRect.Height());
    MoveTo (prefsRect.left, prefsRect.top);
  }
}
Пример #2
0
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
	:
	BView(name, 0),
	fDecorInfoButton(NULL),
	fDecorMenuField(NULL),
	fDecorMenu(NULL)
{
	// Decorator menu
	_BuildDecorMenu();
	fDecorMenuField = new BMenuField("decorator",
		B_TRANSLATE("Decorator:"), fDecorMenu);

	fDecorInfoButton = new BButton(B_TRANSLATE("About"),
		new BMessage(kMsgDecorInfo));

	// scroll bar arrow style
	BBox* arrowStyleBox = new BBox("arrow style");
	arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));

	fSavedDoubleArrowsValue = _DoubleScrollBarArrows();

	fArrowStyleSingle = new FakeScrollBar(true, false,
		new BMessage(kMsgArrowStyleSingle));
	fArrowStyleDouble = new FakeScrollBar(true, true,
		new BMessage(kMsgArrowStyleDouble));

	BView* arrowStyleView;
	arrowStyleView = BLayoutBuilder::Group<>()
		.AddGroup(B_VERTICAL, 1)
			.Add(new BStringView("single", B_TRANSLATE("Single:")))
			.Add(fArrowStyleSingle)
			.AddStrut(B_USE_DEFAULT_SPACING)
			.Add(new BStringView("double", B_TRANSLATE("Double:")))
			.Add(fArrowStyleDouble)
			.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
			.End()
		.View();
	arrowStyleBox->AddChild(arrowStyleView);
	arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_CENTER));
	arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	BStringView* scrollBarLabel
		= new BStringView("scroll bar", B_TRANSLATE("Scroll bar:"));
	scrollBarLabel->SetExplicitAlignment(
		BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

	// control layout
	BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
		.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
		.Add(fDecorInfoButton, 2, 0)
		.Add(scrollBarLabel, 0, 1)
		.Add(arrowStyleBox, 1, 1)
		.AddGlue(0, 2)
		.SetInsets(B_USE_WINDOW_SPACING);

	// TODO : Decorator Preview Image?
}
Пример #3
0
BBox Sketch::CalculateEntityBBox(bool includingInvisible) {
    BBox box = {};
    bool first = true;
    for(int i = 0; i < entity.n; i++) {
        Entity *e = (Entity *)&entity.elem[i];
        if(!(e->IsVisible() || includingInvisible)) continue;

        Vector point;
        double r = 0.0;
        if(e->IsPoint()) {
            point = e->PointGetNum();
        } else {
            switch(e->type) {
                case Entity::ARC_OF_CIRCLE:
                case Entity::CIRCLE:
                    r = e->CircleGetRadiusNum();
                    point = GetEntity(e->point[0])->PointGetNum();
                    break;
                default: continue;
            }
        }

        if(first) {
            box.minp = point;
            box.maxp = point;
            box.Include(point, r);
            first = false;
        } else {
            box.Include(point, r);
        }
    }
    return box;
}
Пример #4
0
// warning: slow
void testTileBBoxes(const MapParams& mp)
{
	// check tile bounding boxes for a few tiles
	for (int64_t tx = -5; tx <= 5; tx++)
		for (int64_t ty = -5; ty <= 5; ty++)
		{
			// get computed BBox
			TileIdx ti(tx,ty);
			BBox bbox = ti.getBBox(mp);

			// this is what the box is supposed to be
			int64_t xmin = 64*mp.B*mp.T*tx - 2*mp.B;
			int64_t ymax = 64*mp.B*mp.T*ty + 17*mp.B;
			int64_t xmax = xmin + mp.tileSize();
			int64_t ymin = ymax - mp.tileSize();

			// test pixels
			for (int64_t x = xmin - 15; x <= xmax + 15; x++)
				for (int64_t y = ymin - 15; y <= ymax + 15; y++)
				{
					bool result = bbox.includes(Pixel(x,y));
					bool expected = x >= xmin && x < xmax && y >= ymin && y < ymax;
					if (result != expected)
					{
						cout << "failed tile bounding box test!  " << tx << " " << ty << endl;
						cout << "[" << bbox.topLeft.x << "," << bbox.topLeft.y << "] to [" << bbox.bottomRight.x << "," << bbox.bottomRight.y << "]" << endl;
						cout << "[" << xmin << "," << ymin << "] to [" << xmax << "," << ymax << "]" << endl;
						cout << x << "," << y << endl;
						return;
					}
				}
		}
}
Пример #5
0
void
DateTimeView::_InitView()
{
	fCalendarView = new BCalendarView("calendar");
	fCalendarView->SetWeekNumberHeaderVisible(false);
	fCalendarView->SetSelectionMessage(new BMessage(kDayChanged));
	fCalendarView->SetInvocationMessage(new BMessage(kDayChanged));

	fDateEdit = new TDateEdit("dateEdit", 3);
	fTimeEdit = new TTimeEdit("timeEdit", 4);
	fClock = new TAnalogClock("analogClock");

	BTime time(BTime::CurrentTime(B_LOCAL_TIME));
	fClock->SetTime(time.Hour(), time.Minute(), time.Second());

	BBox* divider = new BBox(BRect(0, 0, 1, 1),
		B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
		B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
	divider->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED));

	const float kInset = be_control_look->DefaultItemSpacing();
	BLayoutBuilder::Group<>(this)
		.AddGroup(B_VERTICAL, kInset / 2)
			.Add(fDateEdit)
			.Add(fCalendarView)
		.End()
		.Add(divider)
		.AddGroup(B_VERTICAL, 0)
			.Add(fTimeEdit)
			.Add(fClock)
		.End()
		.SetInsets(kInset, kInset, kInset, kInset);
}
BVHAccel::BVHAccel(const std::vector<Primitive *> &_primitives,
                   size_t max_leaf_size) 
{

  this->primitives = _primitives;

  // edge case
  if (primitives.empty()) {
    return;
  }

  // calculate root AABB size
  BBox bb;
  for (size_t i = 0; i < primitives.size(); ++i) {
    bb.expand(primitives[i]->get_bbox());
  }
  root = new BVHNode(bb, 0, primitives.size());

  // calculate morton code for each primitives
  for (size_t i = 0; i < primitives.size(); ++i) {
    unsigned int morton_code = morton3D(bb.getUnitcubePosOf(primitives[i]->get_bbox().centroid()));
    primitives[i]->morton_code = morton_code;
  }

  // sort primitives using morton code
  std::sort(primitives.begin(), primitives.end(), mortonCompare);

  //construct BVH based on the mortan code
  constructBVH(root);

}
Пример #7
0
real FEdge::z_discontinuity() const
{
  if (!(getNature() & Nature::SILHOUETTE) && !(getNature() & Nature::BORDER)) {
    return 0;
  }

  BBox<Vec3r> box = ViewMap::getInstance()->getScene3dBBox();

  Vec3r bbox_size_vec(box.getMax() - box.getMin());
  real bboxsize = bbox_size_vec.norm();
  if (occludee_empty()) {
    // return FLT_MAX;
    return 1.0;
    // return bboxsize;
  }

#if 0
  real result;
  z_discontinuity_functor<SVertex> _functor;
  Evaluate<SVertex, z_discontinuity_functor<SVertex>>(&_functor, iCombination, result);
#endif
  Vec3r middle((_VertexB->point3d() - _VertexA->point3d()));
  middle /= 2;
  Vec3r disc_vec(middle - _occludeeIntersection);
  real res = disc_vec.norm() / bboxsize;

  return res;
  // return fabs((middle.z() - _occludeeIntersection.z()));
}
Пример #8
0
/*******************************************************
*   Our wonderful BWindow, ya its kewl like that.
*   we dont do much here but set up the menubar and 
*   let the view take over.  We also nead some message
*   redirection and handling
*******************************************************/
ToolTipWindow::ToolTipWindow() : BWindow(BRect(0,0,100,19),"Tool Tip",
      B_NO_BORDER_WINDOW_LOOK,
      B_FLOATING_ALL_WINDOW_FEEL,
      B_ASYNCHRONOUS_CONTROLS|B_NOT_RESIZABLE|B_AVOID_FRONT|B_AVOID_FOCUS){
   
   Looper()->SetName(TOOL_TIP_WINDOW);
   
   BView *v = new BView(Bounds(),"",B_FOLLOW_ALL,0);
   v->SetViewColor(255,255,120);
   AddChild(v);
   
   BRect b = v->Bounds();
   b.Set(b.left-1,b.top-1,b.right+1,b.bottom+1);
   BBox *bb = new BBox(b,"",B_FOLLOW_ALL);
   v->AddChild(bb);
   
   b = bb->Frame();
   b.InsetBy(1,1);
   b.left = 4;
   b.bottom --;
   tipv = new BStringView(b,"","...",B_FOLLOW_ALL);
   tipv->SetAlignment(B_ALIGN_CENTER);
   bb->AddChild(tipv);
   
   Run();
}
Пример #9
0
VideoSettingsView::VideoSettingsView()
{
	BBox* defaultsBox = new BBox("defaults");
	defaultsBox->SetLabel(B_TRANSLATE("Defaults"));
	BGridView* defaultsGridView = new BGridView();

	BMenuField* inputMenuField = new BMenuField("inputMenuField",
		B_TRANSLATE("Video input:"), InputMenu());

	BMenuField* outputMenuField = new BMenuField("outputMenuField",
		B_TRANSLATE("Video output:"), OutputMenu());

	BLayoutBuilder::Grid<>(defaultsGridView)
		.SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING,
			B_USE_DEFAULT_SPACING)
		.AddMenuField(inputMenuField, 0, 0)
		.AddMenuField(outputMenuField, 0, 1);

	defaultsBox->AddChild(defaultsGridView);

	BLayoutBuilder::Group<>(this)
		.SetInsets(0, 0, 0, 0)
		.Add(defaultsBox)
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(MakeRestartButton())
			.End()
		.AddGlue();
}
Пример #10
0
void PMRoadGenerator::setupTensor(const Polygon2D& targetArea, const std::vector<std::pair<QVector2D, float>>& regular_elements, cv::Mat& tensor) {
	BBox bbox = targetArea.envelope();
	tensor = cv::Mat(bbox.dy() + 1, bbox.dx() + 1, CV_32F);

	for (int r = 0; r < tensor.rows; ++r) {
		for (int c = 0; c < tensor.cols; ++c) {
			int x = c + bbox.minPt.x();
			int y = r + bbox.minPt.y();

			double total_angle = 0.0;
			double total_weight = 0.0;
			for (int k = 0; k < regular_elements.size(); ++k) {
				float dist = (QVector2D(x, y) - regular_elements[k].first).length();

				double angle = regular_elements[k].second;
				double weight = exp(-dist / 10);
				total_angle += angle * weight;
				total_weight += weight;
			}

			float avg_angle = total_angle / total_weight;
			tensor.at<float>(r, c) = avg_angle;
		}
	}
}
    inline BBox transformed ( const nv_math::mat4f &matrix, int dim=3)
    {
      int i;
      nv_math::vec4f box[16];
      // create box corners
      box[0] = nv_math::vec4f(min.x,min.y,min.z,min.w);
      box[1] = nv_math::vec4f(max.x,min.y,min.z,min.w);
      box[2] = nv_math::vec4f(min.x,max.y,min.z,min.w);
      box[3] = nv_math::vec4f(max.x,max.y,min.z,min.w);
      box[4] = nv_math::vec4f(min.x,min.y,max.z,min.w);
      box[5] = nv_math::vec4f(max.x,min.y,max.z,min.w);
      box[6] = nv_math::vec4f(min.x,max.y,max.z,min.w);
      box[7] = nv_math::vec4f(max.x,max.y,max.z,min.w);

      box[8] = nv_math::vec4f(min.x,min.y,min.z,max.w);
      box[9] = nv_math::vec4f(max.x,min.y,min.z,max.w);
      box[10] = nv_math::vec4f(min.x,max.y,min.z,max.w);
      box[11] = nv_math::vec4f(max.x,max.y,min.z,max.w);
      box[12] = nv_math::vec4f(min.x,min.y,max.z,max.w);
      box[13] = nv_math::vec4f(max.x,min.y,max.z,max.w);
      box[14] = nv_math::vec4f(min.x,max.y,max.z,max.w);
      box[15] = nv_math::vec4f(max.x,max.y,max.z,max.w);

      // transform box corners
      // and find new mins,maxs
      BBox bbox;

      for (i = 0; i < (1<<dim) ; i++){
        nv_math::vec4f point = matrix * box[i];
        bbox.merge(point);
      }

      return bbox;
    }
BBox Scene::get_bbox() {
  BBox bbox;
  for (SceneObject *obj : objects) {
    bbox.expand(obj->get_bbox());
  }
  return bbox;
}
Пример #13
0
MidiSettingsView::MidiSettingsView()
	:
	SettingsView()
{
	BBox* defaultsBox = new BBox("SoundFont");
	defaultsBox->SetLabel(B_TRANSLATE("SoundFont"));
	BGridView* defaultsGridView = new BGridView();

	fListView = new BListView(B_SINGLE_SELECTION_LIST);
	fListView->SetSelectionMessage(new BMessage(kSelectSoundFont));

	BScrollView *scrollView = new BScrollView("ScrollView", fListView,
			0, false, true);
	BLayoutBuilder::Grid<>(defaultsGridView)
		.SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING,
				B_USE_DEFAULT_SPACING)
		.Add(scrollView, 0, 0);

	defaultsBox->AddChild(defaultsGridView);

	BLayoutBuilder::Group<>(this)
		.SetInsets(0, 0, 0, 0)
		.Add(defaultsBox)
		.AddGlue();
}
Пример #14
0
BBox SpherePrimitive::wsBounds(Geo::Geometry::CPtr geometry) const
{
  assert(geometry != NULL);
  assert(geometry->particles() != NULL);

  if (!geometry->particles()) {
    Log::warning("SpherePrimitive has no particles. "
                 "Skipping bounds generation.");
    return BBox();
  }

  BBox wsBBox;

  AttrVisitor visitor(geometry->particles()->pointAttrs(), m_params);
  Attr<V3f>   wsCenter("P");
  Attr<float> radius("radius");

  for (AttrVisitor::const_iterator i = visitor.begin(), end = visitor.end(); 
       i != end; ++i) {
    i.update(wsCenter);
    i.update(radius);
    wsBBox.extendBy(wsCenter.as<Vector>() + radius.as<Vector>());
    wsBBox.extendBy(wsCenter.as<Vector>() - radius.as<Vector>());
  }

  return wsBBox;
}
Пример #15
0
PoorManAdvancedView::PoorManAdvancedView(const char* name)
    :
    BView(name, B_WILL_DRAW, NULL)
{
    PoorManWindow* win;
    win = ((PoorManApplication*)be_app)->GetPoorManWindow();

    BBox* connectionOptions = new BBox(B_TRANSLATE("Connections"));
    connectionOptions->SetLabel(STR_BBX_CONNECTION);

    fMaxConnections = new StatusSlider("Max Slider", STR_SLD_LABEL,
                                       STR_SLD_STATUS_LABEL,
                                       new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200);

    // labels below the slider 1 and 200
    fMaxConnections->SetLimitLabels("1", "200");
    SetMaxSimutaneousConnections(win->MaxConnections());


    BGroupLayout* connectionOptionsLayout = new BGroupLayout(B_VERTICAL, 0);
    connectionOptions->SetLayout(connectionOptionsLayout);

    BLayoutBuilder::Group<>(this, B_VERTICAL)
    .AddGroup(connectionOptionsLayout)
    .SetInsets(B_USE_ITEM_INSETS)
    .AddStrut(B_USE_ITEM_SPACING)
    .Add(fMaxConnections)
    .End()
    .AddGlue()
    .SetInsets(B_USE_ITEM_INSETS);
}
Пример #16
0
TEST_F(BBoxTest, SurfaceAreaWorks) {
	BBox b (Point (0, 0, 0), Point (2, 2, 2));

	float area = b.SurfaceArea();

	EXPECT_FLOAT_EQ (24.f, area);
}
Пример #17
0
  void CPUFontBase::bbox(const wchar_t * wstr, BBox & bbox)
  {
    if(wstr && (*wstr != wchar_t('\0')))
    {
#ifndef WIN32
      const unsigned wchar_t *   wc = (const unsigned wchar_t *)wstr;
#else
      const wchar_t *   wc = (const wchar_t *)wstr;
#endif

      float   advance = 0.f;
      if(checkGlyph(*wc))
      {
        bbox = m_glyphList->bbox(*wc); 
        advance = m_glyphList->advance(*wc, *(wc + 1));
      }

      while(*++wc)
      {
        if(checkGlyph(*wc))
        {
          BBox tempBBox = m_glyphList->bbox(*wc);
          tempBBox.move(Nimble::Vector2(advance, 0.0f));
          bbox.expand(tempBBox);
          advance += m_glyphList->advance(*wc, *(wc + 1));
        }
      }
    }
  }
Пример #18
0
TEST_F(BBoxTest, SurfaceAreaDegenerateBBoxWorks) {
	BBox b (Point(0, 0, 0), Point (0, 0, 0));

	float area = b.SurfaceArea();

	EXPECT_FLOAT_EQ (0.f, area);
}
Пример #19
0
bool GridAccel::IntersectP(const Ray &ray) const {
	if (!gridForRefined) { // NOBOOK
		rayTests.Add(0, 1); // NOBOOK
		rayHits.Add(0, 1); // NOBOOK
	} // NOBOOK
	int rayId = ++curMailboxId;
	// Check ray against overall grid bounds
	float rayT;
	if (bounds.Inside(ray(ray.mint)))
		rayT = ray.mint;
	else if (!bounds.IntersectP(ray, &rayT))
		return false;
	Point gridIntersect = ray(rayT);
	// Set up 3D DDA for ray
	float NextCrossingT[3], DeltaT[3];
	int Step[3], Out[3], Pos[3];
	for (int axis = 0; axis < 3; ++axis) {
		// Compute current voxel for axis
		Pos[axis] = PosToVoxel(gridIntersect, axis);
		if (ray.d[axis] >= 0) {
			// Handle ray with positive direction for voxel stepping
			NextCrossingT[axis] = rayT +
				(VoxelToPos(Pos[axis]+1, axis) - gridIntersect[axis]) /
					ray.d[axis];
			DeltaT[axis] = Width[axis] / ray.d[axis];
			Step[axis] = 1;
			Out[axis] = NVoxels[axis];
		}
		else {
			// Handle ray with negative direction for voxel stepping
			NextCrossingT[axis] = rayT +
				(VoxelToPos(Pos[axis], axis) - gridIntersect[axis]) /
					ray.d[axis];
			DeltaT[axis] = -Width[axis] / ray.d[axis];
			Step[axis] = -1;
			Out[axis] = -1;
		}
	}
	// Walk grid for shadow ray
	for (;;) {
		int offset = Offset(Pos[0], Pos[1], Pos[2]);
		Voxel *voxel = voxels[offset];
		if (voxel && voxel->IntersectP(ray, rayId))
			return true;
		// Advance to next voxel
		// Find _stepAxis_ for stepping to next voxel
		int bits = ((NextCrossingT[0] < NextCrossingT[1]) << 2) +
			((NextCrossingT[0] < NextCrossingT[2]) << 1) +
			((NextCrossingT[1] < NextCrossingT[2]));
		const int cmpToAxis[8] = { 2, 1, 2, 1, 2, 2, 0, 0 };
		int stepAxis = cmpToAxis[bits];
		if (ray.maxt < NextCrossingT[stepAxis])
			break;
		Pos[stepAxis] += Step[stepAxis];
		if (Pos[stepAxis] == Out[stepAxis])
			break;
		NextCrossingT[stepAxis] += DeltaT[stepAxis];
	}
	return false;
}
Пример #20
0
TEST_F(BBoxTest, VolumeWorks) {
	BBox b (Point (0, 0, 0), Point (2, 2, 2));

	float area = b.Volume();

	EXPECT_FLOAT_EQ (8.f, area);
}
Пример #21
0
bool ProfileWindow::handleMouseUp(Point p){
	Point screen_point = screen_to_obj(p.getX(),p.getY());
	for(int a = 0; a < 5; a++){
	  BBox currentBBox = colors[a]->getBBox();
	  if(currentBBox.containPoint(screen_point)){
	    //character->setColor(colors[a]->getColor());
	    cout << "yay" << endl;
	    delete character;
	    profile.setColor(colors[a]->getColor());
	    character = new Rectangle1(6.0, 6.0, Point(0.0, 2.0), "data/character/profilepage",profile.getColor());
	  }
	}
	BBox currentBBox = pexit->getBBox();
	if(currentBBox.containPoint(screen_point)){
	  pexit->setColor(Color(0.5, 0.0, 1.0));
	  exit(0);
	}
	currentBBox = save->getBBox();
	if(currentBBox.containPoint(screen_point)){
	  profile.setNick(nickname->getString());
	  save->setColor(Color(0.5, 0.0, 1.0));
	  saveProfile();
	  return true;
	}
	return false;
}
Пример #22
0
TEST_F(BBoxTest, VolumeDegenerateBBoxWorks) {
	BBox b (Point (0, 0, 0), Point (0, 0, 0));

	float area = b.Volume();

	EXPECT_FLOAT_EQ (0.f, area);
}
Пример #23
0
void gl_draw_image_section(GLimage& img, const BBox& section, int x, int y,
		const Colour& c) {
	if (section.width() == 0 || section.height() == 0)
		return;
	float xscale = img.texw / img.width, yscale = img.texh / img.height;

	float tx1 = section.x1 * xscale, tx2 = section.x2 * xscale;
	float ty1 = section.y1 * yscale, ty2 = section.y2 * yscale;

	int x2 = x + section.width(), y2 = y + section.height();

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, img.texture);

	glColor4ub(c.r, c.g, c.b, c.a);

	glBegin(GL_QUADS);
	//Draw our four points, clockwise.
	glTexCoord2f(tx1, ty1);
	glVertex2i(x, y);

	glTexCoord2f(tx2, ty1);
	glVertex2i(x2, y);

	glTexCoord2f(tx2, ty2);
	glVertex2i(x2, y2);

	glTexCoord2f(ty1, ty2);
	glVertex2i(x, y2);

	glEnd();
	glDisable(GL_TEXTURE_2D);
	//Don't use glBindTexture(GL_TEXTURE_2D, NULL);
}
Пример #24
0
TEST_F(BBoxTest, MaximumExtentWorks) {
	BBox b (Point (0, 0, 0), Point (1, 2, 3));

	int longest_axis = b.MaximumExtent();

	EXPECT_EQ (2, longest_axis);
}
Пример #25
0
MidiView::MidiView()
	:
	BGroupView(B_VERTICAL, B_USE_DEFAULT_SPACING)
{
	BBox* defaultsBox = new BBox("defaults");
	defaultsBox->SetLabel("Defaults");
	BGridView* defaultsGridView = new BGridView();

	fListView = new BListView(B_SINGLE_SELECTION_LIST);
	fImportButton = new BButton("Import SoundFont",
			new BMessage(kImportSoundFont));

	BLayoutBuilder::Grid<>(defaultsGridView)
			.SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING,
					B_USE_DEFAULT_SPACING)
			.Add(fListView, 0, 0)
			.Add(fImportButton, 0, 1);

	defaultsBox->AddChild(defaultsGridView);

	BLayoutBuilder::Group<>(this)
		.SetInsets(0, 0, 0, 0)
		.Add(defaultsBox)
		.AddGlue();
}
Пример #26
0
TEST_F(BBoxTest, MaximumExtentDegenerateBBoxWorks) {
	BBox b (Point (0, 0, 0), Point (0, 0, 0));

	int longest_axis = b.MaximumExtent();

	EXPECT_EQ (2, longest_axis);
}
Пример #27
0
void
ModulesView::_OpenSaver()
{
	// create new screen saver preview & config

	BView* view = fPreviewView->AddPreview();
	fCurrentName = fSettings.ModuleName();
	fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings);
	BScreenSaver* saver = _ScreenSaver();

#ifdef __HAIKU__
	BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4);
#else
	BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4);
	rect.top += 14;
#endif
	fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW);

	fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fSettingsBox->AddChild(fSettingsView);

	if (saver != NULL && fSaverRunner->Run() == B_OK)
		saver->StartConfig(fSettingsView);

	if (fSettingsView->ChildAt(0) == NULL) {
		// There are no settings at all, we add the module name here to
		// let it look a bit better at least.
		BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView,
			fSettings.ModuleName()[0] ? fSettings.ModuleName()
				: B_TRANSLATE("Blackness"),
				saver != NULL || !fSettings.ModuleName()[0]
					? B_TRANSLATE("No options available")
					: B_TRANSLATE("Could not load screen saver"));
	}
}
Пример #28
0
TEST_F(BBoxTest, MaximumExtentNegativeAxisWorks) {
	BBox b (Point (0, 0, 0), Point (-3, 0, 1));

	int longest_axis = b.MaximumExtent();

	EXPECT_EQ (0, longest_axis);
}
Пример #29
0
 Quad::Quad(const BBox& bbox)
 {
   _v[0] = bbox.top_left();
   _v[1] = bbox.top_right();
   _v[2] = bbox.bottom_right();
   _v[3] = bbox.bottom_left();
 }
Пример #30
0
void VBOPmBlocks::saveBlockImage(RoadGraph& roads, Polygon3D& contour, const char* filename) {
	BBox bbox = GraphUtil::getAABoundingBox(roads, true);
	cv::Mat img(bbox.dy() + 1, bbox.dx() + 1, CV_8UC3, cv::Scalar(255, 255, 255));

	RoadEdgeIter ei, eend;
	for (boost::tie(ei, eend) = boost::edges(roads.graph); ei != eend; ++ei) {
		if (!roads.graph[*ei]->valid) continue;

		for (int pl = 0; pl < roads.graph[*ei]->polyline.size() - 1; ++pl) {
			int x1 = roads.graph[*ei]->polyline[pl].x() - bbox.minPt.x();
			int y1 = img.rows - (roads.graph[*ei]->polyline[pl].y() - bbox.minPt.y());
			int x2 = roads.graph[*ei]->polyline[pl + 1].x() - bbox.minPt.x();
			int y2 = img.rows - (roads.graph[*ei]->polyline[pl + 1].y() - bbox.minPt.y());
			cv::line(img, cv::Point(x1, y1), cv::Point(x2, y2), cv::Scalar(224, 224, 224), 3);
		}
	}

	for (int i = 0; i < contour.contour.size(); ++i) {
		int next = (i + 1) % contour.contour.size();
		int x1 = contour.contour[i].x() - bbox.minPt.x();
		int y1 = img.rows - (contour.contour[i].y() - bbox.minPt.y());
		int x2 = contour.contour[next].x() - bbox.minPt.x();
		int y2 = img.rows - (contour.contour[next].y() - bbox.minPt.y());
		cv::line(img, cv::Point(x1, y1), cv::Point(x2, y2), cv::Scalar(0, 0, 0), 3);
	}

	cv::imwrite(filename, img);
}