Exemplo n.º 1
0
static int show_menu(char **x, unsigned n_columns, unsigned width, unsigned percentage) {
        unsigned n, per_column, i, j;
        unsigned break_lines, break_modulo;

        assert(n_columns > 0);

        n = strv_length(x);
        per_column = (n + n_columns - 1) / n_columns;

        break_lines = lines();
        if (break_lines > 2)
                break_lines--;

        /* The first page gets two extra lines, since we want to show
         * a title */
        break_modulo = break_lines;
        if (break_modulo > 3)
                break_modulo -= 3;

        for (i = 0; i < per_column; i++) {

                for (j = 0; j < n_columns; j ++) {
                        _cleanup_free_ char *e = NULL;

                        if (j * per_column + i >= n)
                                break;

                        e = ellipsize(x[j * per_column + i], width, percentage);
                        if (!e)
                                return log_oom();

                        printf("%4u) %-*s", j * per_column + i + 1, width, e);
                }

                putchar('\n');

                /* on the first screen we reserve 2 extra lines for the title */
                if (i % break_lines == break_modulo) {
                        if (!press_any_key())
                                return 0;
                }
        }

        return 0;
}
Exemplo n.º 2
0
void pEditor::convertTabs()
{
    // get original text
    QString originalText = text();
    // all modifications must believe as only one action
    beginUndoAction();
    // get indent width
    const int indentWidth = indentationWidth() != 0 ? indentationWidth() : tabWidth();
    // iterate each line
    for ( int i = 0; i < lines(); i++ )
    {
        // remember if last line was troncate
        static bool lastLineWasTroncate = false;
        // get current line indent width
        int lineIndent = indentation( i );
        // check if need troncate
        int t = lineIndent /indentWidth;
        int r = lineIndent %indentWidth;
        if ( r != 0 && r != indentWidth )
        {
            r += indentWidth -r;
            lineIndent = ( t *indentWidth) +r;
            lastLineWasTroncate = true;
        }
        else if ( lastLineWasTroncate && lineIndent != 0 )
        {
            lastLineWasTroncate = indentation( i +1 ) == lineIndent;
            lineIndent  += indentWidth;
        }
        // remove indentation
        setIndentation( i, 0 );
        // restore it with possible troncate indentation
        setIndentation( i, lineIndent );
    }
    // end global undo action
    endUndoAction();
    // compare original and newer text
    if ( originalText == text() )
    {
        // clear undo buffer
        SendScintilla( SCI_EMPTYUNDOBUFFER );
        // set unmodified
        setModified( false );
    }
}
    void testGutterLines_getSecondLine_getsTheLine()
    {
        auto expected = new NiceMock<LineMock>();

        FakeFactory factory;
        EXPECT_CALL(factory, createLeftGutterLine()).Times(2).
                WillOnce(Return(new NiceMock<LineMock>())).
                WillOnce(Return(expected));

        RZQtIDELeftGutterWidgetLines lines(factory);

        lines.append();
        lines.append();

        auto actual = lines.getLine(2);

        QCOMPARE(actual, expected);
    }
Exemplo n.º 4
0
plist_t<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
{
	plist_t<input_t> *ret = palloc(plist_t<input_t>());
	if (fname != "")
	{
		pstring_list_t lines(filetobuf(fname) , "\n");
		for (unsigned i=0; i<lines.size(); i++)
		{
			pstring l = lines[i].trim();
			if (l != "")
			{
				input_t inp(netlist, l);
				ret->add(inp);
			}
		}
	}
	return ret;
}
Exemplo n.º 5
0
void StaffType::writeProperties(Xml& xml) const
      {
      xml.tag("name", name());
      // uncontionally write properties: staff types are read back over a copy of the built-in types
      // and properties may be different across types => each might need to be properly (re-)set
//      if (lines() != 5)
            xml.tag("lines", lines());
//      if (lineDistance().val() != 1.0)
            xml.tag("lineDistance", lineDistance().val());
//      if (!genClef())
            xml.tag("clef", genClef());
//      if (slashStyle())
            xml.tag("slashStyle", slashStyle());
//      if (!showBarlines())
            xml.tag("barlines", showBarlines());
//      if(!genTimesig())
            xml.tag("timesig", genTimesig());
      }
