Esempio n. 1
0
//************************************************************************
void CDib::SwapLines( int y1, int y2, int iCount )
//************************************************************************
{
HPTR lpLineB, lpSwap1, lpSwap2;
int iHeight = abs( GetHeight() );
int iWidth = GetWidthBytes();

if ( m_bmiHeader.biCompression != BI_RGB )
	return;

if ( !(lpSwap1 = GetXY( 0, y1 )) )
	return;

if ( !(lpSwap2 = GetXY( 0, y2 )) )
	return;

if ( !(lpLineB = Alloc( iWidth )) )
	return;

if ( y1 < 0 )
	y1 = -y1;
if ( y1 >= iHeight )
	y1 = iHeight-1;

if ( y2 < 0 )
	y2 = -y2;
if ( y2 >= iHeight )
	y2 = iHeight-1;

if ( iCount < 0 )
	iCount = -iCount;
if ( y1 + iCount > iHeight )
	iCount = iHeight - y1;
if ( y2 + iCount > iHeight )
	iCount = iHeight - y2;

int iDelta = ( GetHeight() < 0 ? iWidth : -iWidth ); // if its an upside down DIB...
while ( --iCount >= 0 )
	{
	hmemcpy( lpLineB, lpSwap2, iWidth );
	hmemcpy( lpSwap2, lpSwap1, iWidth );
	hmemcpy( lpSwap1, lpLineB, iWidth );
	lpSwap1 += iDelta;
	lpSwap2 += iDelta;
	}

FreeUp( lpLineB );
}
Esempio n. 2
0
void DoSlewingMenu( int *menu )
// Shows slew progress in X and Y.  Called to do the slew from within
// the tracking routine, and returns to tracking when done.
{
   long int X_Target, Y_Target;
   double HA, Alt, Az;
   int x=25, y=TRACKINGDISPLAY, w=y+5;

   clrscr();
   FrameScreen();
   *menu = TrackingMenu;
   gotoxy(37,y); printf("Slewing");
   DisplayCoordinates(w,1,1,0);   
   gotoxy(x,w+0); printf("(Target RA: %4d:%02d:%02d )", _HOURS(RA_Target), 
                          _MINUTES(RA_Target), _SECONDS(RA_Target));
   gotoxy(x,w+1); printf("(Target Dec:%+4d:%02d:%02d )", 
                              _SIGN(DecTarget)*_HOURS(DecTarget), 
                              _MINUTES(DecTarget), _SECONDS(DecTarget));
   gotoxy(18,w+6); printf("Hit q to stop slewing and return to tracking.");
   PrevStatus = Status;
   Status = SLEWING;
   do
   {
      Slew(w+2);
      GetXY( RA_Target, DecTarget, &X_Target, &Y_Target );
      dX = X_Target - gX;
      dY = Y_Target - gY;
   } while ( (pow(dX,2)+pow(dY,2)) > pow(CLOSE_ENOUGH,2) );
   PrevStatus = Status;
   Status = TRACKING;
}
Esempio n. 3
0
void
PluginObject::UpdateXY ()
{
	GetXY (window, &x, &y);

	LOG_PLUGIN ("[%i shocker] PluginObject::SetWindow (window: %p, window->x: %i, window->y: %i, window->width: %i, window->height: %i, x: %i, y: %i)\n", getpid (), window->window, window->x, window->y, window->width, window->height, x, y);
}
NS_IMETHODIMP
HTMLImageElement::GetY(int32_t* aY)
{
  *aY = GetXY().y;

  return NS_OK;
}
NS_IMETHODIMP
HTMLImageElement::GetX(int32_t* aX)
{
  *aX = GetXY().x;

  return NS_OK;
}
Esempio n. 6
0
bool RegularSurfaceRotated<A>::DivideNonConform(const Surface<A> * s2)
{
  A missing_val = surface_.GetMissingValue();
  for (size_t i = 0; i < this->GetN(); i++) {
    if ((*this)(i) != missing_val) {
      double x, y, value;
      GetXY(i, x, y);
      value = s2->GetZ(x, y);
      if (s2->IsMissing(value) == false)
        (*this)(i) /= value;
      else
        (*this)(i) = missing_val;
    }
  }
  return(true);
}
Esempio n. 7
0
int SetPrintPara()
{
   char p[30];
   int i,j;
   static int oldNum=0;

   BEGINOK1;
   //WaitMessageEmpty();
   for (j=0;j<4;j++)
   {
     if (MessageGo(PrintCutWin[wROTATE0+j],GETSTATUS,0l,0l))
       {
        i=j+wROTATE0;
        MessageGo(PrintCutWin[i],SETSTATUS,0l,0l);
        break;
       }
   }

   SetP(PG.PageBlock[CurrentBlock].Xoffset,PrintCutWin[wXPICWIN]);
   SetP(PG.PageBlock[CurrentBlock].Yoffset,PrintCutWin[wYPICWIN]);
   SetP(PG.PageBlock[CurrentBlock].Xscale, PrintCutWin[wXSCALEWIN]);
   SetP(PG.PageBlock[CurrentBlock].Yscale, PrintCutWin[wYSCALEWIN]);
   SetPI(PG.PageBlock[CurrentBlock].PageOffset,PrintCutWin[wPAGEOFFSETWIN]);
   SetPI(PG.PageInc,PrintCutWin[wPAGENUMWIN]);

   MessageGo(PrintCutWin[wROTATE0+PG.PageBlock[CurrentBlock].Rotate%4],SETSTATUS,1l,0l);

  if (oldNum!=PG.Blocks)
  {
   sprintf(p,"%2d",PG.Blocks);
   GetXY(2,&i,&j);
   DispXY(i-10,j,p,COLORPN);
   oldNum=PG.Blocks;
  }
  return 0;
}
Esempio n. 8
0
void DoRA_DecSlewMenu( int *menu )
{
   int      escape=0, acceptable=0, s[255], *p;
   double   oldRA, oldDec, Alt, Az, HA;
   long int X_Target, Y_Target;
   int      letter, firstxx, xx, yy, x=25; 
   int      w=TRACKINGDISPLAY+5, y=w+4+2*ShowXY, i, sign;
   double   temp, hr, min, sec;

   *menu = TrackingMenu;              
   while (!escape && !acceptable)
   {
      for (i=0;i<255;i++) s[i]=NULL;
      gotoxy(x,y); 
      for (i=y; i<25; i++) EraseLine(i);
      FrameScreen();
      gotoxy(x,y+0); printf("Enter coordinates to slew to...");
      gotoxy(x,y+1); printf("     (return to escape)");
      gotoxy(x,y+2); printf(" Enter RA: ");
      firstxx=wherex(); xx=firstxx; yy=wherey();
      p = s;
      do 
      {                                      // Continuously update coord's
         TrackingKeyboard(w,xx,yy,&letter);  // (runs until a key is hit).
         if (letter==BACKSPACE)              // If that key was backspace,
         {
            if (xx > firstxx)
            {
               *(--p) = NULL;                // delete last entry from string
               gotoxy(--xx,yy); 
               printf(" ");                  // and erase screen character.
            }
         }
         else                                // Otherwise,
         {
            *p++ = letter;                   // add that key to the string
            xx++;                            // and advance the screen cursor
         }
      } while (letter!=RETURN);
      p = s;
      RA.hour=ZERO; RA.minute=ZERO; RA.second=ZERO;
      escape = GetCoordinateFromString(s, &RA);
      if (escape) return;

      temp = RA.hour + (RA.minute + RA.second/SIXTY)/SIXTY;
      hr = _HOURS(temp);
      min = _MINUTES(temp);
      sec = _SECONDS(temp);

      for (i=0;i<255;i++) s[i]=NULL;
      gotoxy(x,y); 
      for (i=y; i<23; i++) EraseLine(i);
      gotoxy(x,y);   printf("Enter coordinates to slew to...");
      gotoxy(x,y+1); printf("     (return to escape)");
      gotoxy(x,y+2); printf("       RA: %2.0f:%02.0f:%02.0f", hr, min, sec);
      gotoxy(x,y+3); printf("Enter Dec: ");
      xx=wherex(); firstxx=xx; yy=wherey();
      p = s;
      do 
      {                                      // Continuously update coord's 
         TrackingKeyboard(w,xx,yy,&letter);  // (runs until a key is hit). 
         if (letter==BACKSPACE)              // If that key was backspace,
         {
            if (xx > firstxx)
            {
               *(--p) = NULL;                // delete last entry from string
               gotoxy(--xx,yy); printf(" "); // and erase screen character.
            }
         }
         else                                // Otherwise,
         {
            *p++ = letter;                   // add that key to the string
            ++xx;                            // and advance the screen cursor
         }
      } 
      while (letter!=RETURN);
      p = s;
      Dec.hour=ZERO; Dec.minute=ZERO; Dec.second=ZERO;
      GetSignFromString(s, &sign);
      escape = GetCoordinateFromString(s, &Dec);
      if (escape) return;

      oldRA = RA_Target;
      oldDec = DecTarget;
      RA_Target = RA.hour + (RA.minute + RA.second/SIXTY)/SIXTY;
      DecTarget = Dec.hour + (Dec.minute + Dec.second/SIXTY)/SIXTY;
      DecTarget *= sign;
      GetXY( RA_Target, DecTarget, &X_Target, &Y_Target );
      if ((pow(X_Target,2)+pow(Y_Target,2)) > 
                                 pow(MAXZENITHANGLE*STEPSPERDEGREE,2) )
      {
         escape = 0; acceptable=0;  // If user's requested coordinates would
         dX = 0; dY = 0;            // put the telescope too far over, user
         RA_Target = oldRA;         // is so informed and permitted to try
         DecTarget = oldDec;        // again.
         gotoxy(x,y); 
         for (i=y; i<25; i++) EraseLine(i);
         FrameScreen();
         gotoxy(10,y); 
         printf("     The values you typed will put ");
         printf("the telescope outside its");
         gotoxy(10,y+1); 
         printf("allowed bounds.  It is not allowed lower than a ");
         printf("%ld degree angle.", MAXZENITHANGLE);
         gotoxy(10,y+2);
         printf("               (press any key to continue)");
         xx=wherex(); yy=wherey();
         TrackingKeyboard(10,xx,yy,&letter); // waits for user to press a key
      }
      else 
      {
         acceptable=1;
         *menu=SlewingMenu;
      }
   }
   dX = X_Target - gX;
   dY = Y_Target - gY;
   RA_Orig = RA_Target;
   DecOrig = DecTarget;
   *menu=SlewingMenu;
}
Esempio n. 9
0
int32_t
HTMLImageElement::Y()
{
  return GetXY().y;
}
Esempio n. 10
0
int32_t
HTMLImageElement::X()
{
  return GetXY().x;
}
Esempio n. 11
0
// Note we only support 8bpp DIBs here, and..
// there is no regard for color table matching between the DIBs
//************************************************************************
void CDib::DibBlt(PDIB pdibDst, int dstLeft, int dstTop, int dstWidth, int dstHeight,
				  int srcLeft, int srcTop, int srcWidth, int srcHeight,
				  BOOL bTransparent, LPRGBTRIPLE lpRGB, LPTR lpLut, HPALETTE hPal )
