コード例 #1
0
int main(void)
{
   char numString[MAX_STRING]; 
   int numArray[MAX_STRING];
   int graph[MAX_MATRIX][MAX_MATRIX];
   int limit, i;
   char N[10];

   /* clear the graph */
   clearGraph(graph);

   while (fgets(N, 10, stdin) != NULL)
   {
      int n = atoi(N);
      if (n == 0)
         break;

      for (i = 0; i < n; i++)
      {
         getNumString(numString);
         limit = split(numString, numArray);
         if (numArray[0] == 0)
            break;
         createGraph(numArray, graph);
      }

      /* find out how many cirtical nodes the graph have */
      findCriticalNode(graph, limit);
      clearGraph(graph);
   }

   return 0;
}
コード例 #2
0
ファイル: ZoneGraph.cpp プロジェクト: animatedb/oovaide
void ZoneGraph::updateGraph()
    {
    if(mDiagramChanged & ZDC_Nodes)
        {
        clearGraph();
        for(auto const &type : mModel->mTypes)
            {
            ModelClassifier const *cls = ModelClassifier::getClass(type.get());
            if(cls && cls->getModule() != nullptr)
                {
                if(!isFiltered(cls->getModule(), mFilteredModules))
                    {
                    mNodes.push_back(ZoneNode(type.get()));
                    }
                }
            }
        mDrawOptions.initDrawOptions(mNodes.size() < 500);
        sortNodes();
        }
    if(mDiagramChanged & ZDC_Connections)
        {
        updateConnections();
        }
    mDiagramChanged = ZDC_None;
    }
コード例 #3
0
ファイル: Menu.cpp プロジェクト: pluralism/calproject
void Menu::readDataFile()
{
    clearGraph();
    string answer;
    
    cout << "[*] Enter the filename please: " << endl;
    getline(cin, answer);
    
    
    while(answer.empty())
    {
        cerr << "[!] Invalid option! Try again please: " << endl;
        getline(cin, answer);
    }
    
    desiredSkills = utils.getDesiredSkills(answer.c_str());
    //If there are no desired skills we can't calculate the best team
    if(!desiredSkills.empty())
        addPeopleToGraph(answer.c_str(), desiredSkills);
    else
    {
        cerr << "[!] No desired skills were found in the file " << answer << endl << endl;
        //Go back to the main menu
        performUserAction();
    }
}
コード例 #4
0
ファイル: LogGraph.cpp プロジェクト: tlogger/TMon
CLogGraph::CLogGraph()
{
	m_bCreated = false;
//	m_hQue  = 0;
	m_bNav = false;
	m_tLastNav = time(NULL);
	m_nScaleIndex = -1;
	m_nLastCursorPos = -1;
	m_aTmp = NULL;

	m_bDragSel = false;
	m_bLdown = false;

	m_tStart = time(NULL);
	m_tEnd = time(NULL);
	
	m_nHeaderHeight = 40;
	m_nScaleWidth  = 34;
	m_bAutoZoom = false;

	setZoom(1.0);
	setGrid(20, RGB(70, 70, 70));
	setHeader("Segoe UI", 13, RGB(200, 200, 200), RGB(120, 120, 120));
	setScale("Segoe UI", 13, RGB(200, 200, 0), RGB(100, 100, 100));
	setGraph("Segoe UI", 13, RGB(200, 200, 200), RGB(0, 0, 0));
	setScaleIndex(-1, -1);

	clearGraph();

	m_bLoad = false;
//	uMSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG");
}
コード例 #5
0
ファイル: LogGraph.cpp プロジェクト: tlogger/TMon
CLogGraph::~CLogGraph()
{
	if (m_aTmp)
		delete m_aTmp;

	clearGraph();

	m_fontHeader.DeleteObject();
	m_fontScale.DeleteObject();
	m_fontGraph.DeleteObject();
}
コード例 #6
0
ファイル: Menu.cpp プロジェクト: pluralism/calproject
void Menu::checkOrClear(string line, bool &adding)
{
    if(line == "n" || line == "N")
        adding = false;
    
    if(line == "q" || line == "Q")
    {
        clearGraph();
        performUserAction();
    }

}
コード例 #7
0
	void Interpolator::generatePolyCurve(float constant,float linear,float quadratic,float cubic,float startX,float endX,unsigned int nbSamples)
	{
		// First clear any previous entry
		clearGraph();

		for (size_t i = 0; i < nbSamples; ++i)
		{
			float x = startX + i * (endX - startX) / (nbSamples - 1);
			float x2 = x * x;
			float x3 = x2 * x;
			addEntry(x,constant + x * linear + x2 * quadratic + x3 * cubic);
		}
	}