Exemplo n.º 6
0
int TextBuffer::blockForLine (int line) const
{
  // only allow valid lines
  Q_ASSERT (line >= 0);
  Q_ASSERT (line < lines());

  // block to start search with
  int index = m_lastUsedBlock;
  int blockStart = 0;
  int blockEnd = m_blocks.size();

  // check if start is ok
  if (index < 0 || index >= m_blocks.size())
    index = 0;

  // search for right block
  forever {
    // facts bout this block
    TextBlock* block = m_blocks.at(index);
    const int start = block->startLine();
    const int lines = block->lines ();

    // right block found, remember it and return it
    if (start <= line && line < (start + lines)) {
      m_lastUsedBlock = index;
      return index;
    }

    if (line < start)
	{
	  // Search left of index
	  blockEnd = index;
	}else{
	  // Search right of index
	  blockStart = index+1;
	}
	index = (blockStart + (blockEnd-1)) / 2;
  }

  // we should always find a block
  Q_ASSERT (false);
  return -1;
}
Exemplo n.º 7
0
void QScintillaWidget::setCursorPosition(int pLine, int pColumn)
{
    // Make sure that the line and column numbers make sense

    pLine = qMin(qMax(0, pLine), lines()-1);
    pColumn = qMin(qMax(0, pColumn), text(pLine).size()-1);

    // Make sure that the line is not within a folded block

    ensureLineVisible(pLine);

    // Center ourselves around the given line

    SendScintilla(SCI_LINESCROLL, 0, pLine-firstVisibleLine()-0.5*SendScintilla(SCI_LINESONSCREEN));

    // Set our cursor position

    QsciScintilla::setCursorPosition(pLine, pColumn);
}
void drawEdges(Grid* g, EdgesList* e, sf::RenderWindow* window)
{
    int n = 2 * e->size();
    sf::VertexArray lines(sf::Lines, n);
    int c = 0;
    for (const auto &pair : *e) {
        int idPoint = pair.first.first;
        int w = g->resolution * (idPoint % g->nbPointWidth);
        int h = g->resolution * (idPoint / g->nbPointHeight);
        lines[c+0].position = sf::Vector2f(w, h);
        if (pair.first.second == DIRECTION::right)
            lines[c+1].position = sf::Vector2f(w + g->resolution, h);
        else if (pair.first.second == DIRECTION::down)
            lines[c+1].position = sf::Vector2f(w, h + g->resolution);
        c += 2;
    }

    window->draw(lines);
}
Exemplo n.º 9
0
   void OSGDebugDrawInterface::AddOBB(const dtEntity::Matrix& m, const dtEntity::Vec3f& minCoords, 
      const dtEntity::Vec3f& maxCoords, const dtEntity::Vec4f& color, int lineWidth, 
      float duration, bool depthTestEnabled)
   {
      if(!mEnabled)
         return;
      osg::Vec3 p000(minCoords);
      osg::Vec3 p111(maxCoords);
      osg::Vec3 p001(minCoords[0], minCoords[0], maxCoords[1]);
      osg::Vec3 p010(minCoords[0], maxCoords[0], minCoords[1]);
      osg::Vec3 p100(maxCoords[0], minCoords[0], minCoords[1]);
      osg::Vec3 p011(minCoords[0], maxCoords[0], maxCoords[1]);
      osg::Vec3 p101(maxCoords[0], minCoords[0], maxCoords[1]);
      osg::Vec3 p110(maxCoords[0], maxCoords[0], minCoords[1]);
      
      p000 = p000 * m;
      p111 = p111 * m;
      p001 = p001 * m;
      p010 = p010 * m;
      p100 = p100 * m;
      p011 = p011 * m;
      p101 = p101 * m;
      p110 = p110 * m;

      std::vector<osg::Vec3> lines(24);
      lines[0] = p000; lines[1] = p100;
      lines[2] = p100; lines[3] = p101;
      lines[4] = p101; lines[5] = p001;
      lines[6] = p001; lines[7] = p000;

      lines[8] = p001; lines[9] = p011;
      lines[10] = p101; lines[11] = p111;
      lines[12] = p100; lines[13] = p110;
      lines[14] = p000; lines[15] = p010;

      lines[16] = p011; lines[17] = p111;
      lines[18] = p010; lines[19] = p011;
      lines[20] = p111; lines[21] = p110;
      lines[22] = p010; lines[23] = p110;

      
      AddLines(lines, color, lineWidth, duration, depthTestEnabled);
   }