//************************************************************************
{
HPTR pSrc, pDst;
int iScanS, iScanD, iOverrun;

if ( !pdibDst )
	return;
if ( GetBitCount() != 8 )
	return;
if ( pdibDst->GetBitCount() != 8 )
	return;

// Check the coordinate bounds, to avoid an out of range pointer
if ( srcLeft < 0 )	{ dstLeft -= srcLeft; srcWidth	+= srcLeft; dstWidth  += srcLeft; srcLeft = 0; }
if ( srcTop	 < 0 )	{ dstTop  -= srcTop;  srcHeight += srcTop;	dstHeight += srcTop;  srcTop  = 0; }
if ( dstLeft < 0 )	{ srcLeft -= dstLeft; srcWidth	+= dstLeft; dstWidth  += dstLeft; dstLeft = 0; }
if ( dstTop	 < 0 )	{ srcTop  -= dstTop;  srcHeight += dstTop;	dstHeight += dstTop;  dstTop  = 0; }

if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0 )
	return;

if ( srcLeft - GetWidth()	   >= 0 )	return;
if ( srcTop	 - abs(GetHeight()) >= 0 )	return;
if ( dstLeft - pdibDst->GetWidth()		   >= 0 )	return;
if ( dstTop	 - abs(pdibDst->GetHeight()) >= 0 ) return;

