Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Please answer it Collapse All
Subject Author Date
tera tera Sep 30, 2009 - 12:30 AM

Hello.


http://www.prof-uis.com/prof-uis/tech-support/support-forum/a-grid-is-slow-65574.aspx


I want a command to optimize the selection of the cell.


void CSampleMuGridDlg::OnButton2() {     POINT  pt;    int iRow;     for ( iRow = 0 ; iRow < m_pMuMlGrid->RowCountGet() ; iRow++ ){ if ( m_Flag[iRow] == true ){    pt.x = -1;    pt.y = iRow;    m_pMuMlGrid->Selection1Line( pt , true );   }     }

}

bool CNxL_MlGrid::Selection1Line(     POINT  pt,     bool blFlag     ) {     if ( blFlag == true ){ if ( SelectionGetForCell( -1, pt.y ) == false ){   SelectionSet( pt , false ); }     }else{ if ( SelectionGetForCell( -1, pt.y ) == true ){   SelectionSet( pt , false ); }     }     return true; }


 

tera tera Oct 5, 2009 - 3:49 AM

 


Optimization takes too much time.

By the optimization of 75 lines, it takes the processing time of 120 seconds. 


Technical Support Oct 5, 2009 - 12:49 PM

Optimization does not depend on the number of columns in the case of full row selection based grid control. We tested it using 200 rows in your sample project - not 75 rows. It does not take any visually noticeable time on 200 rows. So, we suspect you have some special conditions besides 75 rows in the selection region. We suspect you didn’t told us something important. Please try to repeat the long optimization delay problem in the sample project you sent us.


tera tera Oct 7, 2009 - 2:36 AM

Hello.


I’m sorry.

SelectionOptimize worked quickly.


Thanks,


 

Technical Support Oct 2, 2009 - 2:04 PM

We added a new CExtGridBaseWnd::SelectionOptimize() virtual method:

// DECLARATION:
virtual bool SelectionOptimize();