Exemplo n.º 10
0
void Visualizer::Run(){
        //std::cout << animationStatus << "...";

        switch(animationStatus) {
        case 0: clear(); break;
        case 1: stroboscope(); break;
        case 2: lightchange(); break;
        case 3: fadeIn(); break;
        case 4: pulseCircle(); break;
        case 5: lines(); break;
        case 6: circles(); break;
        case 7: randomLines(); break;
        case 8: square(); break;
        case 9: randomPixel(); break;
        case 10: rotateLine(); break;
        }
        return;

}
Exemplo n.º 11
0
static void
FormatDecodedMETAR(const METAR &metar, const ParsedMETAR &parsed,
                   tstring &output)
{
  /*
  00 ## Hamburg-Fuhlsbuettel, Germany (EDDH) 53-38N 010-00E 15M ##
  01 ## Dec 14, 2011 - 06:20 PM EST / 2011.12.14 2320 UTC ##
  02 ## Wind: from the SW (220 degrees) at 18 MPH (16 KT):0 ##
  03 ## Visibility: greater than 7 mile(s):0 ##
  04 ## Sky conditions: mostly cloudy ##
  05 ## Temperature: 41 F (5 C) ##
  06 ## Dew Point: 35 F (2 C) ##
  07 ## Relative Humidity: 80% ##
  08 ## Pressure (altimeter): 29.47 in. Hg (0998 hPa) ##
  */

  LineSplitter lines(metar.decoded);
  for (unsigned i = 0; lines.HasNext(); ++i) {
    auto range = lines.Next();

    if (i == 0) {
      // Try to provide a new title line
      if (parsed.name_available) {
        StaticString<256> buffer;
        buffer.Format(_("METAR for %s:"), parsed.name.c_str());
        output += buffer;
        output += '\n';
      } else
        output.append(range.first, range.second);

      output += '\n';

    } else if (i == 1) {
      // ignore second line and continue without line break

    } else {
      if (!FormatDecodedMETARLine(range.first, range.second, parsed, output)) {
        output.append(range.first, range.second);
        output += '\n';
      }
    }
  }
}
Exemplo n.º 12
0
void TsubtitleVobsub::drawalpha(
    int x0,
    int y0,
    unsigned int w,
    unsigned int h,
    const unsigned char* srcY,
    const unsigned char *srcaY,
    int strideY,
    const unsigned char* srcUV,
    const unsigned char *srcaUV,
    int strideUV,
    const TprintPrefs &prefs,
    unsigned char **dst,
    const stride_t *stride)
{
    const TcspInfo *cspInfo = csp_getInfo(prefs.csp);
    if (x0<0 || y0<0 || w==0 || h==0) {
        return;
    }
    TrenderedVobsubWord wrd;
    for (int i=0; i<3; i++) {
        wrd.dx[i]=w>>cspInfo->shiftX[i];
        wrd.dy[i]=h>>cspInfo->shiftY[i];
    }
    wrd.dxChar=wrd.dx[0];
    wrd.dyChar=wrd.dy[0];
    wrd.bmp[0]=(unsigned char*)srcY;
    wrd.msk[0]=(unsigned char*)srcaY;
    wrd.bmp[1]=wrd.bmp[2]=(unsigned char*)srcUV;
    wrd.msk[1]=wrd.msk[2]=(unsigned char*)srcaUV;
    wrd.bmpmskstride[0]=strideY;
    wrd.bmpmskstride[1]=wrd.bmpmskstride[2]=strideUV;
    TrenderedSubtitleLine ln(&wrd);
    TrenderedSubtitleLines lines(&ln);
    if (!prefs.vobchangeposition) {
        TprintPrefs prefs2=prefs;
        prefs2.xpos=-x0;
        prefs2.ypos=-y0;
        lines.print(prefs2,dst,stride);
    } else {
        lines.print(prefs,dst,stride);
    }
}
Exemplo n.º 13
0
/* Displays bottom status line or current prompt */
void do_bottom_line(void)
{
	move(lines()-1, 2);

	if (prompt != NULL) {
		printw("%s: %s", prompt, prompt_val);
	} else {
		addch(A_REVERSE | 'D'); addstr("elay  ");

		/* network */
		addch(A_REVERSE | 'N');
		attr_addstr(show_networks ? COLOR_PAIR(1) : 0, "etworks");
		addstr("  ");
		
		/* VBDs */
		attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "v");
		addch(A_REVERSE | 'B');
		attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds");
		addstr("  ");

		/* tmem */
		addch(A_REVERSE | 'T');
		attr_addstr(show_tmem ? COLOR_PAIR(1) : 0, "mem");
		addstr("  ");


		/* vcpus */
		addch(A_REVERSE | 'V');
		attr_addstr(show_vcpus ? COLOR_PAIR(1) : 0, "CPUs");
		addstr("  ");

		/* repeat */
		addch(A_REVERSE | 'R');
		attr_addstr(repeat_header ? COLOR_PAIR(1) : 0, "epeat header");
		addstr("  ");

		/* sort order */
		addch(A_REVERSE | 'S'); addstr("ort order  ");

		addch(A_REVERSE | 'Q'); addstr("uit  ");
	}
}
Exemplo n.º 14
0
    int compute_mphf_main(int argc, char** argv)
    {
        if (argc < 2) {
            std::cerr << "Expected: " << argv[0] << " <filename> [output_filename]" << std::endl;
            std::terminate();
        }

        const char* filename = argv[1];
        std::string output_filename;

        if (argc >= 3) {
            output_filename = argv[2];
        }

        logger() << "Processing " << filename << std::endl;

        file_lines lines(filename);
        size_t n = lines.size();
        logger() << n << " strings to process." << std::endl;

        stl_string_adaptor adaptor;
        typedef mphf<BaseHasher>mphf_t;
        mphf_t mphf;

        size_t max_nodes = (size_t(std::ceil(double(n) * 1.23)) + 2) / 3 * 3;
        if (max_nodes >= uint64_t(1) << 32) {
            logger() << "Using 64-bit sorter" << std::endl;
            HypergraphSorter64 sorter;
            mphf_t(sorter, n, lines, adaptor).swap(mphf);
        } else {
            logger() << "Using 32-bit sorter" << std::endl;
            HypergraphSorter32 sorter;
            mphf_t(sorter, n, lines, adaptor).swap(mphf);
        }

        if (output_filename.size()) {
            std::ofstream os(output_filename, std::ios::binary);
            mphf.save(os);
        }

        return 0;
    }