コード例 #8
0
ファイル: FreqDisplay.cpp プロジェクト: g4klx/uWSDR
CFreqDisplay::CFreqDisplay(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
wxPanel(parent, id, pos, size, style, name),
m_width(size.GetWidth()),
m_height(size.GetHeight()),
m_bitmap(NULL),
m_lastFrequency(),
m_lightColour(wxColour(0, 255, 255)),
m_mhzDigits(0)
{
	m_bitmap = new wxBitmap(m_width, m_height);

	// Flood the graph area with black to start with
	clearGraph();
}
コード例 #9
0
	void Interpolator::generateSinCurve(float period,float amplitudeMin,float amplitudeMax,float offsetX,float offsetY,float startX,unsigned int length,unsigned int nbSamples)
	{
		// First clear any previous entry
		clearGraph();

		const float PI = 3.1415926535897932384626433832795f;

		for (size_t i = 0; i < nbSamples; ++i)
		{
			float x = startX + i * period * length / (nbSamples - 1);
			float sin = std::sin((x + offsetX) * 2 * PI / period);
			addEntry(x,amplitudeMin * sin + offsetY,amplitudeMax * sin + offsetY);
		}
	}
コード例 #10
0
	void updateGraph(HWND hwnd) {

		HDC hdc = (HDC)GetDC(hwnd);
		
		clearGraph(hwnd, hdc);

		drawAxes(hwnd, hdc);

		drawGrid(hwnd, hdc);

		drawGraph(hwnd, hdc);
		
		ReleaseDC(hwnd, hdc);
		
	}
コード例 #11
0
ファイル: sg_editor.cpp プロジェクト: mottosso/feather
void SceneGraphEditor::updateGraph()
{
    int xpos = 50;
    int ypos = 50;

    clearGraph();

    std::vector<int> uids;

    // disabled selection as root for testing
    //feather::qml::command::get_selected_nodes(uids);
    uids.push_back(0);

    std::cout << uids.size() << " nodes are selected\n";

    std::for_each(uids.begin(),uids.end(),[](int& n){ std::cout << n << ","; });

    updateNode(nullptr,0,xpos,ypos);
    for(auto n : m_nodes) 
        updateLinks(n->uid());
}
コード例 #12
0
ファイル: Menu.cpp プロジェクト: pluralism/calproject
void Menu::showFileData()
{
    clearGraph();
    string answer;
    cout << "[*] Choose the name of the file: " << endl;
    getline(cin, answer);
    
    while(answer.empty())
    {
        cerr << "[*] Hey! You must provide some data. Try again please: " << endl;
        getline(cin, answer);
    }
    
    if(answer == "q" || answer == "Q")
        exit(EXIT_SUCCESS);
    else
    {
        utils.showFile(answer.c_str());
        checkSkillsFile(utils.getDesiredSkills(answer.c_str()), utils.getPeople(answer.c_str()),
                        "[!] The program can't evaluate that graph! The candidates don't conver all the skills that the company needs!");
    }
    performUserAction();
}
コード例 #13
0
ファイル: FreqDisplay.cpp プロジェクト: g4klx/uWSDR
void CFreqDisplay::setFrequency(const CFrequency& frequency)
{
	wxInt64 hz = frequency.get();

	// Only display to 10 Hz
	if ((m_lastFrequency.get() / 10LL) == (hz / 10LL))
		return;

	clearGraph();

	wxMemoryDC memoryDC;
	memoryDC.SelectObject(*m_bitmap);

	int mhzDigits = m_mhzDigits;
	if (mhzDigits == 0) {
		mhzDigits = 1;
		if (hz >= 10000000000LL)		// 10 GHz
			mhzDigits = 5;
		else if (hz >= 1000000000LL)		// 1000 MHz
			mhzDigits = 4;
		else if (hz >= 100000000LL)		// 100 MHz
			mhzDigits = 3;
		else if (hz >= 10000000LL)		// 10 MHz
			mhzDigits = 2;
	}

	const int bigThickness    = 5;
	const int littleThickness = 4;

	int bigHeight    = m_height - 2 * BORDER_SIZE;
	int littleHeight = 3 * bigHeight / 4;

	int bigWidth    = (m_width - 2 * BORDER_SIZE) / (mhzDigits + 5);
	int littleWidth = 3 * bigWidth / 4;

	int bigY    = BORDER_SIZE;
	int littleY = (bigHeight + BORDER_SIZE) - littleHeight;

	int x = BORDER_SIZE + (mhzDigits + 4) * bigWidth;

	wxInt64 rem = hz / 10LL;

	drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false);
	x   -= littleWidth;
	rem /= 10LL;

	drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, true);
	x   -= bigWidth;

	rem = hz / 1000000LL;

	for (int i = 0; i < mhzDigits; i++) {
		wxInt64 n = rem % 10LL;
		rem /= 10LL;

		if (rem != 0LL || (rem == 0LL && n != 0LL))
			drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, n, false);

		x -= bigWidth;
	}

	memoryDC.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);

	m_lastFrequency = frequency;
}
コード例 #14
0
ファイル: Menu.cpp プロジェクト: pluralism/calproject
void Menu::createGraphFile()
{
    vector<Person> people;
    vector<Connection> connections;
    vector<Skill> parsedSkills;
    
    //First of all we want to clear the previous data in the graph(by removing all the vertices)
    clearGraph();
    bool adding = true;
    string line;
    cout << "[*] Ok, first of all tell me the skills you're looking for(separated by a ',', 'n' to go to the next step): " << endl;
    
    while(adding)
    {
        getline(cin, line);
        while(line.empty())
        {
            cerr << "[!] You have to provide some data... Try again: " << endl;
            getline(cin, line);
        }
        
        checkOrClear(line, adding);
        if(!adding)
            break;
        
        //Only the last line will be parsed
        parsedSkills = utils.parseSkills(line);
    }
    adding = true;
    cout << "[*] Ok, let's add some people to the graph..." << endl;
    cout << "[*] Enter the information in the following way: personID,personName,listOfSkills(n/N to go the next step):" << endl;
    
    
    while(adding)
    {
        getline(cin, line);
        while(line.empty())
        {
            cerr << "[!] You have to provide some data... Try again: " << endl;
            getline(cin, line);
        }
        
        checkOrClear(line, adding);
        if(!adding)
            break;
        
        
        Person p = utils.extractPerson(line);
        if(p.getName() != "invalid") {
            personGraph.addVertex(p);
            people.push_back(p);
        }
        
        //Show the list of people that we have till now
        for(int i = 0; i < personGraph.getNumVertex(); i++)
            cout << personGraph.getVertexIndex(i)->getInfo() << endl;
        cout << endl;
    }
    
    
    //The next information is to create connections between them
    adding = true;
    cout << "[*] Ok, you added " << people.size() << " people to the graph!" << endl;
    cout << "[*] Let's build the connections between them now(firstPersonID,secondPersonID,communicationCost) ('n' to go to the next step): " << endl;
    
    while(adding)
    {
        getline(cin, line);
        while(line.empty())
        {
            cerr << "[!] You have to provide some data... Try again: " << endl;
            getline(cin, line);
        }
        
        checkOrClear(line, adding);
        if(!adding)
            break;
        
        
        //Build the connection in the graph
        Connection conn = utils.readConnection(line);
        connections.push_back(conn);
        
        Person src = findPersonById(conn.getSource(), people);
        Person dest = findPersonById(conn.getDest(), people);
        personGraph.addEdge(src, dest, conn.getCost());
    }
    
    
    adding = true;
    cout << "[*] Provide a valid filename so we can save the data: " << endl;
    getline(cin, line);
    while(line.empty())
    {
        cerr << "[!] You have to provide some data... Try again: " << endl;
        getline(cin, line);
    }
    
    
    //Before saving lets check the skills
    checkSkillsFile(parsedSkills, people, "[!] I'm sorry. The graph you're trying to save is invalid! Please try again!");
    if(utils.saveDataToFile(line.c_str(), people, connections, parsedSkills))
    {
        cout << "[*] The file was successfully saved as " << line << endl << endl;
        getchar();
        performUserAction();
    } else
    {
        cerr << "[!] The file could not be saved!" << endl << endl;
        getchar();
        performUserAction();
    }
}
コード例 #15
0
ファイル: sg_editor.cpp プロジェクト: mottosso/feather
SceneGraphEditor::~SceneGraphEditor()
{
    clearGraph();
}