// IMPLEMENTATION:
bool CExtGridBaseWnd::SelectionOptimize()
{
      ASSERT_VALID( this );
INT nAreaNumberOuter, nAreaNumberInner, nAreaCount = SelectionGetAreaCount();
      if( nAreaCount <= 1 )
            return false;
bool bSubtractSelectionAreas = SubtractSelectionAreasGet();
bool bOptimized = false;
      for( nAreaNumberOuter = 0; nAreaNumberOuter < (nAreaCount-1); )
      {
            bool bRemovedOuter = false, bMixWidthOuter = false;
            CRect rcSelectionOuter( SelectionGet( true, nAreaNumberOuter ) );
            for( nAreaNumberInner = nAreaNumberOuter + 1; nAreaNumberInner < nAreaCount; )
            {
                  CRect rcSelectionInner( SelectionGet( true, nAreaNumberInner ) );
                  if( bSubtractSelectionAreas )
                  {
                        if( rcSelectionOuter == rcSelectionInner )
                        {
                              VERIFY( SelectionRemoveAt( nAreaNumberOuter, false ) );
                              VERIFY( SelectionRemoveAt( nAreaNumberInner, false ) );
                              nAreaCount -= 2;
                              ASSERT( nAreaCount == SelectionGetAreaCount() );
                              bOptimized = bRemovedOuter = true;
                              break;
                        }
                        if( rcSelectionOuter.left == rcSelectionInner.left && rcSelectionOuter.right == rcSelectionInner.right )
                        {
                              if( rcSelectionOuter.top <= rcSelectionInner.top )
                              {
                                    if( rcSelectionOuter.bottom == ( rcSelectionInner.top - 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              else if( rcSelectionOuter.bottom >= rcSelectionInner.bottom )
                              {
                                    if( rcSelectionOuter.top == ( rcSelectionInner.bottom + 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              if( bMixWidthOuter )
                              {
                                    rcSelectionOuter.top = min( rcSelectionOuter.top, rcSelectionInner.top );
                                    rcSelectionOuter.bottom = max( rcSelectionOuter.bottom, rcSelectionInner.bottom );
                              }
                        }
                        else if( rcSelectionOuter.top == rcSelectionInner.top && rcSelectionOuter.bottom == rcSelectionInner.bottom )
                        {
                              if( rcSelectionOuter.left <= rcSelectionInner.left )
                              {
                                    if( rcSelectionOuter.right == ( rcSelectionInner.left - 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              else if( rcSelectionOuter.right >= rcSelectionInner.right )
                              {
                                    if( rcSelectionOuter.left == ( rcSelectionInner.right + 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              if( bMixWidthOuter )
                              {
                                    rcSelectionOuter.left = min( rcSelectionOuter.left, rcSelectionInner.left );
                                    rcSelectionOuter.right = max( rcSelectionOuter.right, rcSelectionInner.right );
                              }
                        }
                  } // if( bSubtractSelectionAreas )
                  else
                  {
                        if( rcSelectionOuter == rcSelectionInner )
                        {
                              VERIFY( SelectionRemoveAt( nAreaNumberInner, false ) );
                              nAreaCount --;
                              ASSERT( nAreaCount == SelectionGetAreaCount() );
                              continue;
                        }
                        if( rcSelectionOuter.left == rcSelectionInner.left && rcSelectionOuter.right == rcSelectionInner.right )
                        {
                              if( rcSelectionOuter.top <= rcSelectionInner.top )
                              {
                                    if( rcSelectionOuter.bottom >= ( rcSelectionInner.top - 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              else if( rcSelectionOuter.bottom >= rcSelectionInner.bottom )
                              {
                                    if( rcSelectionOuter.top <= ( rcSelectionInner.bottom + 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              if( bMixWidthOuter )
                              {
                                    rcSelectionOuter.top = min( rcSelectionOuter.top, rcSelectionInner.top );
                                    rcSelectionOuter.bottom = max( rcSelectionOuter.bottom, rcSelectionInner.bottom );
                              }
                        }
                        else if( rcSelectionOuter.top == rcSelectionInner.top && rcSelectionOuter.bottom == rcSelectionInner.bottom )
                        {
                              if( rcSelectionOuter.left <= rcSelectionInner.left )
                              {
                                    if( rcSelectionOuter.right >= ( rcSelectionInner.left - 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              else if( rcSelectionOuter.right >= rcSelectionInner.right )
                              {
                                    if( rcSelectionOuter.left <= ( rcSelectionInner.right + 1 ) )
                                          bOptimized = bMixWidthOuter = true;
                              }
                              if( bMixWidthOuter )
                              {
                                    rcSelectionOuter.left = min( rcSelectionOuter.left, rcSelectionInner.left );
                                    rcSelectionOuter.right = max( rcSelectionOuter.right, rcSelectionInner.right );
                              }
                        }
                        if(         rcSelectionOuter.left <= rcSelectionInner.left && rcSelectionOuter.right >= rcSelectionInner.right
                              &&    rcSelectionOuter.top <= rcSelectionInner.top && rcSelectionOuter.bottom >= rcSelectionInner.bottom
                              )
                        {
                              rcSelectionOuter.top = min( rcSelectionOuter.top, rcSelectionInner.top );
                              rcSelectionOuter.bottom = max( rcSelectionOuter.bottom, rcSelectionInner.bottom );
                              rcSelectionOuter.left = min( rcSelectionOuter.left, rcSelectionInner.left );
                              rcSelectionOuter.right = max( rcSelectionOuter.right, rcSelectionInner.right );
                              bOptimized = bMixWidthOuter = true;
                        }
                  } // else from if( bSubtractSelectionAreas )
                  if( bMixWidthOuter )
                  {
                        VERIFY( SelectionRemoveAt( nAreaNumberInner, false ) );
                        nAreaCount --;
                        ASSERT( nAreaCount == SelectionGetAreaCount() );
                        break;
                  }
                  nAreaNumberInner ++;
            } // for( nAreaNumberInner = nAreaNumberOuter + 1; nAreaNumberInner < nAreaCount; )
            if( bMixWidthOuter )
            {
                  SelectionSetAt( nAreaNumberOuter, rcSelectionOuter, false );
                  nAreaNumberOuter = 0;
            }
            else if( ! bRemovedOuter )
                  nAreaNumberOuter++;
      } // for( nAreaNumberOuter = 0; nAreaNumberOuter < (nAreaCount-1); )
      return bOptimized;
}

You can invoke it either after adding 200 selection areas or after adding each one new selection rectangle. We checked it using your test project:
void CSampleMuGridDlg::OnButton2() 
{
    POINT  pt;
    int iRow;
    for ( iRow = 0 ; iRow < m_pMuMlGrid->RowCountGet() ; iRow++ ){
      pt.x = -1;
      pt.y = iRow;
            m_pMuMlGrid->Selection1Line( pt , true );
      }

      m_pMuMlGrid->SelectionOptimize();
}


Technical Support Oct 1, 2009 - 6:30 AM

Your question is related to the incorrect usage of the grid control - not to Prof-UIS bug. Every app will work slow if you load to much data into it.

Now let’s discuss some additional details. The selection inside all the Prof-UIS grid controls is described as array of rectangles. This does not depend whether the grid control allows user to perform full row selection, single cell selection or multiple cells selection. Each rectangle contains row/column indices of selected sub-region of grid cells. If the grid cell needs to detect whether it’s selected, then it should review all the rectangles in the selection array and check whether cell’s row/column numbers are inside at least one of selection rectangles. This means you should not insert too much selection sub-regions into the grid control. We cannot make the grid control marking each cell as selected because this technique brings even greater performance disadvantages.

tera tera Oct 2, 2009 - 3:45 AM

 


I want a sample program to minimize a selection appointment domain...............