Exemplo n.º 15
0
int agg2RenderLineTiled(imageObj *img, shapeObj *p, imageObj * tile)
{

  mapserver::pattern_filter_bilinear_rgba8 fltr;
  typedef mapserver::line_image_pattern<mapserver::pattern_filter_bilinear_rgba8> pattern_type;
  typedef mapserver::renderer_outline_image<renderer_base, pattern_type> renderer_img_type;
  typedef mapserver::rasterizer_outline_aa<renderer_img_type, mapserver::line_coord_sat> rasterizer_img_type;
  pattern_type patt(fltr);

  AGG2Renderer *r = AGG_RENDERER(img);
  AGG2Renderer *tileRenderer = AGG_RENDERER(tile);

  line_adaptor lines(p);

  patt.create(tileRenderer->m_pixel_format);
  renderer_img_type ren_img(r->m_renderer_base, patt);
  rasterizer_img_type ras_img(ren_img);
  ras_img.add_path(lines);
  return MS_SUCCESS;
}
Exemplo n.º 16
0
/* Unfilled tri:  
 *
 * Note edgeflags in the vertex struct is not sufficient as we will
 * need to manipulate them when decomposing primitives.  
 * 
 * We currently keep the vertex edgeflag and primitive edgeflag mask
 * separate until the last possible moment.
 */