if ( (iOverrun = srcLeft + srcWidth	 - GetWidth())		> 0 )	{ srcWidth	-= iOverrun; dstWidth  -= iOverrun; }
if ( (iOverrun = srcTop	 + srcHeight - abs(GetHeight())) > 0 )	{ srcHeight -= iOverrun; dstHeight -= iOverrun; }
if ( (iOverrun = dstLeft + dstWidth	 - pdibDst->GetWidth())		> 0 )	{ dstWidth	-= iOverrun; srcWidth  -= iOverrun; }
if ( (iOverrun = dstTop	 + dstHeight - abs(pdibDst->GetHeight())) > 0 ) { dstHeight -= iOverrun; srcHeight -= iOverrun; }

if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0 )
	return;

// Get pointers to the start points in the source and destination
if ( !(pSrc = GetXY( srcLeft, srcTop )) )
	return;
if ( !(pDst = pdibDst->GetXY( dstLeft, dstTop )) )
	return;

// Get the scan line widths of each DIB.
iScanS = GetWidthBytes();
iScanD = pdibDst->GetWidthBytes();

// Upside down DIBs have to move backwards
if ( GetHeight() > 0 )
	 iScanS = -iScanS;
if ( pdibDst->GetHeight() > 0 )
	 iScanD = -iScanD;

