EquatorialCoordinateGrid::EquatorialCoordinateGrid( SkyComposite *parent )
        : CoordinateGrid( parent, i18n("Equatorial Coordinate Grid" ) )
{
    KStarsData *data = KStarsData::Instance();

    intro();

    double eps    =   0.1;
    double minRa  =   0.0;
    double maxRa  =  23.0;
    double dRa    =   2.0;
    double minDec = -80.0;
    double maxDec =  90.0;
    double dDec   =  20.0;
    double dDec2  =   4.0;
    double dRa2   =   0.2;

    double max, dec, dec2, ra, ra2;

    LineList* lineList;

    for ( ra = minRa; ra < maxRa; ra += dRa ) {
        for ( dec = -90.0; dec < maxDec - eps; dec += dDec ) {
            lineList = new LineList();
            max = dec + dDec;
            if ( max > 90.0 ) max = 90.0;
            for ( dec2 = dec; dec2 <= max + eps; dec2 += dDec2 ) {
                SkyPoint* p = new SkyPoint( ra, dec2 );
                p->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
                lineList->append( p );
            }
            appendLine( lineList );
        }
    }

    for ( dec = minDec; dec < maxDec + eps; dec += dDec ) {
        // Do not paint the line on the equator
        if ( dec < 0.1 && dec > -0.1 )
            continue;
        
        // Adjust point density
        int nPoints = int(round( fabs(cos(dec* dms::PI / 180.0)) * dRa / dRa2 ));
        if ( nPoints < 5 )
            nPoints = 5;
        double dRa3 = dRa / nPoints;

        for ( ra = minRa; ra < maxRa + eps; ra += dRa ) {
            lineList = new LineList();
            for ( ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa3 ) {
                SkyPoint* p = new SkyPoint( ra2, dec );
                p->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
                lineList->append( p );
            }
            appendLine( lineList );
        }
    }
    
    summary();
}
void ConsoleModel::handleProcessFinish(int exitCode, QProcess::ExitStatus status)
{
    if (status == QProcess::CrashExit) { // if it crashed, then use some error exit code
        exitCode = -99999;
        appendLine(tr("** crashed"));

    } else if (exitCode != 0) {
        appendLine(tr("** error: %1").arg(exitCode));
    }
    emit processExited(exitCode);
}
/*--------------------------------------------------------------------------*/
void HistoryManager::reset(void)
{
    char *commentbeginsession = NULL;

    CommandsList.clear();

    my_file.reset();
    my_file.setDefaultFilename();

    my_search.reset();

    saveconsecutiveduplicatelines = FALSE;
    afterhowmanylineshistoryissaved = 0;
    numberoflinesbeforehistoryissaved = 0;

    CommandHistoryReset();

    /* Add date & time begin session */
    commentbeginsession = getCommentDateSession(FALSE);
    if (commentbeginsession)
    {
        appendLine(commentbeginsession);
        FREE(commentbeginsession);
        commentbeginsession = NULL;
    }

}
Esempio n. 4
0
Ecliptic::Ecliptic(SkyComposite *parent ) :
        LineListIndex( parent, i18n("Ecliptic") ),
        m_label( name() )
{
    KStarsData *data = KStarsData::Instance();
    KSNumbers num( data->ut().djd() );
    dms elat(0.0), elng(0.0);

    const double eps    =   0.1;
    const double minRa  =   0.0;
    const double maxRa  =  23.0;
    const double dRa    =   2.0;
    const double dRa2   =  2. / 5.;

    for(double ra = minRa; ra < maxRa; ra += dRa ) {
        LineList* lineList = new LineList();
        for(double ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa2 ) {
            elng.setH( ra2 );
            SkyPoint* o = new SkyPoint();
            o->setFromEcliptic( num.obliquity(), elng, elat );
            o->setRA0( o->ra().Hours() );
            o->setDec0( o->dec().Degrees() );
            o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
            lineList->append( o );
        }
        appendLine( lineList );
    }
}
void ConsoleModel::readProcessChannels()
{
    while (m_process->canReadLine()) {
        QString line = m_process->readLine();
        appendLine(line);
    }
}
Esempio n. 6
0
/*--------------------------------------------------------------------------*/
BOOL HistoryManager::reset(void)
{
    char* pstCommentBeginSession = NULL;

    m_Commands.clear();

    m_HF.reset();
    m_HF.setDefaultFilename();

    m_HS.reset();

    m_bAllowConsecutiveCommand  = FALSE;
    m_iSaveLimit                = 0;
    m_iSavedLines               = 0;

    CommandHistoryReset();

    /* Add date & time begin session */
    pstCommentBeginSession = getCommentDateSession(FALSE);
    if (pstCommentBeginSession)
    {
        appendLine(pstCommentBeginSession);
        FREE(pstCommentBeginSession);
        pstCommentBeginSession = NULL;
        return TRUE;
    }

    return FALSE;
}
Esempio n. 7
0
RoStringBuilder& RoStringBuilder::appendLine(const wchar_t* format, ...)
{
    va_list argList;
    va_start(argList, format);
    appendLine(RoStringUtil::VFormat(format, argList));
    va_end(argList);
    return *this;
}
Esempio n. 8
0
RoStringBuilder& RoStringBuilder::appendStrLine(const RoString format, ...)
{
    va_list argList;
    va_start(argList, format);
    appendLine(RoStringUtil::VFormat(format.c_str(), argList));
    va_end(argList);
    return *this;
}
Esempio n. 9
0
File: INIFile.C Progetto: HeyJJ/ball
	bool INIFile::appendLine(const String& data)
	{
		if (data[0] == '[')
		{
			return appendSection(data);
		}

		if (sections_.empty()) return false;
		return appendLine((*sections_.rbegin()).name_, data);
	}