static void unfilled_tri( struct draw_stage *stage,
			  struct prim_header *header )
{
   struct unfilled_stage *unfilled = unfilled_stage(stage);
   unsigned mode = unfilled->mode[header->det >= 0.0];
  
   switch (mode) {
   case PIPE_POLYGON_MODE_FILL:
      stage->next->tri( stage->next, header );
      break;
   case PIPE_POLYGON_MODE_LINE:
      lines( stage, header );
      break;
   case PIPE_POLYGON_MODE_POINT:
      points( stage, header );
      break;
   default:
      assert(0);
   }   
}
Exemplo n.º 17
0
bool DocumentEditor::saveCopy(const QString &fileName_) {
	QFile file(fileName_);
	if (!file.open(QFile::WriteOnly)) {
		QMessageBox::warning(this, PACKAGE_NAME,
							 tr("Cannot save file %1:\n%2.")
							 .arg(fileName_)
							 .arg(file.errorString()));
		return false;
	}

	QTextCodec* codec = QTextCodec::codecForName(_codec.toUtf8());
	if(codec == 0) {
		QMessageBox::critical(this, PACKAGE_NAME,
							  tr("Cannot save file %1:\nUnsupported charset %2 !!")
							  .arg(fileName_).arg(_codec));
		return false;
	}

	QApplication::setOverrideCursor(Qt::WaitCursor);
	//file.resize(0);
	//file.write(codec->fromUnicode(text()));

	// check if strip spaces
	if(_trimOnSave == true)
		trimTrailingSpaces();

	// check if add new line to the end
	if (_addNewLineOnSave == true) {
		if (!isLineEmpty(lines() - 1)) {
			append(getEol());
		}
	}

	QTextStream out(&file);
	out.setCodec(codec);
	out.setGenerateByteOrderMark(needBOM());
	out << text();
	out.flush();
	QApplication::restoreOverrideCursor();
	return true;
}
Exemplo n.º 18
0
  int CompiledCode::line(int ip) {
    if(lines()->nil_p()) return -3;

    native_int fin = lines()->num_fields() - 2;
    for(native_int i = 0; i < fin; i += 2) {
      Fixnum* start_ip = as<Fixnum>(lines()->at(i));
      Fixnum* end_ip   = as<Fixnum>(lines()->at(i+2));

      if(start_ip->to_native() <= ip && end_ip->to_native() > ip) {
        return as<Fixnum>(lines()->at(i+1))->to_native();
      }
    }

    return as<Fixnum>(lines()->at(fin+1))->to_native();
  }
