void LLFloaterObjectWeights::refresh()
{
	LLSelectMgr* sel_mgr = LLSelectMgr::getInstance();

	if (sel_mgr->getSelection()->isEmpty())
	{
		updateIfNothingSelected();
	}
	else
	{
		S32 prim_count = sel_mgr->getSelection()->getObjectCount();
		S32 link_count = sel_mgr->getSelection()->getRootObjectCount();
		F32 prim_equiv = sel_mgr->getSelection()->getSelectedLinksetCost();

		mSelectedObjects->setText(llformat("%d", link_count));
		mSelectedPrims->setText(llformat("%d", prim_count));
		mSelectedOnLand->setText(llformat("%.1d", (S32)prim_equiv));

		LLCrossParcelFunctor func;
		if (sel_mgr->getSelection()->applyToRootObjects(&func, true))
		{
			// Some of the selected objects cross parcel bounds.
			// We don't display object weights and land impacts in this case.
			const std::string text = getString("nothing_selected");

			mRezzedOnLand->setText(text);
			mRemainingCapacity->setText(text);
			mTotalCapacity->setText(text);

			toggleLandImpactsLoadingIndicators(false);
		}

		LLViewerRegion* region = gAgent.getRegion();
		if (region && region->capabilitiesReceived())
		{
			for (LLObjectSelection::valid_root_iterator iter = sel_mgr->getSelection()->valid_root_begin();
					iter != sel_mgr->getSelection()->valid_root_end(); ++iter)
			{
				LLAccountingCostManager::getInstance()->addObject((*iter)->getObject()->getID());
			}

			std::string url = region->getCapability("ResourceCostSelected");
			if (!url.empty())
			{
				// Update the transaction id before the new fetch request
				generateTransactionID();

				LLAccountingCostManager::getInstance()->fetchCosts(Roots, url, getObserverHandle());
				toggleWeightsLoadingIndicators(true);
			}
		}
		else
		{
			//LL_WARNS() << "Failed to get region capabilities" << LL_ENDL;
			llwarns << "Failed to get region capabilities" << llendl;
		}
	}
}
//virtual
void LLFloaterObjectWeights::setErrorStatus(U32 status, const std::string& reason)
{
	const std::string text = getString("nothing_selected");

	mSelectedDownloadWeight->setText(text);
	mSelectedPhysicsWeight->setText(text);
	mSelectedServerWeight->setText(text);
	mSelectedDisplayWeight->setText(text);

	toggleWeightsLoadingIndicators(false);
}
// virtual
void LLFloaterObjectWeights::onWeightsUpdate(const SelectionCost& selection_cost)
{
	mSelectedDownloadWeight->setText(llformat("%.1f", selection_cost.mNetworkCost));
	mSelectedPhysicsWeight->setText(llformat("%.1f", selection_cost.mPhysicsCost));
	mSelectedServerWeight->setText(llformat("%.1f", selection_cost.mSimulationCost));

	S32 render_cost = LLSelectMgr::getInstance()->getSelection()->getSelectedObjectRenderCost();
	mSelectedDisplayWeight->setText(llformat("%d", render_cost));

	toggleWeightsLoadingIndicators(false);
}
void LLFloaterObjectWeights::updateIfNothingSelected()
{
	const std::string text = getString("nothing_selected");

	mSelectedObjects->setText(text);
	mSelectedPrims->setText(text);

	mSelectedDownloadWeight->setText(text);
	mSelectedPhysicsWeight->setText(text);
	mSelectedServerWeight->setText(text);
	mSelectedDisplayWeight->setText(text);

	mSelectedOnLand->setText(text);
	mRezzedOnLand->setText(text);
	mRemainingCapacity->setText(text);
	mTotalCapacity->setText(text);

	toggleWeightsLoadingIndicators(false);
	toggleLandImpactsLoadingIndicators(false);
}