if ( !bTransparent )
	{ // Copy the lines.
	while ( --srcHeight >= 0 )
		{
		hmemcpy( pDst, pSrc, srcWidth );
		pSrc += iScanS;
		pDst += iScanD;
		}
	}
else
if (lpRGB)
	{ // Copy lines with transparency mask
	WORD src, dst, wMini;
	BYTE dstPixel, srcColor, red, green, blue;
	int iSinc, iDinc, iCount;
						 
	LPRGBQUAD pTable = GetColors();
	if (lpLut)
		{
		wMini = RGB3toMiniRGB(lpRGB->rgbtRed, lpRGB->rgbtGreen, lpRGB->rgbtBlue);
		srcColor = lpLut[wMini];				
		}
	else
	if (hPal)
		{
		srcColor = (BYTE)GetNearestPaletteIndex( hPal, RGB(lpRGB->rgbtRed, lpRGB->rgbtGreen, lpRGB->rgbtBlue) );
		}
	else
		srcColor = 0;

	iSinc = iScanS - srcWidth; // Source increment value
	iDinc = iScanD - srcWidth; // Destination increment value
	while ( --srcHeight >= 0 )
		{
		iCount = srcWidth;	  // Number of pixels to scan.
		while ( --iCount >= 0 )
			{
			src = (WORD)(*pSrc++);
			// Copy pixel only if it isn't transparent.
			if (src == 0)
				pDst++;
			else
			if (src == 255)
				*pDst++ = srcColor;
			else
				{
				if (src > 127)
					++src;
				dst = 256-src;
				dstPixel = *pDst;
				red = (BYTE)((((WORD)lpRGB->rgbtRed * src) + ((WORD)pTable[dstPixel].rgbRed * dst)) >> 8);
				green = (BYTE)((((WORD)lpRGB->rgbtGreen * src) + ((WORD)pTable[dstPixel].rgbGreen * dst)) >> 8);
				blue = (BYTE)((((WORD)lpRGB->rgbtBlue * src) + ((WORD)pTable[dstPixel].rgbBlue * dst)) >> 8);
				if (lpLut)
					{
					wMini = RGB3toMiniRGB(red, green, blue);
					*pDst++ = lpLut[wMini];					
					}
				else
				if (hPal)
					{
					*pDst++ = (BYTE)GetNearestPaletteIndex( hPal, RGB(red, green, blue) );
					}
				else
					{
					pDst++;
					}
				}
			}

		pSrc += iSinc;
		pDst += iDinc;
		}
	}
else
	{ // Copy lines with transparency.
Esempio n. 12
0
					{
					pDst++;
					}
				}
			}

		pSrc += iSinc;
		pDst += iDinc;
		}
	}
