Exemplo n.º 1
0
void TExportZone::DrawInMarker(BRect updateRect)
{
	// Set up environment
	PushState();
		
	BPoint drawPt;
	
	// Draw left marker
	if (updateRect.Intersects(m_InRect) )
	{
		// Draw indicator in new location
		drawPt.Set(m_InRect.left, m_InRect.top);
		DrawBitmap(m_InMarker, drawPt);
	}

	// Draw right marker
	if (updateRect.Intersects(m_OutRect) )
	{
		// Draw indicator in new location
		drawPt.Set(m_OutRect.left, m_OutRect.top);
		DrawBitmap(m_OutMarker, drawPt);
	}
		
	// Restore environment
	PopState();
}
Exemplo n.º 2
0
void TVideoCaptureToolbar::Draw(BRect updateRect)
{
	// Setup environment
	rgb_color saveColor = HighColor();

	// Fill background
	SetHighColor(kBlueGrey);
	FillRect(Bounds());

	// Frame it
	BPoint endPt;
	SetHighColor(kWhite);
	MovePenTo(Bounds().left, Bounds().top+1);
	endPt.Set( Bounds().right, Bounds().top+1 );
	StrokeLine(endPt);

	SetHighColor(kMediumGrey);
	MovePenTo(Bounds().left, Bounds().bottom-1);
	endPt.Set( Bounds().right, Bounds().bottom-1 );
	StrokeLine(endPt);

	SetHighColor(kBlack);
	MovePenTo(Bounds().left, Bounds().top);
	endPt.Set( Bounds().right, Bounds().top );
	StrokeLine(endPt);
	MovePenTo(Bounds().left, Bounds().bottom);
	endPt.Set( Bounds().right, Bounds().bottom );
	StrokeLine(endPt);

	// Restore Environment
	SetHighColor(saveColor);
}
Exemplo n.º 3
0
void TCueSheetTimeView::Draw(BRect updateRect)
{
	// Set up environment
	PushState();
	
	const BRect bounds = Bounds();
	
	BPoint startPt, endPt;
	
	// Draw TimeRect frame
	SetHighColor(kLightGrey);
	FillRect(bounds);
	
	//	Draw black outline
	SetHighColor(kBlack);
	startPt.Set(bounds.left, bounds.top);
	endPt.Set(bounds.left, bounds.bottom);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.right, bounds.top);
	endPt.Set(bounds.right, bounds.bottom);
	StrokeLine(startPt, endPt);
	
	
	//	Draw shadow
	SetHighColor(kMediumGrey);
	startPt.Set(bounds.right-1, bounds.top);
	endPt.Set(bounds.right-1, bounds.bottom);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.right-1, bounds.bottom);
	endPt.Set(bounds.left+1, bounds.bottom);
	StrokeLine(startPt, endPt);
	
	//	Draw highlight	
	SetHighColor(kWhite);
	startPt.Set(bounds.left+1, bounds.bottom - 2);
	endPt.Set(bounds.left+1, bounds.top);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.left+1, bounds.top);
	endPt.Set(bounds.right-2, bounds.top);
	StrokeLine(startPt, endPt);

	// Draw cue sheet start time
	BFont font; 
   	GetFont(&font); 
	SetFont(be_bold_font);   
   	SetHighColor(kBlack);
   	
	BPoint 	textPt;
	char 	timeStr[256];
	int32 	startTime = m_CueSheetWindow->GetCueSheetView()->StartTime();
	textPt.Set(bounds.left + 9, bounds.top + 16);
	TimeToString(startTime, m_CueSheetWindow->GetCueSheetView()->GetTimeFormat(), timeStr, FALSE);		
	DrawString(timeStr, textPt);
	
	// Restore environment
	PopState();
}
Exemplo n.º 4
0
void CharView::Draw(BRect urect)
{
	BPoint		point;
	font_height	fheight;
	char		utf8Char[3];
	uint16		uniChar[1];

	urect = Bounds();

//	SetLowColor(def_viewcolor);
	SetDrawingMode(B_OP_COPY);
	SetHighColor(strokeColor);
	SetPenSize(1);
	StrokeRect(urect);

	urect.InsetBy(1, 1);
	SetHighColor(bgColor);
	FillRect(urect);
	SetLowColor(bgColor);
	SetHighColor(displayColor);

	if (drawmode) {
		font.SetSize(urect.Width() * 0.6);
		font.GetHeight(&fheight);

		//  Unicode to UTF8 Character encoding
		uniChar[0] = B_HOST_TO_BENDIAN_INT16(((mutf == 0) || (mutf == 65535)) ? 1 : mutf);
		int32 state = 0;
		int32 srcLen = 2;
		int32 destLen = sizeof(utf8Char);
		convert_to_utf8(B_UNICODE_CONVERSION, (const char*)uniChar, &srcLen,
						utf8Char, &destLen, &state);

		SetFont(&font);
	
		bool hasGlyph[1];
		font.GetHasGlyphs(utf8Char, 1, hasGlyph);

		if (hasGlyph[0]) {
			float choffset = (urect.right - urect.left - StringWidth(utf8Char, destLen)) / 2;
			float cvoffset = (urect.Height() - fheight.ascent - fheight.descent) / 2 + fheight.ascent;
			point.Set(choffset, cvoffset);
			DrawString(utf8Char, destLen, point);
		}
	}

/*	printf("\nCharView!\n");
	printf("utf8Char[0]: %x\n", utf8Char[0]);
	printf("utf8Char[1]: %x\n", utf8Char[1]);
	printf("utf8Char[2]: %x\n", utf8Char[2]);*/
}
Exemplo n.º 5
0
pointlist* logicop::logic::hole2simple(const pointlist& outside, const pointlist& inside) {
   segmentlist _segl0(outside,0);
   segmentlist _segl1(inside,1);
   EventQueue* _eq = new EventQueue(_segl0, _segl1); // create the event queue
   SweepLine   _sl;
   BindCollection BC;
   _eq->swipe4bind(_sl, BC);
   BindSegment* sbc = BC.get_highest();
   //insert 2 crossing points and link them
   BPoint* cpsegA = _segl0.insertbindpoint(sbc->poly0seg(), sbc->poly0pnt());
   BPoint* cpsegB = _segl1.insertbindpoint(sbc->poly1seg(), sbc->poly1pnt());
   cpsegA->linkto(cpsegB);
   cpsegB->linkto(cpsegA);

   // normalize the segment lists
   _segl0.normalize(outside);
   _segl1.normalize(inside);
   // dump the new polygons in VList terms
   VPoint* outshape = _segl0.dump_points();
                      _segl1.dump_points();
   
   // traverse and form the resulting shape
   VPoint* centinel = outshape;
   pointlist *shgen = new pointlist();
   bool direction = true; /*next*/
   VPoint* pickup = centinel;
   VPoint* prev = centinel->prev();
   bool modify = false;
   do {
      shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y()));
      modify = (-1 == prev->visited());
      prev = pickup;
      pickup = pickup->follower(direction, modify);
   } while (pickup != centinel);

   // Validate the resulting polygon
   laydata::valid_poly check(*shgen);
