// Test to see if the constraints are compatible enough to merge.
bool TabConstraint::CompatibleConstraints(TabConstraint_LIST* list1,
                                          TabConstraint_LIST* list2) {
  if (list1 == list2)
    return false;
  int y_min = -MAX_INT32;
  int y_max = MAX_INT32;
  if (textord_debug_tabfind > 3)
    tprintf("Testing constraint compatibility\n");
  GetConstraints(list1, &y_min, &y_max);
  GetConstraints(list2, &y_min, &y_max);
  if (textord_debug_tabfind > 3)
    tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
  return y_max >= y_min;
}
//-----------------------------------------------------------------------------
// Purpose: Handles left mouse button down events in the 2D view.
// Input  : Per CWnd::OnLButtonDown.
// Output : Returns true if the message was handled, false if not.
//-----------------------------------------------------------------------------
bool Cordon3D::OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint)
{
	Tool3D::OnLMouseDown2D(pView, nFlags, vPoint);

	Vector vecWorld;
	pView->ClientToWorld(vecWorld, vPoint);

	unsigned int uConstraints = GetConstraints( nFlags );

	if ( HitTest(pView, vPoint, true) )
	{
		StartTranslation( pView, vPoint, m_LastHitTestHandle );
	}
	else
	{
		// getvisiblepoint fills in any coord that's still set to COORD_NOTINIT:
		vecWorld[pView->axThird] = COORD_NOTINIT;
		m_pDocument->GetBestVisiblePoint(vecWorld);

		// snap starting position to grid
		if ( uConstraints & constrainSnap )
			m_pDocument->Snap(vecWorld,uConstraints);
		
		StartNew( pView, vPoint, vecWorld, Vector(0,0,0) );
	}

	return true;
}
void CXTPPropertyGridItemFlags::SetValue(CString strValue)
{
	int nValue = 0;
	strValue.MakeLower();

	CXTPPropertyGridItemConstraints* pConstraints = GetConstraints();
	for (int i = 0; i < pConstraints->GetCount(); i++)
	{
		if (HasFlag(strValue, pConstraints->GetAt(i)))
			nValue |= pConstraints->GetConstraintAt(i)->m_dwData;
	}

	SetFlags(nValue);
}
Exemple #4
0
void TableSettings::OnRemoveColumnClick(wxCommandEvent& event)
{
    Column *col = GetColumn( GetSelectedColumnName() );
    if( col ) {
		// delete associated keys
		SerializableList keys;
		GetConstraints( keys, col->GetName() );
		for(SerializableList::iterator it = keys.begin(); it != keys.end(); ++it ) {
			Constraint *key = (Constraint*) *it;
			m_lstKeys.DeleteObject( key );
			delete key;
		}
		// delete the column
        m_lstColumns.DeleteObject( col );
        delete col;
        UpdateView();
    }
}
// Set all the tops and bottoms as appropriate to a mean of the
// constrained range. Delete all the constraints and list.
void TabConstraint::ApplyConstraints(TabConstraint_LIST* constraints) {
  int y_min = -MAX_INT32;
  int y_max = MAX_INT32;
  GetConstraints(constraints, &y_min, &y_max);
  int y = (y_min + y_max) / 2;
  TabConstraint_IT it(constraints);
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    TabConstraint* constraint = it.data();
    TabVector* v = constraint->vector_;
    if (constraint->is_top_) {
      v->SetYEnd(y);
      v->set_top_constraints(NULL);
    } else {
      v->SetYStart(y);
      v->set_bottom_constraints(NULL);
    }
  }
  delete constraints;
}
//-----------------------------------------------------------------------------
// Purpose: Handles mouse move events in the 2D view.
// Input  : Per CWnd::OnMouseMove.
// Output : Returns true if the message was handled, false if not.
//-----------------------------------------------------------------------------
bool Cordon3D::OnMouseMove2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint) 
{
	vgui::HCursor hCursor = vgui::dc_arrow;

	Tool3D::OnMouseMove2D(pView, nFlags, vPoint) ;

	unsigned int uConstraints = GetConstraints( nFlags );
					    
	// Convert to world coords.
	Vector vecWorld;
	pView->ClientToWorld(vecWorld, vPoint);
	
	// Update status bar position display.
	//
	char szBuf[128];

	m_pDocument->Snap(vecWorld,uConstraints);

	sprintf(szBuf, " @%.0f, %.0f ", vecWorld[pView->axHorz], vecWorld[pView->axVert]);
	SetStatusText(SBI_COORDS, szBuf);
	
	if ( IsTranslating() )
	{
		// cursor is cross here
		Tool3D::UpdateTranslation( pView, vPoint, uConstraints );
		
		hCursor = vgui::dc_none;
	}
	else if ( HitTest(pView, vPoint, true) )
	{
		hCursor = UpdateCursor( pView, m_LastHitTestHandle, m_TranslateMode );
	}
	
	if ( hCursor != vgui::dc_none  )
		pView->SetCursor( hCursor );

	return true;
}
void CXTPPropertyGridItemFlags::OnConstraintsChanged()
{
	GetChilds()->Clear();

	CXTPPropertyGridItemConstraints* pConstraints = GetConstraints();

	int i;

	for (i = 0; i < pConstraints->GetCount(); i++)
	{
		AddChildItem(new CXTPPropertyGridItemFlag(pConstraints->GetAt(i), (int)pConstraints->GetConstraintAt(i)->m_dwData));
	}
	UpdateChilds();
	m_strDefaultValue = m_strValue = GetFlagsString();

	CXTPPropertyGridItems* pItems = GetChilds();
	for (i = 0; i < pItems->GetCount(); i++)
	{
		CXTPPropertyGridItemFlag* pItem = (CXTPPropertyGridItemFlag*)pItems->GetAt(i);
		pItem->SetDefaultValue(pItem->GetValue());
	}

}
CString CXTPPropertyGridItemFlags::GetFlagsString()
{
	CString str;

	CXTPPropertyGridItemConstraints* pConstraints = GetConstraints();
	int nValue = 0;

	for (int i = 0; i < pConstraints->GetCount(); i++)
	{
		CXTPPropertyGridItemConstraint* pConstraint = pConstraints->GetConstraintAt(i);

		if ((nValue & pConstraint->m_dwData) == pConstraint->m_dwData)
			continue;

		if ((m_nValue & pConstraint->m_dwData) == pConstraint->m_dwData)
		{
			str += (str.IsEmpty() ? _T("") : _T(";")) + pConstraint->m_strConstraint;
			nValue |= pConstraint->m_dwData;
		}
	}

	return  _T("[") + str + _T("]");
}
Exemple #9
0
void TableSettings::OnColumnChanged(wxDataViewEvent& event)
{
    Column *col = reinterpret_cast<Column*>(m_dvColumns->GetItemData( event.GetItem() ) );
    if( col ) {
        wxVariant val;
        event.GetModel()->GetValue( val, event.GetItem(), event.GetColumn() );
        if( ! val.IsNull() ) {
            switch( event.GetColumn() ) {
            case 0: {
                // rename local columns in keys
                SerializableList keys;
                GetConstraints( keys, col->GetName() );
                for(SerializableList::iterator it = keys.begin(); it != keys.end(); ++it ) {
                    Constraint *key = (Constraint*) *it;
                    if( key->GetType() == Constraint::primaryKey ) key->SetName( wxT("PK_") + val.GetString() );
                    key->SetLocalColumn( val.GetString() );
                }
                // rename table column
                col->SetName( val.GetString() );
                break;
            }
            case 1: {
                col->SetType( m_pDbAdapter->GetDbTypeByName( val.GetString() ) );
                break;
            }
            case 2: {
                long s1, s2;
                s1 = s2 = 0;
                wxSscanf( val.GetString(), wxT("%ld,%ld"), &s1, &s2 );
                IDbType *type = col->GetType();
                if( type->HaveSize() ) type->SetSize( s1 );
                else {
                    m_infobar->ShowMessage( wxT("This data type doesn't support size definition."), wxICON_WARNING );
                    Refresh();
                }
                if( type->HaveSize2() ) type->SetSize2( s1 );
                else { 
                    m_infobar->ShowMessage( wxT("This data type doesn't support size definition."), wxICON_WARNING );
                    Refresh();
                }
                break;
            }
            case 3: {
                IDbType *type = col->GetType();
                if( type->HaveNotNull() ) type->SetNotNull( val.GetBool() );
                else {
                    m_infobar->ShowMessage( wxT("This data type doesn't support NOT NULL feature."), wxICON_WARNING );
                    Refresh();
                }
                break;
            }
            case 4: {
                IDbType *type = col->GetType();
                if( type->HaveAutoIncrement() ) type->SetAutoIncrement( val.GetBool() );
                else { 
                    m_infobar->ShowMessage( wxT("This data type doesn't support AUTOINCREMENT feature."), wxICON_WARNING );
                    Refresh();
                }
                break;
            }
            case 5: {
                Constraint *key = GetConstraint( Constraint::primaryKey, col->GetName() );
                if( key ) {
                    // remove primary key if exists
                    m_lstKeys.DeleteObject( key );
                    delete key;
                } else {
                    // create new primary key
                    key = new Constraint( wxT("PK_") + col->GetName(),
                                          col->GetName(),
                                          Constraint::primaryKey,
                                          Constraint::noAction,
                                          Constraint::noAction );

                    m_lstKeys.Append( key );
                }
                break;
            }
            }
        }
    }

    event.Skip();

    UpdateView();
}