Exemplo n.º 19
0
void HttpHeader::analyze(const char * str)
{
	//content-valueの中に,が入る物があるとリストと区別できない。また、その場合正しく分割できていない

	fw::slice lines;
	lines(str, "\r\n");

	for (fw::uint i = lines.size() - 1; i>1; --i)
	{
		const char first = lines[i][0];
		if (first == ' ' || first == '\t')
		{
			lines[i - 1] += lines[i];
			lines.pop();
		}
	}

	char phrase[32];
	sscanf(lines[0].c_str(), "HTTP/%s %s %s", Version, Code, phrase);

	for (fw::uint i = 1; i<lines.size(); ++i)
	{
		fw::uint colon = lines[i].find(':');
		fw::uint beg = lines[i].find_first_not_of(" \t", colon + 1);
		if (beg == std::string::npos) printf("Not Found beg\n\n");

		fw::vstring & ref = table[lines[i].substr(0, colon)];	// テーブル(std::map)を増やしてる

		if (beg == std::string::npos) continue;
		fw::slice param;
		const std::string & params = lines[i].substr(beg);
		param(params, ",");

		for (fw::uint j = 0; j < param.size(); ++j)
		{
			ref.add(param[j].substr(param[j].find_first_not_of(" \t")));
			fw::uint spht = ref.last().find_first_of(" \t");
			ref.last() = ref.last().substr(0, spht);
		}
	}
}
Exemplo n.º 20
0
void drawVectorEdges(std::vector<Edge>* e, sf::RenderWindow* window)
{
    // on fixe la seed pour obtenir quasi les meme couleurs a chaque draw
    srand(1);
    int n = 2 * e->size();
    sf::VertexArray lines(sf::Lines, n);
    int c = 0;
    for (const auto &edge : *e) {
        sf::Color col = sf::Color::White;
        col.g = rand() % 255;
        col.r = rand() % 255;
        col.b = rand() % 255;
        lines[c+0].position = sf::Vector2f(edge.p0.x, edge.p0.y);
        lines[c+0].color = col;
        lines[c+1].position = sf::Vector2f(edge.p1.x, edge.p1.y);
        lines[c+1].color = col;
        c += 2;
    }

    window->draw(lines);
}
Exemplo n.º 21
0
InputDeck& InputDeck::build( std::istream& input){
 
  LineExtractor lines(input);

  InputDeck* deck = new InputDeck();

  deck->parseTitle(lines);
  deck->parseCells(lines);
  deck->parseSurfaces(lines);
  deck->parseDataCards(lines);


  for( std::vector<CellCard*>::iterator i = deck->cells.begin(); i!=deck->cells.end(); ++i){
    dynamic_cast<CellCardImpl*>(*i)->finish();
  }

  while(lines.hasLine()){ lines.takeLine(); }
  if( OPT_VERBOSE ) { std::cout << "Total lines read: " << lines.getLineCount()  <<  std::endl; }

  return *deck;
}
Exemplo n.º 22
0
void MainWindow::loadTopics() {
    QString fileName =
            QFileDialog::getOpenFileName(this, tr("Open Agenda File"),
                                         QString(),
                                         tr("Text Files (*.txt)"));
    if (fileName.length() > 0) {
        qDebug() << "loading from" << fileName;
        QStringList topics;
        QFile inputFile(fileName);

        if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text))
            return;

        QTextStream lines(&inputFile);
        while (!lines.atEnd()) {
            topics.push_back(lines.readLine());
        }

        setupAgendaTopics(topics);
    }
}
/**
 * Escribe los resultados en el archivo dado.
 *
 * @param output Archivo de salida.
 * @param sol    Solución final.
 * @param k      Cantidad de clusters.
 */
void Csv::write(char* output, int* sol, float** cent, int k){
    int i, j, l;
    ofstream lines(output);

    for(l = 0; l < k; ++l){
        lines << "Cluster " << l << endl;
        for(i = 0; i < N; ++i){
            if(sol[i] == l){
                j = 0;
                lines << "Objeto " << i << ":\t" << data[i][j]; 
                for(j = 1; j < M; ++j){
                    lines << ", " << data[i][j];
                }
                lines << endl;
            }
        }
        lines << endl;
    }

    lines.close();
}
Exemplo n.º 24
0
std::ostream& DOFInterface::showMe ( bool verbose, std::ostream& out ) const
{
    out << "------------------------------" << std::endl;
    out << "\tNumber of DOF connections (M_localDofMap):" << M_localDofMap.size() << std::endl;
    if ( verbose )
    {
        UInt count ( 0 ), lines ( 10 );
        out << "List of connections between DOF: (global, local)";
        for ( std::map<ID, ID>::const_iterator it = M_localDofMap.begin(); it != M_localDofMap.end(); ++it )
        {
            if ( count++ % lines == 0 )
            {
                out << std::endl;
            }
            out << "(" << it->first << "," << it->second << ")\t";
        }
        out << std::endl;
    }
    out << "------------------------------" << std::endl;
    return out;
}
Exemplo n.º 25
0
Process::Status BasicServer::parseQueryString(QString const& query, Process* process)
{
//   qDebug() <<"BasicServer::parseQueryString handed" << query;
   QStringList lines(query.split(QRegExp("\\n"), QString::SkipEmptyParts));
   Process::Status status(Process::Unknown);

   QString id(process->id());
   id = " " + id + " ";
   QStringList::iterator line;
   for (line = lines.begin(); line != lines.end(); ++line) {
       if ((*line).contains(m_server->executableName()) && (*line).contains(id)) {
          QString time((*line).split(QRegExp("\\s+"), QString::SkipEmptyParts).last());
          process->resetTimer(Timer::toSeconds(time));
          status = Process::Running;
       }
   }
   
   if (query.isEmpty()) return Process::Unknown;

   return status;
}
Exemplo n.º 26
0
/*
 * reverse -- display input in reverse order by line.
 *
 * There are six separate cases for this -- regular and non-regular
 * files by bytes, lines or the whole file.
 *
 * BYTES	display N bytes
 *	REG	reverse scan and display the lines
 *	NOREG	cyclically read characters into a wrap-around buffer
 *
 * LINES	display N lines
 *	REG	reverse scan and display the lines
 *	NOREG	cyclically read lines into a wrap-around array of buffers
 *
 * FILE		display the entire file
 *	REG	reverse scan and display the lines
 *	NOREG	cyclically read input into a linked list of buffers
 */
