/* This originally was for battery charge control, but now it handles * other things that must be periodically checked such as * mux control and task check in (watchdog) */ static void MonitorBattery(void) { static unsigned char LastPercent = 101; #if CHECK_CSTACK if (LastPercent == 101) CheckCStack(); #endif unsigned char ClipChanged = CheckClip(); CheckBattery(); if (ClipChanged || Charging() || CurrentPage[PageType] == StatusPage) { unsigned char CurrPercent = BatteryPercentage(); if (CurrPercent != LastPercent || ClipChanged) { if (CurrentPage[PageType] == StatusPage) DrawWatchStatusScreen(); else UpdateClock(); // must be the last to avoid screen mess-up LastPercent = CurrPercent; } } /* Watchdog requires each task to check in. * If the background task reaches here then it can check in. * Send a message to the other tasks so that they must check in. */ TaskCheckIn(eDisplayTaskCheckInId); CreateAndSendMessage(WrapperTaskCheckInMsg, MSG_OPT_NONE); #if TASK_DEBUG UTL_FreeRtosTaskStackCheck(); #endif }
void Init(void) { __disable_interrupt(); ENABLE_LCD_LED(); DISABLE_LCD_POWER(); /* clear shipping mode, if set to allow configuration */ PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~LOCKLPM5; PMMCTL0_H = 0x00; /* disable DMA during read-modify-write cycles */ DMACTL4 = DMARMWDIS; #ifdef BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #else SaveResetSource(); #endif SetupClockAndPowerManagementModule(); CheckResetCode(); if (niReset != NORMAL_RESET_CODE) { InitProperty(); } InitBufferPool(); // message queue InitBattery(); CheckClip(); PrintF("*** %s:%s", niReset == FLASH_RESET_CODE ? "FLASH" : (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"), niBuild); ShowWatchdogInfo(); WhoAmI(); /* timer for battery checking at a regular frequency. */ StartTimer(BatteryTimer); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawSplashScreen(); SerialRamInit(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
void AmplifyDialog::OnAmpText(wxCommandEvent & event) { if (mLoopDetect) return; wxTextCtrl *c = GetAmpText(); if (c) { double r; mLoopDetect = true; wxString val = c->GetValue(); val.ToDouble(&r); ratio = pow(10.0,TrapDouble(r*10, AMP_MIN, AMP_MAX)/200.0); wxSlider *slider = GetAmpSlider(); if (slider) slider->SetValue((int)(200*log10(ratio)+0.5)); wxString str; if( ratio*peak > 0.0 ) str.Printf(wxT("%.1f"), 20*log10(ratio*peak)); else str = _("-Infinity"); // the case when the waveform is all zero GetPeakText()->SetValue(str); mLoopDetect = false; } CheckClip(); }
void AmplifyDialog::OnAmpSlider(wxCommandEvent & event) { if (mLoopDetect) return; mLoopDetect = true; wxString str; double dB = GetAmpSlider()->GetValue() / 10.0; ratio = pow(10.0,TrapDouble(dB, AMP_MIN, AMP_MAX)/20.0); double dB2 = (GetAmpSlider()->GetValue()-1) / 10.0; double ratio2 = pow(10.0,TrapDouble(dB2, AMP_MIN, AMP_MAX)/20.0); if (!GetClipCheckBox()->GetValue() && ratio * peak > 1.0 && ratio2 * peak < 1.0) ratio = 1.0 / peak; str.Printf(wxT("%.1f"), 20*log10(ratio)); GetAmpText()->SetValue(str); str.Printf(wxT("%.1f"), 20*log10(ratio*peak)); GetPeakText()->SetValue(str); mLoopDetect = false; CheckClip(); }
void AmplifyDialog::OnPeakText(wxCommandEvent & event) { if (mLoopDetect) return; wxTextCtrl *c = GetPeakText(); if (c) { double r; mLoopDetect = true; wxString val = c->GetValue(); val.ToDouble(&r); ratio = pow(10.0, r/20.0) / peak; double dB = TrapDouble(200*log10(ratio), AMP_MIN, AMP_MAX)/10.0; ratio = pow(10.0, dB/20.0); wxSlider *slider = GetAmpSlider(); if (slider) slider->SetValue((int)(10*dB+0.5)); wxString str; str.Printf(wxT("%.1f"), dB); GetAmpText()->SetValue(str); mLoopDetect = false; } CheckClip(); }
void AmplifyDialog::OnAmpText(wxCommandEvent & event) { if (mLoopDetect) return; wxTextCtrl *c = GetAmpText(); if (c) { double r; mLoopDetect = true; wxString val = c->GetValue(); val.ToDouble(&r); ratio = pow(10,TrapDouble(r*10, AMP_MIN, AMP_MAX)/200.0); wxSlider *slider = GetAmpSlider(); if (slider) slider->SetValue((int)(200*log10(ratio)+0.5)); wxString str; str.Printf("%.1f", 20*log10(ratio*peak)); GetPeakText()->SetValue(str); mLoopDetect = false; } CheckClip(); }
static int DrawMarkers(Engine *engine, long n, const GpReal *px, const GpReal *py) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &engine->map; long maxPoints= 4050, nPoints; int type, markEnd= 0; GpPoint *points; int size; char typeString[8]; if (n<1 || gistA.m.type<=0) return 0; if (CheckClip(psEngine)) return 1; if (SetupColor(psEngine, gistA.m.color) || SetupFont(psEngine, gistA.m.size*DEFAULT_MARKER_SIZE)) return 1; if (psEngine->curClip) size= 0; else size= (int)(psEngine->curHeight*NDC_TO_PS); if (gistA.m.type>32 && gistA.m.type<127) { char *now= typeString; *now++= '('; if (gistA.m.type=='(' || gistA.m.type==')' || gistA.m.type=='\\') *now++= '\\'; *now++= type= gistA.m.type; *now++= ')'; *now++= '\0'; } else { if (gistA.m.type<0 || gistA.m.type>M_CROSS) type= M_ASTERISK; else type= gistA.m.type; sprintf(typeString, "%d", type-1); } if (n>90) { long nLines= (n-1)/9 + 1; /* 9 points is 72 characters */ if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } if (Append(psEngine, typeString)) return 1; /* "(A)" or "1", e.g. */ sprintf(line, type<32? "%ld MS" : "%ld M", n); if (Append(psEngine, line) || PutLine(psEngine)) return 1; while ((nPoints= GpIntPoints(map, maxPoints, n, px, py, &points))) { if (PutPoints(psEngine, points, nPoints, size)) return 1; if (n==nPoints) break; n-= nPoints; px+= nPoints; py+= nPoints; } if (markEnd) { if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1; } return 0; }
static void InitDisplay(void) { __disable_interrupt(); ENABLE_LCD_LED(); DISABLE_LCD_POWER(); /* clear shipping mode, if set to allow configuration */ PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~LOCKLPM5; PMMCTL0_H = 0x00; /* disable DMA during read-modify-write cycles */ DMACTL4 = DMARMWDIS; #if BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #endif SetupClockAndPowerManagementModule(); CheckClip(); // enable debuguart __enable_interrupt(); PrintF("\r\n*** %s:%c%c%c ***", (niResetType == NORMAL_RESET ? "NORMAL" : "MASTER"), BUILD[0], BUILD[1], BUILD[2]); if (niResetType != NORMAL_RESET) InitStateLog(); SaveStateLog(); WhoAmI(); ShowStateInfo(); InitAdc(); /* timer for battery checking at a regular frequency. */ StartTimer(BatteryTimer); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawSplashScreen(); InitSerialRam(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ SendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
static int DrawLines(Engine *engine, long n, const GpReal *px, const GpReal *py, int closed, int smooth) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &engine->map; long maxPoints= 4050, nPoints; long np= n + (closed?1:0); int firstPass= 1, markEnd= 0; GpPoint firstPoint, *points; int size; if (CheckClip(psEngine)) return 1; if (n<1) return 0; if (SetupLine(psEngine, &gistA.l)) return 1; if (psEngine->curClip) size= 0; else size= (int)(psEngine->curWidth*0.5*DEFAULT_PS_WIDTH); if (np>90) { long nLines= (np-1)/9 + 1; /* 9 points is 72 characters */ if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } sprintf(line, smooth? "%ld LS" : "%ld L", np); if (Append(psEngine, line) || PutLine(psEngine)) return 1; while ((nPoints= GpIntPoints(map, maxPoints, n, px, py, &points))) { if (closed) { if (firstPass) { firstPoint= points[0]; firstPass= 0; } if (n==nPoints) { n++; points[nPoints++]= firstPoint; } } if (PutPoints(psEngine, points, nPoints, size)) return 1; if (n==nPoints) break; n-= nPoints; px+= nPoints; py+= nPoints; } if (markEnd) { if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1; } return 0; }
static int DrawFill(Engine *engine, long n, const GpReal *px, const GpReal *py) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &engine->map; long maxPoints= 4050, nPoints; int markEnd= 0; GpPoint *points; int value= 0; /* For now, only FillSolid style supported */ if (n<1) return 0; if (CheckClip(psEngine) || SetupColor(psEngine, gistA.f.color)) return 1; if (n>90) { long nLines= (n-1)/9 + 1; /* 9 points is 72 characters */ if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } if (gistA.e.type==L_NONE) sprintf(line, "%ld F", n); else sprintf(line, "%ld E", n); if (Append(psEngine, line) || PutLine(psEngine)) return 1; while ((nPoints= GpIntPoints(map, maxPoints, n, px, py, &points))) { if (PutPoints(psEngine, points, nPoints, 0)) return 1; if (n==nPoints) break; n-= nPoints; px+= nPoints; py+= nPoints; value= 1; /* Polygons with >4050 sides won't be filled correctly */ } if (gistA.e.type!=L_NONE) { /* setup for edge (usually different color than fill), then draw it */ if (SetupLine(psEngine, &gistA.e)) return 1; if (Append(psEngine, "0 E") || PutLine(psEngine)) return 1; } if (markEnd) { if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1; } return value; }
void EffectAmplify::OnAmpText(wxCommandEvent & WXUNUSED(evt)) { if (!mAmpT->GetValidator()->TransferFromWindow()) { EnableApply(false); return; } mRatio = DB_TO_LINEAR(TrapDouble(mAmp * SCL_Amp, MIN_Amp * SCL_Amp, MAX_Amp * SCL_Amp) / SCL_Amp); mAmpS->SetValue((int) (LINEAR_TO_DB(mRatio) * SCL_Amp + 0.5)); mNewPeak = LINEAR_TO_DB(mRatio * mPeak); mNewPeakT->GetValidator()->TransferToWindow(); CheckClip(); }
void AmplifyDialog::OnAmpText(wxCommandEvent & event) { wxString val = mAmpT->GetValue(); double r; val.ToDouble(&r); ratio = pow(10.0,TrapDouble(r*10, AMP_MIN, AMP_MAX)/200.0); mAmpS->SetValue((int)(200*log10(ratio)+0.5)); if( ratio*peak > 0.0 ) val.Printf(wxT("%.1f"), 20*log10(ratio*peak)); else val = _("-Infinity"); // the case when the waveform is all zero mPeakT->ChangeValue(val); CheckClip(); }
void AmplifyDialog::OnPeakText(wxCommandEvent & event) { wxString val = mPeakT->GetValue(); double r; val.ToDouble(&r); ratio = pow(10.0, r/20.0) / peak; double dB = TrapDouble(200*log10(ratio), AMP_MIN, AMP_MAX)/10.0; ratio = pow(10.0, dB/20.0); mAmpS->SetValue((int)(10*dB+0.5)); val.Printf(wxT("%.1f"), dB); mAmpT->ChangeValue(val); CheckClip(); }
void EffectAmplify::OnAmpSlider(wxCommandEvent & evt) { double dB = evt.GetInt() / SCL_Amp; mRatio = DB_TO_LINEAR(TrapDouble(dB, MIN_Amp, MAX_Amp)); double dB2 = (evt.GetInt() - 1) / SCL_Amp; double ratio2 = DB_TO_LINEAR(TrapDouble(dB2, MIN_Amp, MAX_Amp)); if (!mClip->GetValue() && mRatio * mPeak > 1.0 && ratio2 * mPeak < 1.0) { mRatio = 1.0 / mPeak; } mAmp = LINEAR_TO_DB(mRatio); mAmpT->GetValidator()->TransferToWindow(); mNewPeak = LINEAR_TO_DB(mRatio * mPeak); mNewPeakT->GetValidator()->TransferToWindow(); CheckClip(); }
// Returning |true| means that there is more content to be processed and // Continue() should be called again. Returning |false| means that we've // completed the parse and Continue() is complete. bool CPDF_ContentParser::Continue(PauseIndicatorIface* pPause) { while (m_CurrentStage == Stage::kGetContent) { m_CurrentStage = GetContent(); if (pPause && pPause->NeedToPauseNow()) return true; } if (m_CurrentStage == Stage::kPrepareContent) m_CurrentStage = PrepareContent(); while (m_CurrentStage == Stage::kParse) { m_CurrentStage = Parse(); if (pPause && pPause->NeedToPauseNow()) return true; } if (m_CurrentStage == Stage::kCheckClip) m_CurrentStage = CheckClip(); ASSERT(m_CurrentStage == Stage::kComplete); return false; }
bool EffectAmplify::TransferDataToWindow() { // limit range of gain double dBInit = LINEAR_TO_DB(mRatio); double dB = TrapDouble(dBInit, MIN_Amp, MAX_Amp); if (dB != dBInit) mRatio = DB_TO_LINEAR(dB); mAmp = LINEAR_TO_DB(mRatio); mAmpT->GetValidator()->TransferToWindow(); mAmpS->SetValue((int) (mAmp * SCL_Amp + 0.5f)); mNewPeak = LINEAR_TO_DB(mRatio * mPeak); mNewPeakT->GetValidator()->TransferToWindow(); mClip->SetValue(mCanClip); CheckClip(); return true; }
void AmplifyDialog::OnAmpSlider(wxCommandEvent & event) { wxString str; double dB = mAmpS->GetValue() / 10.0; ratio = pow(10.0,TrapDouble(dB, AMP_MIN, AMP_MAX)/20.0); double dB2 = (mAmpS->GetValue()-1) / 10.0; double ratio2 = pow(10.0,TrapDouble(dB2, AMP_MIN, AMP_MAX)/20.0); if (!mClip->GetValue() && ratio * peak > 1.0 && ratio2 * peak < 1.0) ratio = 1.0 / peak; str.Printf(wxT("%.1f"), 20*log10(ratio)); mAmpT->ChangeValue(str); if (ratio*peak > 0.0) str.Printf(wxT("%.1f"), 20*log10(ratio*peak)); else str = _("-Infinity"); // the case when the waveform is all zero mPeakT->ChangeValue(str); CheckClip(); }
void EffectAmplify::OnPeakText(wxCommandEvent & WXUNUSED(evt)) { if (!mNewPeakT->GetValidator()->TransferFromWindow()) { EnableApply(false); return; } if (mNewPeak == 0.0) mRatio = mRatioClip; else mRatio = DB_TO_LINEAR(mNewPeak) / mPeak; double ampInit = LINEAR_TO_DB(mRatio); mAmp = TrapDouble(ampInit, MIN_Amp, MAX_Amp); if (mAmp != ampInit) mRatio = DB_TO_LINEAR(mAmp); mAmpT->GetValidator()->TransferToWindow(); mAmpS->SetValue((int) (mAmp * SCL_Amp + 0.5f)); CheckClip(); }
void AmplifyDialog::OnClipCheckBox(wxCommandEvent & event) { CheckClip(); }
void AmplifyDialog::OnClipCheckBox(wxCommandEvent & WXUNUSED(event)) { CheckClip(); }
static int DrawCells(Engine *engine, GpReal px, GpReal py, GpReal qx, GpReal qy, long width, long height, long nColumns, const GpColor *colors) { PSEngine *psEngine= (PSEngine *)engine; GpXYMap *map= &psEngine->e.map; int nColors= psEngine->nColors; GpColorCell *palette; int ix, iy, idx, idy, depth; long i, j, off; int markEnd= 0; long nLines; char *now= psEngine->line; int nc, ncmax, color, colorMode; if (!psEngine->e.marked && BeginPage(psEngine)) return 1; if (CheckClip(psEngine)) return 1; /* Transform corner coordinates, clipping and adjusting width, height, nColumns, and colors as necessary. */ width = GpClipCells(&map->x, &px, &qx, gistT.window.xmin, gistT.window.xmax, width, &off); colors += gistA.rgb? 3*off : off; height = GpClipCells(&map->y, &py, &qy, gistT.window.ymin, gistT.window.ymax, height, &off); colors += gistA.rgb? 3*nColumns*off : nColumns*off; if (width<=0 || height<=0) return 0; ix= (int)px; iy= (int)py; idx= (int)(qx-px); idy= (int)(qy-py); /* Set bounding box for image if necessary */ if (!psEngine->curClip) { GpBox *wind= &engine->transform.window; GpReal xmin, xmax, ymin, ymax; int xll, yll, xur, yur; if (wind->xmax>wind->xmin) { xmin= wind->xmin; xmax= wind->xmax; } else { xmin= wind->xmax; xmax= wind->xmin; } if (wind->ymax>wind->ymin) { ymin= wind->ymin; ymax= wind->ymax; } else { ymin= wind->ymax; ymax= wind->ymin; } if (px<qx) { if (px>xmin) xmin= px; if (qx<xmax) xmax= qx; } else { if (qx>xmin) xmin= qx; if (px<xmax) xmax= px; } if (py<qy) { if (py>ymin) ymin= py; if (qy<ymax) ymax= qy; } else { if (qy>ymin) ymin= qy; if (py<ymax) ymax= py; } xll= (int)xmin; xur= (int)xmax; yll= (int)ymin; yur= (int)ymax; if (xll<psEngine->pageBB.xll) psEngine->pageBB.xll= xll; if (xur>psEngine->pageBB.xur) psEngine->pageBB.xur= xur; if (yll<psEngine->pageBB.yll) psEngine->pageBB.yll= yll; if (yur>psEngine->pageBB.yur) psEngine->pageBB.yur= yur; } /* Use 4 bit depth if the color table is small, otherwise use 8 bit depth. */ if (nColors>0) { /* Image value will be either */ colorMode= psEngine->colorMode; if (colorMode) { palette= 0; /* palette already written */ if (nColors>16) depth= 8; else depth= 4; } else { palette= psEngine->e.palette; /* must lookup gray level now */ depth= 8; } } else { /* Must assume image varies over maximum possible range */ colorMode= 1; /* That is, use index without trying palette lookup */ depth= 8; palette= 0; } if (gistA.rgb) { /* Write the 6 arguments to the J procedure */ sprintf(line, "%d %d %d %d %d %d", (int)width, (int)height, idx, idy, ix, iy); } else { /* Write the 7 arguments to the I procedure */ sprintf(line, "%d %d %d %d %d %d %d", (int)width, (int)height, depth, idx, idy, ix, iy); } if (Append(psEngine, line)) return 1; if (gistA.rgb) { nLines= 6*width*height; ncmax = 72; /* 12 cells (72 chars) per line */ } else { nLines= width*height; depth= (depth==8); if (depth) nLines*= 2; else if (nLines&1L) nLines++; ncmax = 76; /* Will put 76 or 38 cells per line */ } nLines= 1+(nLines-1)/ncmax; if (nLines>10) { if (psEngine->nchars && PutLine(psEngine)) return 1; sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1); if (Append(psEngine, line) || PutLine(psEngine)) return 1; markEnd= 1; } if (Append(psEngine, gistA.rgb?"J":"I") || PutLine(psEngine)) return 1; i= j= 0; while (nLines--) { for (nc=0 ; nc<ncmax ; ) { if (i>=width) { height--; if (height<=0) break; i= 0; j+= nColumns; } if (gistA.rgb) { const GpColor *ccell = &colors[3*(i+j)]; now[nc++] = hexChar[ccell[0]>>4]; now[nc++] = hexChar[ccell[0]&0xf]; now[nc++] = hexChar[ccell[1]>>4]; now[nc++] = hexChar[ccell[1]&0xf]; now[nc++] = hexChar[ccell[2]>>4]; now[nc++] = hexChar[ccell[2]&0xf]; } else { color= colors[i+j]; if (color>=nColors && nColors>0) color= nColors-1; if (!colorMode) color= (P_R(palette[color])+ P_G(palette[color])+P_B(palette[color]))/3; if (depth) { /* 2 hex chars per cell */ now[nc++]= hexChar[color>>4]; now[nc++]= hexChar[color&0xf]; } else { /* 1 hex char per cell */ now[nc++]= hexChar[color]; } } i++; }
static int DrwText(Engine *engine, GpReal x0, GpReal y0, const char *text) { PSEngine *psEngine= (PSEngine *)engine; int ix, iy, nlines; GpReal width, height, lineHeight; GpXYMap *map= &engine->map; GpBox *wind= &engine->transform.window; GpReal xmin, xmax, ymin, ymax; int xll, yll, xur, yur, alignH, alignV; int count, nchars, firstPass; char *now, c; const char *t; int state= 0; /* zero size text can confuse postscript interpreters */ if ((int)(gistA.t.height*NDC_TO_PS+0.5) <= 0) return 0; if (CheckClip(psEngine) || SetupText(psEngine)) return 1; alignH= psEngine->curAlignH; alignV= psEngine->curAlignV; /* Compute text location in PostScript coordinates. */ x0= map->x.scale*x0 + map->x.offset; y0= map->y.scale*y0 + map->y.offset; /* handle multi-line strings */ nlines= GtTextShape(text, &gistA.t, (WidthFunction)0, &width); lineHeight= gistA.t.height * NDC_TO_PS; width*= 0.6*lineHeight; height= lineHeight*(GpReal)nlines; /* Reject if and only if the specified point is off of the current page by more than the approximate size of the text. Note that the entire block of text is either accepted or rejected -- PostScript does the clipping. */ if (wind->xmax>wind->xmin) { xmin= wind->xmin; xmax= wind->xmax; } else { xmin= wind->xmax; xmax= wind->xmin; } if (wind->ymax>wind->ymin) { ymin= wind->ymin; ymax= wind->ymax; } else { ymin= wind->ymax; ymax= wind->ymin; } if (gistA.t.orient==TX_RIGHT || gistA.t.orient==TX_LEFT) { if (x0<xmin-width || x0>xmax+width || y0<ymin-height || y0>ymax+height) return 0; } else { if (x0<xmin-height || x0>xmax+height || y0<ymin-width || y0>ymax+width) return 0; } /* Adjust y0 (or x0) to represent topmost line */ if (nlines > 1) { if (gistA.t.orient==TX_RIGHT) { if (alignV==TV_BASE || alignV==TV_BOTTOM) y0+= height-lineHeight; if (alignV==TV_HALF) y0+= 0.5*(height-lineHeight); } else if (gistA.t.orient==TX_LEFT) { if (alignV==TV_BASE || alignV==TV_BOTTOM) y0-= height-lineHeight; if (alignV==TV_HALF) y0-= 0.5*(height-lineHeight); } else if (gistA.t.orient==TX_UP) { if (alignV==TV_BASE || alignV==TV_BOTTOM) x0-= height-lineHeight; if (alignV==TV_HALF) x0-= 0.5*(height-lineHeight); } else { if (alignV==TV_BASE || alignV==TV_BOTTOM) x0+= height-lineHeight; if (alignV==TV_HALF) x0+= 0.5*(height-lineHeight); } } ix= (int)x0; iy= (int)y0; /* Guess at the bounding box for the text */ if (!psEngine->curClip) { GpReal dx=0.0, dy=0.0; if (alignH==TH_CENTER) dx= 0.5*width; else if (alignH==TH_RIGHT) dx= width; if (alignV==TV_TOP || alignV==TV_CAP) dy= height; else if (alignV==TV_HALF) dy= height-0.4*lineHeight; else if (alignV==TV_BASE) dy= height-0.8*lineHeight; else if (alignV==TV_BOTTOM) dy= height-lineHeight; if (gistA.t.orient==TX_RIGHT) { x0-= dx; y0-= dy; } else if (gistA.t.orient==TX_LEFT) { x0+= dx; y0+= dy; } else if (gistA.t.orient==TX_UP) { x0-= dy; y0+= dx; } else { x0+= dy; y0-= dx; } if (x0>xmin) xmin= x0; if (x0+width<xmax) xmax= x0+width; if (y0>ymin) ymin= y0; if (y0+height<ymax) ymax= y0+height; xll= (int)xmin; xur= (int)xmax; yll= (int)ymin; yur= (int)ymax; if (xll<psEngine->pageBB.xll) psEngine->pageBB.xll= xll; if (xur>psEngine->pageBB.xur) psEngine->pageBB.xur= xur; if (yll<psEngine->pageBB.yll) psEngine->pageBB.yll= yll; if (yur>psEngine->pageBB.yur) psEngine->pageBB.yur= yur; } if (nlines>1 || gistA.t.orient!=TX_RIGHT) { if (Append(psEngine, "[")) return 1; } nchars= psEngine->nchars; now= psEngine->line+nchars; firstPass= 1; while ((t= GtNextLine(text, &count, gistA.t.orient)) || firstPass) { text= t; firstPass= 0; state= 0; if (nchars > 70) { psEngine->nchars= nchars; if (PutLine(psEngine)) return 1; nchars= 0; now= psEngine->line; } *now++= ' '; *now++= '('; nchars+= 2; while (count--) { if (nchars>72 && break_line_now(psEngine, &now, &nchars)) return 1; c= *text; if (c>=32 && c<127) { if (gtDoEscapes) { if (c=='!' && count) { c= text[1]; /* peek at next char */ if (c=='!' || c=='^' || c=='_') { count--; text++; goto normal; } if (nchars>68 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\024"); /* DC4 is ps.ps escape char */ now+= 4; nchars+= 4; psEngine->fonts|= (1<<T_SYMBOL); /* symbol font used */ if (c==']') { *now++= '^'; /* !] means ^ (perp) in symbol font */ nchars++; text+= 2; count--; continue; } goto escape; } else if (c=='^') { if (state!=0) { /* terminate current super or subscript escape */ strcpy(now, "\\021"); /* DC1 is ps.ps escape char */ now+= 4; nchars+= 4; } if (state!=1) { /* intialize superscript escape */ if (nchars>64 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\021\\022"); /* DC1DC2 is ps.ps escape seq */ now+= 8; nchars+= 8; state= 1; } else { state= 0; } goto escape; } else if (c=='_') { if (state!=0) { /* terminate current super or subscript escape */ if (nchars>68 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\021"); /* DC1 is ps.ps escape char */ now+= 4; nchars+= 4; } if (state!=2) { /* intialize subscript escape */ if (nchars>64 && break_line_now(psEngine, &now, &nchars)) return 1; strcpy(now, "\\021\\023"); /* DC1DC3 is ps.ps escape seq */ now+= 8; nchars+= 8; state= 2; } else { state= 0; } goto escape; } } /* ordinary printing character */ if (c=='(' || c==')' || c=='\\') { *now++= '\\'; nchars++; } normal: *now++= c; nchars++; } else { /* non-printing characters rendered as \ooo */ if (c=='\t') { *now++= '\\'; *now++= 't'; nchars+= 2; } else if (c<'\021' || c>'\024') { /* DC1 through DC4 have special meaning in ps.ps, skip them */ sprintf(now, "\\%03o", (int)((unsigned char)c)); now+= 4; nchars+= 4; } } escape: text++; } if (state!=0) { /* terminate current super or subscript escape */ strcpy(now, "\\021"); /* DC1 is ps.ps escape char */ now+= 4; nchars+= 4; } *now++= ')'; nchars++; *now= '\0'; } psEngine->nchars= nchars; if (gistA.t.orient==TX_RIGHT) { sprintf(line, nlines>1? "] %d %d TA" : "%d %d T", ix, iy); } else { int angle; if (gistA.t.orient==TX_LEFT) angle= 180; else if (gistA.t.orient==TX_UP) angle= 90; else angle= 270; sprintf(line, "] %d %d %d TR", angle, ix, iy); } if (Append(psEngine, line)) return 1; return 0; }
void EffectAmplify::OnClipCheckBox(wxCommandEvent & WXUNUSED(evt)) { CheckClip(); }
static void R_AddLine (seg_t *line) { int x1; int x2; angle_t angle1; angle_t angle2; angle_t span; angle_t tspan; static sector_t tempsec; // killough 3/8/98: ceiling/water hack curline = line; angle1 = R_GetVertexViewAngle(line->v1); angle2 = R_GetVertexViewAngle(line->v2); #ifdef GL_DOOM if (V_GetMode() == VID_MODEGL) { if (curline->linedef->r_flags & RF_IGNORE_CURRENT) return; // Back side, i.e. backface culling - read: endAngle >= startAngle! if (angle2 - angle1 < ANG180 || !line->linedef) { return; } if (!gld_clipper_SafeCheckRange(angle2, angle1)) { return; } map_subsectors[currentsubsectornum] = 1; if (!line->backsector) { gld_clipper_SafeAddClipRange(angle2, angle1); } else { if (line->frontsector == line->backsector) { if (texturetranslation[line->sidedef->midtexture] == NO_TEXTURE) { //e6y: nothing to do here! return; } } if (CheckClip(line, line->frontsector, line->backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); } } if (ds_p == drawsegs+maxdrawsegs) // killough 1/98 -- fix 2s line HOM { unsigned pos = ds_p - drawsegs; // jff 8/9/98 fix from ZDOOM1.14a unsigned newmax = maxdrawsegs ? maxdrawsegs*2 : 128; // killough drawsegs = realloc(drawsegs,newmax*sizeof(*drawsegs)); ds_p = drawsegs + pos; // jff 8/9/98 fix from ZDOOM1.14a maxdrawsegs = newmax; } if(curline->miniseg == false) // figgi -- skip minisegs curline->linedef->flags |= ML_MAPPED; // proff 11/99: the rest of the calculations is not needed for OpenGL ds_p++->curline = curline; gld_AddWall(curline); return; } #endif // Clip to view edges. span = angle1 - angle2; // Back side, i.e. backface culling if (span >= ANG180) return; // Global angle needed by segcalc. rw_angle1 = angle1; angle1 -= viewangle; angle2 -= viewangle; tspan = angle1 + clipangle; if (tspan > 2*clipangle) { tspan -= 2*clipangle; // Totally off the left edge? if (tspan >= span) return; angle1 = clipangle; } tspan = clipangle - angle2; if (tspan > 2*clipangle) { tspan -= 2*clipangle; // Totally off the left edge? if (tspan >= span) return; angle2 = 0-clipangle; } // The seg is in the view range, // but not necessarily visible. angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; // killough 1/31/98: Here is where "slime trails" can SOMETIMES occur: x1 = viewangletox[angle1]; x2 = viewangletox[angle2]; // Does not cross a pixel? if (x1 >= x2) // killough 1/31/98 -- change == to >= for robustness return; backsector = line->backsector; // Single sided line? if (backsector) // killough 3/8/98, 4/4/98: hack for invisible ceilings / deep water backsector = R_FakeFlat(backsector, &tempsec, NULL, NULL, true); /* cph - roll up linedef properties in flags */ if ((linedef = curline->linedef)->r_validcount != gametic) R_RecalcLineFlags(linedef); if (linedef->r_flags & RF_IGNORE_CURRENT) { return; } else R_ClipWallSegment (x1, x2, linedef->r_flags & RF_CLOSED); }