//   delete shgen;
   if (!check.valid()) {
      std::ostringstream ost;
      ost << ": Resulting shape is invalid - " << check.failtype();
      tell_log(console::MT_ERROR, ost.str().c_str());
   }   
   else {
      if (laydata::shp_OK != check.status())
         *shgen = check.get_validated();
   }         
   
   return shgen;
}
Exemplo n.º 6
0
void bx_beos_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
                      unsigned long cursor_x, unsigned long cursor_y,
                      bx_vga_tminfo_t tm_info)
{
  unsigned i, x, y;
  BPoint point;
  unsigned char achar;
  unsigned nchars;

  aWindow->Lock();

  // Number of characters on screen, variable number of rows
  nchars = text_cols * text_rows;

  // first draw over character at original block cursor location
  if ((prev_block_cursor_y*text_cols + prev_block_cursor_x) < nchars) {
    achar = new_text[(prev_block_cursor_y*text_cols + prev_block_cursor_x)*2];
    point.Set(prev_block_cursor_x*8, prev_block_cursor_y*16 + bx_headerbar_y);
    aView->DrawBitmap(vgafont[achar], point);
  }

  for (i=0; i<nchars*2; i+=2) {
    if ((old_text[i]!=new_text[i]) ||
        (old_text[i+1]!=new_text[i+1]))
    {
      achar = new_text[i];

      x = (i/2) % text_cols;
      y = (i/2) / text_cols;

      point.Set(x*8, y*16 + bx_headerbar_y);
      aView->DrawBitmap(vgafont[achar], point);
    }
  }

  prev_block_cursor_x = cursor_x;
  prev_block_cursor_y = cursor_y;

  // now draw character at new block cursor location in reverse
  if ((cursor_y*text_cols + cursor_x) < nchars) {
    achar = new_text[(cursor_y*text_cols + cursor_x)*2];
    point.Set(cursor_x*8, cursor_y*16 + bx_headerbar_y);
    aView->set_inv_text_colors();
    aView->DrawBitmap(vgafont[achar], point);
    aView->set_text_colors();
  }

  aWindow->Unlock();
}
Exemplo n.º 7
0
BPoint
FolderShaperWindow::GetMouse()
{
	BPoint point;
	uint32 buttons;	
	topbox->GetMouse(&point, &buttons);
	point = ConvertToScreen(point);
	
	float width, height;
	m_menubar->	GetPreferredSize(&width, &height);

	point.Set(point.x, point.y+height+2);
		
	return point;
}
Exemplo n.º 8
0
TPolygon::TPolygon( BRect rect )
{	
	m_PointList = new BList();
	
	//	Copy data over
	BPoint tmpPt;
	
	tmpPt.Set(rect.left, rect.top);
	m_PointList->AddItem(&tmpPt);
	tmpPt.Set(rect.right, rect.top);
	m_PointList->AddItem(&tmpPt);
	tmpPt.Set(rect.right, rect.bottom);
	m_PointList->AddItem(&tmpPt);
	tmpPt.Set(rect.left, rect.bottom);
	m_PointList->AddItem(&tmpPt);
}
Exemplo n.º 9
0
status_t GlEllipse::GetChainParams(	const gl_generate_args& args,
									BPoint& ptX, BPoint& ptY,
									BPoint& ptW, BPoint& ptH,
									GlAlgo** outAX, GlAlgo** outAY, GlAlgo** outAZ) const
{
	ptX.Set(DEF_REL_X, DEF_ABS_X);
	ptY.Set(DEF_REL_Y, DEF_ABS_Y);
	ptW.Set(DEF_REL_W, DEF_ABS_W);
	ptH.Set(DEF_REL_H, DEF_ABS_H);
	ptX = Params().Point('x_pt');
	ptY = Params().Point('y_pt');
	ptW = Params().Point('w_pt');
	ptH = Params().Point('h_pt');
	ArpVALIDATE(outAX && outAY && outAZ, return B_ERROR);

	*outAX = GenerateChainAlgo(_X_KEY, args);
	*outAY = GenerateChainAlgo(_Y_KEY, args);
	*outAZ = GenerateChainAlgo(_Z_KEY, args);
	return B_OK;
}
Exemplo n.º 10
0
// PositionMarkerAt
void
ColorField::PositionMarkerAt(BPoint where)
{
	BRect rect = _BitmapRect();
	where.ConstrainTo(rect);
	where -= rect.LeftTop();

	fLastMarkerPosition = fMarkerPosition;
	fMarkerPosition = where;
	Invalidate();
}
Exemplo n.º 11
0
void TElementsSorter::Draw(BRect updateRect)
{
	PushState();

	//  Draw dummy header to the right of our rightmost TSorter
	TSorterContainer* sorter = static_cast<TSorterContainer*>(fSorterList->ItemAt( fSorterList->CountItems()-1) );
	if (sorter) {
		BRect bounds    = Bounds();
		bounds.bottom   = bounds.top + kSorterHeight;
		bounds.left     = sorter->Frame().right;

		if (updateRect.Intersects(bounds) ) {
			// Fill background
			SetHighColor(kBeGrey);
			FillRect(bounds);

			// Frame it
			BPoint endPt;
			SetHighColor(kWhite);
			MovePenTo(bounds.left, bounds.top+1);
			endPt.Set( bounds.right, bounds.top+1 );
			StrokeLine(endPt);

			SetHighColor(kMediumGrey);
			MovePenTo(bounds.left, bounds.bottom-1);
			endPt.Set( bounds.right, bounds.bottom-1 );
			StrokeLine(endPt);

			SetHighColor(kBlack);
			MovePenTo(bounds.left, bounds.top);
			endPt.Set( bounds.right, bounds.top );
			StrokeLine(endPt);
			MovePenTo(bounds.left, bounds.bottom);
			endPt.Set( bounds.right, bounds.bottom );
			StrokeLine(endPt);
		}
	}

	PopState();

}
Exemplo n.º 12
0
void bx_beos_gui_c::show_headerbar(void)
{
  unsigned xorigin;
  BPoint origin;

  // clear header bar area to white

  aWindow->Lock();
  aView->set_headerbar_colors();
  aView->FillRect(BRect(0, 0, dimension_x-1, bx_headerbar_y-1), B_SOLID_LOW);
  for (unsigned i=0; i<bx_headerbar_entries; i++) {
    if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT)
      xorigin = bx_headerbar_entry[i].xorigin;
    else
      xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
    origin.Set(xorigin, 0);
    aView->DrawBitmap(bx_headerbar_entry[i].bitmap, origin);
  }
  aView->set_text_colors();
  aWindow->Unlock();
}
Exemplo n.º 13
0
void MainView::KeyDown(const char *key, int32 num_bytes)
{
	BPoint shift;
	BPoint point = sel_bounds.LeftTop();
	int multiplier = 1;
	uint32 mods = modifiers();
	if(mods & B_SHIFT_KEY) {
		multiplier = 5;
	}
	Invalidate();
	if(key_down) {
		h_ruler->SetSelRect(sel_bounds);
		v_ruler->SetSelRect(sel_bounds);
		key_down = false;
	}
	switch(*key) {
		case B_LEFT_ARROW:
			shift.Set(-1 * multiplier,0);
			h_ruler->UpdateSlider(point);
			moveSelectedFieldsBy(shift);
			break;
		case B_RIGHT_ARROW:
			shift.Set(1 * multiplier,0);
			h_ruler->UpdateSlider(point);
			moveSelectedFieldsBy(shift);
			break;
		case B_UP_ARROW:
			shift.Set(0,-1 * multiplier);
			v_ruler->UpdateSlider(point);
			moveSelectedFieldsBy(shift);
			break;
		case B_DOWN_ARROW:
			shift.Set(0,1 * multiplier);
			v_ruler->UpdateSlider(point);
			moveSelectedFieldsBy(shift);
			break;
		default:
			break;
	}
}
Exemplo n.º 14
0
void
BChannelSlider::DrawChannel(BView* into, int32 channel, BRect area,
	bool pressed)
{
	float hCenter = area.Width() / 2;
	float vCenter = area.Height() / 2;

	BPoint leftTop;
	BPoint bottomRight;
	if (fIsVertical) {
		leftTop.Set(area.left + hCenter, area.top + vCenter);
		bottomRight.Set(leftTop.x, leftTop.y + ThumbRangeFor(channel));
	} else {
		leftTop.Set(area.left, area.top + vCenter);
		bottomRight.Set(area.left + ThumbRangeFor(channel), leftTop.y);
	}

	DrawGroove(into, channel, leftTop, bottomRight);

	BPoint thumbLocation = leftTop;
	if (fIsVertical)
		thumbLocation.y += ThumbDeltaFor(channel);
	else
		thumbLocation.x += ThumbDeltaFor(channel);

	DrawThumb(into, channel, thumbLocation, pressed);
}
Exemplo n.º 15
0
void bx_beos_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
{
  for (unsigned y=0; y<y_tilesize; y++) {
    for (unsigned x=0; x<x_tilesize; x++) {
      rawdata[y*rowsize_padded + x] = cmap_index[ tile[y*x_tilesize + x] ];
    }
  }
  aWindow->Lock();
  image->SetBits(rawdata, rowsize_padded * y_tilesize, 0, B_COLOR_8_BIT);
  image_origin.Set(x0, y0 + bx_headerbar_y);

  aView->DrawBitmap(image, image_origin);
  aWindow->Unlock();
}
Exemplo n.º 16
0
App::App(void)
	:
	BApplication(APP_SIGNATURE),
	fBuildCleanMode(false),
	fBuilder(NULL)
{
	InitFileTypes();
	InitGlobals();
	EnsureTemplates();
	
	gProjectList = new LockableList<Project>(20,true);
	gProjectWindowPoint.Set(5,24);
	
	fOpenPanel = NULL;
}
Exemplo n.º 17
0
App::App(void)
	:	BApplication(APP_SIGNATURE),
		fBuildCleanMode(false),
		fBuilder(NULL)
{
	InitFileTypes();
	InitGlobals();
	EnsureTemplates();
	
	gProjectList = new LockableList<Project>(20,true);
	gProjectWindowPoint.Set(5,24);

	BMessenger msgr(this);
	BEntry entry(gLastProjectPath.GetFullPath());
	entry_ref ref;
	entry.GetRef(&ref);
	fOpenPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_FILE_NODE,true,
								new BMessage(B_REFS_RECEIVED));
	fOpenPanel->Window()->SetTitle("Paladin: Open Project");
}
Exemplo n.º 18
0
bool ListView1::InitiateDrag(BPoint point,  bool wasSelected) {
printf("InitiateDrag():");
	
	point.PrintToStream();
	BRow	*row=FocusRow();
	if (row==NULL) return false;
/*	
	if ((CDMode==DATACD_INDEX) || (CDMode==BOOTABLECD_INDEX)) {	// yes? then we are not in audio mode
		folderRow=new FolderRow(((FolderRow *)row)->GetFilename(),
						((FolderRow *)row)->IsFolder(),
						((FolderRow *)row)->GetBitmap());
	} else */
	if ((CDMode==AUDIOCD_INDEX) || (CDMode==CDEXTRA_INDEX)){
		audioRow=new AudioRow(((AudioRow *)row)->GetTrackNumber(),((AudioRow *)row)->GetFilename(),
						((AudioRow *)row)->GetPregap(),
						((AudioRow *)row)->GetBytes(),
						((AudioRow *)row)->GetLength());
		audioRow->SetCDTitle(((AudioRow *)row)->GetCDTitle());
		audioRow->SetIndexList(((AudioRow *)row)->GetIndexList());
		audioRow->SetPregap(((AudioRow *)row)->GetPregap());
		audioRow->SetStartFrame(((AudioRow *)row)->GetStartFrame());
		audioRow->SetEndFrame(((AudioRow *)row)->GetEndFrame());
//		audioRow->SetStartTime(((AudioRow *)row)->GetStartTime());
//		audioRow->SetEndTime(((AudioRow *)row)->GetEndTime());
		//audioRow=new AudioRow(*((AudioRow *)row));
	}
	
	BMessage	*message=new BMessage(LISTITEM_DROPPED);
	BRect		rect;
	if (GetRowRect(row, &rect)) {
		void *r=(void *)row;
		message->AddPointer("from", r);
		if (!((FolderRow *)row)->IsFolder())
			message->AddInt32("index", (int32)IndexOf(row));
		DragMessage(message, rect);
//		if ((CDMode==AUDIOCD_INDEX) || (CDMode==CDEXTRA_INDEX))
//			RemoveRow(IndexOf(row));
		//delete row;
	}
	return true;
}
Exemplo n.º 19
0
void MediaJack::_drawInto(
	BView *target,
	BRect targetRect,
	int32 layout)
{
	D_METHOD(("MediaJack::_drawInto()\n"));

	bool selected = isConnecting() || isSelected();
	switch (layout)
	{
		case MediaRoutingView::M_ICON_VIEW:
		{
			if (isInput())
			{
				BRect r;
				BPoint p;

				// fill rect
				r = targetRect;
				target->SetLowColor(M_GRAY_COLOR);
				r.left += 2.0;
				target->FillRect(r, B_SOLID_LOW);

				// draw connection point
				r = targetRect;
				p.Set(0.0, Frame().Height() / 2.0 - 2.0);
				target->BeginLineArray(4);
				{
					target->AddLine(r.LeftTop(),
									p,
									M_DARK_GRAY_COLOR);
					target->AddLine(r.LeftTop() + BPoint(1.0, 0.0),
									p + BPoint(1.0, 0.0),
									M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 5.0),
									r.LeftBottom(),
									M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 5.0),
									r.LeftBottom() + BPoint(1.0, 0.0),
									M_LIGHT_GRAY_COLOR);
				}
				target->EndLineArray();

				if (isConnected() || isConnecting())
				{
					target->BeginLineArray(11);
					{
						target->AddLine(p, p, M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(0.0, 4.0), p + BPoint(0.0, 4.0), M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 0.0), p + BPoint(4.0, 0.0), M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 4.0), p + BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR);
						target->AddLine(p + BPoint(4.0, 1.0), p + BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR);
						target->AddLine(p + BPoint(0.0, 1.0), p + BPoint(2.0, 1.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(3.0, 1.0), p + BPoint(3.0, 1.0), M_MED_GRAY_COLOR);
						target->AddLine(p + BPoint(0.0, 2.0), p + BPoint(2.0, 2.0), selected ? M_LIGHT_BLUE_COLOR : M_LIGHT_GRAY_COLOR);
						target->AddLine(p + BPoint(3.0, 2.0), p + BPoint(3.0, 2.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(0.0, 3.0), p + BPoint(2.0, 3.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(3.0, 3.0), p + BPoint(3.0, 3.0), M_MED_GRAY_COLOR);
					}
					target->EndLineArray();
				}
				else
				{
					target->BeginLineArray(7);
					{
						target->AddLine(p, p + BPoint(0.0, 4.0), M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 0.0), p + BPoint(4.0, 0.0), M_DARK_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 4.0), p + BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR);
						target->AddLine(p + BPoint(4.0, 1.0), p + BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 1.0), p + BPoint(3.0, 1.0), M_MED_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 2.0), p + BPoint(3.0, 2.0), M_MED_GRAY_COLOR);
						target->AddLine(p + BPoint(1.0, 3.0), p + BPoint(3.0, 3.0), M_MED_GRAY_COLOR);
					}
					target->EndLineArray();
				}

				// draw abbreviation string
				BFont font(be_plain_font);
				font_height fh;
				font.SetSize(font.Size() - 2.0);
				font.GetHeight(&fh);
				p.x += 7.0;
				p.y = (Frame().Height() / 2.0) + (fh.ascent / 2.0);
				target->SetFont(&font);
				target->SetDrawingMode(B_OP_OVER);
				target->SetHighColor((isConnected() || isConnecting()) ?
									  M_MED_GRAY_COLOR :
									  M_DARK_GRAY_COLOR);
				target->DrawString(m_abbreviation.String(), p);
			}
			else if (isOutput())
			{
				BRect r;
				BPoint p;

				// fill rect
				r = targetRect;
				target->SetLowColor(M_GRAY_COLOR);
				r.right -= 2.0;
				target->FillRect(r, B_SOLID_LOW);

				// draw connection point
				r = targetRect;
				p.Set(targetRect.right - 4.0, Frame().Height() / 2.0 - 2.0);
				target->BeginLineArray(4);
				{
					target->AddLine(r.RightTop(),
									p + BPoint(4.0, 0.0),
									M_DARK_GRAY_COLOR);
					target->AddLine(r.RightTop() + BPoint(-1.0, 0.0),
									p + BPoint(3.0, 0.0),
									M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 5.0),
									r.RightBottom(),
									M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 5.0),
									r.RightBottom() + BPoint(-1.0, 0.0),
									M_MED_GRAY_COLOR);
				}
				target->EndLineArray();

				if (isConnected() || isConnecting())
				{
					target->BeginLineArray(11);
					target->AddLine(p + BPoint(4.0, 0.0), p + BPoint(4.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 4.0), p + BPoint(4.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p, p + BPoint(3.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 1.0), p + BPoint(0.0, 3.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 4.0), p + BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 1.0), p + BPoint(1.0, 1.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 1.0), p + BPoint(4.0, 1.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 2.0), p + BPoint(1.0, 2.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 2.0), p + BPoint(4.0, 2.0), selected ? M_LIGHT_BLUE_COLOR : M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 3.0), p + BPoint(1.0, 3.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 3.0), p + BPoint(4.0, 3.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->EndLineArray();
				}
				else
				{
					target->BeginLineArray(7);
					target->AddLine(p + BPoint(4.0, 0.0), p + BPoint(4.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p, p + BPoint(3.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 1.0), p + BPoint(0.0, 3.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 4.0), p + BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 1.0), p + BPoint(3.0, 1.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 2.0), p + BPoint(3.0, 2.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 3.0), p + BPoint(3.0, 3.0), M_MED_GRAY_COLOR);
					target->EndLineArray();
				}

				// draw abbreviation string
				BFont font(be_plain_font);
				font_height fh;
				font.SetSize(font.Size() - 2.0);
				font.GetHeight(&fh);
				p.x -= font.StringWidth(m_abbreviation.String()) + 2.0;
				p.y = (Frame().Height() / 2.0) + (fh.ascent / 2.0);
				target->SetFont(&font);
				target->SetDrawingMode(B_OP_OVER);
				target->SetHighColor((isConnected() || isConnecting()) ?
									  M_MED_GRAY_COLOR :
									  M_DARK_GRAY_COLOR);
				target->DrawString(m_abbreviation.String(), p);
			}
			break;
		}
		case MediaRoutingView::M_MINI_ICON_VIEW:
		{
			if (isInput())
			{
				BRect r;
				BPoint p;

				// fill rect
				r = targetRect;
				target->SetLowColor(M_GRAY_COLOR);
				r.top += 2.0;
				target->FillRect(r, B_SOLID_LOW);

				// draw connection point
				r = targetRect;
				p.Set(Frame().Width() / 2.0 - 2.0, 0.0);
				target->BeginLineArray(4);
				{
					target->AddLine(r.LeftTop(),
									p,
									M_DARK_GRAY_COLOR);
					target->AddLine(r.LeftTop() + BPoint(0.0, 1.0),
									p + BPoint(0.0, 1.0),
									M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(5.0, 0.0),
									r.RightTop(),
									M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(5.0, 1.0),
									r.RightTop() + BPoint(0.0, 1.0),
									M_LIGHT_GRAY_COLOR);
				}
				target->EndLineArray();
				if (isConnected() || isConnecting())
				{
					target->BeginLineArray(11);
					target->AddLine(p, p, M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 0.0), p + BPoint(4.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 1.0), p + BPoint(0.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 1.0), p + BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 4.0), p + BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 0.0), p + BPoint(1.0, 2.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 3.0), p + BPoint(1.0, 3.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 0.0), p + BPoint(2.0, 2.0), selected ? M_LIGHT_BLUE_COLOR : M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 3.0), p + BPoint(2.0, 3.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 0.0), p + BPoint(3.0, 2.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 3.0), p + BPoint(3.0, 3.0), M_MED_GRAY_COLOR);
					target->EndLineArray();
				}
				else
				{
					target->BeginLineArray(7);
					target->AddLine(p, p + BPoint(4.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(0.0, 1.0), p + BPoint(0.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 1.0), p + BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 4.0), p + BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 1.0), p + BPoint(1.0, 3.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 1.0), p + BPoint(2.0, 3.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 1.0), p + BPoint(3.0, 3.0), M_MED_GRAY_COLOR);
					target->EndLineArray();
				}
			}
			else if (isOutput())
			{
				BRect r = targetRect;
				BPoint p;

				// fill rect
				r = targetRect;
				target->SetLowColor(M_GRAY_COLOR);
				r.bottom -= 2.0;
				target->FillRect(r, B_SOLID_LOW);

				// draw connection point
				r = targetRect;
				p.Set(Frame().Width() / 2.0 - 2.0, targetRect.bottom - 4.0);
				target->BeginLineArray(4);
				{
					target->AddLine(r.LeftBottom(),
									p + BPoint(0.0, 4.0),
									M_DARK_GRAY_COLOR);
					target->AddLine(r.LeftBottom() + BPoint(0.0, -1.0),
									p + BPoint(0.0, 3.0),
									M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(5.0, 4.0),
									r.RightBottom(),
									M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(5.0, 3.0),
									r.RightBottom() + BPoint(0.0, -1.0),
									M_MED_GRAY_COLOR);
				}
				target->EndLineArray();
				if (isConnected() || isConnecting())
				{
					target->BeginLineArray(11);
					target->AddLine(p + BPoint(0.0, 4.0), p + BPoint(0.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 4.0), p + BPoint(4.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p, p + BPoint(0.0, 3.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 0.0), p + BPoint(3.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 0.0), p + BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 1.0), p + BPoint(1.0, 1.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 2.0), p + BPoint(1.0, 4.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 1.0), p + BPoint(2.0, 1.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 2.0), p + BPoint(2.0, 4.0), selected ? M_LIGHT_BLUE_COLOR : M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 1.0), p + BPoint(3.0, 1.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 2.0), p + BPoint(3.0, 4.0), selected ? M_BLUE_COLOR : M_DARK_GRAY_COLOR);
					target->EndLineArray();
				}
				else
				{
					target->BeginLineArray(7);
					target->AddLine(p + BPoint(0.0, 4.0), p + BPoint(4.0, 4.0), M_DARK_GRAY_COLOR);
					target->AddLine(p, p + BPoint(0.0, 3.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 0.0), p + BPoint(3.0, 0.0), M_DARK_GRAY_COLOR);
					target->AddLine(p + BPoint(4.0, 0.0), p + BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR);
					target->AddLine(p + BPoint(1.0, 1.0), p + BPoint(1.0, 3.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(2.0, 1.0), p + BPoint(2.0, 3.0), M_MED_GRAY_COLOR);
					target->AddLine(p + BPoint(3.0, 1.0), p + BPoint(3.0, 3.0), M_MED_GRAY_COLOR);
					target->EndLineArray();
				}
			}
			break;
		}
	}
}
Exemplo n.º 20
0
void
BRadioButton::Draw(BRect updateRect)
{
	if (Window() == NULL) return;

	BFont font;
	GetFont(&font);
	font_height fontHeight;
	font.GetHeight(&fontHeight);
	float sHeight = fontHeight.ascent + fontHeight.descent;

	BRect rect = Frame().OffsetToSelf(B_ORIGIN);
	rect.InsetBy(5, (rect.Height() - sHeight) / 2);
	if (rect.IsValid() == false) return;

	if ((IsFocus() || IsFocusChanging()) && IsEnabled() && Label() != NULL) {
		BPoint penLocation;
		penLocation.Set(rect.left + rect.Height() + 5, rect.Center().y + sHeight / 2 + 1);

		SetHighColor((IsFocus() && Window()->IsActivate()) ? ui_color(B_NAVIGATION_BASE_COLOR) : ViewColor());
		StrokeLine(penLocation, penLocation + BPoint(font.StringWidth(Label()), 0));
	}

	if (IsFocusChanging()) return;

	rgb_color shineColor = ui_color(B_SHINE_COLOR);
	rgb_color shadowColor = ui_color(B_SHADOW_COLOR);

	if (!IsEnabled()) {
		shineColor.disable(ViewColor());
		shadowColor.disable(ViewColor());
	}

	rect.right = rect.left + rect.Height();
	SetHighColor(shineColor.mix_copy(0, 0, 0, 5));
	FillEllipse(rect);
	SetHighColor(shineColor);
	StrokeArc(rect, 225, 180);
	SetHighColor(shadowColor);
	StrokeArc(rect, 45, 180);

	if (Value() == B_CONTROL_ON) {
		SetHighColor(shadowColor.mix_copy(255, 255, 255, 50));
		BRect r = rect.InsetByCopy(3, 3);
		FillEllipse(r);
	}

	if (Label() != NULL) {
		BPoint penLocation;
		penLocation.x = rect.right + 5;
		penLocation.y = rect.Center().y - sHeight / 2.f;
		penLocation.y += fontHeight.ascent + 1;

		SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor()));
		SetLowColor(ViewColor());

		DrawString(Label(), penLocation);
		if (!IsEnabled()) {
			SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor()));
			DrawString(Label(), penLocation - BPoint(1, 1));
		}
	}
}
Exemplo n.º 21
0
void
ShortcutsSpec::DrawItemColumn(BView* owner, BRect item_column_rect,
	int32 column_index, bool columnSelected, bool complete)
{
	const float STRING_COLUMN_LEFT_MARGIN = 25.0f; // 16 for the icon,+9 empty

	rgb_color color;
	bool selected = IsSelected();
	if (selected)
		color = columnSelected ? BeBackgroundGrey : BeListSelectGrey;
	else
		color = BeInactiveControlGrey;
	owner->SetLowColor(color);
	owner->SetDrawingMode(B_OP_COPY);
	owner->SetHighColor(color);
	owner->FillRect(item_column_rect);

	const char* text = GetCellText(column_index);

	if (text == NULL)
		return;

	_CacheViewFont(owner);
		// Ensure that sViewFont is configured before using it to calculate
		// widths.  The lack of this call was causing the initial display of
		// columns to be incorrect, with a "jump" as all the columns correct
		// themselves upon the first column resize.

	float textWidth = sViewFont.StringWidth(text);
	BPoint point;
	rgb_color lowColor = color;

	if (column_index == STRING_COLUMN_INDEX) {
		// left justified
		point.Set(item_column_rect.left + STRING_COLUMN_LEFT_MARGIN,
			item_column_rect.top + fTextOffset);

		item_column_rect.left = point.x;
			// keep text from drawing into icon area

		// scroll if too wide
		float rectWidth = item_column_rect.Width() - STRING_COLUMN_LEFT_MARGIN;
		float extra = textWidth - rectWidth;
		if (extra > 0.0f)
			point.x -= extra;
	} else {
		if ((column_index < NUM_META_COLUMNS) && (text[0] == '('))
			return; // don't draw for this ...

		if ((column_index <= NUM_META_COLUMNS) && (text[0] == '\0'))
			return; // don't draw for this ...

		// centered
		point.Set((item_column_rect.left + item_column_rect.right) / 2.0,
			item_column_rect.top + fTextOffset);
		_CacheViewFont(owner);
		point.x -= textWidth / 2.0f;
	}

	BRegion Region;
	Region.Include(item_column_rect);
	owner->ConstrainClippingRegion(&Region);
	if (column_index != STRING_COLUMN_INDEX) {
		const float KEY_MARGIN = 3.0f;
		const float CORNER_RADIUS = 3.0f;
		_CacheViewFont(owner);

		// How about I draw a nice "key" background for this one?
		BRect textRect(point.x - KEY_MARGIN, (point.y-sFontHeight) - KEY_MARGIN
			, point.x + textWidth + KEY_MARGIN - 2.0f, point.y + KEY_MARGIN);

		if (column_index == KEY_COLUMN_INDEX)
			lowColor = ReallyLightPurple;
		else
			lowColor = LightYellow;

		owner->SetHighColor(lowColor);
		owner->FillRoundRect(textRect, CORNER_RADIUS, CORNER_RADIUS);
		owner->SetHighColor(Black);
		owner->StrokeRoundRect(textRect, CORNER_RADIUS, CORNER_RADIUS);
	}

	owner->SetHighColor(Black);
	owner->SetLowColor(lowColor);
	owner->DrawString(text, point);
	// with a cursor at the end if highlighted
	if (column_index == STRING_COLUMN_INDEX) {
		// Draw cursor
		if ((columnSelected) && (selected)) {
			point.x += textWidth;
			point.y += (fTextOffset / 4.0f);

			BPoint pt2 = point;
			pt2.y -= fTextOffset;
			owner->StrokeLine(point, pt2);

			fCursorPt1 = point;
			fCursorPt2 = pt2;
			fCursorPtsValid = true;
		}

		BRegion bitmapRegion;
		item_column_rect.left	-= (STRING_COLUMN_LEFT_MARGIN - 4.0f);
		item_column_rect.right	= item_column_rect.left + 16.0f;
		item_column_rect.top	+= 3.0f;
		item_column_rect.bottom	= item_column_rect.top + 16.0f;

		bitmapRegion.Include(item_column_rect);
		owner->ConstrainClippingRegion(&bitmapRegion);
		owner->SetDrawingMode(B_OP_ALPHA);

		if ((fCommand != NULL) && (fCommand[0] == '*'))
			owner->DrawBitmap(sActuatorBitmaps[fBitmapValid ? 1 : 0],
				ICON_BITMAP_RECT, item_column_rect);
		else
			// Draw icon, if any
			if (fBitmapValid)
				owner->DrawBitmap(&fBitmap, ICON_BITMAP_RECT,
					item_column_rect);
	}

	owner->SetDrawingMode(B_OP_COPY);
	owner->ConstrainClippingRegion(NULL);
}
Exemplo n.º 22
0
void
ActivityView::_DrawHistory(bool drawBackground)
{
	_UpdateOffscreenBitmap();

	BView* view = this;
	if (fOffscreen != NULL) {
		fOffscreen->Lock();
		view = _OffscreenView();
	}

	BRect frame = _HistoryFrame();
	BRect outerFrame = frame.InsetByCopy(-2, -2);

	// draw the outer frame
	uint32 flags = 0;
	if (!drawBackground)
		flags |= BControlLook::B_BLEND_FRAME;
	be_control_look->DrawTextControlBorder(this, outerFrame,
		outerFrame, fLegendBackgroundColor, flags);

	// convert to offscreen view if necessary
	if (view != this)
		frame.OffsetTo(B_ORIGIN);

	view->SetLowColor(fHistoryBackgroundColor);
	view->FillRect(frame, B_SOLID_LOW);

	uint32 step = 2;
	uint32 resolution = fDrawResolution;
	if (fDrawResolution > 1) {
		step = 1;
		resolution--;
	}

	// We would get a negative number of steps which isn't a good idea.
	if (frame.IntegerWidth() <= 10)
		return;

	uint32 width = frame.IntegerWidth() - 10;
	uint32 steps = width / step;
	bigtime_t timeStep = RefreshInterval() * resolution;
	bigtime_t now = system_time();

	// Draw scale
	// TODO: add second markers?

	view->SetPenSize(1);

	rgb_color scaleColor = view->LowColor();
	uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
	if (average < 96)
		scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
	else
		scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);

	view->SetHighColor(scaleColor);
	view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
		BPoint(frame.right, frame.top + frame.Height() / 2));

	// Draw values

	view->SetPenSize(1.5);
	BAutolock _(fSourcesLock);

	for (uint32 i = fSources.CountItems(); i-- > 0;) {
		ViewHistory* viewValues = fViewValues.ItemAt(i);
		DataSource* source = fSources.ItemAt(i);
		DataHistory* values = fValues.ItemAt(i);

		viewValues->Update(values, steps, fDrawResolution, now, timeStep,
			RefreshInterval());

		if (viewValues->Start() >= (int32)steps - 1)
			continue;

		uint32 x = viewValues->Start() * step;

		bool first = true;

		view->SetHighColor(source->Color());
		view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
		view->MovePenTo(B_ORIGIN);

		try {
			view->BeginLineArray(steps - viewValues->Start() - 1);

			BPoint prev;

			for (uint32 j = viewValues->Start(); j < steps; x += step, j++) {
				float y = _PositionForValue(source, values,
					viewValues->ValueAt(j));

				if (first) {
					first = false;
				} else
					view->AddLine(prev, BPoint(x, y), source->Color());

				prev.Set(x, y);
			}

		} catch (std::bad_alloc) {
			// Not enough memory to allocate the line array.
			// TODO we could try to draw using the slower but less memory
			// consuming solution using StrokeLine.
		}

		view->EndLineArray();
	}

	// TODO: add marks when an app started or quit
	view->Sync();
	if (fOffscreen != NULL) {
		fOffscreen->Unlock();
		DrawBitmap(fOffscreen, outerFrame.LeftTop());
	}
}
Exemplo n.º 23
0
//calc
_DLL_EXPORT int STDCALL calculate()
{
  bool info = false;


  //calc footprint
  if(     lBPoint.size() == 0 &&
          lCam_bore.size() == 1 &&
          m_is_set_RefGroundSurface &&
          m_is_set_GlobalCarReferencePoint &&
          m_is_set_GlobalReferenceFrame &&
          m_is_set_distance_epi)
  {
     // cout << endl << "### in function foot print ##"<<flush;

     //todo foot print
                     double offset = I.m_distance_epi;
                     double dist_to_cut = 20;

                     Gps_pos gps_pos;
                     gps_pos.set_Easting(I.m_Easting);
                     gps_pos.set_Northing(I.m_Northing);
                     gps_pos.set_EllH(I.m_eHeight);
                     gps_pos.set_Roll(I.m_roll);
                     gps_pos.set_Pitch(I.m_pitch);
                     gps_pos.set_Heading(I.m_heading);
                     gps_pos.set_Latitude(I.m_latitude);
                     gps_pos.set_Longitude(I.m_longitude);

                     Ebene m_E(I.m_nx,I.m_ny,I.m_nz,I.m_d);

                     double sensor_m = (*lCam_bore.rbegin()).get_pix_row();
                     double sensor_n = (*lCam_bore.rbegin()).get_pix_col();

                     double lo_m = offset;               double lo_n = offset;
                     double lu_m = offset;               double lu_n = sensor_n - offset;
                     double ro_m = sensor_m - offset;    double ro_n = offset;
                     double ru_m = sensor_m - offset;    double ru_n = sensor_n - offset;

                     BPoint_bore BP_lo( *lCam_bore.rbegin() , gps_pos , 1 , lo_m , lo_n );
                     BP_lo.calc_footprint_point(m_E,BPoint_bore::car,dist_to_cut);
                     Point_nr Plo = BP_lo.get_measurement_point(BPoint_bore::global);

                     BPoint_bore BP_lu( *lCam_bore.rbegin()  , gps_pos , 2 , lu_m , lu_n );
                     BP_lu.calc_footprint_point(m_E,BPoint_bore::car,dist_to_cut);
                     Point_nr Plu = BP_lu.get_measurement_point(BPoint_bore::global);

                     BPoint_bore BP_ro( *lCam_bore.rbegin()  , gps_pos , 3 , ro_m , ro_n );
                     BP_ro.calc_footprint_point(m_E,BPoint_bore::car,dist_to_cut);
                     Point_nr Pro = BP_ro.get_measurement_point(BPoint_bore::global);

                     BPoint_bore BP_ru( *lCam_bore.rbegin()  , gps_pos , 4 , ru_m , ru_n );
                     BP_ru.calc_footprint_point(m_E,BPoint_bore::car,dist_to_cut);
                     Point_nr Pru = BP_ru.get_measurement_point(BPoint_bore::global);

                     //cout << endl << "  P lo: " <<Plo;
                     //cout         << "  P ro: " <<Pro;
                     //cout << endl << "  P lu: " <<Plu;
                     //cout         << "  P ru: " <<Pru;

                     //save back into the structure
                     I.m_x_P1_global = Plo.get_X();
                     I.m_x_P2_global = Pro.get_X();
                     I.m_x_P3_global = Plu.get_X();
                     I.m_x_P4_global = Pru.get_X();

                     I.m_y_P1_global = Plo.get_Y();
                     I.m_y_P2_global = Pro.get_Y();
                     I.m_y_P3_global = Plu.get_Y();
                     I.m_y_P4_global = Pru.get_Y();

                     I.m_z_P1_global = Plo.get_Z();
                     I.m_z_P2_global = Pro.get_Z();
                     I.m_z_P3_global = Plu.get_Z();
                     I.m_z_P4_global = Pru.get_Z();

  }


  //calc local measurement point -> forward intersection
  if(lBPoint.size() > 1)
    {
      //calc forward intersection with min. 2 picture points
      Vorwaertsschnitt vws(lBPoint);
      Point p;
      p=vws.get_Schnittpunkt();

      //cout<<endl<<"intern P local:"<<p<<endl;

      if(vws.get_is_error())
        {
          cerr << endl << endl;
          cerr << "error in forward intersection!" <<flush;
        }
      else
        {

          I.m_x_local	=p.get_X();
          I.m_y_local	=p.get_Y();
          I.m_z_local	=p.get_Z();
          I.m_stdx_local=p.get_dX();
          I.m_stdy_local=p.get_dY();
          I.m_stdz_local=p.get_dZ();

          //control
          info=true;
          m_is_calc_vws=true;
          m_is_set_LocalMeasurementPoint=true;
        }
    }

	//calculate a point on the epipolarline
	if( 	lCam_bore.size() == 2 && lBPoint.size() == 1 &&
			m_is_set_distance_epi
			)
	{
	  Cam *cam = new Cam(*lCam_bore.rbegin());

	  BPoint bp = lBPoint.begin()->get_KernlinenPunkt( *cam , I.m_distance_epi );

	  delete cam;

	  I.m_m = bp.get_m();
	  I.m_n = bp.get_n();


	  m_is_set_distance_epi = false;
	  m_is_calc_epipolarline =true;
	  info=true;
	}

	//forward intersection from a pixel coordinate to a object ray into a plane
	//for e.g. mono photogrammetrie with one cam and informations about the ground surface
	if( 	lCam_bore.size() == 1 &&
			m_is_set_RefGroundSurface
			)
	{
			//create a plane
			Ebene E(I.m_nx,I.m_ny,I.m_nz,I.m_d);

			//rotation parameter boreside
			Point BT;
			BT = (lCam_bore.rbegin())->get_B();
			Rotation_matrix BR(Rotation_matrix::math,lCam_bore.rbegin()->get_B_rotx(),lCam_bore.rbegin()->get_B_roty(),lCam_bore.rbegin()->get_B_rotz());

			E=E.RotationRueck(BT,BR);

			Cam *cam = new Cam(*lCam_bore.rbegin());

			BPoint bp(*cam,I.m_m,I.m_n);

			Point p;
			p = bp.calc_mono_cam_to_plane_intersection(E);

			I.m_x_local	=p.get_X();
			I.m_y_local	=p.get_Y();
			I.m_z_local	=p.get_Z();
			I.m_stdx_local=p.get_dX();
			I.m_stdy_local=p.get_dY();
			I.m_stdz_local=p.get_dZ();

			delete cam;

			//control
			info=true;
			m_is_set_LocalMeasurementPoint=true;
			m_is_calc_lokal_RefGroundSurface=true;
	}


	//calc global measurement point > boreside calibration
	if( m_is_set_LocalMeasurementPoint && m_is_set_GlobalCarReferencePoint && m_is_set_GlobalReferenceFrame)
	{
		Point p;

		if(!m_is_set_GlobalCarReferencePoint_CamSetGlobal)
		{
			Boresight_transformation bore(*lCam_bore.begin());

			if(!m_is_set_GlobalCarReferencePoint_std)
				I.m_dEasting=I.m_dNorthing=I.m_deHeigth=I.m_droll=I.m_dpitch=I.m_dheading=0.0;

			//cout<<endl<<"carpos: E: "<<m_Easting<<"  N:"<<m_Northing<<"  H:"<<m_eHeight<<"  r:"<<m_roll<<"  p:"<<m_pitch<<"  h:"<<m_heading;
			bore.set_car_position_global(I.m_Easting,I.m_Northing,I.m_eHeight,I.m_roll,I.m_pitch,I.m_heading);

			//cout<<endl<<"intern P local: "<<m_x_local <<" "<< m_y_local <<" "<<  m_z_local;
			bore.set_local_coordinate( I.m_x_local , I.m_y_local , I.m_z_local );

			p=bore.get_global_coordinate();
		}
		else
		{
			//for global coordinate into the forward intersection function -- boresight transformation is not necessary
			Point tmp(I.m_x_local , I.m_y_local , I.m_z_local);
			tmp.set_dX(I.m_stdx_local);
			tmp.set_dY(I.m_stdy_local);
			tmp.set_dZ(I.m_stdz_local);
			//I=p;
			p=tmp;
		}

		I.m_x_global		=p.get_X();
		I.m_y_global		=p.get_Y();
		I.m_z_global		=p.get_Z();
		I.m_stdx_global	    =p.get_dX();
		I.m_stdy_global	    =p.get_dY();
		I.m_stdz_global	    =p.get_dZ();

		//control
		m_is_calc_bore = true;
		m_is_set_GlobalMeasurementPoint=true;
	}


	//backward calculation from a global point back to pixel coordinate
	//for e.g. paint the global Point XYZ into the picture
	if( 	lCam_bore.size() == 1 &&
			m_is_set_GlobalCarReferencePoint &&
			m_is_set_GlobalReferenceFrame &&
			m_is_set_GlobalMeasurementPoint
			)
	{
		    //calc the bore side transformation with the global car position
		    Boresight_transformation bore(*lCam_bore.rbegin());

			bore.set_car_position_global(I.m_Easting,I.m_Northing,I.m_eHeight,I.m_roll,I.m_pitch,I.m_heading);

			bore.set_global_coordinate(I.m_x_global,I.m_y_global,I.m_z_global);

			Point P_local;
			P_local = bore.get_local_coordinate();

			Cam *cam = new Cam(*lCam_bore.rbegin());
		    BPoint bp(*cam,P_local.get_X(),P_local.get_Y(),P_local.get_Z());

		    I.m_m = bp.get_m();
		    I.m_n = bp.get_n();

		    delete cam;

			//control
			info=true;
			m_is_set_mn=true;
	}


	//backward calculation from a local point back to pixel coordinate
	//for e.g. paint the local Point XYZ into the picture
	if( 	lCam_bore.size() == 1 &&
			m_is_set_LocalMeasurementPoint
			)
	{
			Cam *cam = new Cam(*lCam_bore.rbegin());
		    BPoint bp(*cam, I.m_x_local , I.m_y_local , I.m_z_local );

		    I.m_m = bp.get_m();
		    I.m_n = bp.get_n();

		    delete cam;

		    //control
			info=true;
			m_is_set_mn=true;
	}



  return static_cast<int>(info);
}
Exemplo n.º 24
0
    const stk_classic::mesh::Entity *
    STKSearcher<SpatialDim>::findElement(MDArray& input_phy_points, MDArray& found_parametric_coordinates,
                                         unsigned& found_it, const mesh::Entity *hint_element )
    {
      //return 0;
      mesh::fem::FEMMetaData& metaData = stk_classic::mesh::fem::FEMMetaData::get(*m_bulk);
      mesh::BulkData& bulkData = *m_bulk;

      //VectorFieldType *coords_field = metaData.get_field<VectorFieldType >("coordinates");

      PerceptMesh meshUtil(&metaData, &bulkData);

      double pts[SpatialDim];
      for (unsigned iDim = 0; iDim < SpatialDim; iDim++)
        {
          pts[iDim] = input_phy_points(0, iDim);
        }
      BPoint pointBoundingBox;
      pointBoundingBox.key.ident = 123;  // FIXME for multiple points
      pointBoundingBox.set_center(pts);
      std::vector<BPoint> points(1, pointBoundingBox);

      stk_classic::search::FactoryOrder order;
      order.m_communicator = bulkData.parallel();
      order.m_algorithm = stk_classic::search::FactoryOrder::BIHTREE;

      if (0 || EXTRA_PRINT)
        {
          bool box_p = m_boxes[0].intersect(pointBoundingBox);
          bool p_box = pointBoundingBox.intersect(m_boxes[0]);

          std::cout << "STKSearcher::findElement: m_boxes[0]=  " << m_boxes[0] << std::endl;
          std::cout << "STKSearcher::findElement: pointBoundingBox=  " << pointBoundingBox << std::endl;
          std::cout << "STKSearcher::findElement: box_p=  " << box_p << std::endl;
          std::cout << "STKSearcher::findElement: p_box=  " << p_box << std::endl;
        }

      if (0 || EXTRA_PRINT) std::cout << "STKSearcher::findElement: nboxes=  " << m_boxes.size()  << std::endl;

      IdentProcRelation relation;
      stk_classic::search::coarse_search(relation,  m_boxes, points, order);
      //stk_classic::search::coarse_search(relation,   points, m_boxes, order);

      if (0 || EXTRA_PRINT) std::cout << "STKSearcher::findElement: found  " << relation.size() << " containing bboxes"  << std::endl;

      if (relation.size())
        {
          IsInElement isIn(input_phy_points, found_parametric_coordinates);

          for (unsigned i = 0; i < relation.size(); i++)
            {
              if (0 || EXTRA_PRINT)
                std::cout << "relation[ " << i << "]= {" << relation[i].first << "} --> { " << relation[i].second << "}" << std::endl;
              mesh::Entity *element = bulkData.get_entity(metaData.element_rank(), relation[i].second.ident);
              //bool loop_break = ... intentionally ignoring return value
              isIn(*element, bulkData);
              if (0 || EXTRA_PRINT) std::cout << "STKSearcher::findElement: found it= " << isIn.m_found_it << std::endl;
              if (isIn.m_found_it)
                {
                  found_it = 1;
                  return isIn.m_foundElement;
                }
              else
                {
                  found_it = 0;
                  return 0;
                }
            }
        }

      return 0;
    }
Exemplo n.º 25
0
void
View::FrameMoved(BPoint point)
{
	point.PrintToStream();
}