void
reverse(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
{
	if (style != REVERSE && off == 0)
		return;

	if (!S_ISREG(sbp->st_mode) || r_reg(fp, style, off, sbp) != 0)
		switch(style) {
		case FBYTES:
		case RBYTES:
			(void)bytes(fp, off);
			break;
		case FLINES:
		case RLINES:
			(void)lines(fp, off);
			break;
		case REVERSE:
			r_buf(fp);
			break;
		}
}
Exemplo n.º 27
0
void TestQgsDistanceArea::collections()
{
    Q_NOWARN_DEPRECATED_PUSH
    //test measuring for collections
    QgsDistanceArea myDa;
    myDa.setSourceAuthId( "EPSG:4030" );
    myDa.setEllipsoidalMode( true );
    myDa.setEllipsoid( "WGS84" );

    //collection of lines, should be sum of line length
    QgsGeometry lines( QgsGeometryFactory::geomFromWkt( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70) )" ) );
    double result = myDa.measure( &lines ); //should measure length
    QVERIFY( qgsDoubleNear( result, 12006159, 1 ) );
    result = myDa.measureLength( &lines );
    QVERIFY( qgsDoubleNear( result, 12006159, 1 ) );
    result = myDa.measureArea( &lines );
    QVERIFY( qgsDoubleNear( result, 0 ) );

    //collection of polygons
    QgsGeometry polys( QgsGeometryFactory::geomFromWkt( "GeometryCollection( Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) );
    result = myDa.measure( &polys ); //should measure area
    QVERIFY( qgsDoubleNear( result, 670434859475LL, 1 ) );
    result = myDa.measureArea( &polys );
    QVERIFY( qgsDoubleNear( result, 670434859475LL, 1 ) );
    result = myDa.measureLength( &polys );
    QVERIFY( qgsDoubleNear( result, 0 ) );

    //mixed collection
    QgsGeometry mixed( QgsGeometryFactory::geomFromWkt( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70), Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) );
    result = myDa.measure( &mixed ); //should measure area
    QVERIFY( qgsDoubleNear( result, 670434859475LL, 1 ) );
    //measure area specifically
    result = myDa.measureArea( &mixed );
    QVERIFY( qgsDoubleNear( result, 670434859475LL, 1 ) );
    //measure length
    result = myDa.measureLength( &mixed );
    QVERIFY( qgsDoubleNear( result, 12006159, 1 ) );

    Q_NOWARN_DEPRECATED_POP
}
Exemplo n.º 28
0
void PLY_Writer::writePLY(vector<cv::Mat>* pointC,vector<cv::Mat >* pointCN,vector<vector<int> >* pointCC ){

	const char* filePath = this->getFilePath();
	ofstream head(filePath);

	string header = "ply\nformat binary_little_endian 1.0\nelement vertex " + NumberToString<unsigned int>(pointC->size()) + "\n"
			+"property float x\nproperty float y\nproperty float z\nproperty float nx\nproperty float ny\nproperty float nz\n"
			+"property uchar diffuse_red\nproperty uchar diffuse_green\nproperty uchar diffuse_blue\nend_header\n";

	head << header;
	head.close();

	ofstream lines(filePath, ios::app | ios::binary);
	
	int nPts = static_cast<int>(pointC->size());
	//Write out each point	
	for(int i = 0; i<nPts; i++){

		float x = static_cast<float>((*pointC)[i].at<double>(0,0));
		float y = static_cast<float>((*pointC)[i].at<double>(1,0));
		float z = static_cast<float>((*pointC)[i].at<double>(2,0));
		float nx = static_cast<float>((*pointCN)[i].at<double>(0,0));
		float ny = static_cast<float>((*pointCN)[i].at<double>(1,0));
		float nz = static_cast<float>((*pointCN)[i].at<double>(2,0));
		unsigned char r = static_cast<unsigned char>((*pointCC)[i][0]);
		unsigned char g = static_cast<unsigned char>((*pointCC)[i][1]);
		unsigned char b = static_cast<unsigned char>((*pointCC)[i][2]);
		
		lines.write( reinterpret_cast<char*>(&x), sizeof(x));
		lines.write( reinterpret_cast<char*>(&y), sizeof(y));
		lines.write( reinterpret_cast<char*>(&z), sizeof(z));
		lines.write( reinterpret_cast<char*>(&nx), sizeof(nx));
		lines.write( reinterpret_cast<char*>(&ny), sizeof(ny));
		lines.write( reinterpret_cast<char*>(&nz), sizeof(nz));
		lines.write( reinterpret_cast<char*>(&r), sizeof(r));
		lines.write( reinterpret_cast<char*>(&g), sizeof(g));
		lines.write( reinterpret_cast<char*>(&b), sizeof(b));
	}
	lines.close();
}
Exemplo n.º 29
0
void TextWidget::redraw()
{
  Image& target=get_redraw_target();
  target.fill(m_BGColor);
  Rect rect=get_rect();
  const xstring& text = get_text();
  str_vec lines(1, text);
  Rect bounds=m_Font->get_bounds(text);
  if (bounds.get_width() > rect.get_width())
  {
    break_text_lines(m_Font, text, rect.get_width(),lines);
    bounds = Rect(0, 0, 0, 0);
    for (auto& line : lines)
    {
      Rect b = m_Font->get_bounds(line);
      bounds.right = Max(bounds.right, b.get_width());
      bounds.bottom += b.get_height();
    }
  }
  Point d(rect.get_width()-bounds.get_width(),rect.get_height()-bounds.get_height());
  if ((get_alignment() & ALIGN_HCENTER)==ALIGN_HCENTER) bounds.offset(Point(d.x/2,0));
  else
  if ((get_alignment() & ALIGN_RIGHT)==ALIGN_RIGHT) bounds.offset(Point(d.x,0));

  if ((get_alignment() & ALIGN_VCENTER)==ALIGN_VCENTER) bounds.offset(Point(0,d.y/2));
  else
  if ((get_alignment() & ALIGN_BOTTOM)==ALIGN_BOTTOM) bounds.offset(Point(0,d.y));
  int x = bounds.left, y = bounds.top;
  for (auto& line : lines)
  {
    Rect line_bounds = m_Font->get_bounds(line);
    int dx = 0;
    if ((get_alignment() & ALIGN_HCENTER) == ALIGN_HCENTER) dx = (bounds.get_width() - line_bounds.get_width()) / 2;
    else
    if ((get_alignment() & ALIGN_RIGHT) == ALIGN_RIGHT) dx = (bounds.get_width() - line_bounds.get_width());
    m_Font->draw(target, Point(x + dx, y), line, m_Color);
    y += line_bounds.get_height();
  }
}
Exemplo n.º 30
0
sf::VertexArray create_lines (Conteneur && points, const sf::Color couleur =  sf::Color::White)
{

    sf::VertexArray lines (sf::LinesStrip, points.size() );

    // définit les points
    size_t cpt = 0 ;
    for (auto && point : points )
    {
        lines[cpt].position = sf::Vector2f(getX(point), getY(point));
        
         // la couleur 
        lines[cpt].color = couleur;
        
        cpt++;
    }
    
   

    return lines;

}