Esempio n. 10
0
/*------------------------------------------------------------------------*/
BOOL HistoryManager::appendLines(char** _pstLines, int _iLines)
{
    for (int i = 0 ; i < _iLines ; i++)
    {
        if (appendLine(_pstLines[i]) == FALSE)
        {
            return FALSE;
        }
    }
    return TRUE;
}
Esempio n. 11
0
File: INIFile.C Progetto: HeyJJ/ball
	bool INIFile::setContent(const list<String>& lines)
		
	{
		list<String>::const_iterator it = lines.begin();
		for (; it != lines.end(); ++it)
		{
			if (!appendLine(*it)) return false;
		}

		return true;
	}
Esempio n. 12
0
/*------------------------------------------------------------------------*/
BOOL HistoryManager::appendLines(char **lines, int nbrlines)
{
    BOOL bOK = TRUE;
    int i = 0;

    for (i = 0; i < nbrlines; i++)
    {
        if ((lines[i] == NULL) || (!appendLine(lines[i])))
            bOK = FALSE;
    }
    return bOK;
}
Esempio n. 13
0
File: INIFile.C Progetto: HeyJJ/ball
	bool INIFile::insertValue(const String& section_name, const String& key, const String& value)
	{
		// does section exists?
		if (!section_index_.has(section_name) || hasEntry(section_name, key))
		{
			return false;
		}

		String new_line(key + "=" + value);
		appendLine(section_name, new_line);

		return true;
	}
