void AddNewItem (LPMRUMENU lpMruMenu, LPCSTR lpItem, BOOL fRO) { WORD i, j; for (i = 0; i < lpMruMenu->wNbItemFill; i++) { if (strcmpi(lpItem, (lpMruMenu->lpMRU) + ((lpMruMenu->wMaxSizeLruItem) * (UINT)i)) == 0) { // Shift the other items for (j = i; j > 0; j--) { strcpy ((lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)j), (lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)(j-1))); lpMruMenu->lpfRO[j] = lpMruMenu->lpfRO[j-1]; } strncpy(lpMruMenu->lpMRU, lpItem, lpMruMenu->wMaxSizeLruItem-1); lpMruMenu->lpfRO[0] = fRO; return; } } lpMruMenu->wNbItemFill = tmin(lpMruMenu->wNbItemFill+1,lpMruMenu->wNbLruMenu); for (i = lpMruMenu->wNbItemFill-1; i > 0; i--) { strcpy (lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i), lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i-1))); lpMruMenu->lpfRO[i] = lpMruMenu->lpfRO[i-1]; } strncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1); lpMruMenu->lpfRO[0] = fRO; }
void CleanupSwatch::CleanupSwatchArea::keyPressEvent(QKeyEvent *event) { if (!m_sw->m_resampledRaster || m_sw->m_lx == 0 || m_sw->m_ly == 0) return; int key = event->key(); if (key != '+' && key != '-' && key != '0') return; if (key == '0') m_sw->m_viewAff = TAffine(); else { bool forward = (key == '+'); double currZoomScale = sqrt(m_sw->m_viewAff.det()); double factor = getQuantizedZoomFactor(currZoomScale, forward); double minZoom = tmin((double)m_sw->m_lx / m_sw->m_resampledRaster->getLx(), (double)m_sw->m_ly / m_sw->m_resampledRaster->getLy()); if ((!forward && factor < minZoom) || (forward && factor > 40.0)) return; TPointD delta(0.5 * width(), 0.5 * height()); m_sw->m_viewAff = (TTranslation(delta) * TScale(factor / currZoomScale) * TTranslation(-delta)) * m_sw->m_viewAff; } m_sw->m_leftSwatch->updateRaster(); m_sw->m_rightSwatch->updateRaster(); }
void TColorValue::getHls(double &h, double &l, double &s) const { double max, min; double delta; max = tmax(m_r, m_g, m_b); min = tmin(m_r, m_g, m_b); l = (max + min) / 2; if (max == min) { s = 0; h = 0; } else { if (l <= 0.5) s = (max - min) / (max + min); else s = (max - min) / (2 - max - min); delta = max - min; if (m_r == max) h = (m_g - m_b) / delta; else if (m_g == max) h = 2 + (m_b - m_r) / delta; else if (m_b == max) h = 4 + (m_r - m_g) / delta; h = h * 60; if (h < 0) h += 360; } }
int t32bitsrv::RasterExchanger<PIXEL>::read(const char *srcBuf, int len) { if (m_ras->getWrap() == m_ras->getLx()) { memcpy(m_pix, srcBuf, len); m_pix = (PIXEL *)((UCHAR *)m_pix + len); } else { int xStart = (m_pix - m_ras->pixels(0)) % m_ras->getWrap(); int remainingData = len; int lineData = m_ras->getLx() * sizeof(PIXEL); int lineDataToRead = tmin((int)((m_ras->getLx() - xStart) * sizeof(PIXEL)), remainingData); for (; remainingData > 0; m_pix += (m_ras->getWrap() - xStart), remainingData -= lineDataToRead, lineDataToRead = tmin(lineData, remainingData), xStart = 0) memcpy(m_pix, srcBuf, lineDataToRead); } return len; }
TRectD getBBox() const { if (!m_isValidBBox) { m_bBox = TRectD(); for (UINT i = 0; i < m_edge.size(); i++) m_bBox += m_edge[i]->m_s->getBBox(tmin(m_edge[i]->m_w0, m_edge[i]->m_w1), tmax(m_edge[i]->m_w0, m_edge[i]->m_w1)); m_isValidBBox = true; } return m_bBox; }
int t32bitsrv::RasterExchanger<PIXEL>::write(char *dstBuf, int len) { //We pass entire pixels, not just bytes len = len - (len % sizeof(PIXEL)); if (m_ras->getWrap() == m_ras->getLx()) { memcpy(dstBuf, m_pix, len); m_pix = (PIXEL *)((UCHAR *)m_pix + len); } else { int xStart = (m_pix - m_ras->pixels(0)) % m_ras->getWrap(); int remainingData = len; int lineData = m_ras->getLx() * sizeof(PIXEL); int lineDataToWrite = tmin((int)((m_ras->getLx() - xStart) * sizeof(PIXEL)), remainingData); for (; remainingData > 0; m_pix += (m_ras->getWrap() - xStart), remainingData -= lineDataToWrite, lineDataToWrite = tmin(lineData, remainingData), xStart = 0) memcpy(dstBuf, m_pix, lineDataToWrite); } return len; }
bool DateChooserWidget::GetDate(wxDateTime &date) { int ret = wxID_OK; date_control->SetDate(date); hour_control->SetValue(date.GetHour()); minute_control->SetValue(date.GetMinute()); current_minute = date.GetMinute(); current_second = date.GetSecond(); while( (ret = ShowModal()) == wxID_OK){ date = date_control->GetDate(); // ustawiamy godzine date.SetHour(hour_control->GetValue()); date.SetMinute(minute_control->GetValue()); if (second_control) date.SetSecond(second_control->GetValue()); wxDateTime tmin(time_t(0)); wxDateTime tmax(MAX_TIME_T_FOR_WX_DATE_TIME); if (date <= tmin || date >= tmax) { wxMessageBox(_("Invalid (too large/small) date"), _("Error!"), wxOK); return false; } if (min_date == -1 && max_date == -1) return true; if(date.GetTicks() >= min_date && date.GetTicks() <= max_date) return true; else { wxString buf; buf = _("Please choose the date from between: "); buf += wxDateTime(min_date).Format(_T("%Y-%m-%d %H:%M ")); buf += _("and"); buf += wxDateTime(max_date).Format(_T(" %Y-%m-%d %H:%M\n")); wxMessageDialog *mesg = new wxMessageDialog(this, buf, _("Incorrect date range"), wxOK); mesg->ShowModal(); delete mesg; } } return false; }
int main() { printf("Test with main.\n"); printf("bitAnd Result: %d\n", bitAnd(15,3)); printf("getByte Result: %d \n",getByte(0x12345678,22)); printf("bitcount Result: %d \n", bitCount(1)); printf("bang result is: %d \n", bang(3)); printf("minimum two's complement integer is: %d \n",tmin()); printf("fitbits result is: %d \n",fitsBits(-4,3)); printf("divpwr2 result is: %d \n",divpwr2(-33,4)); printf("negate result is: %d \n",negate(4)); printf("isPositive result is: %d \n",isPositive(-4)); printf("isLessOrEqual result is: %d \n",isLessOrEqual(5,5)); printf("float_neg result is: %d \n",float_neg(13)); printf("float_i2f result is: %d \n",float_i2f(15)); printf("float_twice result is: %d \n",float_twice(9.84)); }
void TColorValue::getHsv(int &ih, int &is, int &iv) const { double max, min; double delta; double r, g, b; double v, s, h; r = m_r; g = m_g; b = m_b; assert(0 <= r && r <= 1); assert(0 <= g && g <= 1); assert(0 <= b && b <= 1); max = tmax(r, g, b); min = tmin(r, g, b); v = max; if (max != 0) s = (max - min) / max; else s = 0; if (s == 0) h = 0; else { delta = max - min; if (r == max) h = (g - b) / delta; else if (g == max) h = 2 + (b - r) / delta; else if (b == max) h = 4 + (r - g) / delta; h = h * 60; if (h < 0) h += 360; } assert(0 <= h && h <= 360); assert(0 <= s && s <= 1); assert(0 <= v && v <= 1); ih = (int)h; is = (int)(s * 100); iv = (int)(v * 100); }
void octave_print(std::ostream &ostr, const std::string &varname, const piecewise_curve_type &pc) { index_type i; data_type tmin(pc.get_parameter_min()), tmax(pc.get_parameter_max()); // initialize the t parameters std::vector<data_type> t(101); for (i=0; i<static_cast<index_type>(t.size()); ++i) { t[i]=tmin+(tmax-tmin)*static_cast<data_type>(i)/(t.size()-1); } std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(t.size()); for (i=0; i<static_cast<index_type>(pts.size()); ++i) pts[i]=pc.f(t[i]); octave_print(ostr, varname, pts); }
///////////////////////////////////////////////////////////////////////////// // IClassProperty specific functions STDMETHODIMP CTextSearchEngine::GetPropInfo (LPSTR pBuffer, WORD wLen, DWORD *pdwFlags) { try { if (NULL != pBuffer && wLen > 0) { // Namen der Property kopieren ULONG ulLen = tmin ((size_t)(wLen-1), m_strDesc.length()); strncpy (pBuffer, m_strDesc.c_str(), ulLen); pBuffer[ulLen] = '\0'; } } catch (...) { return E_FAIL; } // wenn gewünscht, Flags übergeben if (pdwFlags) *pdwFlags = PROPCAPS_ACTION_SEARCHENGINE|PROPCAPS_ACTION_SOURCE; return S_OK; }
bool Grid::initInfiniteRay (const Vec3r &orig, const Vec3r& dir, unsigned timestamp) { _ray_dir = dir; _t_end = FLT_MAX; _t = 0; _ray_dir.normalize(); _timestamp = timestamp; // check whether the origin is in or out the box: Vec3r boxMin(_orig); Vec3r boxMax(_orig+_size); BBox<Vec3r> box(boxMin, boxMax); if(box.inside(orig)){ for(unsigned i = 0; i < 3; i++) { _current_cell[i] = (unsigned)floor((orig[i] - _orig[i]) / _cell_size[i]); unsigned u = _current_cell[i]; _pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i]; } }else{ // is the ray intersecting the box? real tmin(-1.0), tmax(-1.0); if(GeomUtils::intersectRayBBox(orig, _ray_dir, boxMin, boxMax, 0, _t_end, tmin, tmax)){ assert(tmin != -1.0); Vec3r newOrig = orig + tmin*_ray_dir; for(unsigned i = 0; i < 3; i++) { _current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]); if(_current_cell[i] == _cells_nb[i]) _current_cell[i] = _cells_nb[i] - 1; unsigned u = _current_cell[i]; _pt[i] = newOrig[i] - _orig[i] - _current_cell[i] * _cell_size[i]; } }else{ return false; } } //_ray_occluders.clear(); return true; }
void CleanupSwatch::CleanupSwatchArea::wheelEvent(QWheelEvent *event) { if (!m_sw->m_resampledRaster || m_sw->m_lx == 0 || m_sw->m_ly == 0) return; int step = event->delta() > 0 ? 120 : -120; double factor = exp(0.001 * step); if (factor == 1.0) return; double scale = m_sw->m_viewAff.det(); double minZoom = tmin((double)m_sw->m_lx / m_sw->m_resampledRaster->getLx(), (double)m_sw->m_ly / m_sw->m_resampledRaster->getLy()); if ((factor < 1 && sqrt(scale) < minZoom) || (factor > 1 && scale > 1200.0)) return; TPointD delta(event->pos().x(), height() - event->pos().y()); m_sw->m_viewAff = (TTranslation(delta) * TScale(factor) * TTranslation(-delta)) * m_sw->m_viewAff; m_sw->m_leftSwatch->updateRaster(); m_sw->m_rightSwatch->updateRaster(); }
STDMETHODIMP CPropertyChoice::GetDescription (LPSTR pDesc, ULONG ulLen, ULONG *pulWritten) { if (NULL == pDesc) return E_POINTER; if (0 == ulLen) return E_INVALIDARG; if (!m_fIsInitialized) { HRESULT hr = InitNew(); if (FAILED(hr)) return hr; } ULONG ulL = tmin((ULONG)m_strDesc.length(), ulLen-1); strncpy (pDesc, m_strDesc.c_str(), ulL); pDesc[ulL] = '\0'; if (pulWritten) *pulWritten = ulL; return NOERROR; }
STDMETHODIMP CTextSearchEngine::HelpInfo (LPSTR pBuffer, ULONG wLen, LPSTR pHelpFile, ULONG *pulHelpCtx) { try { if (NULL != pBuffer && wLen > 0) { // Beschreibung übergeben ResourceFile RF (g_pDLLName); ResString resHelp (ResID (IDS_HELPDESC_IDENTOTYP, &RF), 128); ULONG ulLen = tmin ((size_t)(wLen-1), strlen(resHelp)); strncpy (pBuffer, resHelp, ulLen); pBuffer[ulLen] = '\0'; } } catch (...) { return E_FAIL; } // HelpFileInfo übergeben if (pHelpFile) pHelpFile[0] = '\0'; if (pulHelpCtx) *pulHelpCtx = 0L; return S_OK; }
//--------------------------------------------------------------------------------------- BOOL CBigTerrain::Create(const BYTE* hmap, const V3& start, const V3& size, int xt, int yt) { Clear(1); p_dummyBrush = new Brush(); p_dummyBrush->MakeCube((V3&)size); p_dummyBrush->Recalc(); p_dummyBrush->_brushflags = BRSH_BIGTERRAIN|TERR_GOR|TERR_UTT0; p_dummyBrush->_pUsrData = this; p_dummyBrush->Reverse(); p_dummyBrush->_pUsrData=this; strcpy(p_dummyBrush->_name,"terrain"); n_xtiles = xt; n_ztiles = yt; b_box._min = start; b_box._max = start + size; BYTE* pwhmap = (BYTE*)hmap; int k=0; BYTE bmin=255; BYTE bmax=0; v_vxes.ObjReserve((n_xtiles+1)*(n_ztiles+1)); for(int x=0 ; x <= n_xtiles; x++) { for(int z=0 ; z <= n_ztiles; z++) { bmin = tmin(*pwhmap,bmin); bmax = tmax(*pwhmap,bmax); v_vxes[k++] = *pwhmap++; } } return 1; }
void AdjustLevelsPopup::autoAdjust() { if (!m_inputRas) return; Histograms *histograms = m_histogram->getHistograms(); int channelIdx = histograms->currentIndex(); int inputBarIdx = (channelIdx << 1); EditableMarksBar *editableMarksBar = m_marksBar[inputBarIdx]; int min, max; //Clamp histogram const QVector<int> &values = histograms->getHistogramView(channelIdx)->values(); if (channelIdx == 0) { int minR, maxR, minG, maxG, minB, maxB; ::getRange(histograms->getHistogramView(1)->values(), m_threshold, minR, maxR); ::getRange(histograms->getHistogramView(2)->values(), m_threshold, minG, maxG); ::getRange(histograms->getHistogramView(3)->values(), m_threshold, minB, maxB); min = tmin(minR, minG, minB); max = tmax(maxR, maxG, maxB); } else ::getRange(values, m_threshold, min, max); QVector<int> &marks = editableMarksBar->marksBar()->values(); if (min < max) marks[0] = min, marks[1] = max + 1; else marks[0] = 0, marks[1] = 256; editableMarksBar->updateFields(); onParamsChanged(); update(); }
/////////////////////////////////////////////////////////////////////////////// // IClassProperty specific functions STDMETHODIMP CPropertyChoice::GetPropInfo (LPSTR pBuffer, WORD wLen, DWORD *pdwFlags) { try { if (NULL != pBuffer && wLen > 0) { // Namen der Property kopieren ULONG ulLen = tmin ((size_t)(wLen-1), m_strDesc.length()); strncpy (pBuffer, m_strDesc.c_str(), ulLen); pBuffer[ulLen] = '\0'; } // wenn gewünscht, Flags aufsammeln und übergeben if (pdwFlags) { DWORD dwFlags = 0; for (CActionList::iterator it = m_Actions.begin(); it != m_Actions.end(); it++) { WClassProperty IProp = (*it).Action(); // throws hr DWORD dw = 0; if (SUCCEEDED(IProp -> GetPropInfo (NULL, 0, &dw))) dwFlags |= dw; } *pdwFlags = dwFlags; } } catch (_com_error& hr) { return _COM_ERROR(hr); } catch (...) { return E_FAIL; } return NOERROR; }
void TRop::brush( TRaster32P ras, const TPoint &aa, const TPoint &bb, int radius, const TPixel32 &col) { TPoint a = aa; TPoint b = bb; if (a.y > b.y) tswap(a, b); // a e' piu' in basso di b int lx = ras->getLx(); int ly = ras->getLy(); ras->lock(); // ----- radius = 0 if (radius == 0) { // k = +1/-1 se il rettangolo e' inclinato positivamente (0<=m)/negativamente (m<0) // (se k<0 viene fatta una riflessione sulle ascisse prima di tornare alle // coordinate "di schermo") int k = 1; int dy = b.y - a.y; int dx = b.x - a.x; if (dx < 0) { dx = -dx; k = -1; } assert(dx >= 0); assert(dy >= 0); double m; // m sara' definita solo per dx!=0) if (dx > 0) { m = dy / (double)dx; } //double length = sqrt(dx*dx + dy*dy); const int alpha = dy, beta = -dx; const int incE = alpha; const int incNE = alpha + beta; const int incN = beta; // N.B. le coordinate sono relative ad un sist. di rif. con l'origine in a // l'eq. della retta e' alpha * x + beta * y = 0 int yMin = tmax(a.y, 0) - a.y; // clipping y + cambio riferimento int yMax = tmin(b.y, ly - 1) - a.y; // (trasporto dell'origine in a) if (dx > 0 && m <= 1) { // midpoint algorithm TPoint segm; if (dy == 0) // segmento orizzontale: inizializza segm { segm.x = 0; segm.y = yMin; } else // 0<m<=1 : inizializza segm { segm.x = tceil((yMin - 0.5) / m); segm.y = yMin; } int dSegm = tfloor(alpha * (segm.x + 1) + beta * (segm.y + 0.5)); while (segm.y <= yMax) { int count = 0; // i trati orizzontali di segm vengono disegnati in "blocco" while (dSegm < 0 && segm.x <= dx) // Est: segm.x<=dx evita il ciclo { // infinito quando m=0 (incE=0) dSegm = dSegm + incE; segm.x++; count++; } // NordEst int xMin, xMax; if (k > 0) { xMin = tmax(a.x + segm.x - count, a.x, 0); // clipping x + ritorno alle xMax = tmin(a.x + segm.x, b.x, lx - 1); // coordinate "di schermo" } else { xMin = tmax(a.x - segm.x, a.x - dx, 0); // clipping x + riflessione + ritorno xMax = tmin(a.x - segm.x + count, a.x, lx - 1); // alle coordinate "di schermo" } TPixel32 *p = ras->pixels(segm.y + a.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; dSegm = dSegm + incNE; segm.x++; segm.y++; } } else // m>1 oppure segmento verticale { // midpoint algorithm TPoint segm; if (dx == 0) // segmento verticale: inizializza segm { segm.x = 0; segm.y = yMin; } else // m>1 : inizializza segm { segm.x = tround(yMin / m); segm.y = yMin; } int dSegm = tfloor(alpha * (segm.x + 0.5) + beta * (segm.y + 1)); while (segm.y <= yMax) { int xMin, xMax; if (k > 0) { xMin = tmax(a.x + segm.x, 0); // clipping x + ritorno alle xMax = tmin(a.x + segm.x, lx - 1); // coordinate "di schermo" } else { xMin = tmax(a.x - segm.x, 0); // clipping x + riflessione + ritorno xMax = tmin(a.x - segm.x, lx - 1); // alle coordinate "di schermo" } TPixel32 *p = ras->pixels(segm.y + a.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; if (dSegm <= 0) // NordEst { dSegm = dSegm + incNE; segm.x++; } else // Nord { dSegm = dSegm + incN; } segm.y++; } } ras->unlock(); return; } HalfCord halfCord(radius); int x, y; // ----- punti iniziali coincidenti: disegna un cerchio if (a == b) { int yMin = tmax(a.y - radius, 0); // clipping y int yMax = tmin(a.y + radius, ly - 1); // clipping y for (y = yMin; y <= yMax; y++) { int deltay = abs(y - a.y); int xMin = tmax(a.x - halfCord.getCord(deltay), 0); // clipping x int xMax = tmin(a.x + halfCord.getCord(deltay), lx - 1); // clipping x TPixel32 *p = ras->pixels(y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; } ras->unlock(); return; } // ----- rettangolo orizzontale (a.y = b.y, a.x != b.x) if (a.y == b.y) { int yMin = tmax((a.y - radius), 0); // clipping y int yMax = tmin((a.y + radius), ly - 1); // clipping y int xLeft = tmin(a.x, b.x); int xRight = tmax(a.x, b.x); for (y = yMin; y <= yMax; y++) { int deltay = abs(y - a.y); int xMin = tmax(xLeft - halfCord.getCord(deltay), 0); // clipping x int xMax = tmin(xRight + halfCord.getCord(deltay), lx - 1); // clipping x TPixel32 *p = ras->pixels(y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; } ras->unlock(); return; } // ----- rettangolo verticale (a.x = b.x, a.y != b.y) if (a.x == b.x) { int xMin = tmax(a.x - radius, 0); // clipping x int xMax = tmin(a.x + radius, lx - 1); // clipping x for (x = xMin; x <= xMax; x++) { int deltax = abs(x - a.x); int yMin = tmax(a.y - halfCord.getCord(deltax), 0); // clipping y int yMax = tmin(b.y + halfCord.getCord(deltax), ly - 1); // clipping y if (yMin <= yMax) { TPixel32 *p = ras->pixels(yMin) + x; TPixel32 *q = ras->pixels(yMax) + x; int wrap = ras->getWrap(); while (p <= q) { *p = col; p += wrap; } } } ras->unlock(); return; } // ----- rettangolo inclinato // k = +1/-1 se il rettangolo e' inclinato positivamente/negativamente int k = 1; int dx = b.x - a.x; if (dx < 0) { dx = -dx; k = -1; } int dy = b.y - a.y; assert(dx > 0); assert(dy > 0); double length = sqrt((double)(dx * dx + dy * dy)); const double m = dy / (double)dx; //punto di tangenza superiore nel sistema di riferimento del cerchio TPointD up(-radius * dy / length, radius * dx / length); //semi-ampiezza orizzontale delle "calotte" circolari int halfAmplCap = tfloor(-up.x); // A meno di intersezioni relative tra le diverse zone: // le scanline della "calotta" circolare superiore sono (b.y+cutExt,b.y+radius] // le scanline del trapezoide circolare superiore sono [b.y-cutIn,b.y+cutExt] // le scanline del parallelogramma sono (a.y+cutIn,b.y-cutIn) // le scanline del trapezoide circolare inferiore sono [a.y-cutExt,a.y+cutIn] // le scanline della "calotta" circolare inferiore sono [a.y-radius,a.y-cutExt) int cutExt, cutIn; // vertici del parallelogramma TPointD rightUp; TPointD rightDown; TPointD leftUp; TPointD leftDown; double mParall; //coeff. angolare parallelogramma // NOTA BENE: halfAmplCap=0 <=> (radius=0 (caso a parte) , 1) if (radius > 1) { for (cutExt = radius; cutExt >= 0 && halfCord.getCord(cutExt) <= halfAmplCap; cutExt--) ; cutIn = cutExt; // vedi else successivo rightUp.x = dx + halfCord.getCord(cutIn); rightUp.y = dy - cutIn; rightDown.x = halfCord.getCord(cutIn); rightDown.y = -cutIn; leftUp.x = dx - halfCord.getCord(cutIn); leftUp.y = dy + cutIn; leftDown.x = -halfCord.getCord(cutIn); leftDown.y = cutIn; mParall = dy / (double)dx; } else // N.B. cutExt != cutIn solo quando radius=1 { cutExt = radius; // radius=1 => halfAmplCap=0 (non ci sono mai le "calotte" circolari) cutIn = 0; // anche per radius=1 il limite "interno" dei trapezoidi circolari e' < radius rightUp.x = dx - up.x; rightUp.y = dy - up.y; rightDown.x = -up.x; rightDown.y = -up.y; leftUp.x = dx + up.x; leftUp.y = dy + up.y; leftDown.x = up.x; leftDown.y = up.y; mParall = m; } // ----- riempie "calotte" circolari // ----- riempie "calotta" circolare inferiore int yMin = tmax(a.y - radius, 0); // clipping y int yMax = tmin(a.y - cutExt - 1, ly - 1); // clipping y for (y = yMin; y <= yMax; y++) { int r = halfCord.getCord(a.y - y); int xMin = tmax(a.x - r, 0); // clipping x int xMax = tmin(a.x + r, lx - 1); // clipping x TPixel32 *p = ras->pixels(y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; } // ----- riempie "calotta" circolare superiore yMin = tmax(b.y + cutExt + 1, 0); // clipping y yMax = tmin(b.y + radius, ly - 1); // clipping y for (y = yMin; y <= yMax; y++) { int r = halfCord.getCord(y - b.y); int xMin = tmax(b.x - r, 0); // clipping x int xMax = tmin(b.x + r, lx - 1); // clipping x TPixel32 *p = ras->pixels(y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; } // ----- riempie trapezoidi // (se k<0 viene fatta una riflessione sulle ascisse prima di tornare alle // coordinate "di schermo") // limite destro assoluto delle scanline trapezoide: int xSegmMax = tround(dx - up.x); // coordinata x del punto di tangenza inferiore sul cerchio superiore // limite sinistro assoluto delle scanline: int xSegmMin = tround(up.x); // coordinata x del punto di tangenza superiore sul cerchio inferiore // ----- riempie trapezoide inferiore // N.B. le coordinate sono relative ad un sist. di rif. con l'origine sul centro // del cerchio inferiore yMin = tmax(a.y - cutExt, 0) - a.y; // clipping y yMax = tmin(a.y + cutIn, b.y - cutIn - 1, ly - 1) - a.y; // clipping y // l'eq. della retta e' alpha * x + beta * y + gammaRight = 0 const int alpha = dy, beta = -dx; const double gammaRight = rightDown.y * dx - rightDown.x * dy; const int incE = alpha; const int incNE = alpha + beta; const int incN = beta; if (m <= 1) { // midpoint algorithm; le scanline vengono disegnate solo // sul NordEst. L'ultima scanline non viene disegnata TPoint segmRight(tceil((yMin + 0.5 - rightDown.y) / mParall + rightDown.x) - 1, yMin); int dSegmRight = tfloor(alpha * (segmRight.x + 1) + beta * (segmRight.y + 0.5) + gammaRight); while (segmRight.y <= yMax) { if (dSegmRight < 0) // Est { dSegmRight = dSegmRight + incE; segmRight.x++; } else // NordEst { int xMin, xMax; if (k > 0) { xMin = tmax(a.x - halfCord.getCord(abs(segmRight.y)), 0); // clipping x xMax = tmin(a.x + tmin(segmRight.x, xSegmMax), lx - 1); // clipping x } else { xMin = tmax(a.x - tmin(segmRight.x, xSegmMax), 0); // clipping x + ritorno alle xMax = tmin(a.x + halfCord.getCord(abs(segmRight.y)), lx - 1); // coordinate "di schermo" } TPixel32 *p = ras->pixels(segmRight.y + a.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; dSegmRight = dSegmRight + incNE; segmRight.x++; segmRight.y++; } } } else // m>1 { // midpoint algorithm; le scanline vengono disegnate sempre TPoint segmRight(tround((yMin - rightDown.y) / mParall + rightDown.x), yMin); int dSegmRight = tfloor(alpha * (segmRight.x + 0.5) + beta * (segmRight.y + 1) + gammaRight); while (segmRight.y <= yMax) { int xMin, xMax; if (k > 0) { xMin = tmax(a.x - halfCord.getCord(abs(segmRight.y)), 0); // clipping x xMax = tmin(a.x + segmRight.x, lx - 1); // clipping x } else { xMin = tmax(a.x - segmRight.x, 0); // clipping x + ritorno alle coordinate xMax = tmin(a.x + halfCord.getCord(abs(segmRight.y)), lx - 1); // "di schermo" } TPixel32 *p = ras->pixels(segmRight.y + a.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; if (dSegmRight <= 0) // NordEst { dSegmRight = dSegmRight + incNE; segmRight.x++; } else // Nord { dSegmRight = dSegmRight + incN; } segmRight.y++; } } // ----- riempie trapezoide superiore // N.B. le coordinate sono relative ad un sist. di rif. con l'origine sul centro // del cerchio superiore yMin = tmax(b.y - cutIn, a.y + cutIn + 1, 0) - b.y; // clipping y yMax = tmin(b.y + cutExt, ly - 1) - b.y; // clipping y // l'eq. della retta e' alpha * x + beta * y + gammaLeft = 0 const double gammaLeft = leftDown.y * dx - leftDown.x * dy; if (m <= 1) { // midpoint algorithm; le scanline vengono disegnate solo // sul NordEst. L'ultima scanline non viene disegnata TPoint segmLeft(tceil((yMin - 0.5 - leftDown.y) / mParall + leftDown.x), yMin); int dSegmLeft = tfloor(alpha * (segmLeft.x + 1) + beta * (segmLeft.y + 0.5) + gammaLeft); while (segmLeft.y <= yMax) { int xMin, xMax; if (k > 0) { xMin = tmax(b.x + tmax(segmLeft.x, xSegmMin - dx), 0); // clipping x xMax = tmin(b.x + halfCord.getCord(abs(segmLeft.y)), lx - 1); // clipping x } else { xMin = tmax(b.x - halfCord.getCord(abs(segmLeft.y)), 0); // clipping x + ritorno alle xMax = tmin(b.x - tmax(segmLeft.x, xSegmMin - dx), lx - 1); // coordinate "di schermo" } TPixel32 *p = ras->pixels(segmLeft.y + b.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; while (dSegmLeft < 0) { dSegmLeft = dSegmLeft + incE; segmLeft.x++; } dSegmLeft = dSegmLeft + incNE; segmLeft.x++; segmLeft.y++; } } else // m>1 { // midpoint algorithm; le scanline vengono disegnate sempre TPoint segmLeft(tround((yMin - leftDown.y) / mParall + leftDown.x), yMin); int dSegmLeft = tfloor(alpha * (segmLeft.x + 0.5) + beta * (segmLeft.y + 1) + gammaLeft); while (segmLeft.y <= yMax) { int xMin, xMax; if (k > 0) { xMin = tmax(b.x + segmLeft.x, 0); // clipping x xMax = tmin(b.x + halfCord.getCord(abs(segmLeft.y)), lx - 1); // clipping x } else { xMin = tmax(b.x - halfCord.getCord(abs(segmLeft.y)), 0); // clipping x + ritorno alle xMax = tmin(b.x - segmLeft.x, lx - 1); // coordinate "di schermo" } TPixel32 *p = ras->pixels(segmLeft.y + b.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; if (dSegmLeft <= 0) // NordEst { dSegmLeft = dSegmLeft + incNE; segmLeft.x++; } else // Nord { dSegmLeft = dSegmLeft + incN; } segmLeft.y++; } } // ----- parallelogramma (in alternativa a "parallelogrammoide circolare") // N.B. le coordinate sono relative ad un sist. di rif. con l'origine sul centro // del cerchio inferiore // retta destra di equaz. alpha * x + beta * y + gammaRight = 0 // retta sinistra di equaz. alpha * x + beta * y + gammaLeft = 0 yMin = tmax(a.y + cutIn + 1, 0) - a.y; //clipping y yMax = tmin(b.y - cutIn - 1, ly - 1) - a.y; //clipping y if (m <= 1) { // midpoint algorithm; le scanline vengono disegnate solo // sul NordEst. L'ultima scanline non viene disegnata TPoint segmRight(tceil((yMin + 0.5 - rightDown.y) / mParall + rightDown.x) - 1, yMin); TPoint segmLeft = TPoint(tceil((yMin - 0.5 - leftDown.y) / mParall + leftDown.x), yMin); int dSegmRight = tfloor(alpha * (segmRight.x + 1) + beta * (segmRight.y + 0.5) + gammaRight); int dSegmLeft = tfloor(alpha * (segmLeft.x + 1) + beta * (segmLeft.y + 0.5) + gammaLeft); while (segmRight.y <= yMax) { if (dSegmRight < 0) // segmRight a Est { dSegmRight = dSegmRight + incE; segmRight.x++; } else // segmRight a NordEst { int xMin, xMax; if (k > 0) { xMin = tmax(a.x + tmax(segmLeft.x, xSegmMin), 0); // clipping x xMax = tmin(a.x + tmin(segmRight.x, xSegmMax), lx - 1); // clipping x } else { xMin = tmax(a.x - tmin(segmRight.x, xSegmMax), 0); // clipping x + ritorno alle xMax = tmin(a.x - tmax(segmLeft.x, xSegmMin), lx - 1); // coordinate "di schermo" } TPixel32 *p = ras->pixels(segmRight.y + a.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; dSegmRight = dSegmRight + incNE; segmRight.x++; segmRight.y++; while (dSegmLeft < 0) // segmLeft a Est { dSegmLeft = dSegmLeft + incE; segmLeft.x++; } // segmLeft a NordEst dSegmLeft = dSegmLeft + incNE; segmLeft.x++; segmLeft.y++; } } } else // m>1 { // midpoint algorithm; le scanline vengono disegnate sempre TPoint segmRight(tround((yMin - rightDown.y) / mParall + rightDown.x), yMin); TPoint segmLeft(tround((yMin - leftDown.y) / mParall + leftDown.x), yMin); int dSegmRight = tfloor(alpha * (segmRight.x + 0.5) + beta * (segmRight.y + 1) + gammaRight); int dSegmLeft = tfloor(alpha * (segmLeft.x + 0.5) + beta * (segmLeft.y + 1) + gammaLeft); while (segmRight.y <= yMax) { int xMin, xMax; if (k > 0) { xMin = tmax(a.x + segmLeft.x, 0); // clipping x xMax = tmin(a.x + segmRight.x, lx - 1); // clipping x } else { xMin = tmax(a.x - segmRight.x, 0); // clipping x + ritorno alle xMax = tmin(a.x - segmLeft.x, lx - 1); // coordinate "di schermo" } TPixel32 *p = ras->pixels(segmRight.y + a.y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; if (dSegmRight <= 0) // segmRight a NordEst { dSegmRight = dSegmRight + incNE; segmRight.x++; } else // segmRight a Nord { dSegmRight = dSegmRight + incN; } segmRight.y++; if (dSegmLeft <= 0) // segmLeft a NordEst { dSegmLeft = dSegmLeft + incNE; segmLeft.x++; } else // segmLeft a Nord { dSegmLeft = dSegmLeft + incN; } } } // ---- parallelogrammoide circolare (in alternativa a parallelogramma) // N.B. coordinate di schermo (riflessione per k<0 ) yMin = tmax(b.y - cutIn, 0); yMax = tmin(a.y + cutIn, ly - 1); for (y = yMin; y <= yMax; y++) { int xMin, xMax; if (k > 0) { xMin = tmax(a.x - halfCord.getCord(abs(y - a.y)), 0); // clipping x xMax = tmin(b.x + halfCord.getCord(abs(b.y - y)), lx - 1); // clipping x } else { xMin = tmax(b.x - halfCord.getCord(abs(b.y - y)), 0); // clipping x + ritorno alle xMax = tmin(a.x + halfCord.getCord(abs(y - a.y)), lx - 1); // coordinate "di schermo" } TPixel32 *p = ras->pixels(y) + xMin; TPixel32 *q = p + (xMax - xMin); while (p <= q) *p++ = col; } ras->unlock(); }
void CasmSubmitPage::Data::submit() { if (m_filepathTextField->getText() == toWideString("")) { TMessage::error("You must load a file"); return; } CasmTask *casm = m_configPanel->getTask(); TFarmController *controller = Application::instance()->getController(); string nativeCmdLine("runcasm "); nativeCmdLine += casm->m_casmFile; nativeCmdLine += " "; if (casm->m_setupFile != "") { nativeCmdLine += "-setup "; nativeCmdLine += casm->m_setupFile; nativeCmdLine += " "; } nativeCmdLine += casm->getCommandLine(); string casmName = TFilePath(casm->m_casmFile).getName(); int stepCount = casm->m_end - casm->m_start + 1; TFarmTaskGroup task( casmName, nativeCmdLine, TSystem::getUserName(), TSystem::getHostName(), stepCount); int ra = casm->m_start; for (;;) { CasmTask subcasm(*casm); string cmdLine("runcasm "); int rb = tmin(ra + casm->m_taskChunksize - 1, casm->m_end); subcasm.m_start = ra; subcasm.m_end = rb; cmdLine += subcasm.m_casmFile; cmdLine += " "; if (subcasm.m_setupFile != "") { cmdLine += "-setup "; cmdLine += subcasm.m_setupFile; cmdLine += " "; } cmdLine += subcasm.getCommandLine(); cmdLine += " -nowait "; try { string name = casmName + " " + toString(ra) + "-" + toString(rb); stepCount = rb - ra + 1; task.addTask(new TFarmTask( name, cmdLine, TSystem::getUserName(), TSystem::getHostName(), stepCount)); } catch (TException &e) { TMessage::error(toString(e.getMessage())); } if (rb == casm->m_end) break; ra = rb + 1; } try { controller->addTask(task, m_submitAsSuspended->isSelected()); } catch (TException &e) { TMessage::error(toString(e.getMessage())); } }
void build_lw_lut(float ref_lw[256], float lw[256], UCHAR lut[256]) { /* crea una lut tale che l'immagine con il profilo di linewidths lw venga mappata in un'immagine con il profilo di riferimento ref_lw. Le lw sono non decrescenti e delimitate da 0.0 li' dove non sono valide */ int i, j; float bot_ref_lw, top_ref_lw, bot_lw, top_lw; int bot_ref_gr, top_ref_gr, bot_gr, top_gr; float min_lw, max_lw; int min_ref_gr, max_ref_gr, min_gr, max_gr; float fac; for (i = 0; !ref_lw[i]; i++) { } bot_ref_lw = ref_lw[i]; bot_ref_gr = i; for (i = 255; !ref_lw[i]; i--) { } top_ref_lw = ref_lw[i]; top_ref_gr = i; for (i = 0; !lw[i]; i++) { } bot_lw = lw[i]; bot_gr = i; for (i = 255; !lw[i]; i--) { } top_lw = lw[i]; top_gr = i; min_lw = tmax(bot_ref_lw, bot_lw); max_lw = tmin(top_ref_lw, top_lw); if (min_lw >= max_lw) { for (i = 0; i < 256; i++) lut[i] = i; return; } for (i = bot_ref_gr; ref_lw[i] < min_lw; i++) { } min_ref_gr = i; for (i = top_ref_gr; ref_lw[i] > max_lw; i--) { } max_ref_gr = i; for (i = bot_gr; lw[i] < min_lw; i++) { } min_gr = i; for (i = top_gr; lw[i] > max_lw; i--) { } max_gr = i; j = min_ref_gr; for (i = min_gr; i <= max_gr; i++) { while (ref_lw[j] < lw[i] && j < max_ref_gr) j++; lut[i] = j; } fac = (float)min_ref_gr / (float)min_gr; for (i = 0; i < min_gr; i++) lut[i] = troundp(i * fac); fac = (float)(255 - max_ref_gr) / (float)(255 - max_gr); for (i = 255; i > max_gr; i--) lut[i] = 255 - troundp((255 - i) * fac); /*** printf ("-----\n\lut:\n\n"); for (i = 255; i >= 0; i--) printf ("%4d :%4u\n", i, lut[i]); printf ("\n"); ***/ }
TImageP TImageReader::load0() { if (!m_reader && !m_vectorReader) open(); if (m_reader) { TImageInfo info = m_reader->getImageInfo(); if (info.m_lx <= 0 || info.m_ly <= 0) return TImageP(); // Initialize raster info assert(m_shrink > 0); // Build loading rect int x0 = 0; int x1 = info.m_lx - 1; int y0 = 0; int y1 = info.m_ly - 1; if (!m_region.isEmpty()) { // Intersect with the externally specified loading region x0 = tmax(x0, m_region.x0); y0 = tmax(y0, m_region.y0); x1 = tmin(x1, m_region.x1); y1 = tmin(y1, m_region.y1); if (x0 >= x1 || y0 >= y1) return TImageP(); } if (m_shrink > 1) { // Crop to shrink multiples x1 -= (x1 - x0) % m_shrink; y1 -= (y1 - y0) % m_shrink; } assert(x0 <= x1 && y0 <= y1); TDimension imageDimension = TDimension((x1 - x0) / m_shrink + 1, (y1 - y0) / m_shrink + 1); if (m_path.getType() == "tzp" || m_path.getType() == "tzu") { // Colormap case TRasterCM32P ras(imageDimension); readRaster(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); // Build the savebox TRect saveBox(info.m_x0, info.m_y0, info.m_x1, info.m_y1); if (!m_region.isEmpty()) { // Intersect with the loading rect if (m_region.overlaps(saveBox)) { saveBox *= m_region; int sbx0 = saveBox.x0 - m_region.x0; int sby0 = saveBox.y0 - m_region.y0; int sbx1 = sbx0 + saveBox.getLx() - 1; int sby1 = sby0 + saveBox.getLy() - 1; assert(sbx0 >= 0); assert(sby0 >= 0); assert(sbx1 >= 0); assert(sby1 >= 0); saveBox = TRect(sbx0, sby0, sbx1, sby1); } else saveBox = TRect(0, 0, 1, 1); } if (m_shrink > 1) { saveBox.x0 = saveBox.x0 / m_shrink; saveBox.y0 = saveBox.y0 / m_shrink; saveBox.x1 = saveBox.x1 / m_shrink; saveBox.y1 = saveBox.y1 / m_shrink; } TToonzImageP ti(ras, ras->getBounds() * saveBox); ti->setDpi(info.m_dpix, info.m_dpiy); return ti; } else if (info.m_bitsPerSample >= 8) { // Common byte-based rasters (see below, we have black-and-white bit-based images too) if (info.m_samplePerPixel == 1 && m_readGreytones) { // Greymap case // NOTE: Uses a full 32-bit raster first, and then copies down to the GR8 // Observe that GR16 file images get immediately down-cast to GR8... // Should we implement that too? TRasterGR8P ras(imageDimension); readRaster_copyLines(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); TRasterImageP ri(ras); ri->setDpi(info.m_dpix, info.m_dpiy); return ri; } // assert(info.m_samplePerPixel == 3 || info.m_samplePerPixel == 4); TRasterP _ras; if (info.m_bitsPerSample == 16) { if (m_is64BitEnabled || m_path.getType() != "tif") { // Standard 64-bit case. // Also covers down-casting to 32-bit from a 64-bit image file whenever // not a tif file (see below). TRaster64P ras(imageDimension); readRaster(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); _ras = ras; } else { // The Tif reader has got an automatically down-casting readLine(char*, ...) // in case the input file is 64-bit. The advantage is that no intermediate // 64-bit raster is required in this case. TRaster32P ras(imageDimension); readRaster(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); _ras = ras; } } else if (info.m_bitsPerSample == 8) { // Standard 32-bit case TRaster32P ras(imageDimension); readRaster(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); _ras = ras; } else throw TImageException(m_path, "Image format not supported"); // 64-bit to 32-bit conversions if necessary (64 bit images not allowed) if (!m_is64BitEnabled && (TRaster64P)_ras) { TRaster32P raux(_ras->getLx(), _ras->getLy()); TRop::convert(raux, _ras); _ras = raux; } // Return the image TRasterImageP ri(_ras); ri->setDpi(info.m_dpix, info.m_dpiy); return ri; } else if (info.m_samplePerPixel == 1 && info.m_valid == true) { // Previously dubbed as 'Palette cases'. No clue about what is this... :| TRaster32P ras(imageDimension); readRaster(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); TRasterImageP ri(ras); ri->setDpi(info.m_dpix, info.m_dpiy); return ri; } else if (info.m_samplePerPixel == 1 && m_readGreytones) { // Black-and-White case, I guess. Standard greymaps were considered above... TRasterGR8P ras(imageDimension); readRaster_copyLines(ras, m_reader, x0, y0, x1, y1, info.m_lx, info.m_ly, m_shrink); TRasterImageP ri(ras); ri->setDpi(info.m_dpix, info.m_dpiy); if (info.m_bitsPerSample == 1) // I suspect this always evaluates true... ri->setScanBWFlag(true); return ri; } else return TImageP(); } else if (m_vectorReader) { TVectorImage *vi = m_vectorReader->read(); return TVectorImageP(vi); } else return TImageP(); }
// place a triangle into intesected cells void TXGrid3D::PlaceTriangle(TXTriangle *t) { // bounding box CVector3f tmin(FLT_MAX, FLT_MAX, FLT_MAX), tmax(-FLT_MAX, -DBL_MAX, -FLT_MAX); for (int v=0; v<3; v++) { tmin.Set( MIN(tmin.GetX(),t->m_v[v]->m_pos.GetX()), MIN(tmin.GetY(),t->m_v[v]->m_pos.GetY()), MIN(tmin.GetZ(),t->m_v[v]->m_pos.GetZ()) ); tmax.Set( MAX(tmax.GetX(),t->m_v[v]->m_pos.GetX()), MAX(tmax.GetY(),t->m_v[v]->m_pos.GetY()), MAX(tmax.GetZ(),t->m_v[v]->m_pos.GetZ()) ); } // starting and ending cells of the bounding box CVector3 start( MAX((int)floor((tmin.GetX() - m_min.GetX())/m_xstep), 0), MAX((int)floor((tmin.GetY() - m_min.GetY())/m_ystep), 0), MAX((int)floor((tmin.GetZ() - m_min.GetZ())/m_zstep), 0) ); CVector3 end( MIN((int)floor((tmax.GetX() - m_min.GetX())/m_xstep), m_size-1), MIN((int)floor((tmax.GetY() - m_min.GetY())/m_ystep), m_size-1), MIN((int)floor((tmax.GetZ() - m_min.GetZ())/m_zstep), m_size-1) ); TXGridTriangle* gt = new TXGridTriangle(t); bool sa = (gt->m_n.GetX() >= 0), sb = (gt->m_n.GetY() >= 0), sc = (gt->m_n.GetZ() >= 0); CVector3f p1, p2; bool sd1, sd2; // put triangle in the cells in its bounding box // still excessive, treat triangle as a plane to detect intersection for (int i=(int)start.GetX(); i<=(int)end.GetX(); i++) { p1.Set(m_min.GetX() + i*m_xstep,p1.GetY(),p2.GetZ()); p2.Set(p1.GetX() + m_xstep,p2.GetY(),p2.GetZ()); for (int j=(int)start.GetY(); j<=(int)end.GetY(); j++) { if (sb == sa) { p1.Set(p1.GetX(),m_min.GetY() + j*m_ystep,p1.GetZ()); p2.Set(p2.GetX(),p1.GetY()+ m_ystep,p2.GetZ()); } else { p2.Set(p2.GetX(), m_min.GetY() + j*m_ystep,p2.GetZ()); p1.Set(p1.GetX(),p2.GetY() + m_ystep,p1.GetZ()); } for (int k=start.GetZ(); k<=end.GetZ(); k++) { if (sc == sa) { p1.Set(p1.GetX(),p1.GetY(),m_min.GetZ() + k*m_zstep); p2.Set(p2.GetX(),p2.GetY(),p1.GetZ() + m_zstep); } else { p2.Set(p2.GetX(),p2.GetY(),m_min.GetZ() + k*m_zstep); p1.Set(p1.GetX(),p1.GetY(),p2.GetZ() + m_zstep); } CVector3f p1gt, p2gt; p1gt.Sub(p1,gt->m_t->m_v[0]->m_pos); p2gt.Sub(p2,gt->m_t->m_v[0]->m_pos); sd1 = gt->m_n.Dot(p1gt) >= 0; sd2 = gt->m_n.Dot(p2gt) >= 0; if (sd1 != sd2) m_grid[i][j][k].push_back(gt); } } } }
//----------------------------------------------------------------------------- bool TRegion::Imp::contains(const TPointD &p) const { bool leftAreOdd = false; if (!getBBox().contains(p)) return false; //printContains(p); UINT i; int side = 0; for (i = 0; i < m_edge.size() * 2; i++) //i pari, esplora gli edge, //i dispari esplora i segmenti di autoclose tra un edge e il successivo { if (i & 0x1) { TPointD p0 = m_edge[i / 2]->m_s->getPoint(m_edge[i / 2]->m_w1); TPointD p1; if (i / 2 < m_edge.size() - 1) p1 = m_edge[i / 2 + 1]->m_s->getPoint(m_edge[i / 2 + 1]->m_w0); else p1 = m_edge[0]->m_s->getPoint(m_edge[0]->m_w0); if (tmin(p0.y, p1.y) > p.y || tmax(p0.y, p1.y) < p.y) continue; if (!areAlmostEqual(p0, p1, 1e-2)) side = findSides(p, TQuadratic(p0, 0.5 * (p0 + p1), p1), 0.0, 1.0, leftAreOdd, side); continue; } TEdge *e = m_edge[i / 2]; TStroke *s = e->m_s; if (s->getBBox().y0 > p.y || s->getBBox().y1 < p.y) continue; double t0, t1; int chunkIndex0, chunkIndex1; const TThickQuadratic *q0, *q1; s->getChunkAndT(e->m_w0, chunkIndex0, t0); s->getChunkAndT(e->m_w1, chunkIndex1, t1); q0 = s->getChunk(chunkIndex0); q1 = s->getChunk(chunkIndex1); if (i == 0 && areAlmostEqual(q0->getPoint(t0).y, p.y)) { double tEnd; int chunkIndexEnd; TEdge *edgeEnd = m_edge.back(); edgeEnd->m_s->getChunkAndT(edgeEnd->m_w1, chunkIndexEnd, tEnd); assert(areAlmostEqual(edgeEnd->m_s->getChunk(chunkIndexEnd)->getPoint(tEnd).y, p.y)); side = edgeEnd->m_s->getChunk(chunkIndexEnd)->getSpeed(tEnd).y > 0 ? 1 : -1; } if (chunkIndex0 != chunkIndex1) { /*if (chunkIndex0>chunkIndex1) { tswap(chunkIndex0, chunkIndex1); tswap(t0, t1); }*/ if (chunkIndex0 > chunkIndex1) { side = findSides(p, *q0, t0, 0, leftAreOdd, side); for (int j = chunkIndex0 - 1; j > chunkIndex1; j--) side = findSides(p, *s->getChunk(j), 1, 0, leftAreOdd, side); side = findSides(p, *q1, 1, t1, leftAreOdd, side); } else { side = findSides(p, *q0, t0, 1, leftAreOdd, side); for (int j = chunkIndex0 + 1; j < chunkIndex1; j++) side = findSides(p, *s->getChunk(j), 0, 1, leftAreOdd, side); side = findSides(p, *q1, 0, t1, leftAreOdd, side); } } else side = findSides(p, *q0, t0, t1, leftAreOdd, side); if (i & 0x1) delete q0; } return leftAreOdd; }
/***********************************************************************//** * @brief Test observations optimizer. * * @param[in] mode Testing mode. * * This method supports two testing modes: 0 = unbinned and 1 = binned. ***************************************************************************/ void TestOpenMP::test_observations_optimizer(const int& mode) { // Create Test Model GTestModelData model; // Create Models conteners GModels models; models.append(model); // Time iterval GTime tmin(0.0); GTime tmax(1800.0); // Rate : events/sec double rate = RATE; // Create observations GObservations obs; // Add some observation for (int i = 0; i < 6; ++i) { // Random Generator GRan ran; ran.seed(i); // Allocate events pointer GEvents *events; // Create either a event list or an event cube if (mode == UN_BINNED) { events = model.generateList(rate,tmin,tmax,ran); } else { events = model.generateCube(rate,tmin,tmax,ran); } // Create an observation GTestObservation ob; ob.id(gammalib::str(i)); // Add events to the observation ob.events(*events); ob.ontime(tmax.secs()-tmin.secs()); obs.append(ob); // Delete events pointer delete events; } // Add the model to the observation obs.models(models); // Create a GLog for show the interations of optimizer. GLog log; // Create an optimizer. GOptimizerLM opt(log); opt.max_stalls(50); // Optimize obs.optimize(opt); // Get the result GModelPar result = (*(obs.models()[0]))[0]; // Check if converged test_assert(opt.status()==0, "Check if converged", "Optimizer did not converge"); // Check if value is correct test_value(result.factor_value(),RATE,result.factor_error()*3); // Return return; }
//------------------------------------------------------------------------------ GDChart & GDChart::createChart() { create(width_,height_); bool isIntergerOnlyValues = true; intptr_t i, j, xCount = 0, x, y, x0 = 0, y0 = 0; // calc min max ldouble minValue = DBL_MAX, maxValue = -DBL_MAX; for( i = data_.count() - 1; i >= 0; i-- ){ j = data_[i].count(); xCount = tmax(xCount,j); const Array<ldouble> & data = data_[i]; for( j = data.count() - 1; j >= 0; j-- ){ volatile intmax_t v = intmax_t(data[j]); volatile ldouble lv = ldouble(v); if( lv != data[j] ) isIntergerOnlyValues = false; minValue = tmin(minValue,data[j]); maxValue = tmax(maxValue,data[j]); } } ldouble yAxis = (maxValue - minValue) / (height_ - topBorder_ - bottomBorder_); intptr_t leftBorderDelta = 0, rightBorderDelta = 0, topBorderDelta = 0, bottomBorderDelta = 0; // clear image fill(0,0,colorAllocate(255,255,255)); // draw lines intptr_t lineColor = colorAllocate(230,230,230); // draw vert grid lines for( j = 0; j < xCount; j++ ){ x = (width_ - leftBorder_ - rightBorder_) * j / (xCount - 1) + leftBorder_; line(x,topBorder_,x,height_ - bottomBorder_,lineColor); } intptr_t yLabelColor = makeColor(ldouble(j),ldouble(j),ldouble(j)); for( y = topBorder_; uintptr_t(y) <= height_ - bottomBorder_; y += fontHeight(font_) * 2 ){ ldouble v = maxValue - (y - topBorder_) * yAxis; // draw horiz grid line line(leftBorder_,y,width_ - rightBorder_,y,lineColor); // draw ylabel utf8::String label; if( isIntergerOnlyValues ){ label = printTraffic(intmax_t(v),true);//utf8::String::print("%"PRIdPTR,intptr_t(v)); } else { label = utf8::String::print("%.2"PRF_LDBL"f",v); } uintptr_t sz = label.size(); x = leftBorder_ - sz * fontWidth(font_); string(GD::font(font_),x,y,label.c_str(),yLabelColor); if( x < 0 && -x > leftBorderDelta ) leftBorderDelta = -x; } // draw data lines for( i = 0; uintptr_t(i) < data_.count(); i++ ){ intptr_t color = makeColor(ldouble(i + 1),ldouble(i + 1),ldouble(i + 1)); const Array<ldouble> & data = data_[i]; for( j = 0; uintptr_t(j) < data.count(); j++ ){ x = (width_ - leftBorder_ - rightBorder_) * j / (xCount - 1) + leftBorder_; y = intptr_t(height_ - topBorder_ - bottomBorder_ - (data[j] - minValue) / yAxis) + topBorder_; if( j > 0 ) line(x0,y0,x,y,color); x0 = x; y0 = y; } } intptr_t xBarSize = 2, yBarSize = 2; intptr_t barColor = colorAllocate(255,0,0); intptr_t xLabelColor = makeColor(ldouble(i + 1),ldouble(i + 1),ldouble(i + 1)); for( i = 0; uintptr_t(i) < data_.count(); i++ ){ const Array<ldouble> & data = data_[i]; for( j = 0; uintptr_t(j) < data.count(); j++ ){ x = (width_ - leftBorder_ - rightBorder_) * j / (xCount - 1) + leftBorder_; y = intptr_t(height_ - topBorder_ - bottomBorder_ - (data[j] - minValue) / yAxis) + topBorder_; // draw bar filledRectangle( tmax(leftBorder_,uintptr_t(x - xBarSize)), tmax(topBorder_,uintptr_t(y - yBarSize)), tmin(width_ - rightBorder_,uintptr_t(x + xBarSize)), tmin(height_ - bottomBorder_,uintptr_t(y + yBarSize)), barColor ); x0 = x; y0 = y; // draw xlabel y = height_ - bottomBorder_ + xBarSize; utf8::String label(utf8::String::print("%"PRIdPTR,intptr_t(j + xlvs_))); string(GD::font(font_),x + xBarSize,y,label.c_str(),xLabelColor); if( y + fontHeight(font_) >= height_ ) bottomBorderDelta = y + fontHeight(font_) - height_ + 1; x = x + xBarSize + fontWidth(font_) * label.size(); if( uintptr_t(x) >= width_ ) rightBorderDelta = x - width_ + 1; } } if( leftBorderDelta != 0 || rightBorderDelta != 0 || topBorderDelta != 0 || bottomBorderDelta != 0 ){ GDChart chart(*this); chart.leftBorder_ += leftBorderDelta; chart.rightBorder_ += rightBorderDelta; chart.topBorder_ += topBorderDelta; chart.bottomBorder_ += bottomBorderDelta; chart.createChart(); xchg(image_,chart.image_); xchg(png_,chart.png_); xchg(pngSize_,chart.pngSize_); } else { gdFree(png_); png_ = pngPtrEx(&pngSize_,9); } return *this; }
void PhysicsServer::ProcessCollision( void *data, dGeomID o1, dGeomID o2 ) { // skip connected bodies dBodyID bodyID1 = dGeomGetBody( o1 ); dBodyID bodyID2 = dGeomGetBody( o2 ); if (bodyID1 && bodyID2 && dAreConnected( bodyID1, bodyID2 )) return; if (!bodyID1 && !bodyID2) return; // do collision int nContacts = dCollide( o1, o2, c_MaxContacts, &m_Contacts[0].geom, sizeof( dContact ) ); if (nContacts == 0) return; float scale = GetWorldScale(); nContacts = tmin( nContacts, c_MaxContacts - m_NContacts ); for (int i = 0; i < nContacts; i++) { PhysMaterial* pSurf1 = GetGeomSurface( o1 ); PhysMaterial* pSurf2 = GetGeomSurface( o2 ); dContact& contact = m_Contacts[i]; dSurfaceParameters& surface = contact.surface; // TODO: proper flags setup m_Contacts[i].surface.mode = //dContactApprox1 | //dContactFDir1 | dContactSoftERP | dContactSoftCFM | //dContactSlip1 | //dContactSlip2 | dContactBounce; if (!pSurf1 && !pSurf2) { surface.mu = 8.0f; surface.mu2 = 8.0f; surface.bounce = 1.0f; surface.bounce_vel = 0.0f; surface.soft_erp = 0.1f; surface.soft_cfm = 1e-3f; surface.motion1 = 0.0f; surface.motion2 = 0.0f; surface.slip1 = 0.1f; surface.slip2 = 0.1f; } else if (pSurf2 == pSurf1) { surface.mu = pSurf1->m_Mu; surface.mu2 = pSurf1->m_Mu2; surface.bounce = pSurf1->m_Bounce; surface.bounce_vel = pSurf1->m_BounceVel; surface.soft_erp = pSurf1->m_SoftERP; surface.soft_cfm = pSurf1->m_SoftCFM; surface.motion1 = pSurf1->m_Motion1; surface.motion2 = pSurf1->m_Motion2; surface.slip1 = pSurf1->m_Slip1; surface.slip2 = pSurf1->m_Slip2; } else { if (!pSurf1) pSurf1 = pSurf2; if (!pSurf2) pSurf2 = pSurf1; surface.mu = sqrtf( pSurf1->m_Mu * pSurf2->m_Mu ); surface.mu2 = sqrtf( pSurf1->m_Mu2 * pSurf2->m_Mu2 ); surface.bounce = 0.5f*( pSurf1->m_Bounce + pSurf2->m_Bounce ); surface.bounce_vel = tmin( pSurf1->m_BounceVel, pSurf2->m_BounceVel ); surface.soft_erp = sqrtf( pSurf1->m_SoftERP * pSurf2->m_SoftERP ); surface.soft_cfm = 0.5f*( pSurf1->m_SoftCFM + pSurf2->m_SoftCFM ); surface.motion1 = sqrtf( pSurf1->m_Motion1 * pSurf2->m_Motion1 ); surface.motion2 = sqrtf( pSurf1->m_Motion2 * pSurf2->m_Motion2 ); surface.slip1 = sqrtf( pSurf1->m_Slip1 * pSurf2->m_Slip1 ); surface.slip2 = sqrtf( pSurf1->m_Slip2 * pSurf2->m_Slip2 ); } PhysObject* pObj1 = (PhysObject*)dGeomGetData( o1 ); PhysObject* pObj2 = (PhysObject*)dGeomGetData( o2 ); int obj1 = pObj1 ? pObj1->GetID() : -1; int obj2 = pObj2 ? pObj2->GetID() : -1; dContactGeom& geom = contact.geom; m_NContacts++; if (IsDrawBounds()) { Vec3 pos = Vec3( geom.pos[0], geom.pos[1], geom.pos[2] ); pos /= scale; Vec3 norm = Vec3( geom.normal[0], geom.normal[1], geom.normal[2] ); const float c_HandleSize = 0.3f; g_pDrawServer->SetWorldTM( Mat4::identity ); g_pDrawServer->DrawBox( AABox( pos, c_HandleSize*0.5f ), 0x5500FF00, 0x22FFFF00 ); g_pDrawServer->DrawLine( pos, pos + norm*c_HandleSize, 0x5500FF00, 0x5500FF00 ); } dJointID jID = dJointCreateContact( m_WorldID, m_ContactGroupID, &contact ); dJointAttach( jID, bodyID1, bodyID2 ); } } // PhysicsServer::ProcessCollision
/***********************************************************************//** * @brief Setup observation container * * @exception GException::no_cube * No event cube found in CTA observation. * * This method sets up the observation container for processing. There are * two cases: * * If there are no observations in the actual observation container, the * method will check in "infile" parameter. If this parameter is "NONE" or * empty, the task parameters will be used to construct a model map. * Otherwise, the method first tries to interpret the "infile" parameter as * a counts map, and attemps loading of the file in an event cube. If this * fails, the method tries to interpret the "infile" parameter as an * observation definition XML file. If this also fails, an exception will * be thrown. * * If observations exist already in the observation container, the method * will simply keep them. * * Test if all CTA observations contain counts maps. * * Finally, if no models exist so far in the observation container, the * models will be loaded from the model XML file. ***************************************************************************/ void ctmodel::setup_obs(void) { // If there are no observations in the container then try to build some if (m_obs.size() == 0) { // If no input filename has been specified, then create a model map // from the task parameters if ((m_infile == "NONE") || (gammalib::strip_whitespace(m_infile) == "")) { // Set pointing direction GCTAPointing pnt; GSkyDir skydir; skydir.radec_deg(m_ra, m_dec); pnt.dir(skydir); // Setup energy range covered by model GEnergy emin(m_emin, "TeV"); GEnergy emax(m_emax, "TeV"); GEbounds ebds(m_enumbins, emin, emax); // Setup time interval covered by model GGti gti; GTime tmin(m_tmin); GTime tmax(m_tmax); gti.append(tmin, tmax); // Setup skymap GSkymap map = GSkymap(m_proj, m_coordsys, m_xref, m_yref, -m_binsz, m_binsz, m_nxpix, m_nypix, m_enumbins); // Create model cube from sky map GCTAEventCube cube(map, ebds, gti); // Allocate CTA observation GCTAObservation obs; // Set CTA observation attributes obs.pointing(pnt); obs.ontime(gti.ontime()); obs.livetime(gti.ontime()*m_deadc); obs.deadc(m_deadc); // Set event cube in observation obs.events(cube); // Append CTA observation to container m_obs.append(obs); // Signal that no XML file should be used for storage m_use_xml = false; } // endif: created model map from task parameters // ... otherwise try to load information from the file else { // First try to open the file as a counts map try { // Allocate CTA observation GCTAObservation obs; // Load counts map in CTA observation obs.load_binned(m_infile); // Append CTA observation to container m_obs.append(obs); // Signal that no XML file should be used for storage m_use_xml = false; } // ... otherwise try to open as XML file catch (GException::fits_open_error &e) { // Load observations from XML file. This will throw // an exception if it fails. m_obs.load(m_infile); // Signal that XML file should be used for storage m_use_xml = true; } } // endelse: loaded information from input file } // endif: there was no observation in the container // If there are no models associated with the observations then // load now the model definition from the XML file if (m_obs.models().size() == 0) { m_obs.models(GModels(m_srcmdl)); } // Check if all CTA observations contain an event cube and setup response // for all observations for (int i = 0; i < m_obs.size(); ++i) { // Is this observation a CTA observation? GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); // Yes ... if (obs != NULL) { // Throw an exception if this observation does not contain // an event cube if (dynamic_cast<const GCTAEventCube*>(obs->events()) == NULL) { throw GException::no_cube(G_SETUP_OBS); } // Set response if it isn't set already if (obs->response().aeff() == NULL) { // Set calibration database. If specified parameter is a // directory then use this as the pathname to the calibration // database. Otherwise interpret this as the instrument name, // the mission being "cta" GCaldb caldb; if (gammalib::dir_exists(m_caldb)) { caldb.rootdir(m_caldb); } else { caldb.open("cta", m_caldb); } // Set reponse obs->response(m_irf, caldb); } // endif: observation already has a response } // endif: observation was a CTA observation } // endfor: looped over all observations // Return return; }
//!Converts a TVectorImage into a TRasterImage. The input vector image //!is transformed through the passed affine \b aff, and put into a //!TRasterImage strictly covering the bounding box of the transformed //!vector image. The output image has its lower-left position in the //!world reference specified by the \b pos parameter, which is granted to //!be an integer displacement of the passed value. Additional parameters //!include an integer \b enlarge by which the output image is enlarged with //!respect to the transformed image's bbox, and the bool \b transformThickness //!to specify whether the transformation should involve strokes' thickensses //!or not. TRasterImageP TRasterImageUtils::vectorToFullColorImage( const TVectorImageP &vimage, const TAffine &aff, TPalette *palette, const TPointD &outputPos, const TDimension &outputSize, const std::vector<TRasterFxRenderDataP> *fxs, bool transformThickness) { if (!vimage || !palette) return 0; //Transform the vector image through aff TVectorImageP vi = vimage->clone(); vi->transform(aff, transformThickness); //Allocate the output ToonzImage TRaster32P raster(outputSize.lx, outputSize.ly); raster->clear(); TRasterImageP ri(raster); ri->setPalette(palette->clone()); //Shift outputPos to the origin vi->transform(TTranslation(-outputPos)); int strokeCount = vi->getStrokeCount(); std::vector<int> strokeIndex(strokeCount); std::vector<TStroke *> strokes(strokeCount); int i; for (i = 0; i < strokeCount; ++i) { strokeIndex[i] = i; strokes[i] = vi->getStroke(i); } vi->notifyChangedStrokes(strokeIndex, strokes); int maxStyleId = palette->getStyleCount() - 1; for (i = 0; i < (int)vi->getRegionCount(); ++i) { TRegion *region = vi->getRegion(i); fastAddPaintRegion(ri, region, tmin(maxStyleId, region->getStyle()), maxStyleId); } set<int> colors; if (fxs) { for (i = 0; i < (int)fxs->size(); i++) { SandorFxRenderData *sandorData = dynamic_cast<SandorFxRenderData *>((*fxs)[i].getPointer()); if (sandorData && sandorData->m_type == BlendTz) { std::string indexes = toString(sandorData->m_blendParams.m_colorIndex); std::vector<std::string> items; parseIndexes(indexes, items); PaletteFilterFxRenderData paletteFilterData; insertIndexes(items, &paletteFilterData); colors = paletteFilterData.m_colors; break; } } } for (i = 0; i < strokeCount; ++i) { TStroke *stroke = vi->getStroke(i); bool visible = false; int styleId = stroke->getStyle(); TColorStyleP style = palette->getStyle(styleId); assert(style); int colorCount = style->getColorParamCount(); if (colorCount == 0) visible = true; else { visible = false; for (int j = 0; j < style->getColorParamCount() && !visible; j++) { TPixel32 color = style->getColorParamValue(j); if (color.m != 0) visible = true; } } if (visible) fastAddInkStroke(ri, stroke, TRectD(), 1, true); } return ri; }
void makeStripCharts(const Char_t* ratefn, const Char_t* voltfn, const Char_t* outtag, const Char_t* statfn=0, // def 0 for backwards compatibility const Float_t zoomDays=7.0, const Bool_t finFromData=kFALSE) { // finFromData = true => max of time axis determined by last data point // = false => determined by time at which the script is run gSystem->Setenv("TZ","UTC"); gStyle->SetTimeOffset(0); gStyle->SetOptStat(0); ratef = TFile::Open(ratefn); if ( (ratef==0) || (ratef->IsZombie()) ) { Error("makeStripCharts","Could not open [%s]",ratefn); } else { gERvsT = dynamic_cast<TGraph*>(ratef->Get("gERvsT")); } voltf = TFile::Open(voltfn); if ( (voltf==0) || (voltf->IsZombie()) ) { Error("makeStripCharts","Could not open [%s]",voltfn); } else { gVolt = dynamic_cast<TGraph*>(voltf->Get("gVolt")); gCurr = dynamic_cast<TGraph*>(voltf->Get("gCurr")); } if (statfn!=0) { statf = TFile::Open(statfn); if ( (statf!=0) && (statf->IsZombie()==kFALSE) ) { gStERvsT = dynamic_cast<TGraph*>(statf->Get("gStERvsT")); gStVvsT = dynamic_cast<TGraph*>(statf->Get("gStVvsT")); gStCvsT = dynamic_cast<TGraph*>(statf->Get("gStCvsT")); } if (gERvsT==0) { gERvsT = gStERvsT; } if (gVolt==0) { gVolt = gStVvsT; } if (gCurr==0) { gCurr = gStCvsT; } } if ( (gERvsT!=0) && (gVolt!=0) && (gCurr!=0) ) { setStyle(gERvsT, kRate); setStyle(gVolt, kVolt); setStyle(gCurr, kCurr); if (gStVvsT!=0) { setStyle(gStVvsT, kStVolt); } if (gStCvsT!=0) { setStyle(gStCvsT, kStCurr); } // assume gERvsT is ordered Double_t start = (gERvsT->GetX())[0]; Double_t fin = (gERvsT->GetX())[(gERvsT->GetN())-1]; if (gStERvsT!=0) { setStyle(gStERvsT, kStRate); // gStERvsT not ordered Double_t sst, sfn; getStartFinFrom(*gStERvsT, sst, sfn); if (sst<start) { start = sst; } if (sfn>fin) { fin = sfn; } } if (finFromData==kFALSE) { const TDatime now; fin = now.Convert(); } Int_t tbins(100); Double_t tmin(0), tmax(1); TSnMath::GetNiceDateAxisFor(start, fin, tbins, tmin, tmax); TH2F* hrd = new TH2F("hrd", gERvsT->GetTitle(), tbins, tmin, tmax, rbins, rmin, rmax); TH2F* hvd = new TH2F("hvd", gVolt->GetTitle(), tbins, tmin, tmax, vbins, vmin, vmax); TH2F* hzd = new TH2F("hzd", gVolt->GetTitle(), tbins, tmin, tmax, zbins, zmin, zmax); TH2F* hcd = new TH2F("hcd", gCurr->GetTitle(), tbins, tmin, tmax, cbins, cmin, cmax); setTimeDisp(*hrd); setTimeDisp(*hvd); setTimeDisp(*hzd); setTimeDisp(*hcd); c1 = new TCanvas("c1","c1",cwid,chit); c1->Divide(1,4); c1->cd(1); hrd->Draw("axis"); if (gStERvsT!=0) { gStERvsT->Draw(grphDrawOpt); } gERvsT->Draw(grphDrawOpt); c1->GetPad(1)->SetLogy(); c1->GetPad(1)->SetGridx(); c1->cd(2); hzd->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c1->GetPad(2)->SetGridx(); c1->cd(3); hvd->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c1->GetPad(3)->SetGridx(); c1->cd(4); hcd->Draw("axis"); if (gStCvsT!=0) { gStCvsT->Draw(grphDrawOpt); } gCurr->Draw(grphDrawOpt); c1->GetPad(4)->SetGridx(); c1->cd(); c1->Update(); c1->Print(Form("%s.root",outtag)); c1->Print(Form("%s.gif",outtag)); TSnMath::GetNiceDateAxisFor( fin - (zoomDays*kSecPerDay), fin, tbins, tmin, tmax); TH2F* hrz = new TH2F("hrz", gERvsT->GetTitle(), tbins, tmin, tmax, rbins, rmin, rmax); TH2F* hvz = new TH2F("hvz", gVolt->GetTitle(), tbins, tmin, tmax, zbins, zmin, zmax); TH2F* hzz = new TH2F("hzz", gVolt->GetTitle(), tbins, tmin, tmax, vbins, vmin, vmax); TH2F* hcz = new TH2F("hcz", gCurr->GetTitle(), tbins, tmin, tmax, cbins, cmin, cmax); setTimeDisp(*hrz, 515); setTimeDisp(*hvz, 515); setTimeDisp(*hzz, 515); setTimeDisp(*hcz, 515); c2 = new TCanvas("c2","c2",cwid,chit); c2->Divide(1,4); c2->cd(1); hrz->Draw("axis"); if (gStERvsT!=0) { gStERvsT->Draw(grphDrawOpt); } gERvsT->Draw(grphDrawOpt); c2->GetPad(1)->SetLogy(); c2->GetPad(1)->SetGridx(); c2->cd(2); hvz->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c2->GetPad(2)->SetGridx(); c2->cd(3); hzz->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c2->GetPad(3)->SetGridx(); c2->cd(4); hcz->Draw("axis"); if (gStCvsT!=0) { gStCvsT->Draw(grphDrawOpt); } gCurr->Draw(grphDrawOpt); c2->GetPad(4)->SetGridx(); c2->cd(); c2->Update(); c2->Print(Form("%s.now.root",outtag)); c2->Print(Form("%s.now.gif",outtag)); } else { Error("makeStripCharts","Could not get graphs"); } }