/**
\brief      match_trace_id
\Access    public 
\param  WTelemeterGlyph * item
\param  int step
\param  const WPointF & p
\retval     void
\remark     
*/
void TelemeterHelper::match_trace_id( WTelemeterGlyph* item, int step, const WPointF& p )
{
	WTelemeterGlyph::data_type& d = *(item->data());
	
	WPointF pOut;
	if (step == 0)
	{
		d.m_startTraceId = search_for_id(p, pOut);
		if (d.m_startTraceId != -1)
		{
			d.m_line.setP1(pOut);
		}
	}
	else
	{
		d.m_endTraceId = search_for_id(p, pOut);
		if (d.m_startTraceId == d.m_endTraceId) // 保证不能同一个目标进行相连,同一目标相连,无意义 
		{
			d.m_endTraceId = -1;
		}
	
		if (d.m_endTraceId != -1)
		{
			d.m_line.setP2(pOut);
		}
	}
}
Exemple #2
0
static char *command_generator(const char *text, int state)
{
	static int list_index, len;
	static int entries_idx;
	unsigned name_size;
	char *name, *arg;
	char *ret;

	/* If this is a new word to complete, initialize now.  This includes
	   saving the length of TEXT for efficiency, and initializing the index
	   variable to 0. */
	if (!state) {
		list_index = 0;
		entries_idx = 0;
		len = strlen(text);
	}

	/* Return the next name which partially matches from the command list. */
	while ((name = commands[list_index].name)) {
		name_size = commands[list_index].name_size;
		arg = commands[list_index].arg;
		list_index++;

		if (cmd_start > name_size) {
			/* check for user or ID options */
			if (rl_line_buffer != NULL &&
			    c_strncasecmp(rl_line_buffer, name, name_size) == 0
			    &&
			    /* make sure only one argument is appended */
			    rl_line_buffer[name_size] != 0 &&
			    strchr(&rl_line_buffer[name_size + 1],
				   ' ') == NULL) {

				if (arg != NULL) {
					ret = NULL;
					if (strcmp(arg, "[NAME]") == 0)
						ret =
						    search_for_user(entries_idx,
								    text, len);
					else if (strcmp(arg, "[ID]") == 0)
						ret =
						    search_for_id(entries_idx,
								  text, len);
					else if (strcmp(arg, "[IP]") == 0)
						ret =
						    search_for_ip(entries_idx,
								  text, len);
					if (ret != NULL) {
						entries_idx++;
					}
					list_index--;	/* restart at the same cmd */
					return ret;
				}
			}

			continue;
		}

		if (cmd_start > 0 && name[cmd_start - 1] != ' ')
			continue;

		if (rl_line_buffer != NULL
		    && c_strncasecmp(rl_line_buffer, name, cmd_start) != 0)
			continue;

		name += cmd_start;
		if (c_strncasecmp(name, text, len) == 0) {
			return (strdup(name));
		}
	}

	return NULL;
}
void legalConnectionInput(int& IDpers, int& IDcomp, QSqlDatabase& db)
{
    bool error = false;
    IDpers = 0;
    IDcomp = 0;
    vector<Person> VECTpers;
    cout << "Inputing Person" << endl;
    QString person = getPeopleQueryString();
    QSqlQuery query = getQuery(db, person);
    int NUMpeople = printPersonTableINT(query, VECTpers);
    if(NUMpeople < 1)
        error = true;
    if(!error)
    {
        if(NUMpeople ==1)
        {
            cout << "1 person found and set" << endl;
            IDpers = NUMpeople -1;
            error = false;
        }
        else
        {
            cout << NUMpeople << " people found" << endl;
            cout << "Enter the row number of the correct person:";
            IDpers = inputInt();
            if(IDpers < 1)
            {
                cout << "Number not on list. Ending Input." << endl;
                error = true;
            }
            else
            {
                error = false;
                IDpers--;
                cout << "Person set." << endl;
            }
        } // else for if(NUMpeople ==1) END
        if(!error)
        {
            error = false; // Justin Case
            vector<Computer> VECTcomp;
            cout << "Inputing Computer" << endl;
            QString computer = getComputerQueryString();
            QSqlQuery query2 = getQuery(db, computer);
            int NUMcomputers = printComputerTableINT(query2, VECTcomp);
            if(NUMpeople < 1)
                error = true;
            if(!error)
            {
                if(NUMcomputers ==1)
                {
                    cout << "1 computer found and set" << endl;
                    IDcomp = NUMcomputers -1;
                    error = false;
                }
                else
                {
                    cout << NUMcomputers << " computers found" << endl;
                    cout << "Enter the row number of the correct computer:";
                    IDcomp = inputInt();
                    if(IDcomp < 1)
                    {
                        cout << "Number not on list. Ending Input." << endl;
                        error = true;
                    }
                    else
                    {
                        error = false;
                        IDcomp--;
                        cout << "Computer set." << endl;
                    }

                } // else for if(NUMcomputers ==1) END
                if(!error)
                    {
                        IDpers = search_for_id(db, VECTpers.at(IDpers));
                        IDcomp = search_for_id(db, VECTcomp.at(IDcomp));
                    } // if(!error) #3 END
            }
            else
                cout << "No computer found. Ending Input." << endl;
        } // if(!error) #2 END
    } // if(!error) #1 END
    else
        cout << "No person found. Ending Input." << endl;


}