本文整理汇总了C++中LineBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ LineBuffer类的具体用法?C++ LineBuffer怎么用?C++ LineBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LineBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glEnable
void VolumeSample::demonstrate(const int width, const int height, const Crystal::Graphics::ICamera<float>& camera)
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
LegacyRenderer renderer;
PointBuffer buffer;
buffer.add(*volume);
renderer.render(camera, buffer);
LineBuffer lineBuffer;
lineBuffer.add(*polygon, ColorRGBA<float>(1.0, 0.0, 0.0, 1.0));
renderer.render(camera, lineBuffer);
}
示例2: PathLabels
void SE_PositioningAlgorithms::PathLabels(SE_ApplyContext* applyCtx,
SE_RenderStyle* rstyle)
{
SE_Renderer* se_renderer = applyCtx->renderer;
LineBuffer* geometry = applyCtx->geometry;
// path labeling only applies to linestring feature geometry
switch (geometry->geom_type())
{
case GeometryType_LineString:
case GeometryType_MultiLineString:
case GeometryType_CurveString:
case GeometryType_MultiCurveString:
break;
default:
return;
}
// in the case of a point style, just use the default placement algorithm
if (rstyle->type == SE_RenderStyle_Point)
return SE_PositioningAlgorithms::Default(applyCtx, rstyle);
// path labeling using an area style is not supported
if (rstyle->type == SE_RenderStyle_Area)
return;
// the style needs to contain at least one primitive
SE_RenderPrimitiveList& prims = rstyle->symbol;
if (prims.size() == 0)
return;
// If the symbol contains just a single text element then add the
// text as a regular path label (non-symbol). Use 0.5 as the
// default value for the scale limit.
if (prims.size() == 1 && prims[0]->type == SE_RenderPrimitive_Text)
{
SE_RenderText* rt = (SE_RenderText*)prims[0];
RS_LabelInfo info(0.0, 0.0, 0.0, 0.0, RS_Units_Device, rt->tdef);
RS_OverpostType overpostType = rstyle->checkExclusionRegion? RS_OverpostType_AllFit : RS_OverpostType_All;
return se_renderer->ProcessLabelGroup(&info, 1, rt->content, overpostType, rstyle->addToExclusionRegion, geometry, 0.5);
}
se_renderer->ProcessLineLabels(geometry, (SE_RenderLineStyle*)rstyle);
}
示例3: executeCommand
void Shell::executeCommand(const LineBuffer& line){
_out << '\n';
_modules.commandExecute(line.line(), *this);
const auto executionResult = handleExecuteCommand(line);
_modules.commandExecuted(executionResult, line.line(), *this);
switch (executionResult.status()) {
case Status::NoMatch:
_out << "Command not found [" << line.firstWord() << "]\n";
case Status::Ok:
prompt();
break;
case Status::Incomplete:
_function.parse(":prompt_feed", _out, true);
_column = _cursor.position().x;
break;
}
}
示例4: ContigPair
explicit ContigPair(LineBuffer &source)
: count(0)
{
auto const line = source.get();
if (line.first == nullptr) return;
auto n = 0;
for (auto i = line.first, end = i; ; ++end) {
if (end == line.second || *end == '\t') {
switch (n) {
case 0:
first.ref = unsigned(references[std::string(i, end)]);
break;
case 1:
if (!string_to_i(first.start, i, end)) goto CONVERSION_ERROR;
break;
case 2:
if (!string_to_i(first.end, i, end)) goto CONVERSION_ERROR;
break;
case 3:
second.ref = unsigned(references[std::string(i, end)]);
break;
case 4:
if (!string_to_i(second.start, i, end)) goto CONVERSION_ERROR;
break;
case 5:
if (!string_to_i(second.end, i, end)) goto CONVERSION_ERROR;
break;
case 6:
group = unsigned(groups[std::string(i, end)]);
break;
case 7:
std::cerr << "extra data in record: " << std::string(line.first, line.second) << std::endl;
return;
}
++n;
if (end == line.second)
break;
i = end + 1;
}
}
if (n < 6) {
std::cerr << "truncated record: " << std::string(line.first, line.second) << std::endl;
return;
}
if (n < 7)
group = groups[""];
count = 1;
return;
CONVERSION_ERROR:
std::cerr << "error parsing record: " << std::string(line.first, line.second) << std::endl;
return;
}
示例5: render
void LegacyRenderer::render(const Matrix4d<float>& projectionMatrix, const Matrix4d<float>& modelviewMatrix, const LineBuffer& buffer, const GLfloat width)
{
const auto& positions = buffer.getPosition().get();// buffers[0].get();
const auto& colors = buffer.getColor().get();
const auto& indices = buffer.getIds();
if (positions.empty()) {
return;
}
glLineWidth(width);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glLoadMatrixf(projectionMatrix.toArray().data());
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLoadMatrixf(modelviewMatrix.toArray().data());
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, positions.data());
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_FLOAT, 0, colors.data());
assert(glGetError() == GL_NO_ERROR);
//glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions.size()) / 3);
glDrawElements(GL_LINES, static_cast<GLsizei>(indices.size()), GL_UNSIGNED_INT, indices.data());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_DEPTH_TEST);
glLineWidth(1);
}
示例6: handleExecuteCommand
ParseResult Shell::handleExecuteCommand(const LineBuffer& line){
_buffer += line.line();
const ParseResult executionResult {
_commands.parse(_buffer, _out, true)};
switch (executionResult.status()) {
case Status::Incomplete:
_buffer += '\n';
break;
default:
_buffer.clear();
break;
}
return executionResult;
}
示例7: extents
void SE_Renderer::DrawSymbol(SE_RenderPrimitiveList& symbol,
const SE_Matrix& xform,
double angleRad,
bool excludeRegion)
{
RS_Bounds extents(DBL_MAX, DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX, -DBL_MAX);
unsigned int nprims = symbol.size();
for (unsigned int i=0; i<nprims; ++i)
{
SE_RenderPrimitive* primitive = symbol[i];
if (primitive->type == SE_RenderPrimitive_Polygon || primitive->type == SE_RenderPrimitive_Polyline)
{
SE_RenderPolyline* rp = (SE_RenderPolyline*)primitive;
LineBuffer* lb = rp->geometry->xf_buffer();
// update the extents with this primitive
RS_Bounds lbnds;
lb->ComputeBounds(lbnds);
extents.add_bounds(lbnds);
if (m_bSelectionMode)
{
if (primitive->type == SE_RenderPrimitive_Polygon)
DrawScreenPolygon(lb, &xform, m_selFillColor);
m_selLineStroke.cap = rp->lineStroke.cap;
m_selLineStroke.join = rp->lineStroke.join;
m_selLineStroke.miterLimit = rp->lineStroke.miterLimit;
DrawScreenPolyline(lb, &xform, m_selLineStroke);
}
else
{
if (primitive->type == SE_RenderPrimitive_Polygon)
DrawScreenPolygon(lb, &xform, ((SE_RenderPolygon*)primitive)->fill);
DrawScreenPolyline(lb, &xform, rp->lineStroke);
}
}
else if (primitive->type == SE_RenderPrimitive_Text)
{
SE_RenderText* tp = (SE_RenderText*)primitive;
// update the extents with this primitive's bounds
for (int j=0; j<4; ++j)
extents.add_point(primitive->bounds[j]);
// get position and angle to use
double x, y;
xform.transform(tp->position[0], tp->position[1], x, y);
RS_TextDef tdef = tp->tdef;
tdef.rotation() += angleRad * M_180PI;
if (m_bSelectionMode)
{
tdef.textcolor() = m_textForeColor;
tdef.ghostcolor() = m_textBackColor;
// tdef.framecolor() = m_textBackColor;
// tdef.opaquecolor() = m_textBackColor;
}
// Here we cannot use the cached RS_TextMetrics in the SE_RenderText object.
// We must recalculate the text metrics with the new tdef before we can call DrawScreenText.
RS_TextMetrics tm;
if (this->GetRSFontEngine()->GetTextMetrics(tp->content, tdef, tm, false))
DrawScreenText(tm, tdef, x, y, NULL, 0, 0.0);
}
else if (primitive->type == SE_RenderPrimitive_Raster)
{
SE_RenderRaster* rp = (SE_RenderRaster*)primitive;
if (m_bSelectionMode)
{
// if the raster symbol is selected, then draw the mask selection polygon only
LineBuffer *lb = LineBufferPool::NewLineBuffer(m_pPool, 5);
std::auto_ptr<LineBuffer> spLB(lb);
lb->MoveTo(rp->bounds[3].x, rp->bounds[3].y);
for (int i = 0; i < 4; ++i)
{
lb->LineTo(rp->bounds[i].x, rp->bounds[i].y);
}
DrawScreenPolygon(lb, &xform, m_selFillColor);
DrawScreenPolyline(lb, &xform, m_selLineStroke);
LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
}
else
{
ImageData& imgData = rp->imageData;
if (imgData.data != NULL)
{
// update the extents with this primitive's bounds
for (int j=0; j<4; ++j)
extents.add_point(primitive->bounds[j]);
// get position and angle to use
//.........这里部分代码省略.........
示例8: ProcessLine
///////////////////////////////////////////////////////////////////////////////
// Called when applying a line style on a feature geometry. Line styles can
// only be applied to linestring and polygon feature geometry types.
void SE_Renderer::ProcessLine(SE_ApplyContext* ctx, SE_RenderLineStyle* style)
{
// the feature geometry we're applying the style on...
LineBuffer* featGeom = ctx->geometry;
// can't apply a line style to point geometry types
switch (featGeom->geom_type())
{
case GeometryType_Point:
case GeometryType_MultiPoint:
return;
}
//--------------------------------------------------------------
// special code to handle simple straight solid line styles
//--------------------------------------------------------------
if (style->solidLine)
{
// just draw it and bail out of the layout function
SE_RenderPolyline* rp = (SE_RenderPolyline*)style->symbol[0];
SE_Matrix w2s;
GetWorldToScreenTransform(w2s);
if (m_bSelectionMode)
{
m_selLineStroke.cap = rp->lineStroke.cap;
m_selLineStroke.join = rp->lineStroke.join;
m_selLineStroke.miterLimit = rp->lineStroke.miterLimit;
DrawScreenPolyline(featGeom, &w2s, m_selLineStroke);
}
else
DrawScreenPolyline(featGeom, &w2s, rp->lineStroke);
return;
}
//--------------------------------------------------------------
// handle the case repeat <= 0 - here we ignore vertex control
//--------------------------------------------------------------
if (style->repeat <= 0.0)
{
// this can be handled using the overlap direct algorithm with:
// - repeat set to larger than each contour length
// - vertex angle limit set to >180 degrees
double old_val = style->vertexAngleLimit;
double old_rep = style->repeat;
style->vertexAngleLimit = M_PI + 1.0; // any value greater than M_PI
style->repeat = DBL_MAX;
ProcessLineOverlapDirect(featGeom, style);
style->vertexAngleLimit = old_val;
style->repeat = old_rep;
return;
}
//--------------------------------------------------------------
// check the vertex control type and call the appropriate helper
//--------------------------------------------------------------
if (style->vertexControl == SE_VertexControl_OverlapNone)
ProcessLineOverlapNone(featGeom, style);
else if (style->vertexControl == SE_VertexControl_OverlapDirect)
ProcessLineOverlapDirect(featGeom, style);
else
ProcessLineOverlapWrap(featGeom, style);
}
示例9: switch
///////////////////////////////////////////////////////////////////////////////
// Called when applying an area style on a feature geometry. Area styles can
// can only be applied to polygon feature geometry types.
void SE_Renderer::ProcessArea(SE_ApplyContext* ctx, SE_RenderAreaStyle* style)
{
// the feature geometry we're applying the style on...
LineBuffer* featGeom = ctx->geometry;
// can't apply an area style to point and linestring geometry types
switch (featGeom->geom_type())
{
case GeometryType_Point:
case GeometryType_MultiPoint:
case GeometryType_LineString:
case GeometryType_MultiLineString:
case GeometryType_CurveString:
case GeometryType_MultiCurveString:
return;
}
SE_Matrix w2s;
GetWorldToScreenTransform(w2s);
//--------------------------------------------------------------
// special code to handle simple solid fill styles
//--------------------------------------------------------------
if (style->solidFill)
{
// just draw it and bail out of the layout function
SE_RenderPolygon* rp = (SE_RenderPolygon*)style->symbol[0];
if (m_bSelectionMode)
DrawScreenPolygon(featGeom, &w2s, m_selFillColor);
else
DrawScreenPolygon(featGeom, &w2s, rp->fill);
return;
}
// transform the feature geometry to rendering space
LineBuffer* xfgeom = LineBufferPool::NewLineBuffer(m_pPool, featGeom->point_count());
std::auto_ptr<LineBuffer> spLB(xfgeom);
*xfgeom = *featGeom;
int size = featGeom->point_count();
for (int i=0; i<size; ++i)
w2s.transform(xfgeom->x_coord(i), xfgeom->y_coord(i));
// recompute the bounds
RS_Bounds& bounds = const_cast<RS_Bounds&>(xfgeom->bounds());
bounds.minx = bounds.miny = bounds.minz = +DBL_MAX;
bounds.maxx = bounds.maxy = bounds.maxz = -DBL_MAX;
xfgeom->ComputeBounds(bounds);
// account for any viewport rotation
SE_AreaPositioning ap(xfgeom, style, GetWorldToScreenRotation());
double baserot = ap.PatternRotation();
SE_Matrix xform;
SE_Matrix xformbase = *ctx->xform;
xformbase.rotate(baserot);
for (const Point2D* pos = ap.NextLocation(); pos != NULL; pos = ap.NextLocation())
{
xform = xformbase;
xform.translate(pos->x, pos->y);
DrawSymbol(style->symbol, xform, baserot, style->addToExclusionRegion);
}
LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
}
示例10: EvalString
void PointAdapter::Stylize(Renderer* renderer,
RS_FeatureReader* features,
bool initialPass,
SE_Evaluator* eval,
LineBuffer* geometry,
MdfModel::FeatureTypeStyle* style,
const MdfModel::MdfString* tooltip,
const MdfModel::MdfString* url,
RS_ElevationSettings* elevSettings,
CSysTransformer* /*layer2mapxformer*/)
{
m_eval = eval;
// no need to do anything if the style is not a point style, so quit
if (FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(style) != FeatureTypeStyleVisitor::ftsPoint)
return;
//-------------------------------------------------------
// determine the rule for the feature
//-------------------------------------------------------
MdfModel::RuleCollection* prc = style->GetRules();
MdfModel::PointRule* rule = NULL;
for (int i=0; i<prc->GetCount(); ++i)
{
rule = static_cast<MdfModel::PointRule*>(prc->GetAt(i));
// apply any filter on the rule - if it fails move to the next rule
if (!ExecFilter(&rule->GetFilter()))
{
// don't stylize with failed rule
rule = NULL;
continue;
}
break;
}
if (!rule)
return;
MdfModel::PointSymbolization2D* psym = rule->GetSymbolization();
MdfModel::PointTypeStyle* pfs = (MdfModel::PointTypeStyle*)style;
//-------------------------------------------------------
// prepare the geometry on which to apply the style
//-------------------------------------------------------
// NOTE: clipping of geometry for rendering (the RequiresClipping
// option) does not need to be done for points. Points
// outside the map extents already get clipped away as part
// of the FDO query.
LineBuffer* lb = geometry;
std::auto_ptr<LineBuffer> spClipLB;
if (renderer->RequiresClipping())
{
// clip geometry to given extents
// NOTE: point styles do not require a clip offset
LineBuffer* lbc = lb->Clip(renderer->GetBounds(), LineBuffer::ctAGF, m_lbPool);
if (lbc != lb)
{
// if the clipped buffer is NULL (completely clipped) just move on to
// the next feature
if (!lbc)
return;
// otherwise continue processing with the clipped buffer
lb = lbc;
if (lb != geometry)
spClipLB.reset(lb);
}
}
//-------------------------------------------------------
// do the StartFeature notification
//-------------------------------------------------------
RS_String tip; //TODO: this should be quick since we are not assigning
RS_String eurl;
const RS_String &theme = rule->GetLegendLabel();
if (tooltip && !tooltip->empty())
EvalString(*tooltip, tip);
if (url && !url->empty())
EvalString(*url, eurl);
// elevation settings
RS_ElevationType elevType = RS_ElevationType_RelativeToGround;
double zOffset = 0.0;
double zExtrusion = 0.0;
GetElevationParams(elevSettings, zOffset, zExtrusion, elevType);
renderer->StartFeature(features, initialPass,
tip.empty()? NULL : &tip,
eurl.empty()? NULL : &eurl,
theme.empty()? NULL : &theme,
//.........这里部分代码省略.........
示例11: lock
void
OutputFile::writePixels (int numScanLines)
{
try
{
Lock lock (*_data);
if (_data->slices.size() == 0)
throw Iex::ArgExc ("No frame buffer specified "
"as pixel data source.");
//
// Maintain two iterators:
// nextWriteBuffer: next linebuffer to be written to the file
// nextCompressBuffer: next linebuffer to compress
//
int first = (_data->currentScanLine - _data->minY) /
_data->linesInBuffer;
int nextWriteBuffer = first;
int nextCompressBuffer;
int stop;
int step;
int scanLineMin;
int scanLineMax;
{
//
// Create a task group for all line buffer tasks. When the
// taskgroup goes out of scope, the destructor waits until
// all tasks are complete.
//
TaskGroup taskGroup;
//
// Determine the range of lineBuffers that intersect the scan
// line range. Then add the initial compression tasks to the
// thread pool. We always add in at least one task but the
// individual task might not do anything if numScanLines == 0.
//
if (_data->lineOrder == INCREASING_Y)
{
int last = (_data->currentScanLine + (numScanLines - 1) -
_data->minY) / _data->linesInBuffer;
scanLineMin = _data->currentScanLine;
scanLineMax = _data->currentScanLine + numScanLines - 1;
int numTasks = max (min ((int)_data->lineBuffers.size(),
last - first + 1),
1);
for (int i = 0; i < numTasks; i++)
{
ThreadPool::addGlobalTask
(new LineBufferTask (&taskGroup, _data, first + i,
scanLineMin, scanLineMax));
}
nextCompressBuffer = first + numTasks;
stop = last + 1;
step = 1;
}
else
{
int last = (_data->currentScanLine - (numScanLines - 1) -
_data->minY) / _data->linesInBuffer;
scanLineMax = _data->currentScanLine;
scanLineMin = _data->currentScanLine - numScanLines + 1;
int numTasks = max (min ((int)_data->lineBuffers.size(),
first - last + 1),
1);
for (int i = 0; i < numTasks; i++)
{
ThreadPool::addGlobalTask
(new LineBufferTask (&taskGroup, _data, first - i,
scanLineMin, scanLineMax));
}
nextCompressBuffer = first - numTasks;
stop = last - 1;
step = -1;
}
while (true)
{
if (_data->missingScanLines <= 0)
{
throw Iex::ArgExc ("Tried to write more scan lines "
"than specified by the data window.");
}
//
// Wait until the next line buffer is ready to be written
//.........这里部分代码省略.........
示例12: ObtainStyle
void PolygonAdapter::Stylize(Renderer* renderer,
RS_FeatureReader* features,
bool initialPass,
SE_Evaluator* eval,
LineBuffer* geometry,
MdfModel::FeatureTypeStyle* style,
const MdfModel::MdfString* tooltip,
const MdfModel::MdfString* url,
RS_ElevationSettings* elevSettings,
CSysTransformer* /*layer2mapxformer*/)
{
m_eval = eval;
// no need to do anything if the style is not an area style, so quit
if (FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(style) != FeatureTypeStyleVisitor::ftsArea)
return;
//-------------------------------------------------------
// determine the rule for the feature
//-------------------------------------------------------
MdfModel::RuleCollection* arc = style->GetRules();
MdfModel::AreaRule* rule = NULL;
for (int i=0; i<arc->GetCount(); ++i)
{
rule = static_cast<MdfModel::AreaRule*>(arc->GetAt(i));
// apply any filter on the rule - if it fails move to the next rule
if (!ExecFilter(&rule->GetFilter()))
{
// don't stylize with failed rule
rule = NULL;
continue;
}
break;
}
if (!rule)
return;
MdfModel::AreaSymbolization2D* asym = rule->GetSymbolization();
if (asym == NULL)
return;
//-------------------------------------------------------
// evaluate the style to use
//-------------------------------------------------------
// quick check if style is already cached
RS_FillStyle* fillStyle = m_hAreaSymCache[asym];
if (!fillStyle)
{
// if not, then we need to either cache or evaluate it
fillStyle = &m_fillStyle;
ObtainStyle(asym, *fillStyle);
}
//-------------------------------------------------------
// compute the clip offset from the styles
//-------------------------------------------------------
double clipOffsetWU = 0.0; // in mapping units
bool bClip = renderer->RequiresClipping();
bool bLabelClip = renderer->RequiresLabelClipping();
if (bClip || bLabelClip)
{
double mapScale = renderer->GetMapScale();
// in meters in device units
double clipOffsetMeters = GetClipOffset(fillStyle->outline(), mapScale);
// add one pixel's worth to handle any roundoff
clipOffsetMeters += METERS_PER_INCH / renderer->GetDpi();
// limit the offset to something reasonable
if (clipOffsetMeters > MAX_CLIPOFFSET_IN_METERS)
clipOffsetMeters = MAX_CLIPOFFSET_IN_METERS;
// convert to mapping units
clipOffsetWU = clipOffsetMeters * mapScale / renderer->GetMetersPerUnit();
}
//-------------------------------------------------------
// prepare the geometry on which to apply the style
//-------------------------------------------------------
LineBuffer* lb = geometry;
std::auto_ptr<LineBuffer> spClipLB;
if (bClip)
{
// the clip region is the map request extents expanded by the offset
RS_Bounds clip = renderer->GetBounds();
clip.minx -= clipOffsetWU;
clip.miny -= clipOffsetWU;
clip.maxx += clipOffsetWU;
//.........这里部分代码省略.........
示例13: switch
void SE_PositioningAlgorithms::EightSurrounding(SE_ApplyContext* applyCtx,
SE_RenderStyle* rstyle,
double mm2su)
{
SE_Renderer* se_renderer = applyCtx->renderer;
LineBuffer* geometry = applyCtx->geometry;
// eight surrounding labeling only applies to point feature geometry
switch (geometry->geom_type())
{
case GeometryType_Point:
case GeometryType_MultiPoint:
break;
default:
return;
}
// eight surrounding labeling only works with point styles
if (rstyle->type != SE_RenderStyle_Point)
return;
// the style needs to contain at least one primitive
SE_RenderPrimitiveList& prims = rstyle->symbol;
if (prims.size() == 0)
return;
SE_RenderPointStyle* rpstyle = (SE_RenderPointStyle*)rstyle;
// get actual feature point and transform to screen space
// TODO: in the case of a multi-point feature we get the average of all the points;
// generating candidate labels around this point doesn't make a whole lot of
// sense
double cx = 0.0;
double cy = 0.0;
geometry->Centroid(LineBuffer::ctPoint, &cx, &cy, NULL);
// don't add a label if we can't compute the centroid
if (_isnan(cx) || _isnan(cy))
return;
se_renderer->WorldToScreenPoint(cx, cy, cx, cy);
// Get the extent of the last drawn point symbol so that we know how much to offset
// the label. This call assumes the symbol draws right before the label.
// TODO: remove this assumption
const RS_F_Point* cfpts = se_renderer->GetLastSymbolExtent();
RS_F_Point fpts[4];
if(cfpts[0].x == 0 && cfpts[0].y == 0 &&
cfpts[1].x == 0 && cfpts[1].y == 0 &&
cfpts[2].x == 0 && cfpts[2].y == 0 &&
cfpts[3].x == 0 && cfpts[3].y == 0)
{
for (int i=0; i<4; ++i)
{
fpts[i].x = cx;
fpts[i].y = cy;
}
}
else
memcpy(fpts, cfpts, 4*sizeof(RS_F_Point));
double dx = fpts[1].x - fpts[0].x;
double dy = fpts[1].y - fpts[0].y;
double symbol_rot_rad = atan2(dy, dx);
// factor out position and rotation
SE_Matrix ixform;
ixform.translate(-cx, -cy); // factor out point position
ixform.rotate(-symbol_rot_rad); // factor out rotation
for (int i=0; i<4; ++i)
ixform.transform(fpts[i].x, fpts[i].y);
bool yUp = se_renderer->YPointsUp();
if (!yUp)
symbol_rot_rad = -symbol_rot_rad;
// unrotated bounds
RS_Bounds symbol_bounds(fpts[0].x, fpts[0].y, fpts[2].x, fpts[2].y);
double symbol_width = symbol_bounds.width(); // symbol width in screen units
double symbol_height = symbol_bounds.height(); // symbol height in screen units
// offset the label from the symbol's edge
double offset = POINT_LABEL_OFFSET_MM * mm2su; // offset in screen units
// make sure we have at least one pixel's worth of offset
double screenUnitsPerPixel = MILLIMETERS_PER_INCH * se_renderer->GetScreenUnitsPerMillimeterDevice() / se_renderer->GetDpi();
if (offset < screenUnitsPerPixel)
offset = screenUnitsPerPixel;
// compute how far label needs to be offset from center point of symbol
double w2 = 0.5 * symbol_width;
double h2 = 0.5 * symbol_height;
double ch = 0.0; // vertical center point
double cw = 0.0; // horizontal center point
w2 += offset;
h2 += offset;
bool useBounds = symbol_bounds.IsValid();
//.........这里部分代码省略.........
示例14: StdErrReaderThread
static DWORD WINAPI StdErrReaderThread(LPVOID lpParameter)
{
CDownloader* pObj = ((PipeThreadParm*)lpParameter)->pObj;
char Line[4096+1]; // When output is redirected, RAW ASCII is used
const DWORD dwToRead = countof(Line)-1;
DWORD dwRead, nValue, nErrCode;
BOOL bSuccess;
CEStr szLine;
const wchar_t *ptr;
const wchar_t sProgressMark[] = L" " CEDLOG_MARK_PROGR;
const wchar_t sInformationMark[] = L" " CEDLOG_MARK_INFO;
const wchar_t sErrorMark[] = L" " CEDLOG_MARK_ERROR;
LineBuffer buffer = {};
bool bExit = false;
while (!bExit)
{
bSuccess = ReadFile(pObj->mh_PipeErrRead, Line, dwToRead, &dwRead, NULL);
if (!bSuccess || dwRead == 0)
{
nErrCode = GetLastError();
break;
}
_ASSERTE(dwRead < countof(Line));
Line[dwRead] = 0; // Ensure it is ASCIIZ
// Append to the line-buffer
buffer.AddBlock(Line, dwRead);
// Parse read line
while (buffer.GetLine(szLine))
{
bool bProgress = false;
if ((ptr = wcsstr(szLine, sProgressMark)) != NULL)
{
bProgress = true;
if (pObj->mfn_Callback[dc_ProgressCallback])
{
// 09:01:20.811{1234} Progr: Bytes downloaded 1656
wchar_t* ptrEnd = NULL;
LPCWSTR pszFrom = wcspbrk(ptr+wcslen(sProgressMark), L"0123456789");
nValue = pszFrom ? wcstoul(pszFrom, &ptrEnd, 10) : 0;
if (nValue)
{
CEDownloadInfo progrInfo = {
sizeof(progrInfo),
pObj->m_CallbackLParam[dc_ProgressCallback]
};
progrInfo.argCount = 1;
progrInfo.Args[0].argType = at_Uint;
progrInfo.Args[0].uintArg = nValue;
pObj->mfn_Callback[dc_ProgressCallback](&progrInfo);
}
}
}
// For logging purposes
if (!bProgress && ((ptr = wcsstr(szLine, sErrorMark)) != NULL))
{
if (pObj->mfn_Callback[dc_ErrCallback])
{
CEDownloadInfo Error = {
sizeof(Error),
pObj->m_CallbackLParam[dc_ErrCallback],
szLine.ms_Val
};
pObj->mfn_Callback[dc_ErrCallback](&Error);
}
}
else //if (bProgress || ((ptr = wcsstr(szLine, sInformationMark)) != NULL))
{
if (pObj->mfn_Callback[dc_LogCallback])
{
CEDownloadInfo Info = {
sizeof(Info),
pObj->m_CallbackLParam[dc_LogCallback],
szLine.ms_Val
};
pObj->mfn_Callback[dc_LogCallback](&Info);
}
// Exit?
ptr = wcsstr(szLine, sInformationMark);
if (ptr)
{
ptr += wcslen(sInformationMark);
if (wcsncmp(ptr, L"Exit", 4) == 0)
{
bExit = true;
break;
}
}
}
}
}
return 0;
};
示例15: MultipleHighwaysShields
void SE_PositioningAlgorithms::MultipleHighwaysShields(SE_ApplyContext* applyCtx,
SE_RenderStyle* rstyle,
double mm2su,
RS_FeatureReader* featureReader,
SE_SymbolManager* symbolManager)
{
if (featureReader == NULL)
return;
SE_Renderer* se_renderer = applyCtx->renderer;
LineBuffer* geometry = applyCtx->geometry;
// this placement algorithm only applies to line styles
if (rstyle->type != SE_RenderStyle_Line)
return;
SE_RenderLineStyle* rlStyle = (SE_RenderLineStyle*)rstyle;
// ... and the units control must be absolute
if (rlStyle->unitsControl != SE_UnitsControl_Absolute)
return;
// highway info format: countryCode|type1|num1|type2|num2|type3|num3|...
// example: US|2|101|3|1
StringOfTokens highwayInfo(featureReader->GetString(L"Url"), L"|");
int shieldCount = (highwayInfo.getTokenCount() - 1) / 2;
if (shieldCount < 1)
return;
double startOffset = rlStyle->startOffset;
double increment = rlStyle->repeat;
// the endOffset is used in this context as the increment between multiple shields in one group
// double incrementS = 10.0 * mm2su;
double incrementS = rlStyle->endOffset;
// calc the overall length of this geometry
double totalLen = 0.0;
for (int i=0; i<geometry->cntr_count(); ++i)
{
int pt = geometry->contour_start_point(i);
int last = geometry->contour_end_point(i);
while (pt < last)
{
// transform the point to screen space
double cx1, cy1, cx2, cy2;
se_renderer->WorldToScreenPoint(geometry->x_coord(pt), geometry->y_coord(pt), cx1, cy1);
pt++;
se_renderer->WorldToScreenPoint(geometry->x_coord(pt), geometry->y_coord(pt), cx2, cy2);
// calc length
double dx = cx2 - cx1;
double dy = cy2 - cy1;
totalLen += sqrt(dx*dx + dy*dy);
}
}
if (startOffset >= 0.0)
{
// calc optimal start offset (with rlStyle->startOffset taken as a minimum)
// to co-locate shield groups placed on two-line highways where the two
// parallel lines are processed from opposit ends.
// this avoids a problem with perceived irregular placement when overposting
// removes just some of the duplicate shields
double shieldGroupLen = (shieldCount - 1) * incrementS;
// length in excess of the required length to place one group with startOffset on each side
double availLen = totalLen - (shieldGroupLen + 2.0 * startOffset);
if (availLen < 0.0)
{
// there is no room to 'properly' place even one group, nothing to do but cry about it
return;
}
int numAdditionalGroups = (int) (availLen / (shieldGroupLen + increment));
double additionalOffset = (availLen - numAdditionalGroups * (shieldGroupLen + increment)) / 2;
startOffset += additionalOffset;
}
else
{
// negative startOffset value disables the optimization
// use absolute value as the offset
startOffset = -startOffset;
}
SE_RenderPrimitiveList* symbolVectors = new SE_RenderPrimitiveList[shieldCount];
std::wstring countryCode = highwayInfo.getFirstToken();
int shieldIndex;
for (shieldIndex=0; shieldIndex<shieldCount; ++shieldIndex)
{
std::wstring shieldType = highwayInfo.getNextToken();
std::wstring highwayNum = highwayInfo.getNextToken();
//.........这里部分代码省略.........