else
	{ // Copy lines with transparency.
	BYTE pixel, cTransparent;
	int iSinc, iDinc, iCount;

	cTransparent = *GetXY(0, 0);
	iSinc = iScanS - srcWidth; // Source increment value
	iDinc = iScanD - srcWidth; // Destination increment value
	while ( --srcHeight >= 0 )
		{
		iCount = srcWidth;	  // Number of pixels to scan.
		while ( --iCount >= 0 )
			{
			pixel = *pSrc++;
			// Copy pixel only if it isn't transparent.
			if (pixel != cTransparent)
				*pDst++ = pixel;
			else
				pDst++;
			}
Esempio n. 13
0
File: RTOS.c Progetto: chregubr85/42
static portTASK_FUNCTION(Remote, pvParameters) {
	int32_t valMotR = 0;
	int32_t valMotL = 0;


  for(;;) {

#if PL_HAS_REMOTE && PL_IS_FRDM


	protocol42 txdata;

if (analogOn) {
		GetXY(&x_anal,&y_anal);

		txdata.target = isROBOcop;
		txdata.type = anal_x;
		txdata.data = x_anal;
		sendData42(txdata);

		txdata.type = anal_y;
		txdata.data = y_anal;
		sendData42(txdata);
}
if (accelOn){
	x_ac = MMA1_GetXmg();
	y_ac = MMA1_GetYmg();


	x_accel = scaleFromAccelToU8(x_ac);
	y_accel = scaleFromAccelToU8(y_ac);


	txdata.target = isROBOcop;
	txdata.type = accel_x;
	txdata.data = x_accel;
	sendData42(txdata);

	txdata.type = accel_y;
	txdata.data = y_accel;
	sendData42(txdata);

}
#endif
#if PL_HAS_MOTOR
	if(valX > 0) {
		valMotR = valY-valX;
		valMotL = valY;
	}
	else if (valX < 0) {
		valMotR = valY;
		valMotL = valY+valX;
	}
	else {
		valMotR = valY;
		valMotL = valY;
	}

	if((valY < 3) && (valY > -3)) {
		valMotR = 0;
		valMotL = 0;
	}


	MOT_SetSpeedPercent(MOT_GetMotorHandle(MOT_MOTOR_RIGHT), valMotR);
	MOT_SetSpeedPercent(MOT_GetMotorHandle(MOT_MOTOR_LEFT) , valMotL);


#endif

	FRTOS1_vTaskDelay(20/TRG_TICKS_MS);
  }
}
Esempio n. 14
0
static void InitPrintCut(void)
{
   HWND Window,Mid;
   int xw,yw,i,j;
   char p[40];
   int SaveColor;
   struct viewporttype SaveViewPort;


   BEGINOK;
   //WaitMessageEmpty();

   MouseHidden();
   getviewsettings(&SaveViewPort);
   SaveColor=getcolor();

   SetPrinter(-CurrentPrinter);
   Window=PrintCutWin[wDISPWIN];
   Mid=WindowGetFather(Window);
   ScreenDispWidth=WindowGetWidth(Window)-10;
   ScreenDispHeight=WindowGetHeight(Window)-10;
   WinX=ScreenX=WindowGetLeft(Window)+WindowGetLeft(Mid);
   WinY=ScreenY=WindowGetTop(Window)+WindowGetTop(Mid);

   setviewport(WinX,WinY,WinX+ScreenDispWidth+9,WinY+ScreenDispHeight+9,1);
   setwritemode(COPY_PUT);
   setcolor(EGA_WHITE);
   //setcolor(11);
   bar(0,0,ScreenDispWidth+9,ScreenDispHeight+9);

   PaperW=(float)(printer->xpixel)*25.4/PrinterDPI;
   PaperH=(float)(printer->ypixel)*25.4/PrinterDPI;

   SCRscaleX=PaperW/ScreenDispWidth;
   SCRscaleY=PaperH/ScreenDispHeight;
   if (SCRscaleX>SCRscaleY)
        SCRscaleY=SCRscaleX;
   else
        SCRscaleX=SCRscaleY;

   xw=mXw=PaperW/SCRscaleX;
   yw=mYw=PaperH/SCRscaleY;

   ScreenX=ScreenX+5+(ScreenDispWidth-mXw)/2;
   ScreenY=ScreenY+5+(ScreenDispHeight-mYw)/2;

   //setwritemode(COPY_PUT);
   setcolor(EGA_DARKGRAY);       //gray
   setviewport(0,0,getmaxx(),getmaxy(),1);
   rectangle(ScreenX-1,ScreenY-1,ScreenX+xw,ScreenY+yw);
   //setviewport(ScreenX-1,ScreenY-1,ScreenX+xw,ScreenY+yw,1);
   //rectangle(ScreenX-1,ScreenY-1,ScreenX+xw,ScreenY+yw);
   //setviewport(ScreenX,ScreenY,ScreenX+mXw-1,ScreenY+mYw-1,1);

   GetUserFrame(0,&xw,&yw);
   PageWI=xw;
   PageHI=yw;
   PageW=xw*25.4/1000;
   PageH=yw*25.4/1000;

   sprintf(p,"%4d",(int)(PaperW+.5));
   GetXY(3,&i,&j);
   DispXY(i-10,j,p,COLORP);

   sprintf(p,"%4d",(int)(PaperH+.5));
   GetXY(4,&i,&j);
   DispXY(i-10,j,p,COLORP);

   setwritemode(COPY_PUT);
   setcolor(SaveColor);
   setviewport(SaveViewPort.left,SaveViewPort.top,SaveViewPort.right,
              SaveViewPort.bottom,SaveViewPort.clip);
   MouseShow();

}