Esempio n. 14
0
void ProtocolView::processOutput()
{
    int pos;
    while ( (pos = buf.find('\n')) != -1)
	{
	    QString line = buf.left(pos);
	    if (!line.isEmpty())
                {
		    appendLine(line);
                    emit receivedLine(line);
                }
	    buf = buf.right(buf.length()-pos-1);
	}
}
Esempio n. 15
0
bool PrefsFile::priv_newPrefEntry(const QString &prefId, const QString &val) {
    if (filePath == NULL)
        return false;

    QFileInfo checkFile(filePath);
    if (!checkFile.exists()) {
        return false;
    } else {
        QFile f(filePath);
        QString appendLine(prefId + " " + val);
        if (f.open( QIODevice::Append )) {
            QTextStream wr(&f);
            wr << "\n" << appendLine;
            return true;
        }
    }
}
Esempio n. 16
0
/*------------------------------------------------------------------------*/
BOOL HistoryManager::loadFromFile(char *filename)
{

    if (filename)
    {
        char *commentbeginsession = NULL;

        std::string name;
        name.assign(filename);

        if (my_file.loadFromFile(name) == HISTORY_TRUNCATED)
        {
            bTruncated = TRUE;
        }

        CommandsList.clear();
        CommandsList = my_file.getHistory();

        if (CommandsList.size() > 0)
        {
            char *firstLine = getFirstLine();

            if (firstLine)
            {
                if (!isBeginningSessionLine(firstLine))
                {
                    fixHistorySession();
                }
                FREE(firstLine);
                firstLine = NULL;
            }
        }

        /* add date & time @ begin session */
        commentbeginsession = getCommentDateSession(FALSE);
        appendLine(commentbeginsession);
        FREE(commentbeginsession);
        commentbeginsession = NULL;

        CommandHistoryLoadFromFile();

        return TRUE;
    }
    return FALSE;
}
Esempio n. 17
0
File: INIFile.C Progetto: HeyJJ/ball
	bool INIFile::insertLine(LineIterator line_it, const String& line)
	{
		if (!isValid(line_it))
		{
      Log.error() << "In INIFile " << filename_ << " , error while inserting line: "
                  << line << " . Illegal iterator!" << endl;			
			return false;
		}

		if (line_it.isSectionLastLine())
    {
			return appendLine(line_it.getSection()->getName(), line);
		}

		Section& section(*line_it.getSection());

		// key?
    if (line.hasSubstring("=", 1))
    {
			String key(line.before("="));
			key.trim();

			if (section.key_map_.has(key) && check_duplicate_keys_)
			{

        Log.error() << "In INIFile " << filename_ << " , error while appending line: "
                    << line << " . Key '" << key << "' already exists in section." << endl;
				return false;
			}

			line_it.getSectionNextLine();

			section.key_map_[key] = section.lines_.insert(line_it.position_, line);
			return true;
		}

		line_it.getSectionNextLine();
		section.lines_.insert(line_it.position_, line);
		return true;
	}
Esempio n. 18
0
/*------------------------------------------------------------------------*/
BOOL HistoryManager::loadFromFile(char* _pstFilename)
{
    if (_pstFilename)
    {
        char* pstCommentBeginSession = NULL;
        if (m_HF.loadFromFile(_pstFilename) == HISTORY_TRUNCATED)
        {
            m_bTruncated = TRUE;
        }

        m_Commands.clear();
        m_Commands = m_HF.getHistory();

        if (m_Commands.size() > 0)
        {
            char* pstFirstLine = getFirstLine();
            if (pstFirstLine)
            {
                if (!isBeginningSessionLine(pstFirstLine))
                {
                    fixHistorySession();
                }
                FREE(pstFirstLine);
                pstFirstLine = NULL;
            }
        }

        /* add date & time @ begin session */
        pstCommentBeginSession = getCommentDateSession(FALSE);
        appendLine(pstCommentBeginSession);
        FREE(pstCommentBeginSession);
        pstCommentBeginSession = NULL;

        CommandHistoryLoadFromFile();

        return TRUE;
    }
    return FALSE;
}
Esempio n. 19
0
void DisassemblerLines::appendSourceLine(const QString &fileName, uint lineNumber)
{

    if (fileName.isEmpty() || lineNumber == 0)
        return;
    lineNumber--; // Fix 1..n range.
    SourceFileCache *cache = sourceFileCache();
    if (fileName != cache->fileName) {
        cache->fileName = fileName;
        cache->lines.clear();
        QFile file(fileName);
        if (file.open(QIODevice::ReadOnly)) {
            QTextStream ts(&file);
            cache->lines = ts.readAll().split(QLatin1Char('\n'));
        }
    }
    if (lineNumber >= uint(cache->lines.size()))
        return;
    DisassemblerLine dl;
    dl.lineNumber = lineNumber;
    dl.data = cache->lines.at(lineNumber);
    appendLine(dl);
}
Esempio n. 20
0
File: INIFile.C Progetto: HeyJJ/ball
	bool INIFile::read()
	{
		// destroy all datastructures - we make a new start
		// we only keep the filename...
		clear();

		// If the filename is empty, there's no point in opening it...
		if (filename_ == "")
		{
			return false;
		}

		// try to open the file
		ifstream infile(filename_.c_str());

		// if we couldn't open the file: abort
		if (!infile)
		{
			return false;
		}

		list<Section>::iterator	section_it(sections_.begin());

		// read all lines from the file
		std::vector<char> buffer(MAX_LINE_LENGTH);
		while (infile.getline(&(buffer[0]), MAX_LINE_LENGTH))
		{
			// remove leading blanks
			String line(&(buffer[0]));
			line.trimLeft();

			// check for comment lines or empty line
			if (line.empty()     || (line[0] == '!') ||
			   (line[0] == ';')  || (line[0] == '#'))
			{
				section_it->lines_.push_back(&(buffer[0]));
				continue;
			}

			// check for start of section
			if (line[0] == '[')
			{	
				if (!appendSection(line))
				{
					return false;
				}

				section_it++;
				
				continue;
			}
			
			// this is neither a comment line nor a section start
			// line still has to be added
			if (!appendLine("", line))
			{
				return false;
			}
		}
		
		// close the file
		infile.close();

		// done.
		valid_ = true;
		return true;
	}
