コード例 #1
0
void CDirectoryTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	UINT uFlags;
	HTREEITEM hItem = HitTest(point, &uFlags);
	HTREEITEM tItem = GetFirstVisibleItem();

	if((hItem) && (uFlags & TVHT_ONITEMSTATEICON))
	{
		CheckChanged(hItem, !GetCheck(hItem));

		if(nFlags & MK_CONTROL)
		{
			Expand(hItem, TVE_TOGGLE);
			HTREEITEM hChild;
			hChild = GetChildItem(hItem);
			while (hChild != NULL)
			{
				MarkChilds(hChild,!GetCheck(hItem));
				hChild = GetNextSiblingItem(hChild);
			}
			Expand(hItem, TVE_TOGGLE);
		}
	}
	SelectSetFirstVisible(tItem);
	CTreeCtrl::OnLButtonDown(nFlags, point);
}
コード例 #2
0
void CDirectoryTreeCtrl::MarkChilds(HTREEITEM hChild,bool mark) { 
	CheckChanged(hChild, mark); 
	SetCheck(hChild,mark);  
	Expand(hChild, TVE_TOGGLE); // VQB - make sure tree has entries 
	HTREEITEM hChild2; 
	hChild2 = GetChildItem(hChild); 
	while( hChild2 != NULL) 
	{ 
		MarkChilds(hChild2,mark); 
		hChild2 = GetNextSiblingItem( hChild2 ); 
	} 
	Expand(hChild, TVE_TOGGLE); // VQB - restore tree to initial disposition 
}
コード例 #3
0
void CDirectoryTreeCtrl::MarkChilds(HTREEITEM hChild, bool mark)
{
	CheckChanged(hChild, mark);
	SetCheck(hChild,mark);
	Expand(hChild, TVE_TOGGLE);
	HTREEITEM hChild2;
	hChild2 = GetChildItem(hChild);

	while( hChild2 != NULL)
	{
		MarkChilds(hChild2,mark);
		hChild2 = GetNextSiblingItem( hChild2 );
	}

	Expand(hChild, TVE_TOGGLE);
}
コード例 #4
0
void CDirectoryTreeCtrl::OnTvnKeydown(NMHDR *pNMHDR, LRESULT *pResult)
{ 
	LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pNMHDR);

	switch(pTVKeyDown->wVKey)
	{
		case VK_SPACE:
		case VK_RETURN:
		{
			HTREEITEM hItem = GetSelectedItem();

			if(hItem)
			{		
				HTREEITEM tItem = GetFirstVisibleItem();

				CheckChanged(hItem, !GetCheck(hItem));
								
				if(m_bCtrlPressed)
				{
					Expand(hItem, TVE_TOGGLE);
					HTREEITEM hChild;
					hChild = GetChildItem(hItem);

					while(hChild != NULL)
					{ 
						MarkChilds(hChild,!GetCheck(hItem));
						hChild = GetNextSiblingItem( hChild );
					}

					SetCheck(hItem, !GetCheck(hItem));
					Expand(hItem, TVE_TOGGLE);
				}
		 
				SelectSetFirstVisible(tItem);
			}

			break;
		}

		default:
			break;
	}

	*pResult = 0;
}
コード例 #5
0
ファイル: dlgClasses.cpp プロジェクト: kleopatra999/pgadmin3
void pgFrame::OnRecent(wxCommandEvent &event)
{
	int fileNo = event.GetId() - MNU_RECENT;
	wxString newPath = settings->Read(recentKey + wxString::Format(wxT("/%d"), fileNo), wxT(""));

	if (!newPath.IsNull())
	{
		if (CheckChanged(true))
			return;

		lastPath = newPath;
		int dirsep;
		dirsep = lastPath.Find(wxFILE_SEP_PATH, true);
		lastDir = lastPath.Mid(0, dirsep);
		lastFilename = lastPath.Mid(dirsep + 1);
		OpenLastFile();
	}
}
コード例 #6
0
void frmMainConfig::OnOpen(wxCommandEvent &event)
{
	if (CheckChanged(true))
		return;

#ifdef __WXMSW__
	wxFileDialog dlg(this, _("Open configuration file"), lastDir, wxT(""),
	                 _("Configuration files (*.conf)|*.conf|All files (*.*)|*.*"), wxFD_OPEN);
#else
	wxFileDialog dlg(this, _("Open configuration file"), lastDir, wxT(""),
	                 _("Configuration files (*.conf)|*.conf|All files (*)|*"), wxFD_OPEN);
#endif
	if (dlg.ShowModal() == wxID_OK)
	{
		Init();

		lastFilename = dlg.GetFilename();
		lastDir = dlg.GetDirectory();
		lastPath = dlg.GetPath();
		OpenLastFile();
		UpdateRecentFiles();
	}
}
コード例 #7
0
void CDirectoryTreeCtrl::ShareSubDirTree(HTREEITEM hItem, BOOL bRecurse)
{
	CWaitCursor curWait;
	SetRedraw(FALSE);

	HTREEITEM hItemVisibleItem = GetFirstVisibleItem();
	CheckChanged(hItem, !GetCheck(hItem));
	if (bRecurse)
	{
		Expand(hItem, TVE_TOGGLE);
		HTREEITEM hChild = GetChildItem(hItem);
		while (hChild != NULL)
		{
			MarkChilds(hChild, !GetCheck(hItem));
			hChild = GetNextSiblingItem(hChild);
		}
		Expand(hItem, TVE_TOGGLE);
	}
	if (hItemVisibleItem)
		SelectSetFirstVisible(hItemVisibleItem);

	SetRedraw(TRUE);
	Invalidate();
}
コード例 #8
0
int vtkKMeansClustering::RequestData(vtkInformation *vtkNotUsed(request),
                                     vtkInformationVector **inputVector,
                                     vtkInformationVector *outputVector)
{
    // Get the info objects
    vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
    vtkInformation *outInfoColoredPoints = outputVector->GetInformationObject(0);
    vtkInformation *outInfoClusterCenters = outputVector->GetInformationObject(1);

    // Get the input and ouptut
    vtkPolyData *input = vtkPolyData::SafeDownCast(
                             inInfo->Get(vtkDataObject::DATA_OBJECT()));

    this->Points->ShallowCopy(input->GetPoints());

    vtkPolyData *outputColoredPoints = vtkPolyData::SafeDownCast(
                                           outInfoColoredPoints->Get(vtkDataObject::DATA_OBJECT()));

    vtkPolyData *outputClusterCenters = vtkPolyData::SafeDownCast(
                                            outInfoClusterCenters->Get(vtkDataObject::DATA_OBJECT()));

    // Create a KDTree of the points
    this->KDTree->SetDataSet(input);
    this->KDTree->BuildLocator();

    // Seed a random number generator
    if(this->Random)
    {
        vtkMath::RandomSeed(time(NULL));
    }
    else
    {
        vtkMath::RandomSeed(0);
    }

    // Initialize the structure in which to store the cluster centers
    vtkSmartPointer<vtkPoints> clusterCenters =
        vtkSmartPointer<vtkPoints>::New();
    clusterCenters->SetNumberOfPoints(this->K);

    if(this->InitMethod == RANDOM)
    {
        RandomInit(clusterCenters);
    }
    else if(this->InitMethod == KMEANSPP) // http://en.wikipedia.org/wiki/K-means%2B%2B
    {
        MeansPPInit(clusterCenters);
    }
    else
    {
        std::cerr << "An invalid initialization method has been specified!" << std::endl;
        exit(-1);
    }

    /*
    // Output cluster centers
    std::cout << "Initial cluster centers: " << std::endl;
    for(unsigned int i = 0; i < clusterCenters->GetNumberOfPoints(); i++)
    {
    double p[3];
    clusterCenters->GetPoint(i, p);
    std::cout << "Cluster center " << i << " : " << p[0] << " " << p[1] << " " << p[2] << std::endl;
    }
    */

    // We must store the labels at the previous iteration to determine whether any labels changed at each iteration.
    std::vector<unsigned int> oldLabels(input->GetNumberOfPoints(), 0); // initialize to all zeros

    // Initialize the labels array
    this->Labels.resize(input->GetNumberOfPoints());

    // The current iteration number
    int iter = 0;

    // Track whether any labels changed in the last iteration
    bool changed = true;
    do
    {
        AssignLabels(input->GetPoints(), clusterCenters);

        EstimateClusterCenters(input->GetPoints(), clusterCenters);

        changed = CheckChanged(this->Labels, oldLabels);

        // Save the old labels
        oldLabels = this->Labels;
        iter++;
    } while(changed);
    //}while(iter < 100); // You could use this stopping criteria to make kmeans run for a specified number of iterations

    std::cout << "KMeans finished in " << iter << " iterations." << std::endl;

    // Create the color map
    this->ColorLookupTable->SetTableRange(0, this->K);
    this->ColorLookupTable->Build();

    CreateCentersPolyData(clusterCenters, outputClusterCenters);
    CreateOutputPointsPolyData(outputColoredPoints);

    return 1;
}