Esempio n. 21
0
void KviIrcView::mouseReleaseEvent(QMouseEvent *e)
{
	if(m_pSelectionInitLine)
	{
		killTimer(m_iSelectTimer);
		m_iSelectTimer = 0;

		KviIrcViewLine *tempLine=getVisibleLineAt(e->pos().y());
		if(tempLine)
		{
			m_pSelectionEndLine = tempLine;
			int iTmp=getVisibleCharIndexAt(m_pSelectionEndLine, e->pos().x(), e->pos().y());
			if(iTmp > -1)
				m_iSelectionEndCharIndex = iTmp;
		}

		//check if selection is bottom to top or viceversa
		KviIrcViewLine *init, *end;
		int initChar, endChar;
		if(m_pSelectionInitLine->uIndex == m_pSelectionEndLine->uIndex)
		{
			init=m_pSelectionInitLine;
			end=m_pSelectionEndLine;
			if(m_iSelectionInitCharIndex<=m_iSelectionEndCharIndex)
			{
				//one line ltor selection
				initChar=m_iSelectionInitCharIndex;
				endChar=m_iSelectionEndCharIndex;
			} else {
				//one line rtol selection
				initChar=m_iSelectionEndCharIndex;
				endChar=m_iSelectionInitCharIndex;
			}
		} else if(m_pSelectionInitLine->uIndex < m_pSelectionEndLine->uIndex)
		{
			//multi line uptobottom selection
			init=m_pSelectionInitLine;
			end=m_pSelectionEndLine;
			initChar=m_iSelectionInitCharIndex;
			endChar=m_iSelectionEndCharIndex;
		} else {
			//multi line bottomtotop selection
			end=m_pSelectionInitLine;
			init=m_pSelectionEndLine;
			initChar=m_iSelectionEndCharIndex;
			endChar=m_iSelectionInitCharIndex;
		}

		tempLine = init;
		QString szSelectionText;
		while(tempLine)
		{
			if(KVI_OPTION_BOOL(KviOption_boolRequireControlToCopy) && !m_bCtrlPressed)
				break;
			if(tempLine->uIndex == init->uIndex)
			{
				if(tempLine->uIndex == end->uIndex)
				{
					//selection starts and ends in this line
					if(m_bShiftPressed)
					{
						bool bStarted=false;
						KviIrcViewLineChunk *pC;
						for(unsigned int i=0;i<tempLine->uChunkCount; i++)
						{
							pC = &tempLine->pChunks[i];
							if(bStarted)
							{
								if(endChar >= (pC->iTextStart + pC->iTextLen))
								{
									//the entire chunk is included
									addControlCharacter(pC, szSelectionText);
									szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen));
								} else {
									//ends in this chunk
									addControlCharacter(pC, szSelectionText);
									szSelectionText.append(tempLine->szText.mid(pC->iTextStart, endChar-pC->iTextStart));
									break;
								}
							} else {
								if(initChar <= (pC->iTextStart + pC->iTextLen))
								{
									//starts in this chunk
									addControlCharacter(pC, szSelectionText);
									if((endChar-initChar) > pC->iTextLen)
									{
										//don't end in this chunk
										szSelectionText.append(tempLine->szText.mid(initChar, pC->iTextLen-(initChar-pC->iTextStart)));
										bStarted=true;
									} else {
										//ends in this chunk
										szSelectionText.append(tempLine->szText.mid(initChar, endChar-initChar));
										break;
									}
								}
							}
						}
					} else {
						szSelectionText.append(tempLine->szText.mid(initChar, endChar-initChar));
					}
					break;
				} else {
					// the first line of a multi line selection
					if(m_bShiftPressed)
					{
						bool bStarted=false;
						KviIrcViewLineChunk *pC;
						for(unsigned int i=0;i<tempLine->uChunkCount; i++)
						{
							pC = &tempLine->pChunks[i];
							if(bStarted)
							{
								//the entire chunk is included
								addControlCharacter(pC, szSelectionText);
								szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen));
							} else {
								if(initChar <= (pC->iTextStart + pC->iTextLen))
								{
									//starts in this chunk
									addControlCharacter(pC, szSelectionText);
									szSelectionText.append(tempLine->szText.mid(initChar, pC->iTextLen-(initChar-pC->iTextStart)));
									bStarted=true;
								}
							}
						}
					} else {
						szSelectionText.append(tempLine->szText.mid(initChar));
					}
					szSelectionText.append("\n");
				}
			} else {
				if(tempLine->uIndex == end->uIndex)
				{
					// the last line of a multi line selection
					if(m_bShiftPressed)
					{
						KviIrcViewLineChunk *pC;
						for(unsigned int i=0;i<tempLine->uChunkCount; i++)
						{
							pC = &tempLine->pChunks[i];
							if(endChar >= (pC->iTextStart + pC->iTextLen))
							{
								//the entire chunk is included
								addControlCharacter(pC, szSelectionText);
								szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen));
							} else {
								//ends in this chunk
								addControlCharacter(pC, szSelectionText);
								szSelectionText.append(tempLine->szText.mid(pC->iTextStart, endChar-pC->iTextStart));
								break;
							}
						}
					} else {
						szSelectionText.append(tempLine->szText.left(endChar));
					}
					break;
				} else {
					//a middle line of a multi line selection
					if(m_bShiftPressed)
					{
						KviIrcViewLineChunk *pC;
						for(unsigned int i=0;i<tempLine->uChunkCount; i++)
						{
							pC = &tempLine->pChunks[i];
							//the entire chunk is included
							addControlCharacter(pC, szSelectionText);
							szSelectionText.append(tempLine->szText.mid(pC->iTextStart, pC->iTextLen));
						}
					} else {
						szSelectionText.append(tempLine->szText);
					}
					szSelectionText.append("\n");
				}
			}
			tempLine = tempLine->pNext;
		}

		QClipboard * c = QApplication::clipboard();
		if(c && !szSelectionText.isEmpty())
		{
			// copy to both!
			c->setText(szSelectionText,QClipboard::Clipboard);
			if(c->supportsSelection())
				c->setText(szSelectionText,QClipboard::Selection);
		}
		m_pSelectionInitLine = 0;
		m_pSelectionEndLine = 0;
		m_iSelectionInitCharIndex=0;
		m_iSelectionEndCharIndex=0;
	}

	if(m_bMouseIsDown)
	{
		m_bMouseIsDown = false;
		m_bShiftPressed = false;
		m_bCtrlPressed = false;
		// Insert the lines blocked while selecting
		while(KviIrcViewLine * l = m_pMessagesStoppedWhileSelecting->first())
		{
			m_pMessagesStoppedWhileSelecting->removeFirst();
			appendLine(l,false);
		}
		repaint();
	}
}
Esempio n. 22
0
void Console::returnKeyPrompt() {
    // Clears the prompt buffer thing and appends to command history
    appendLine(prompt);
    prompt="";
}
Esempio n. 23
0
void Console::appendBlankLine() {
    std::string blank = std::string(getWidth(),' ');
    appendLine(blank);
}
void ConsoleModel::handleProcessError(QProcess::ProcessError error)
{
    Q_UNUSED(error);
    emit processExited(-88888); // if error, then use some error exit code
    appendLine(tr("** error"));
}
Esempio n. 25
0
/** print row in PPM format to file stream */
static
void printRow(
   SCIP*                 scip,               /**< SCIP data structure */
   FILE*                 file,               /**< output file (or NULL for standard output) */
   SCIP_READERDATA*      readerdata,         /**< information for reader */
   SCIP_VAR**            vars,               /**< array of constraint variables */
   SCIP_Real*            vals,               /**< array of constraint values */
   int                   nvars,              /**< number of constraint variables */
   int                   ntotalvars,         /**< number of variables */
   SCIP_Real             maxcoef             /**< maximal coefficient */
   )
{
   int v;
   int i;
   int j;

   int red;
   int green;
   int blue;

   char linebuffer[PPM_MAX_LINELEN];
   int linecnt;
   int varindex;
   int actvarindex;
   int maxvarindex;
   int indexvar = 0;

   char buffer[PPM_MAX_LINELEN];
   const unsigned char max = (unsigned char)255;
   char white[4];

   assert( scip != NULL );
   assert (nvars > 0);
   assert (readerdata != NULL);

   i = 0;
   varindex = -1;
   maxvarindex = 0;

   (void) SCIPsnprintf(white, 4, "%c%c%c", max, max, max);
   clearLine(linebuffer, &linecnt);

   /* calculate maximum index of the variables in this constraint */
   for( v = 0; v < nvars; ++v )
   {
      if(maxvarindex < SCIPvarGetProbindex(vars[v]))
         maxvarindex = SCIPvarGetProbindex(vars[v]);
   }

   assert(maxvarindex < ntotalvars);

   /* print coefficients */
   for(v = 0; v < nvars; ++v)
   {
      actvarindex = maxvarindex;
      for(j = 0; j < nvars; ++j)
      {
         if( varindex < SCIPvarGetProbindex(vars[j]) && SCIPvarGetProbindex(vars[j]) <= actvarindex )
         {
            actvarindex = SCIPvarGetProbindex(vars[j]);
            indexvar = j;
         }
      }
      varindex = actvarindex;

      /* fill in white points since these variables indices do not exits in this constraint */
      for( ; i < varindex; ++i )
      {
         if(readerdata->rgb_ascii)
            appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
         else
            appendLine(scip, file, readerdata, linebuffer, &linecnt, " 255 255 255 ");
      }


      calcColorValue(scip, readerdata, REALABS(vals[indexvar]), &red, &green, &blue, maxcoef);
      if(readerdata->rgb_ascii)
      {
         if(red == 35 || red == 0) red++;
         if(green==35 || green == 0) green++;
         if(blue==35 || blue == 0) blue++;
         (void) SCIPsnprintf(buffer, PPM_MAX_LINELEN, "%c%c%c", (unsigned char)red, (unsigned char)green, (unsigned char)blue);
      }
      else
         (void) SCIPsnprintf(buffer, PPM_MAX_LINELEN, " %d %d %d ", red, green, blue);

      appendLine(scip, file, readerdata, linebuffer, &linecnt, buffer);
      i++;
   }

   /* fill in white points since these variables indices do not exits in this constraint */
   for( ; i < ntotalvars; ++i )
   {
      if(readerdata->rgb_ascii)
         appendLine(scip, file, readerdata, linebuffer, &linecnt, white);
      else
         appendLine(scip, file, readerdata, linebuffer, &linecnt, " 255 255 255 ");
   }

   endLine(scip, file, readerdata, linebuffer, &linecnt);
}
Esempio n. 26
0
void DisassemblerLines::appendComment(const QString &line)
{
    DisassemblerLine dl;
    dl.data = line;
    appendLine(dl);
}